@hyperbrowser/sdk 0.53.0 → 0.54.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/base.d.ts +1 -1
- package/dist/services/base.js +2 -2
- package/dist/services/computer-action.d.ts +13 -0
- package/dist/services/computer-action.js +87 -0
- package/dist/types/computer-action.d.ts +93 -0
- package/dist/types/computer-action.js +16 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/session.d.ts +1 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { CuaService } from "./services/agents/cua";
|
|
|
10
10
|
import { ClaudeComputerUseService } from "./services/agents/claude-computer-use";
|
|
11
11
|
import { HyperAgentService } from "./services/agents/hyper-agent";
|
|
12
12
|
import { TeamService } from "./services/team";
|
|
13
|
+
import { ComputerActionService } from "./services/computer-action";
|
|
13
14
|
export declare class HyperbrowserError extends Error {
|
|
14
15
|
statusCode?: number | undefined;
|
|
15
16
|
constructor(message: string, statusCode?: number | undefined);
|
|
@@ -28,5 +29,6 @@ export declare class HyperbrowserClient {
|
|
|
28
29
|
hyperAgent: HyperAgentService;
|
|
29
30
|
};
|
|
30
31
|
readonly team: TeamService;
|
|
32
|
+
readonly computerAction: ComputerActionService;
|
|
31
33
|
constructor(config?: HyperbrowserConfig);
|
|
32
34
|
}
|
package/dist/client.js
CHANGED
|
@@ -12,6 +12,7 @@ const cua_1 = require("./services/agents/cua");
|
|
|
12
12
|
const claude_computer_use_1 = require("./services/agents/claude-computer-use");
|
|
13
13
|
const hyper_agent_1 = require("./services/agents/hyper-agent");
|
|
14
14
|
const team_1 = require("./services/team");
|
|
15
|
+
const computer_action_1 = require("./services/computer-action");
|
|
15
16
|
class HyperbrowserError extends Error {
|
|
16
17
|
constructor(message, statusCode) {
|
|
17
18
|
super(`[Hyperbrowser]: ${message}`);
|
|
@@ -35,6 +36,7 @@ class HyperbrowserClient {
|
|
|
35
36
|
this.profiles = new profiles_1.ProfilesService(apiKey, baseUrl, timeout);
|
|
36
37
|
this.extensions = new extensions_1.ExtensionService(apiKey, baseUrl, timeout);
|
|
37
38
|
this.team = new team_1.TeamService(apiKey, baseUrl, timeout);
|
|
39
|
+
this.computerAction = new computer_action_1.ComputerActionService(apiKey, baseUrl, timeout);
|
|
38
40
|
this.agents = {
|
|
39
41
|
browserUse: new browser_use_1.BrowserUseService(apiKey, baseUrl, timeout),
|
|
40
42
|
claudeComputerUse: new claude_computer_use_1.ClaudeComputerUseService(apiKey, baseUrl, timeout),
|
package/dist/services/base.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export declare class BaseService {
|
|
|
4
4
|
protected readonly baseUrl: string;
|
|
5
5
|
protected readonly timeout: number;
|
|
6
6
|
constructor(apiKey: string, baseUrl: string, timeout?: number);
|
|
7
|
-
protected request<T>(path: string, init?: RequestInit, params?: Record<string, string | number | undefined
|
|
7
|
+
protected request<T>(path: string, init?: RequestInit, params?: Record<string, string | number | undefined>, fullUrl?: boolean): Promise<T>;
|
|
8
8
|
}
|
package/dist/services/base.js
CHANGED
|
@@ -12,9 +12,9 @@ class BaseService {
|
|
|
12
12
|
this.baseUrl = baseUrl;
|
|
13
13
|
this.timeout = timeout;
|
|
14
14
|
}
|
|
15
|
-
async request(path, init, params) {
|
|
15
|
+
async request(path, init, params, fullUrl = false) {
|
|
16
16
|
try {
|
|
17
|
-
const url = new URL(`${this.baseUrl}/api${path}`);
|
|
17
|
+
const url = new URL(fullUrl ? path : `${this.baseUrl}/api${path}`);
|
|
18
18
|
if (params) {
|
|
19
19
|
Object.entries(params).forEach(([key, value]) => {
|
|
20
20
|
if (value !== undefined) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SessionDetail } from "../types";
|
|
2
|
+
import { ComputerActionResponse, Coordinate } from "../types/computer-action";
|
|
3
|
+
import { BaseService } from "./base";
|
|
4
|
+
export declare class ComputerActionService extends BaseService {
|
|
5
|
+
private executeRequest;
|
|
6
|
+
click(session: SessionDetail | string, x: number, y: number, button?: "left" | "right" | "middle" | "back" | "forward" | "wheel", numClicks?: number, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
|
|
7
|
+
typeText(session: SessionDetail | string, text: string, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
|
|
8
|
+
screenshot(session: SessionDetail | string): Promise<ComputerActionResponse>;
|
|
9
|
+
pressKeys(session: SessionDetail | string, keys: string[], returnScreenshot?: boolean): Promise<ComputerActionResponse>;
|
|
10
|
+
drag(session: SessionDetail | string, path: Coordinate[], returnScreenshot?: boolean): Promise<ComputerActionResponse>;
|
|
11
|
+
moveMouse(session: SessionDetail | string, x: number, y: number, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
|
|
12
|
+
scroll(session: SessionDetail | string, x: number, y: number, scrollX: number, scrollY: number, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComputerActionService = void 0;
|
|
4
|
+
const computer_action_1 = require("../types/computer-action");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
const client_1 = require("../client");
|
|
7
|
+
class ComputerActionService extends base_1.BaseService {
|
|
8
|
+
async executeRequest(session, params) {
|
|
9
|
+
try {
|
|
10
|
+
let sessionDetail;
|
|
11
|
+
if (typeof session === "string") {
|
|
12
|
+
sessionDetail = await this.request(`/session/${session}`);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
sessionDetail = session;
|
|
16
|
+
}
|
|
17
|
+
if (!sessionDetail.computerActionEndpoint) {
|
|
18
|
+
throw new client_1.HyperbrowserError("Computer action endpoint not available for this session", undefined);
|
|
19
|
+
}
|
|
20
|
+
return await this.request(sessionDetail.computerActionEndpoint, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
body: JSON.stringify(params),
|
|
23
|
+
}, undefined, true);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error instanceof client_1.HyperbrowserError) {
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
throw new client_1.HyperbrowserError("Failed to execute computer action", undefined);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async click(session, x, y, button = "left", numClicks = 1, returnScreenshot = false) {
|
|
33
|
+
return this.executeRequest(session, {
|
|
34
|
+
action: computer_action_1.ComputerAction.CLICK,
|
|
35
|
+
x,
|
|
36
|
+
y,
|
|
37
|
+
button,
|
|
38
|
+
numClicks,
|
|
39
|
+
returnScreenshot,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async typeText(session, text, returnScreenshot = false) {
|
|
43
|
+
return this.executeRequest(session, {
|
|
44
|
+
action: computer_action_1.ComputerAction.TYPE_TEXT,
|
|
45
|
+
text,
|
|
46
|
+
returnScreenshot,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async screenshot(session) {
|
|
50
|
+
return this.executeRequest(session, {
|
|
51
|
+
action: computer_action_1.ComputerAction.SCREENSHOT,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async pressKeys(session, keys, returnScreenshot = false) {
|
|
55
|
+
return this.executeRequest(session, {
|
|
56
|
+
action: computer_action_1.ComputerAction.PRESS_KEYS,
|
|
57
|
+
keys,
|
|
58
|
+
returnScreenshot,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async drag(session, path, returnScreenshot = false) {
|
|
62
|
+
return this.executeRequest(session, {
|
|
63
|
+
action: computer_action_1.ComputerAction.DRAG,
|
|
64
|
+
path,
|
|
65
|
+
returnScreenshot,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async moveMouse(session, x, y, returnScreenshot = false) {
|
|
69
|
+
return this.executeRequest(session, {
|
|
70
|
+
action: computer_action_1.ComputerAction.MOVE_MOUSE,
|
|
71
|
+
x,
|
|
72
|
+
y,
|
|
73
|
+
returnScreenshot,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async scroll(session, x, y, scrollX, scrollY, returnScreenshot = false) {
|
|
77
|
+
return this.executeRequest(session, {
|
|
78
|
+
action: computer_action_1.ComputerAction.SCROLL,
|
|
79
|
+
x,
|
|
80
|
+
y,
|
|
81
|
+
scrollX,
|
|
82
|
+
scrollY,
|
|
83
|
+
returnScreenshot,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.ComputerActionService = ComputerActionService;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computer action types enumeration
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ComputerAction {
|
|
5
|
+
CLICK = "click",
|
|
6
|
+
DRAG = "drag",
|
|
7
|
+
PRESS_KEYS = "press_keys",
|
|
8
|
+
MOVE_MOUSE = "move_mouse",
|
|
9
|
+
SCREENSHOT = "screenshot",
|
|
10
|
+
SCROLL = "scroll",
|
|
11
|
+
TYPE_TEXT = "type_text"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Coordinate model for drag actions
|
|
15
|
+
*/
|
|
16
|
+
export interface Coordinate {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parameters for click action
|
|
22
|
+
*/
|
|
23
|
+
export interface ClickActionParams {
|
|
24
|
+
action: ComputerAction.CLICK;
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
button?: "left" | "right" | "middle" | "back" | "forward" | "wheel";
|
|
28
|
+
numClicks?: number;
|
|
29
|
+
returnScreenshot?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parameters for drag action
|
|
33
|
+
*/
|
|
34
|
+
export interface DragActionParams {
|
|
35
|
+
action: ComputerAction.DRAG;
|
|
36
|
+
path: Coordinate[];
|
|
37
|
+
returnScreenshot?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parameters for press keys action
|
|
41
|
+
*/
|
|
42
|
+
export interface PressKeysActionParams {
|
|
43
|
+
action: ComputerAction.PRESS_KEYS;
|
|
44
|
+
keys: string[];
|
|
45
|
+
returnScreenshot?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parameters for move mouse action
|
|
49
|
+
*/
|
|
50
|
+
export interface MoveMouseActionParams {
|
|
51
|
+
action: ComputerAction.MOVE_MOUSE;
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
returnScreenshot?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parameters for screenshot action
|
|
58
|
+
*/
|
|
59
|
+
export interface ScreenshotActionParams {
|
|
60
|
+
action: ComputerAction.SCREENSHOT;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parameters for scroll action
|
|
64
|
+
*/
|
|
65
|
+
export interface ScrollActionParams {
|
|
66
|
+
action: ComputerAction.SCROLL;
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
scrollX: number;
|
|
70
|
+
scrollY: number;
|
|
71
|
+
returnScreenshot?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parameters for type text action
|
|
75
|
+
*/
|
|
76
|
+
export interface TypeTextActionParams {
|
|
77
|
+
action: ComputerAction.TYPE_TEXT;
|
|
78
|
+
text: string;
|
|
79
|
+
returnScreenshot?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Union type for all computer action parameters
|
|
83
|
+
*/
|
|
84
|
+
export type ComputerActionParams = ClickActionParams | DragActionParams | PressKeysActionParams | MoveMouseActionParams | ScreenshotActionParams | ScrollActionParams | TypeTextActionParams;
|
|
85
|
+
/**
|
|
86
|
+
* Response from computer action API
|
|
87
|
+
*/
|
|
88
|
+
export interface ComputerActionResponse {
|
|
89
|
+
success: boolean;
|
|
90
|
+
screenshot?: string;
|
|
91
|
+
error?: string;
|
|
92
|
+
message?: string;
|
|
93
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComputerAction = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Computer action types enumeration
|
|
6
|
+
*/
|
|
7
|
+
var ComputerAction;
|
|
8
|
+
(function (ComputerAction) {
|
|
9
|
+
ComputerAction["CLICK"] = "click";
|
|
10
|
+
ComputerAction["DRAG"] = "drag";
|
|
11
|
+
ComputerAction["PRESS_KEYS"] = "press_keys";
|
|
12
|
+
ComputerAction["MOVE_MOUSE"] = "move_mouse";
|
|
13
|
+
ComputerAction["SCREENSHOT"] = "screenshot";
|
|
14
|
+
ComputerAction["SCROLL"] = "scroll";
|
|
15
|
+
ComputerAction["TYPE_TEXT"] = "type_text";
|
|
16
|
+
})(ComputerAction || (exports.ComputerAction = ComputerAction = {}));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export { CreateProfileParams, ProfileResponse, CreateProfileResponse, ProfileLis
|
|
|
11
11
|
export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
|
|
12
12
|
export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ClaudeComputerUseLlm, ScrapeScreenshotFormat, ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, RecordingStatus, DownloadsStatus, HyperAgentLlm, HyperAgentTaskStatus, ClaudeComputerUseTaskStatus, CuaTaskStatus, } from "./constants";
|
|
13
13
|
export { TeamCreditInfo } from "./team";
|
|
14
|
+
export { ComputerAction, Coordinate, ClickActionParams, DragActionParams, PressKeysActionParams, MoveMouseActionParams, ScreenshotActionParams, ScrollActionParams, TypeTextActionParams, ComputerActionParams, ComputerActionResponse, } from "./computer-action";
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComputerAction = void 0;
|
|
4
|
+
var computer_action_1 = require("./computer-action");
|
|
5
|
+
Object.defineProperty(exports, "ComputerAction", { enumerable: true, get: function () { return computer_action_1.ComputerAction; } });
|
package/dist/types/session.d.ts
CHANGED