@hyperbrowser/sdk 0.38.0 → 0.40.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 +2 -0
- package/dist/client.js +2 -0
- package/dist/services/agents/claude-computer-use.d.ts +30 -0
- package/dist/services/agents/claude-computer-use.js +103 -0
- package/dist/services/sessions.d.ts +6 -1
- package/dist/services/sessions.js +15 -0
- package/dist/types/agents/claude-computer-use.d.ts +36 -0
- package/dist/types/agents/claude-computer-use.js +2 -0
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/session.d.ts +10 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { ExtensionService } from "./services/extensions";
|
|
|
7
7
|
import { ExtractService } from "./services/extract";
|
|
8
8
|
import { BrowserUseService } from "./services/agents/browser-use";
|
|
9
9
|
import { CuaService } from "./services/agents/cua";
|
|
10
|
+
import { ClaudeComputerUseService } from "./services/agents/claude-computer-use";
|
|
10
11
|
export declare class HyperbrowserError extends Error {
|
|
11
12
|
statusCode?: number | undefined;
|
|
12
13
|
constructor(message: string, statusCode?: number | undefined);
|
|
@@ -20,6 +21,7 @@ export declare class HyperbrowserClient {
|
|
|
20
21
|
readonly extensions: ExtensionService;
|
|
21
22
|
readonly agents: {
|
|
22
23
|
browserUse: BrowserUseService;
|
|
24
|
+
claudeComputerUse: ClaudeComputerUseService;
|
|
23
25
|
cua: CuaService;
|
|
24
26
|
};
|
|
25
27
|
constructor(config?: HyperbrowserConfig);
|
package/dist/client.js
CHANGED
|
@@ -9,6 +9,7 @@ const extensions_1 = require("./services/extensions");
|
|
|
9
9
|
const extract_1 = require("./services/extract");
|
|
10
10
|
const browser_use_1 = require("./services/agents/browser-use");
|
|
11
11
|
const cua_1 = require("./services/agents/cua");
|
|
12
|
+
const claude_computer_use_1 = require("./services/agents/claude-computer-use");
|
|
12
13
|
class HyperbrowserError extends Error {
|
|
13
14
|
constructor(message, statusCode) {
|
|
14
15
|
super(`[Hyperbrowser]: ${message}`);
|
|
@@ -33,6 +34,7 @@ class HyperbrowserClient {
|
|
|
33
34
|
this.extensions = new extensions_1.ExtensionService(apiKey, baseUrl, timeout);
|
|
34
35
|
this.agents = {
|
|
35
36
|
browserUse: new browser_use_1.BrowserUseService(apiKey, baseUrl, timeout),
|
|
37
|
+
claudeComputerUse: new claude_computer_use_1.ClaudeComputerUseService(apiKey, baseUrl, timeout),
|
|
36
38
|
cua: new cua_1.CuaService(apiKey, baseUrl, timeout),
|
|
37
39
|
};
|
|
38
40
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BasicResponse } from "../../types";
|
|
2
|
+
import { BaseService } from "../base";
|
|
3
|
+
import { ClaudeComputerUseTaskResponse, ClaudeComputerUseTaskStatusResponse, StartClaudeComputerUseTaskParams, StartClaudeComputerUseTaskResponse } from "../../types/agents/claude-computer-use";
|
|
4
|
+
export declare class ClaudeComputerUseService extends BaseService {
|
|
5
|
+
/**
|
|
6
|
+
* Start a new Claude Computer Use task job
|
|
7
|
+
* @param params The parameters for the task job
|
|
8
|
+
*/
|
|
9
|
+
start(params: StartClaudeComputerUseTaskParams): Promise<StartClaudeComputerUseTaskResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Get the status of a Claude Computer Use task job
|
|
12
|
+
* @param id The ID of the task job to get
|
|
13
|
+
*/
|
|
14
|
+
getStatus(id: string): Promise<ClaudeComputerUseTaskStatusResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Get the result of a Claude Computer Use task job
|
|
17
|
+
* @param id The ID of the task job to get
|
|
18
|
+
*/
|
|
19
|
+
get(id: string): Promise<ClaudeComputerUseTaskResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Stop a Claude Computer Use task job
|
|
22
|
+
* @param id The ID of the task job to stop
|
|
23
|
+
*/
|
|
24
|
+
stop(id: string): Promise<BasicResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Start a Claude Computer Use task job and wait for it to complete
|
|
27
|
+
* @param params The parameters for the task job
|
|
28
|
+
*/
|
|
29
|
+
startAndWait(params: StartClaudeComputerUseTaskParams): Promise<ClaudeComputerUseTaskResponse>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClaudeComputerUseService = 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");
|
|
8
|
+
class ClaudeComputerUseService extends base_1.BaseService {
|
|
9
|
+
/**
|
|
10
|
+
* Start a new Claude Computer Use task job
|
|
11
|
+
* @param params The parameters for the task job
|
|
12
|
+
*/
|
|
13
|
+
async start(params) {
|
|
14
|
+
try {
|
|
15
|
+
return await this.request("/task/claude-computer-use", {
|
|
16
|
+
method: "POST",
|
|
17
|
+
body: JSON.stringify(params),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof client_1.HyperbrowserError) {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
throw new client_1.HyperbrowserError("Failed to start Claude Computer Use task job", undefined);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the status of a Claude Computer Use task job
|
|
29
|
+
* @param id The ID of the task job to get
|
|
30
|
+
*/
|
|
31
|
+
async getStatus(id) {
|
|
32
|
+
try {
|
|
33
|
+
return await this.request(`/task/claude-computer-use/${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 Claude Computer Use task job ${id} status`, undefined);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the result of a Claude Computer Use task job
|
|
44
|
+
* @param id The ID of the task job to get
|
|
45
|
+
*/
|
|
46
|
+
async get(id) {
|
|
47
|
+
try {
|
|
48
|
+
return await this.request(`/task/claude-computer-use/${id}`);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error instanceof client_1.HyperbrowserError) {
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
throw new client_1.HyperbrowserError(`Failed to get Claude Computer Use task job ${id}`, undefined);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Stop a Claude Computer Use task job
|
|
59
|
+
* @param id The ID of the task job to stop
|
|
60
|
+
*/
|
|
61
|
+
async stop(id) {
|
|
62
|
+
try {
|
|
63
|
+
return await this.request(`/task/claude-computer-use/${id}/stop`, {
|
|
64
|
+
method: "PUT",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof client_1.HyperbrowserError) {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
throw new client_1.HyperbrowserError(`Failed to stop Claude Computer Use task job ${id}`, undefined);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Start a Claude Computer Use task job and wait for it to complete
|
|
76
|
+
* @param params The parameters for the task job
|
|
77
|
+
*/
|
|
78
|
+
async startAndWait(params) {
|
|
79
|
+
const job = await this.start(params);
|
|
80
|
+
const jobId = job.jobId;
|
|
81
|
+
if (!jobId) {
|
|
82
|
+
throw new client_1.HyperbrowserError("Failed to start Claude Computer Use task job, could not get job ID");
|
|
83
|
+
}
|
|
84
|
+
let failures = 0;
|
|
85
|
+
while (true) {
|
|
86
|
+
try {
|
|
87
|
+
const { status } = await this.getStatus(jobId);
|
|
88
|
+
if (status === "completed" || status === "failed" || status === "stopped") {
|
|
89
|
+
return await this.get(jobId);
|
|
90
|
+
}
|
|
91
|
+
failures = 0;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
failures++;
|
|
95
|
+
if (failures >= constants_1.POLLING_ATTEMPTS) {
|
|
96
|
+
throw new client_1.HyperbrowserError(`Failed to poll Claude Computer Use task job ${jobId} after ${constants_1.POLLING_ATTEMPTS} attempts: ${error}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
await (0, utils_1.sleep)(2000);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.ClaudeComputerUseService = ClaudeComputerUseService;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasicResponse, CreateSessionParams, GetSessionRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording } from "../types/session";
|
|
1
|
+
import { BasicResponse, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording } from "../types/session";
|
|
2
2
|
import { BaseService } from "./base";
|
|
3
3
|
export declare class SessionsService extends BaseService {
|
|
4
4
|
/**
|
|
@@ -31,4 +31,9 @@ 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 downloads URL of a session
|
|
36
|
+
* @param id The ID of the session to get the downloads URL from
|
|
37
|
+
*/
|
|
38
|
+
getDownloadsURL(id: string): Promise<GetSessionDownloadsUrlResponse>;
|
|
34
39
|
}
|
|
@@ -103,5 +103,20 @@ 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 downloads URL of a session
|
|
108
|
+
* @param id The ID of the session to get the downloads URL from
|
|
109
|
+
*/
|
|
110
|
+
async getDownloadsURL(id) {
|
|
111
|
+
try {
|
|
112
|
+
return await this.request(`/session/${id}/downloads-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 downloads url for session ${id}`, undefined);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
106
121
|
}
|
|
107
122
|
exports.SessionsService = SessionsService;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ClaudeComputerUseTaskStatus } from "../constants";
|
|
2
|
+
import { CreateSessionParams } from "../session";
|
|
3
|
+
export interface StartClaudeComputerUseTaskParams {
|
|
4
|
+
task: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
maxFailures?: number;
|
|
7
|
+
maxSteps?: number;
|
|
8
|
+
keepBrowserOpen?: boolean;
|
|
9
|
+
sessionOptions?: CreateSessionParams;
|
|
10
|
+
}
|
|
11
|
+
export interface StartClaudeComputerUseTaskResponse {
|
|
12
|
+
jobId: string;
|
|
13
|
+
liveUrl: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface ClaudeComputerUseTaskStatusResponse {
|
|
16
|
+
status: ClaudeComputerUseTaskStatus;
|
|
17
|
+
}
|
|
18
|
+
export interface ClaudeComputerUseStepResponse {
|
|
19
|
+
role: string;
|
|
20
|
+
type: string;
|
|
21
|
+
model: string;
|
|
22
|
+
content: any[];
|
|
23
|
+
stop_reason: string | null;
|
|
24
|
+
stop_sequence: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ClaudeComputerUseTaskData {
|
|
27
|
+
steps: ClaudeComputerUseStepResponse[];
|
|
28
|
+
finalResult: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface ClaudeComputerUseTaskResponse {
|
|
31
|
+
jobId: string;
|
|
32
|
+
status: ClaudeComputerUseTaskStatus;
|
|
33
|
+
data?: ClaudeComputerUseTaskData | null;
|
|
34
|
+
error?: string | null;
|
|
35
|
+
liveUrl: string | null;
|
|
36
|
+
}
|
|
@@ -4,10 +4,13 @@ export type ExtractJobStatus = "pending" | "running" | "completed" | "failed";
|
|
|
4
4
|
export type CrawlJobStatus = "pending" | "running" | "completed" | "failed";
|
|
5
5
|
export type BrowserUseTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
|
|
6
6
|
export type CuaTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
|
|
7
|
+
export type ClaudeComputerUseTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
|
|
7
8
|
export type ScrapePageStatus = "completed" | "failed" | "pending" | "running";
|
|
8
9
|
export type CrawlPageStatus = "completed" | "failed";
|
|
9
10
|
export type ScrapeWaitUntil = "load" | "domcontentloaded" | "networkidle";
|
|
10
11
|
export type ScrapeScreenshotFormat = "jpeg" | "png" | "webp";
|
|
12
|
+
export type RecordingStatus = "not_enabled" | "pending" | "in_progress" | "completed" | "failed";
|
|
13
|
+
export type DownloadsStatus = "not_enabled" | "pending" | "in_progress" | "completed" | "failed";
|
|
11
14
|
export declare const POLLING_ATTEMPTS = 5;
|
|
12
15
|
export type BrowserUseLlm = "gpt-4o" | "gpt-4o-mini" | "claude-3-7-sonnet-20250219" | "claude-3-5-sonnet-20241022" | "claude-3-5-haiku-20241022" | "gemini-2.0-flash";
|
|
13
16
|
export type Country = "AD" | "AE" | "AF" | "AL" | "AM" | "AO" | "AR" | "AT" | "AU" | "AW" | "AZ" | "BA" | "BD" | "BE" | "BG" | "BH" | "BJ" | "BO" | "BR" | "BS" | "BT" | "BY" | "BZ" | "CA" | "CF" | "CH" | "CI" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "EC" | "EE" | "EG" | "ES" | "ET" | "EU" | "FI" | "FJ" | "FR" | "GB" | "GE" | "GH" | "GM" | "GR" | "HK" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IN" | "IQ" | "IR" | "IS" | "IT" | "JM" | "JO" | "JP" | "KE" | "KH" | "KR" | "KW" | "KZ" | "LB" | "LI" | "LR" | "LT" | "LU" | "LV" | "MA" | "MC" | "MD" | "ME" | "MG" | "MK" | "ML" | "MM" | "MN" | "MR" | "MT" | "MU" | "MV" | "MX" | "MY" | "MZ" | "NG" | "NL" | "NO" | "NZ" | "OM" | "PA" | "PE" | "PH" | "PK" | "PL" | "PR" | "PT" | "PY" | "QA" | "RANDOM_COUNTRY" | "RO" | "RS" | "RU" | "SA" | "SC" | "SD" | "SE" | "SG" | "SI" | "SK" | "SN" | "SS" | "TD" | "TG" | "TH" | "TM" | "TN" | "TR" | "TT" | "TW" | "UA" | "UG" | "US" | "UY" | "UZ" | "VE" | "VG" | "VN" | "YE" | "ZA" | "ZM" | "ZW" | "ad" | "ae" | "af" | "al" | "am" | "ao" | "ar" | "at" | "au" | "aw" | "az" | "ba" | "bd" | "be" | "bg" | "bh" | "bj" | "bo" | "br" | "bs" | "bt" | "by" | "bz" | "ca" | "cf" | "ch" | "ci" | "cl" | "cm" | "cn" | "co" | "cr" | "cu" | "cy" | "cz" | "de" | "dj" | "dk" | "dm" | "ec" | "ee" | "eg" | "es" | "et" | "eu" | "fi" | "fj" | "fr" | "gb" | "ge" | "gh" | "gm" | "gr" | "hk" | "hn" | "hr" | "ht" | "hu" | "id" | "ie" | "il" | "in" | "iq" | "ir" | "is" | "it" | "jm" | "jo" | "jp" | "ke" | "kh" | "kr" | "kw" | "kz" | "lb" | "li" | "lr" | "lt" | "lu" | "lv" | "ma" | "mc" | "md" | "me" | "mg" | "mk" | "ml" | "mm" | "mn" | "mr" | "mt" | "mu" | "mv" | "mx" | "my" | "mz" | "ng" | "nl" | "no" | "nz" | "om" | "pa" | "pe" | "ph" | "pk" | "pl" | "pr" | "pt" | "py" | "qa" | "ro" | "rs" | "ru" | "sa" | "sc" | "sd" | "se" | "sg" | "si" | "sk" | "sn" | "ss" | "td" | "tg" | "th" | "tm" | "tn" | "tr" | "tt" | "tw" | "ua" | "ug" | "us" | "uy" | "uz" | "ve" | "vg" | "vn" | "ye" | "za" | "zm" | "zw";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export { StartCrawlJobParams, StartCrawlJobResponse, CrawledPage, CrawlJobRespon
|
|
|
3
3
|
export { StartScrapeJobParams, StartScrapeJobResponse, ScrapeJobData, ScrapeJobResponse, ScrapeOptions, ScrapeJobStatusResponse, BatchScrapeJobStatusResponse, } from "./scrape";
|
|
4
4
|
export { StartExtractJobParams, StartExtractJobResponse, ExtractJobResponse, ExtractJobStatusResponse, } from "./extract";
|
|
5
5
|
export { StartBrowserUseTaskParams, StartBrowserUseTaskResponse, BrowserUseTaskStatusResponse, BrowserUseTaskResponse, BrowserUseTaskData, } from "./agents/browser-use";
|
|
6
|
+
export { StartClaudeComputerUseTaskParams, StartClaudeComputerUseTaskResponse, ClaudeComputerUseTaskStatusResponse, ClaudeComputerUseTaskResponse, ClaudeComputerUseTaskData, ClaudeComputerUseStepResponse, } from "./agents/claude-computer-use";
|
|
6
7
|
export { StartCuaTaskParams, StartCuaTaskResponse, CuaTaskStatusResponse, CuaTaskResponse, CuaTaskData, CuaStepResponse, } from "./agents/cua";
|
|
7
|
-
export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, } from "./session";
|
|
8
|
+
export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, } from "./session";
|
|
8
9
|
export { ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
|
|
9
10
|
export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
|
|
10
|
-
export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ScrapeScreenshotFormat, ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, } from "./constants";
|
|
11
|
+
export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ScrapeScreenshotFormat, ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, RecordingStatus, DownloadsStatus, } from "./constants";
|
package/dist/types/session.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Country, ISO639_1, OperatingSystem, Platform, State } from "./constants";
|
|
1
|
+
import { Country, DownloadsStatus, ISO639_1, OperatingSystem, Platform, RecordingStatus, State } from "./constants";
|
|
2
2
|
export type SessionStatus = "active" | "closed" | "error";
|
|
3
3
|
export interface BasicResponse {
|
|
4
4
|
success: boolean;
|
|
@@ -62,6 +62,7 @@ export interface CreateSessionParams {
|
|
|
62
62
|
acceptCookies?: boolean;
|
|
63
63
|
urlBlocklist?: string[];
|
|
64
64
|
browserArgs?: string[];
|
|
65
|
+
saveDownloads?: boolean;
|
|
65
66
|
}
|
|
66
67
|
export interface SessionRecording {
|
|
67
68
|
type: number;
|
|
@@ -70,5 +71,12 @@ export interface SessionRecording {
|
|
|
70
71
|
delay?: number;
|
|
71
72
|
}
|
|
72
73
|
export interface GetSessionRecordingUrlResponse {
|
|
73
|
-
|
|
74
|
+
status: RecordingStatus;
|
|
75
|
+
recordingUrl?: string | null;
|
|
76
|
+
error?: string | null;
|
|
77
|
+
}
|
|
78
|
+
export interface GetSessionDownloadsUrlResponse {
|
|
79
|
+
status: DownloadsStatus;
|
|
80
|
+
downloadsUrl?: string | null;
|
|
81
|
+
error?: string | null;
|
|
74
82
|
}
|