@hyperbrowser/sdk 0.93.0 → 1.0.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/README.md +190 -0
- package/dist/client.d.ts +2 -20
- package/dist/client.js +5 -17
- package/dist/error.d.ts +27 -0
- package/dist/error.js +32 -0
- package/dist/image-builds.d.ts +6 -0
- package/dist/image-builds.js +12 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +12 -1
- package/dist/retry.d.ts +14 -0
- package/dist/retry.js +49 -0
- package/dist/sandbox/base.d.ts +27 -0
- package/dist/sandbox/base.js +298 -99
- package/dist/sandbox/files.d.ts +24 -25
- package/dist/sandbox/files.js +146 -37
- package/dist/sandbox/image-build/artifacts.d.ts +16 -0
- package/dist/sandbox/image-build/artifacts.js +16 -0
- package/dist/sandbox/image-build/blake2b.d.ts +2 -0
- package/dist/sandbox/image-build/blake2b.js +89 -0
- package/dist/sandbox/image-build/common.d.ts +19 -0
- package/dist/sandbox/image-build/common.js +109 -0
- package/dist/sandbox/image-build/context.d.ts +43 -0
- package/dist/sandbox/image-build/context.js +599 -0
- package/dist/sandbox/image-build/docker-image.d.ts +34 -0
- package/dist/sandbox/image-build/docker-image.js +472 -0
- package/dist/sandbox/image-build/dockerfile-analysis.d.ts +17 -0
- package/dist/sandbox/image-build/dockerfile-analysis.js +409 -0
- package/dist/sandbox/image-build/dockerignore.d.ts +18 -0
- package/dist/sandbox/image-build/dockerignore.js +275 -0
- package/dist/sandbox/image-build/gzip.d.ts +11 -0
- package/dist/sandbox/image-build/gzip.js +91 -0
- package/dist/sandbox/image-build/image-init.d.ts +5 -0
- package/dist/sandbox/image-build/image-init.js +97 -0
- package/dist/sandbox/image-build/index.d.ts +13 -0
- package/dist/sandbox/image-build/index.js +36 -0
- package/dist/sandbox/image-build/local-docker.d.ts +11 -0
- package/dist/sandbox/image-build/local-docker.js +72 -0
- package/dist/sandbox/image-build/resolution.d.ts +27 -0
- package/dist/sandbox/image-build/resolution.js +137 -0
- package/dist/sandbox/image-build/tar.d.ts +41 -0
- package/dist/sandbox/image-build/tar.js +378 -0
- package/dist/sandbox/image-build/upload.d.ts +10 -0
- package/dist/sandbox/image-build/upload.js +143 -0
- package/dist/sandbox/index.d.ts +2 -1
- package/dist/sandbox/index.js +4 -1
- package/dist/sandbox/process-output.d.ts +36 -0
- package/dist/sandbox/process-output.js +117 -0
- package/dist/sandbox/process.d.ts +25 -1
- package/dist/sandbox/process.js +197 -29
- package/dist/sandbox/terminal.js +9 -5
- package/dist/sandbox/ws.d.ts +4 -1
- package/dist/sandbox/ws.js +33 -7
- package/dist/services/base.d.ts +2 -0
- package/dist/services/base.js +46 -30
- package/dist/services/normalize.d.ts +3 -0
- package/dist/services/normalize.js +21 -0
- package/dist/services/sandboxes.d.ts +40 -3
- package/dist/services/sandboxes.js +569 -53
- package/dist/services/volumes.js +29 -14
- package/dist/types/index.d.ts +2 -1
- package/dist/types/sandbox.d.ts +246 -30
- package/dist/types/volume.d.ts +7 -7
- package/package.json +24 -5
package/dist/services/volumes.js
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VolumesService = void 0;
|
|
4
|
-
const
|
|
4
|
+
const error_1 = require("../error");
|
|
5
|
+
const normalize_1 = require("./normalize");
|
|
5
6
|
const base_1 = require("./base");
|
|
7
|
+
const normalizeVolume = (volume) => ({
|
|
8
|
+
...volume,
|
|
9
|
+
size: (0, normalize_1.optionalInteger)(volume.size),
|
|
10
|
+
transferAmount: (0, normalize_1.optionalInteger)(volume.transferAmount),
|
|
11
|
+
});
|
|
6
12
|
class VolumesService extends base_1.BaseService {
|
|
7
13
|
/**
|
|
8
14
|
* Create a new sandbox volume.
|
|
9
15
|
*/
|
|
10
16
|
async create(params) {
|
|
11
17
|
try {
|
|
12
|
-
return await this.request("/volume", {
|
|
18
|
+
return normalizeVolume(await this.request("/volume", {
|
|
13
19
|
method: "POST",
|
|
14
20
|
body: JSON.stringify(params),
|
|
15
|
-
});
|
|
21
|
+
}));
|
|
16
22
|
}
|
|
17
23
|
catch (error) {
|
|
18
|
-
if (error instanceof
|
|
24
|
+
if (error instanceof error_1.HyperbrowserError) {
|
|
19
25
|
throw error;
|
|
20
26
|
}
|
|
21
|
-
throw new
|
|
27
|
+
throw new error_1.HyperbrowserError("Failed to create volume", undefined);
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
@@ -26,17 +32,24 @@ class VolumesService extends base_1.BaseService {
|
|
|
26
32
|
*/
|
|
27
33
|
async list(params = {}) {
|
|
28
34
|
try {
|
|
29
|
-
|
|
35
|
+
const response = await this.request("/volume", undefined, {
|
|
30
36
|
search: params.search,
|
|
31
37
|
page: params.page,
|
|
32
38
|
limit: params.limit,
|
|
33
39
|
});
|
|
40
|
+
return {
|
|
41
|
+
...response,
|
|
42
|
+
volumes: response.volumes.map(normalizeVolume),
|
|
43
|
+
totalCount: (0, normalize_1.optionalInteger)(response.totalCount),
|
|
44
|
+
page: (0, normalize_1.optionalInteger)(response.page),
|
|
45
|
+
perPage: (0, normalize_1.optionalInteger)(response.perPage),
|
|
46
|
+
};
|
|
34
47
|
}
|
|
35
48
|
catch (error) {
|
|
36
|
-
if (error instanceof
|
|
49
|
+
if (error instanceof error_1.HyperbrowserError) {
|
|
37
50
|
throw error;
|
|
38
51
|
}
|
|
39
|
-
throw new
|
|
52
|
+
throw new error_1.HyperbrowserError("Failed to list volumes", undefined);
|
|
40
53
|
}
|
|
41
54
|
}
|
|
42
55
|
/**
|
|
@@ -44,13 +57,13 @@ class VolumesService extends base_1.BaseService {
|
|
|
44
57
|
*/
|
|
45
58
|
async get(id) {
|
|
46
59
|
try {
|
|
47
|
-
return await this.request(`/volume/${id}`);
|
|
60
|
+
return normalizeVolume(await this.request(`/volume/${id}`));
|
|
48
61
|
}
|
|
49
62
|
catch (error) {
|
|
50
|
-
if (error instanceof
|
|
63
|
+
if (error instanceof error_1.HyperbrowserError) {
|
|
51
64
|
throw error;
|
|
52
65
|
}
|
|
53
|
-
throw new
|
|
66
|
+
throw new error_1.HyperbrowserError(`Failed to get volume ${id}`, undefined);
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
69
|
/**
|
|
@@ -60,13 +73,15 @@ class VolumesService extends base_1.BaseService {
|
|
|
60
73
|
*/
|
|
61
74
|
async delete(key) {
|
|
62
75
|
try {
|
|
63
|
-
return await this.request(`/volume/${encodeURIComponent(key)}`, {
|
|
76
|
+
return await this.request(`/volume/${encodeURIComponent(key)}`, {
|
|
77
|
+
method: "DELETE",
|
|
78
|
+
});
|
|
64
79
|
}
|
|
65
80
|
catch (error) {
|
|
66
|
-
if (error instanceof
|
|
81
|
+
if (error instanceof error_1.HyperbrowserError) {
|
|
67
82
|
throw error;
|
|
68
83
|
}
|
|
69
|
-
throw new
|
|
84
|
+
throw new error_1.HyperbrowserError(`Failed to delete volume ${key}`, undefined);
|
|
70
85
|
}
|
|
71
86
|
}
|
|
72
87
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { StartGrokComputerUseTaskParams, StartGrokComputerUseTaskResponse, GrokC
|
|
|
11
11
|
export { StartMetaComputerUseTaskParams, StartMetaComputerUseTaskResponse, MetaComputerUseTaskStatusResponse, MetaComputerUseTaskResponse, MetaComputerUseTaskData, MetaComputerUseStepResponse, MetaComputerUseStepError, MetaComputerUseStepIncompleteDetails, MetaComputerUseStepReasoning, MetaComputerUseApiKeys, MetaComputerUseTaskMetadata, } from "./agents/meta-computer-use";
|
|
12
12
|
export { StartJevComputerUseTaskParams, StartJevComputerUseTaskResponse, JevComputerUseTaskStatusResponse, JevComputerUseTaskResponse, JevComputerUseTaskData, JevComputerUseStepResponse, JevComputerUseApiKeys, JevComputerUseTaskMetadata, } from "./agents/jev-computer-use";
|
|
13
13
|
export { BasicResponse, BrowserMemorySize, SessionStatus, Session, SessionDetail, SessionGetParams, SessionListParams, SessionListResponse, ScreenConfig, CaptchaEvaluationPageResult, CaptchaEvaluationParams, CaptchaEvaluationResponse, CaptchaEvaluationTarget, CaptchaEvaluationType, CaptchaSolverType, CreateSessionParams, CreateSessionSnapshotResponse, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, UploadFileResponse, UploadFileOptions, GetActiveSessionsCountResponse, SessionEventLogListParams, SessionEventLogListResponse, SessionEventLog, SessionProfile, SessionLaunchState, SessionCreditBreakdown, StartSessionFromSnapshotParams, UpdateSessionProfileParams, UpdateSessionProxyLocationParams, UpdateSessionProxyParams, UpdateSessionScreenParams, UpdateSessionSolveCaptchasParams, UpdateSessionSolveCaptchasResponse, } from "./session";
|
|
14
|
-
export { SandboxStatus, SandboxRuntimeTarget, SandboxNetworkPolicy, SandboxNetworkPolicyPatch, SandboxNetworkUpdateResult, Sandbox, SandboxDetail, SandboxVolumeMountType, SandboxVolumeMount, SandboxListParams, SandboxListResponse, SandboxImageSource, SandboxImageSummary, SandboxImageListParams, SandboxImageListResponse, SandboxSnapshotStatus, SandboxSnapshotSummary, SandboxSnapshotListParams, SandboxSnapshotListResponse, SandboxSnapshotDeleteResult, SandboxImageDeleteResult, SandboxImageBuildStatus, SandboxImageBuildUpload, SandboxImageBuild, CreateSandboxImageBuildParams, CompleteSandboxImageBuildParams, SandboxImageBuildCreateResult, SandboxImageBuildListParams, SandboxImageBuildListResponse, CreateSandboxParams, SandboxMemorySnapshotParams, SandboxMemorySnapshotResult, SandboxExposeParams, SandboxExposeResult, SandboxUnexposeResult, SandboxProcessStatus, SandboxExecParams, SandboxExecOptions, SandboxProcessSummary, SandboxProcessResult, SandboxProcessListParams, SandboxProcessListResponse, SandboxProcessWaitParams, SandboxProcessSignal, SandboxProcessStdinParams, SandboxProcessStreamEvent, SandboxFileType, SandboxFileInfo, SandboxFileWriteInfo, SandboxFileListOptions, SandboxFileReadFormat, SandboxFileReadOptions, SandboxFileWriteData, SandboxFileWriteEntry, SandboxFileTextWriteOptions, SandboxFileBytesWriteOptions, SandboxFileMakeDirOptions, SandboxFileCopyParams, SandboxFileChmodParams, SandboxFileChownParams, SandboxFileTransferResult, SandboxFileSystemEventType, SandboxFileSystemEvent, SandboxWatchDirOptions, SandboxPresignFileParams, SandboxPresignedUrl, SandboxTerminalCreateParams, SandboxTerminalOutputChunk, SandboxTerminalStatus, SandboxTerminalWaitParams, SandboxTerminalKillParams, SandboxTerminalEvent, } from "./sandbox";
|
|
14
|
+
export { SandboxStatus, SandboxRuntimeTarget, SandboxNetworkPolicy, SandboxNetworkPolicyPatch, SandboxNetworkUpdateResult, Sandbox, SandboxDetail, SandboxVolumeMountType, SandboxVolumeMount, SandboxListParams, SandboxListResponse, SandboxImageSource, SandboxImageSummary, SandboxImageListParams, SandboxImageListResponse, SandboxSnapshotStatus, SandboxSnapshotSummary, SandboxSnapshotListParams, SandboxSnapshotListResponse, SandboxSnapshotDeleteResult, SandboxImageDeleteResult, SandboxImageInit, SandboxImageBuildStatus, SandboxImageBuildInputFormat, SandboxImageBuildSourcePlatform, SandboxImageBuildUpload, SandboxImageBuild, SandboxBuildContextBundle, SandboxBuildContextMode, SandboxBuildContextManifest, SandboxDockerImageConfig, SandboxDockerImageLayer, SandboxDockerImageManifest, CreateSandboxImageBuildParams, ReuseSandboxDockerImageParams, CompleteSandboxImageBuildParams, SandboxImageBuildCreateResult, SandboxDockerImageReuseResult, SandboxImageBuildResolutionOutcome, SandboxImageBuildResolution, SandboxImageBuildWaitOptions, BuildSandboxImageFromDockerImageOptions, BuildSandboxImageFromDockerfileOptions, GetOrBuildSandboxImageOptions, SandboxImageBuildListParams, SandboxImageBuildListResponse, CreateSandboxParams, SandboxMemorySnapshotParams, SandboxMemorySnapshotResult, SandboxExposeParams, SandboxExposeResult, SandboxUnexposeResult, SandboxProcessStatus, SandboxExecParams, SandboxExecOptions, SandboxProcessSummary, SandboxProcessResult, SandboxProcessListParams, SandboxProcessListResponse, SandboxProcessWaitParams, SandboxProcessSignal, SandboxProcessStdinParams, SandboxProcessOutputEvent, SandboxProcessExitEvent, SandboxProcessStreamEvent, SandboxFileType, SandboxFileInfo, SandboxFileWriteInfo, SandboxFileListOptions, SandboxFileReadFormat, SandboxFileReadOptions, SandboxFileWriteData, SandboxFileWriteEntry, SandboxFileTextWriteOptions, SandboxFileBytesWriteOptions, SandboxFileMakeDirOptions, SandboxFileCopyParams, SandboxFileChmodParams, SandboxFileChownParams, SandboxFileTransferResult, SandboxFileSystemEventType, SandboxFileSystemEvent, SandboxWatchDirOptions, SandboxPresignFileParams, SandboxPresignedUrl, SandboxTerminalCreateParams, SandboxTerminalOutputChunk, SandboxTerminalStatus, SandboxTerminalWaitParams, SandboxTerminalKillParams, SandboxTerminalEvent, } from "./sandbox";
|
|
15
15
|
export { CreateVolumeParams, Volume, VolumeListParams, VolumeListResponse, VolumeDeleteResult, } from "./volume";
|
|
16
16
|
export { CreateProfileParams, ForkProfileParams, ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
|
|
17
17
|
export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
|
|
@@ -23,3 +23,4 @@ export { StartBatchFetchJobParams, GetBatchFetchJobParams, StartBatchFetchJobRes
|
|
|
23
23
|
export { WebSearchParams, WebSearchResponse, WebSearchResponseData, WebSearchResultItem, WebSearchFilters, WebSearchLocation, WebSearchFiletype, WebSearchStatus, } from "./web/search";
|
|
24
24
|
export { FetchStealthMode, FetchSanitizeMode, FetchWaitUntil, FetchScreenshotFormat, PageStatus, FetchOutputScreenshotOptions, FetchStorageStateOptions, FetchBrowserLocationOptions, PageData, FetchOutputMarkdown, FetchOutputHtml, FetchOutputLinks, FetchOutputScreenshot, FetchOutputJsonOptions, FetchOutputJson, FetchOutputBranding, FetchOutputFormat, FetchOutputOptions, FetchBrowserOptions, FetchNavigationOptions, FetchCacheOptions, } from "./web/common";
|
|
25
25
|
export { BrandingProfile, BrandingColors, BrandingFont, BrandingFontRole, BrandingTypography, BrandingFontFamilies, BrandingFontStacks, BrandingFontSizes, BrandingSpacing, BrandingComponents, BrandingButtonStyle, BrandingInputStyle, BrandingBorderRadiusCorners, BrandingImages, BrandingPersonality, BrandingPersonalityTone, BrandingPersonalityEnergy, BrandingDesignSystem, BrandingDesignFramework, BrandingConfidence, BrandingColorScheme, } from "./web/branding";
|
|
26
|
+
export type { StartSandboxFromSnapshotParams, SandboxRuntimeSession, SandboxFileUploadStream, SandboxFileUploadStreamOptions, SandboxFileDownloadStreamOptions, SandboxFileMoveParams, SandboxFileRenameOptions, SandboxFileWatchParams, SandboxFileWatchEvent, SandboxFileWatchStatus, SandboxFileWatchEventsParams, SandboxFileWatchStreamEvent, } from "./sandbox";
|
package/dist/types/sandbox.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { SessionRegion } from "./constants";
|
|
|
4
4
|
import { SessionLaunchState, SessionStatus } from "./session";
|
|
5
5
|
export type SandboxStatus = SessionStatus;
|
|
6
6
|
export interface SandboxNetworkPolicy {
|
|
7
|
-
allowInternetAccess
|
|
7
|
+
allowInternetAccess?: boolean | null;
|
|
8
8
|
allowOut: string[];
|
|
9
9
|
denyOut: string[];
|
|
10
10
|
}
|
|
@@ -22,6 +22,18 @@ export interface SandboxRuntimeTarget {
|
|
|
22
22
|
baseUrl: string;
|
|
23
23
|
}
|
|
24
24
|
export interface Sandbox {
|
|
25
|
+
runtimeClass?: "firecracker" | "gvisor-cpu";
|
|
26
|
+
capabilities?: {
|
|
27
|
+
commands: boolean;
|
|
28
|
+
files: boolean;
|
|
29
|
+
pty: boolean;
|
|
30
|
+
gpu: boolean;
|
|
31
|
+
snapshots: boolean;
|
|
32
|
+
volumes: boolean;
|
|
33
|
+
exposedPorts: boolean;
|
|
34
|
+
internetAccess: boolean;
|
|
35
|
+
writableStorage: "memory";
|
|
36
|
+
};
|
|
25
37
|
id: string;
|
|
26
38
|
teamId: string;
|
|
27
39
|
status: SandboxStatus;
|
|
@@ -30,21 +42,21 @@ export interface Sandbox {
|
|
|
30
42
|
createdAt: string;
|
|
31
43
|
updatedAt: string;
|
|
32
44
|
closeReason?: string | null;
|
|
33
|
-
dataConsumed?: number;
|
|
34
|
-
proxyDataConsumed?: number;
|
|
35
|
-
usageType?: string;
|
|
45
|
+
dataConsumed?: number | null;
|
|
46
|
+
proxyDataConsumed?: number | null;
|
|
47
|
+
usageType?: string | null;
|
|
36
48
|
jobId?: string | null;
|
|
37
49
|
launchState?: SessionLaunchState | null;
|
|
38
50
|
creditsUsed: number | null;
|
|
39
51
|
region: SessionRegion;
|
|
40
52
|
sessionUrl: string;
|
|
41
53
|
duration: number;
|
|
42
|
-
proxyBytesUsed
|
|
54
|
+
proxyBytesUsed?: number | null;
|
|
43
55
|
cpu?: number | null;
|
|
44
56
|
memoryMiB?: number | null;
|
|
45
57
|
diskMiB?: number | null;
|
|
46
58
|
timeoutMinutes?: number | null;
|
|
47
|
-
network?: SandboxNetworkPolicy;
|
|
59
|
+
network?: SandboxNetworkPolicy | null;
|
|
48
60
|
runtime: SandboxRuntimeTarget;
|
|
49
61
|
exposedPorts: SandboxExposeResult[];
|
|
50
62
|
}
|
|
@@ -59,6 +71,7 @@ export interface SandboxVolumeMount {
|
|
|
59
71
|
shared?: boolean;
|
|
60
72
|
}
|
|
61
73
|
interface SandboxCreateCommonParams {
|
|
74
|
+
runtimeClass?: "firecracker" | "gvisor-cpu";
|
|
62
75
|
region?: SessionRegion;
|
|
63
76
|
enableRecording?: boolean;
|
|
64
77
|
exposedPorts?: SandboxExposeParams[];
|
|
@@ -100,13 +113,20 @@ export interface SandboxListResponse {
|
|
|
100
113
|
perPage: number;
|
|
101
114
|
}
|
|
102
115
|
export type SandboxImageSource = "public" | "team";
|
|
116
|
+
export interface SandboxImageInit {
|
|
117
|
+
env?: Record<string, string>;
|
|
118
|
+
command?: string;
|
|
119
|
+
args?: string[];
|
|
120
|
+
workingDir?: string;
|
|
121
|
+
}
|
|
103
122
|
export interface SandboxImageSummary {
|
|
104
123
|
id: string;
|
|
105
124
|
imageName: string;
|
|
106
125
|
namespace: string;
|
|
107
126
|
source?: SandboxImageSource;
|
|
108
|
-
imageInit?: Record<string, unknown> | null;
|
|
127
|
+
imageInit?: SandboxImageInit | Record<string, unknown> | null;
|
|
109
128
|
uploaded: boolean;
|
|
129
|
+
ready?: boolean | null;
|
|
110
130
|
createdAt: string;
|
|
111
131
|
updatedAt: string;
|
|
112
132
|
}
|
|
@@ -134,7 +154,7 @@ export interface SandboxSnapshotSummary {
|
|
|
134
154
|
vcpus?: number | null;
|
|
135
155
|
memMiB?: number | null;
|
|
136
156
|
diskSizeMiB?: number | null;
|
|
137
|
-
compatibilityTag
|
|
157
|
+
compatibilityTag?: string | null;
|
|
138
158
|
metadata: Record<string, unknown>;
|
|
139
159
|
uploaded: boolean;
|
|
140
160
|
createdAt: string;
|
|
@@ -163,7 +183,10 @@ export interface SandboxImageDeleteResult {
|
|
|
163
183
|
uploaded?: boolean;
|
|
164
184
|
}
|
|
165
185
|
export type SandboxImageBuildStatus = "awaiting_upload" | "upload_verified" | "dispatching" | "building" | "verifying" | "completed" | "failed" | "canceled";
|
|
186
|
+
export type SandboxImageBuildInputFormat = "rootfs_export_tar_gz" | "dockerfile_context_tar_gz" | "dockerfile_context_manifest_v1" | "docker_image_manifest_v1";
|
|
187
|
+
export type SandboxImageBuildSourcePlatform = "linux/amd64";
|
|
166
188
|
export interface SandboxImageBuildUpload {
|
|
189
|
+
sha256?: string | null;
|
|
167
190
|
url: string;
|
|
168
191
|
method: string;
|
|
169
192
|
headers: Record<string, string>;
|
|
@@ -193,27 +216,150 @@ export interface SandboxImageBuild {
|
|
|
193
216
|
createdAt?: string | null;
|
|
194
217
|
updatedAt?: string | null;
|
|
195
218
|
}
|
|
219
|
+
export interface SandboxBuildContextBundle {
|
|
220
|
+
sha256: string;
|
|
221
|
+
sizeBytes: number;
|
|
222
|
+
uncompressedSizeBytes: number;
|
|
223
|
+
entryCount: number;
|
|
224
|
+
}
|
|
225
|
+
export type SandboxBuildContextMode = "sparse" | "full";
|
|
226
|
+
export interface SandboxBuildContextManifest {
|
|
227
|
+
version: 1;
|
|
228
|
+
dockerfilePath: string;
|
|
229
|
+
contextMode: SandboxBuildContextMode;
|
|
230
|
+
fallbackReason?: string;
|
|
231
|
+
bundles: SandboxBuildContextBundle[];
|
|
232
|
+
}
|
|
233
|
+
export interface SandboxDockerImageConfig {
|
|
234
|
+
sha256: string;
|
|
235
|
+
sizeBytes: number;
|
|
236
|
+
dataBase64: string;
|
|
237
|
+
}
|
|
238
|
+
export interface SandboxDockerImageLayer {
|
|
239
|
+
sha256: string;
|
|
240
|
+
sizeBytes: number;
|
|
241
|
+
}
|
|
242
|
+
export interface SandboxDockerImageManifest {
|
|
243
|
+
version: 1;
|
|
244
|
+
imageDigest: string;
|
|
245
|
+
descriptor?: SandboxDockerImageConfig;
|
|
246
|
+
config: SandboxDockerImageConfig;
|
|
247
|
+
layers: SandboxDockerImageLayer[];
|
|
248
|
+
}
|
|
196
249
|
export interface CreateSandboxImageBuildParams {
|
|
197
250
|
imageName: string;
|
|
198
251
|
inputSha256: string;
|
|
199
252
|
inputSizeBytes: number;
|
|
200
|
-
|
|
201
|
-
|
|
253
|
+
/** Builder vCPUs (sent as `vcpus`). */
|
|
254
|
+
builderCpus?: number;
|
|
255
|
+
/** Builder memory in MiB (sent as `memMiB`). */
|
|
256
|
+
builderMemoryMiB?: number;
|
|
257
|
+
/** Builder scratch disk in MiB (sent as `scratchMiB`). */
|
|
258
|
+
builderScratchMiB?: number;
|
|
259
|
+
inputFormat?: SandboxImageBuildInputFormat;
|
|
260
|
+
sourcePlatform?: SandboxImageBuildSourcePlatform;
|
|
202
261
|
imageConfigUser?: string;
|
|
203
|
-
imageInit?:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
262
|
+
imageInit?: SandboxImageInit;
|
|
263
|
+
dockerfilePath?: string;
|
|
264
|
+
contextManifest?: SandboxBuildContextManifest;
|
|
265
|
+
dockerImageManifest?: SandboxDockerImageManifest;
|
|
266
|
+
}
|
|
267
|
+
export interface ReuseSandboxDockerImageParams {
|
|
268
|
+
imageName: string;
|
|
269
|
+
sourceImageDigest: string;
|
|
270
|
+
sourcePlatform?: SandboxImageBuildSourcePlatform;
|
|
271
|
+
imageConfigUser?: string;
|
|
272
|
+
imageInit?: SandboxImageInit;
|
|
208
273
|
}
|
|
209
274
|
export interface CompleteSandboxImageBuildParams {
|
|
210
275
|
inputSha256: string;
|
|
211
276
|
inputSizeBytes: number;
|
|
212
|
-
inputFormat?:
|
|
277
|
+
inputFormat?: SandboxImageBuildInputFormat;
|
|
213
278
|
}
|
|
214
279
|
export interface SandboxImageBuildCreateResult {
|
|
215
280
|
build: SandboxImageBuild;
|
|
216
|
-
upload
|
|
281
|
+
upload?: SandboxImageBuildUpload | null;
|
|
282
|
+
uploads?: SandboxImageBuildUpload[];
|
|
283
|
+
}
|
|
284
|
+
export interface SandboxDockerImageReuseResult {
|
|
285
|
+
hit: boolean;
|
|
286
|
+
build?: SandboxImageBuild | null;
|
|
287
|
+
}
|
|
288
|
+
export type SandboxImageBuildResolutionOutcome = "reused" | "joined" | "created";
|
|
289
|
+
/**
|
|
290
|
+
* The result of resolving content-derived image inputs.
|
|
291
|
+
*
|
|
292
|
+
* `imageId` is populated only for a ready image. With `wait: false`, `build`
|
|
293
|
+
* identifies the submitted or joined build, which the caller can poll later.
|
|
294
|
+
*/
|
|
295
|
+
export interface SandboxImageBuildResolution {
|
|
296
|
+
outcome: SandboxImageBuildResolutionOutcome;
|
|
297
|
+
imageName: string;
|
|
298
|
+
imageId?: string;
|
|
299
|
+
build?: SandboxImageBuild;
|
|
300
|
+
}
|
|
301
|
+
export interface SandboxImageBuildWaitOptions {
|
|
302
|
+
signal?: AbortSignal;
|
|
303
|
+
/** Seconds between status polls. Defaults to 3. */
|
|
304
|
+
pollInterval?: number;
|
|
305
|
+
/** Seconds to wait before giving up. `null` waits forever. Defaults to 35 minutes. */
|
|
306
|
+
timeout?: number | null;
|
|
307
|
+
}
|
|
308
|
+
interface SandboxImageBuildCommonOptions {
|
|
309
|
+
/** Cancel this caller's polling; accepted builds and uploads continue independently. */
|
|
310
|
+
signal?: AbortSignal;
|
|
311
|
+
imageName: string;
|
|
312
|
+
platform?: string;
|
|
313
|
+
imageInit?: SandboxImageInit;
|
|
314
|
+
imageConfigUser?: string;
|
|
315
|
+
builderCpus?: number;
|
|
316
|
+
builderMemoryMiB?: number;
|
|
317
|
+
builderScratchMiB?: number;
|
|
318
|
+
/** Wait for the build to complete. Defaults to true. */
|
|
319
|
+
wait?: boolean;
|
|
320
|
+
pollInterval?: number;
|
|
321
|
+
waitTimeout?: number | null;
|
|
322
|
+
/** Directory for temporary packaging artifacts. */
|
|
323
|
+
tempDir?: string;
|
|
324
|
+
/** Per-upload inactivity timeout in seconds. */
|
|
325
|
+
uploadTimeout?: number | null;
|
|
326
|
+
}
|
|
327
|
+
export interface BuildSandboxImageFromDockerImageOptions extends SandboxImageBuildCommonOptions {
|
|
328
|
+
dockerImage: string;
|
|
329
|
+
expectedImageDigest?: string;
|
|
330
|
+
}
|
|
331
|
+
export interface BuildSandboxImageFromDockerfileOptions extends SandboxImageBuildCommonOptions {
|
|
332
|
+
contextPath: string;
|
|
333
|
+
dockerfile?: string;
|
|
334
|
+
/** Send the build context to Hyperbrowser (default) instead of building with local Docker. */
|
|
335
|
+
remote?: boolean;
|
|
336
|
+
remoteFullContext?: boolean;
|
|
337
|
+
expectedContextFingerprint?: string;
|
|
338
|
+
dockerTag?: string;
|
|
339
|
+
buildArgs?: Record<string, string>;
|
|
340
|
+
}
|
|
341
|
+
export interface GetOrBuildSandboxImageOptions {
|
|
342
|
+
/** Cancel this caller's polling; accepted builds and uploads continue independently. */
|
|
343
|
+
signal?: AbortSignal;
|
|
344
|
+
contextPath?: string;
|
|
345
|
+
dockerImage?: string;
|
|
346
|
+
imageNamePrefix?: string;
|
|
347
|
+
dockerfile?: string;
|
|
348
|
+
platform?: string;
|
|
349
|
+
remoteFullContext?: boolean;
|
|
350
|
+
expectedContextFingerprint?: string;
|
|
351
|
+
expectedImageDigest?: string;
|
|
352
|
+
imageInit?: SandboxImageInit;
|
|
353
|
+
imageConfigUser?: string;
|
|
354
|
+
builderCpus?: number;
|
|
355
|
+
builderMemoryMiB?: number;
|
|
356
|
+
builderScratchMiB?: number;
|
|
357
|
+
forceBuild?: boolean;
|
|
358
|
+
wait?: boolean;
|
|
359
|
+
pollInterval?: number;
|
|
360
|
+
waitTimeout?: number | null;
|
|
361
|
+
uploadTimeout?: number | null;
|
|
362
|
+
tempDir?: string;
|
|
217
363
|
}
|
|
218
364
|
export interface SandboxImageBuildListParams {
|
|
219
365
|
status?: SandboxImageBuildStatus;
|
|
@@ -242,7 +388,7 @@ export interface SandboxExposeResult {
|
|
|
242
388
|
port: number;
|
|
243
389
|
auth: boolean;
|
|
244
390
|
url: string;
|
|
245
|
-
browserUrl?: string;
|
|
391
|
+
browserUrl?: string | null;
|
|
246
392
|
browserUrlExpiresAt?: string | null;
|
|
247
393
|
}
|
|
248
394
|
export interface SandboxUnexposeResult {
|
|
@@ -251,7 +397,11 @@ export interface SandboxUnexposeResult {
|
|
|
251
397
|
}
|
|
252
398
|
export type SandboxProcessStatus = "queued" | "running" | "exited" | "failed" | "killed" | "timed_out";
|
|
253
399
|
export interface SandboxExecParams {
|
|
400
|
+
/** Cancel local collection without killing the detached command. */
|
|
401
|
+
signal?: AbortSignal;
|
|
254
402
|
command: string;
|
|
403
|
+
/** Maximum combined stdout/stderr bytes collected locally. Defaults to 64 MiB. */
|
|
404
|
+
maxOutputBytes?: number;
|
|
255
405
|
/** @deprecated Legacy compatibility only. Converted into a single shell command string. */
|
|
256
406
|
args?: string[];
|
|
257
407
|
cwd?: string;
|
|
@@ -267,12 +417,12 @@ export interface SandboxProcessSummary {
|
|
|
267
417
|
id: string;
|
|
268
418
|
status: SandboxProcessStatus;
|
|
269
419
|
command: string;
|
|
270
|
-
args?: string[];
|
|
420
|
+
args?: string[] | null;
|
|
271
421
|
cwd: string;
|
|
272
|
-
pid?: number;
|
|
422
|
+
pid?: number | null;
|
|
273
423
|
exitCode?: number | null;
|
|
274
424
|
startedAt: number;
|
|
275
|
-
completedAt?: number;
|
|
425
|
+
completedAt?: number | null;
|
|
276
426
|
}
|
|
277
427
|
export interface SandboxProcessResult {
|
|
278
428
|
id: string;
|
|
@@ -281,8 +431,10 @@ export interface SandboxProcessResult {
|
|
|
281
431
|
stdout: string;
|
|
282
432
|
stderr: string;
|
|
283
433
|
startedAt: number;
|
|
284
|
-
completedAt?: number;
|
|
285
|
-
error?: string;
|
|
434
|
+
completedAt?: number | null;
|
|
435
|
+
error?: string | null;
|
|
436
|
+
outputTruncated?: boolean;
|
|
437
|
+
lastSeq?: number | null;
|
|
286
438
|
}
|
|
287
439
|
export interface SandboxProcessListParams {
|
|
288
440
|
status?: SandboxProcessStatus | SandboxProcessStatus[];
|
|
@@ -305,15 +457,17 @@ export interface SandboxProcessStdinParams {
|
|
|
305
457
|
encoding?: "utf8" | "base64";
|
|
306
458
|
eof?: boolean;
|
|
307
459
|
}
|
|
308
|
-
export
|
|
460
|
+
export interface SandboxProcessOutputEvent {
|
|
309
461
|
type: "stdout" | "stderr" | "system";
|
|
310
462
|
seq: number;
|
|
311
463
|
data: string;
|
|
312
464
|
timestamp: number;
|
|
313
|
-
}
|
|
465
|
+
}
|
|
466
|
+
export interface SandboxProcessExitEvent {
|
|
314
467
|
type: "exit";
|
|
315
468
|
result: SandboxProcessResult;
|
|
316
|
-
}
|
|
469
|
+
}
|
|
470
|
+
export type SandboxProcessStreamEvent = SandboxProcessOutputEvent | SandboxProcessExitEvent;
|
|
317
471
|
export type SandboxFileType = "file" | "dir";
|
|
318
472
|
export interface SandboxFileInfo {
|
|
319
473
|
path: string;
|
|
@@ -426,17 +580,17 @@ export interface SandboxTerminalOutputChunk {
|
|
|
426
580
|
export interface SandboxTerminalStatus {
|
|
427
581
|
id: string;
|
|
428
582
|
command: string;
|
|
429
|
-
args?: string[];
|
|
583
|
+
args?: string[] | null;
|
|
430
584
|
cwd: string;
|
|
431
|
-
pid?: number;
|
|
585
|
+
pid?: number | null;
|
|
432
586
|
running: boolean;
|
|
433
587
|
exitCode?: number | null;
|
|
434
|
-
error?: string;
|
|
588
|
+
error?: string | null;
|
|
435
589
|
timedOut?: boolean;
|
|
436
590
|
rows: number;
|
|
437
591
|
cols: number;
|
|
438
592
|
startedAt: number;
|
|
439
|
-
finishedAt?: number;
|
|
593
|
+
finishedAt?: number | null;
|
|
440
594
|
output?: SandboxTerminalOutputChunk[];
|
|
441
595
|
}
|
|
442
596
|
export interface SandboxTerminalWaitParams {
|
|
@@ -453,4 +607,66 @@ export type SandboxTerminalEvent = ({
|
|
|
453
607
|
type: "exit";
|
|
454
608
|
status: SandboxTerminalStatus;
|
|
455
609
|
};
|
|
610
|
+
/** True streaming transfer inputs; strings in iterable chunks are UTF-8. */
|
|
611
|
+
export type SandboxFileUploadStream = AsyncIterable<Uint8Array | string> | Iterable<Uint8Array | string>;
|
|
612
|
+
export interface SandboxFileUploadStreamOptions {
|
|
613
|
+
contentLength?: number;
|
|
614
|
+
signal?: AbortSignal;
|
|
615
|
+
}
|
|
616
|
+
export interface SandboxFileDownloadStreamOptions {
|
|
617
|
+
signal?: AbortSignal;
|
|
618
|
+
}
|
|
619
|
+
export interface SandboxFileMoveParams {
|
|
620
|
+
source: string;
|
|
621
|
+
destination: string;
|
|
622
|
+
overwrite?: boolean;
|
|
623
|
+
}
|
|
624
|
+
export interface SandboxFileRenameOptions {
|
|
625
|
+
overwrite?: boolean;
|
|
626
|
+
}
|
|
627
|
+
export interface SandboxFileWatchParams {
|
|
628
|
+
recursive?: boolean;
|
|
629
|
+
}
|
|
630
|
+
export interface SandboxFileWatchEvent {
|
|
631
|
+
seq: number;
|
|
632
|
+
path: string;
|
|
633
|
+
op: string;
|
|
634
|
+
timestamp: number;
|
|
635
|
+
}
|
|
636
|
+
export interface SandboxFileWatchStatus {
|
|
637
|
+
id: string;
|
|
638
|
+
path: string;
|
|
639
|
+
recursive: boolean;
|
|
640
|
+
active: boolean;
|
|
641
|
+
error?: string | null;
|
|
642
|
+
createdAt: number;
|
|
643
|
+
stoppedAt?: number | null;
|
|
644
|
+
oldestSeq?: number;
|
|
645
|
+
lastSeq?: number;
|
|
646
|
+
eventCount?: number;
|
|
647
|
+
events?: SandboxFileWatchEvent[] | null;
|
|
648
|
+
}
|
|
649
|
+
export interface SandboxFileWatchEventsParams {
|
|
650
|
+
cursor?: number;
|
|
651
|
+
route?: "ws" | "stream";
|
|
652
|
+
signal?: AbortSignal;
|
|
653
|
+
}
|
|
654
|
+
export type SandboxFileWatchStreamEvent = {
|
|
655
|
+
type: "event";
|
|
656
|
+
event: SandboxFileWatchEvent;
|
|
657
|
+
} | {
|
|
658
|
+
type: "done";
|
|
659
|
+
status: SandboxFileWatchStatus;
|
|
660
|
+
};
|
|
661
|
+
export type StartSandboxFromSnapshotParams = Extract<CreateSandboxParams, {
|
|
662
|
+
snapshotName: string;
|
|
663
|
+
}>;
|
|
664
|
+
export interface SandboxRuntimeSession {
|
|
665
|
+
sandboxId: string;
|
|
666
|
+
status: SandboxStatus;
|
|
667
|
+
region: SessionRegion;
|
|
668
|
+
token: string;
|
|
669
|
+
tokenExpiresAt: string | null;
|
|
670
|
+
runtime: SandboxRuntimeTarget;
|
|
671
|
+
}
|
|
456
672
|
export {};
|
package/dist/types/volume.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export interface CreateVolumeParams {
|
|
|
4
4
|
export interface Volume {
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
7
|
-
size?: number;
|
|
8
|
-
transferAmount?: number;
|
|
7
|
+
size?: number | null;
|
|
8
|
+
transferAmount?: number | null;
|
|
9
9
|
}
|
|
10
10
|
export interface VolumeListParams {
|
|
11
11
|
search?: string;
|
|
@@ -14,12 +14,12 @@ export interface VolumeListParams {
|
|
|
14
14
|
}
|
|
15
15
|
export interface VolumeListResponse {
|
|
16
16
|
volumes: Volume[];
|
|
17
|
-
totalCount?: number;
|
|
18
|
-
page?: number;
|
|
19
|
-
perPage?: number;
|
|
17
|
+
totalCount?: number | null;
|
|
18
|
+
page?: number | null;
|
|
19
|
+
perPage?: number | null;
|
|
20
20
|
}
|
|
21
21
|
export interface VolumeDeleteResult {
|
|
22
22
|
deleted: boolean;
|
|
23
|
-
id?: string;
|
|
24
|
-
name?: string;
|
|
23
|
+
id?: string | null;
|
|
24
|
+
name?: string | null;
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperbrowser/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Node SDK for Hyperbrowser API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"repository": {
|
|
@@ -17,13 +17,15 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsc",
|
|
20
|
-
"lint": "eslint src/**/*.ts",
|
|
20
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
21
21
|
"prepare": "yarn build",
|
|
22
22
|
"test": "vitest run",
|
|
23
|
-
"test:
|
|
24
|
-
"test:
|
|
23
|
+
"test:unit": "vitest run --project unit",
|
|
24
|
+
"test:e2e": "vitest run --project e2e",
|
|
25
|
+
"test:integration": "vitest run --project integration",
|
|
25
26
|
"test:watch": "vitest",
|
|
26
|
-
"format": "prettier --write 'src/**/*.ts'"
|
|
27
|
+
"format": "prettier --write 'src/**/*.ts'",
|
|
28
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.tests.json"
|
|
27
29
|
},
|
|
28
30
|
"files": [
|
|
29
31
|
"dist",
|
|
@@ -73,6 +75,14 @@
|
|
|
73
75
|
"./tools": {
|
|
74
76
|
"types": "./dist/tools/index.d.ts",
|
|
75
77
|
"default": "./dist/tools/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./image-builds": {
|
|
80
|
+
"types": "./dist/image-builds.d.ts",
|
|
81
|
+
"default": "./dist/image-builds.js"
|
|
82
|
+
},
|
|
83
|
+
"./sandbox": {
|
|
84
|
+
"types": "./dist/sandbox/index.d.ts",
|
|
85
|
+
"default": "./dist/sandbox/index.js"
|
|
76
86
|
}
|
|
77
87
|
},
|
|
78
88
|
"typesVersions": {
|
|
@@ -82,7 +92,16 @@
|
|
|
82
92
|
],
|
|
83
93
|
"tools": [
|
|
84
94
|
"./dist/tools/index.d.ts"
|
|
95
|
+
],
|
|
96
|
+
"image-builds": [
|
|
97
|
+
"./dist/image-builds.d.ts"
|
|
98
|
+
],
|
|
99
|
+
"sandbox": [
|
|
100
|
+
"./dist/sandbox/index.d.ts"
|
|
85
101
|
]
|
|
86
102
|
}
|
|
103
|
+
},
|
|
104
|
+
"engines": {
|
|
105
|
+
"node": ">=20.20.2"
|
|
87
106
|
}
|
|
88
107
|
}
|