disk 1.14.0 → 1.15.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 +149 -37
- package/dist/{archil-DaIWdn2s.d.cts → archil-CenIy1WD.d.mts} +86 -2
- package/dist/{archil-DbdoAk0f.d.mts → archil-DHPfg1b9.d.cts} +86 -2
- package/dist/archil-cli.mjs +591 -0
- package/dist/cli.mjs +6 -275
- package/dist/disk-command-CvRVHqnG.mjs +285 -0
- package/dist/index.cjs +21 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -2
- package/dist/internal/tools.d.cts +1 -1
- package/dist/internal/tools.d.mts +1 -1
- package/dist/node/index.cjs +21 -1
- package/dist/node/index.mjs +14 -2
- package/dist/node/sandbox-desktop-CrvuoiGi.mjs +150 -0
- package/dist/node/sandbox-desktop-DBs8jhKW.cjs +197 -0
- package/dist/node/tunnel.cjs +253 -0
- package/dist/node/tunnel.mjs +248 -0
- package/dist/sandbox-cli.mjs +4 -496
- package/dist/sandbox-command-DJZqMVHm.mjs +1073 -0
- package/dist/sandbox-desktop-CrvuoiGi.mjs +150 -0
- package/dist/sandbox-desktop-DBs8jhKW.cjs +197 -0
- package/dist/{sandbox-options-trHjQs_f.mjs → sandbox-options-AO9jKF4-.mjs} +182 -9
- package/dist/{src-DGB_iQTG.mjs → src-BFPiWUCL.mjs} +13 -1
- package/dist/tunnel.cjs +253 -0
- package/dist/tunnel.d.cts +77 -0
- package/dist/tunnel.d.mts +77 -0
- package/dist/tunnel.mjs +248 -0
- package/package.json +12 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as ApiTokenResponse, $t as SandboxFileUploadOptions, A as DiskMultipart, At as ExecVmOptions, B as MultipartUploadListing, Bt as SandboxMount, C as AppendObjectOptions, Ct as RootAttrs, D as DeleteObjectsOptions, Dt as TokenUser, E as DeleteObjectsError, Et as S3User, F as ListObjectsOptions, Ft as SandboxEgressPolicy, G as PosixCreateAttrs, Gt as SandboxPortTokenPage, H as ObjectMetadata, Ht as SandboxNetwork, I as ListObjectsResult, It as SandboxEgressRule, J as S3Object, Jt as SandboxStatus, K as PutObjectOptions, Kt as SandboxResponse, L as ListPartsOptions, Lt as SandboxEgressTransform, M as GrepOptions, Mt as CreatedSandboxPortToken, N as GrepResult, Nt as ListSandboxPortTokensOptions, O as DeleteObjectsResult, Ot as FileSystem, P as ListMultipartUploadsOptions, Pt as Sandbox, Q as effectiveUploadPartSize, Qt as SandboxFileSource, R as MountOptions, Rt as SandboxEndpoint, S as ListDisksOptions, St as R2Mount, T as CreateBranchOptions, Tt as S3Mount, U as PartInfo, Ut as SandboxNetworkAction, V as MultipartUploadSummary, Vt as SandboxMountSpec, W as PartListing, Wt as SandboxPortToken, X as ShareUrlResult, Xt as SandboxTimeoutOptions, Y as ShareUrlOptions, Yt as SandboxTimeoutAction, Z as UploadPart, Zt as SandboxWaitOptions, _ as Images, _t as GrepMatch, a as ExecOptions, an as SandboxProcessOutputHandler, at as CreateApiTokenRequest, b as DiskListPage, bt as MountConfigResponse, c as Tokens, cn as SandboxProcessStatus, ct as DiskMetrics, d as Sandboxes, dn as SandboxTerminalOptions, dt as DiskUser, en as SandboxFileWriter, et as AuthorizedUser, f as BuildImageOptions, fn as
|
|
1
|
+
import { $ as ApiTokenResponse, $t as SandboxFileUploadOptions, A as DiskMultipart, At as ExecVmOptions, B as MultipartUploadListing, Bt as SandboxMount, C as AppendObjectOptions, Ct as RootAttrs, D as DeleteObjectsOptions, Dt as TokenUser, E as DeleteObjectsError, Et as S3User, F as ListObjectsOptions, Ft as SandboxEgressPolicy, G as PosixCreateAttrs, Gt as SandboxPortTokenPage, H as ObjectMetadata, Ht as SandboxNetwork, I as ListObjectsResult, It as SandboxEgressRule, J as S3Object, Jt as SandboxStatus, K as PutObjectOptions, Kt as SandboxResponse, L as ListPartsOptions, Lt as SandboxEgressTransform, M as GrepOptions, Mt as CreatedSandboxPortToken, N as GrepResult, Nt as ListSandboxPortTokensOptions, O as DeleteObjectsResult, Ot as FileSystem, P as ListMultipartUploadsOptions, Pt as Sandbox, Q as effectiveUploadPartSize, Qt as SandboxFileSource, R as MountOptions, Rt as SandboxEndpoint, S as ListDisksOptions, Sn as ArchilTlsOptions, St as R2Mount, T as CreateBranchOptions, Tt as S3Mount, U as PartInfo, Ut as SandboxNetworkAction, V as MultipartUploadSummary, Vt as SandboxMountSpec, W as PartListing, Wt as SandboxPortToken, X as ShareUrlResult, Xt as SandboxTimeoutOptions, Y as ShareUrlOptions, Yt as SandboxTimeoutAction, Z as UploadPart, Zt as SandboxWaitOptions, _ as Images, _n as DesktopMouseButton, _t as GrepMatch, a as ExecOptions, an as SandboxProcessOutputHandler, at as CreateApiTokenRequest, b as DiskListPage, bn as SandboxDesktop, bt as MountConfigResponse, c as Tokens, cn as SandboxProcessStatus, ct as DiskMetrics, d as Sandboxes, dn as SandboxTerminalOptions, dt as DiskUser, en as SandboxFileWriter, et as AuthorizedUser, f as BuildImageOptions, fn as DESKTOP_IMAGE, ft as ExecDiskResult, g as ImageStatus, gn as DESKTOP_VCPUS, gt as GrepGroupLine, h as ImageFailureReason, hn as DESKTOP_PORT, ht as GrepGroup, i as ExecMountSpec, in as SandboxProcessOutput, it as ConnectedClient, j as ExecResult, jt as CreateSandboxPortTokenOptions, k as Disk, kt as ExecNetwork, l as CreateSandboxRequest, ln as SandboxProcessStream, lt as DiskResponse, m as Image, mn as DESKTOP_MEMORY_MIB, mt as GCSMount, n as ArchilOptions, nn as SandboxProcess, nt as AzureBlobMount, o as Workspace, on as SandboxProcessResult, ot as CreateDiskRequest, p as BuildImageRequest, pn as DESKTOP_MAX_TTL_SECONDS, pt as ExecRequest, q as PutObjectResult, qt as SandboxStartOptions, r as ExecMount, rn as SandboxProcessConnectOptions, rt as Branch, s as ListTokensOptions, sn as SandboxProcessStartOptions, st as Delegation, t as Archil, tn as SandboxFiles, tt as AwsStsUser, u as ListSandboxesOptions, un as SandboxProcesses, ut as DiskStatus, v as RegistryAuth, vn as DesktopNotInstalledError, vt as GrepStoppedReason, w as CompletedMultipartUpload, wt as S3CompatibleMount, x as Disks, xn as desktopViewerPath, xt as MountResponse, y as CreateDiskResult, yn as DesktopScrollDirection, yt as MountConfig, z as MultipartUpload, zt as SandboxForkOptions } from "./archil-DHPfg1b9.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -82,4 +82,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
82
82
|
*/
|
|
83
83
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
84
84
|
//#endregion
|
|
85
|
-
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type Branch, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateBranchOptions, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecNetwork, type ExecOptions, type ExecRequest, type ExecResult, type ExecVmOptions, type FileSystem, type GCSMount, type GrepGroup, type GrepGroupLine, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, type S3User, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutAction, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
85
|
+
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type Branch, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateBranchOptions, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, DESKTOP_IMAGE, DESKTOP_MAX_TTL_SECONDS, DESKTOP_MEMORY_MIB, DESKTOP_PORT, DESKTOP_VCPUS, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, type DesktopMouseButton, DesktopNotInstalledError, type DesktopScrollDirection, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecNetwork, type ExecOptions, type ExecRequest, type ExecResult, type ExecVmOptions, type FileSystem, type GCSMount, type GrepGroup, type GrepGroupLine, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, type S3User, Sandbox, SandboxDesktop, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutAction, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, desktopViewerPath, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as ApiTokenResponse, $t as SandboxFileUploadOptions, A as DiskMultipart, At as ExecVmOptions, B as MultipartUploadListing, Bt as SandboxMount, C as AppendObjectOptions, Ct as RootAttrs, D as DeleteObjectsOptions, Dt as TokenUser, E as DeleteObjectsError, Et as S3User, F as ListObjectsOptions, Ft as SandboxEgressPolicy, G as PosixCreateAttrs, Gt as SandboxPortTokenPage, H as ObjectMetadata, Ht as SandboxNetwork, I as ListObjectsResult, It as SandboxEgressRule, J as S3Object, Jt as SandboxStatus, K as PutObjectOptions, Kt as SandboxResponse, L as ListPartsOptions, Lt as SandboxEgressTransform, M as GrepOptions, Mt as CreatedSandboxPortToken, N as GrepResult, Nt as ListSandboxPortTokensOptions, O as DeleteObjectsResult, Ot as FileSystem, P as ListMultipartUploadsOptions, Pt as Sandbox, Q as effectiveUploadPartSize, Qt as SandboxFileSource, R as MountOptions, Rt as SandboxEndpoint, S as ListDisksOptions, St as R2Mount, T as CreateBranchOptions, Tt as S3Mount, U as PartInfo, Ut as SandboxNetworkAction, V as MultipartUploadSummary, Vt as SandboxMountSpec, W as PartListing, Wt as SandboxPortToken, X as ShareUrlResult, Xt as SandboxTimeoutOptions, Y as ShareUrlOptions, Yt as SandboxTimeoutAction, Z as UploadPart, Zt as SandboxWaitOptions, _ as Images, _t as GrepMatch, a as ExecOptions, an as SandboxProcessOutputHandler, at as CreateApiTokenRequest, b as DiskListPage, bt as MountConfigResponse, c as Tokens, cn as SandboxProcessStatus, ct as DiskMetrics, d as Sandboxes, dn as SandboxTerminalOptions, dt as DiskUser, en as SandboxFileWriter, et as AuthorizedUser, f as BuildImageOptions, fn as
|
|
1
|
+
import { $ as ApiTokenResponse, $t as SandboxFileUploadOptions, A as DiskMultipart, At as ExecVmOptions, B as MultipartUploadListing, Bt as SandboxMount, C as AppendObjectOptions, Ct as RootAttrs, D as DeleteObjectsOptions, Dt as TokenUser, E as DeleteObjectsError, Et as S3User, F as ListObjectsOptions, Ft as SandboxEgressPolicy, G as PosixCreateAttrs, Gt as SandboxPortTokenPage, H as ObjectMetadata, Ht as SandboxNetwork, I as ListObjectsResult, It as SandboxEgressRule, J as S3Object, Jt as SandboxStatus, K as PutObjectOptions, Kt as SandboxResponse, L as ListPartsOptions, Lt as SandboxEgressTransform, M as GrepOptions, Mt as CreatedSandboxPortToken, N as GrepResult, Nt as ListSandboxPortTokensOptions, O as DeleteObjectsResult, Ot as FileSystem, P as ListMultipartUploadsOptions, Pt as Sandbox, Q as effectiveUploadPartSize, Qt as SandboxFileSource, R as MountOptions, Rt as SandboxEndpoint, S as ListDisksOptions, Sn as ArchilTlsOptions, St as R2Mount, T as CreateBranchOptions, Tt as S3Mount, U as PartInfo, Ut as SandboxNetworkAction, V as MultipartUploadSummary, Vt as SandboxMountSpec, W as PartListing, Wt as SandboxPortToken, X as ShareUrlResult, Xt as SandboxTimeoutOptions, Y as ShareUrlOptions, Yt as SandboxTimeoutAction, Z as UploadPart, Zt as SandboxWaitOptions, _ as Images, _n as DesktopMouseButton, _t as GrepMatch, a as ExecOptions, an as SandboxProcessOutputHandler, at as CreateApiTokenRequest, b as DiskListPage, bn as SandboxDesktop, bt as MountConfigResponse, c as Tokens, cn as SandboxProcessStatus, ct as DiskMetrics, d as Sandboxes, dn as SandboxTerminalOptions, dt as DiskUser, en as SandboxFileWriter, et as AuthorizedUser, f as BuildImageOptions, fn as DESKTOP_IMAGE, ft as ExecDiskResult, g as ImageStatus, gn as DESKTOP_VCPUS, gt as GrepGroupLine, h as ImageFailureReason, hn as DESKTOP_PORT, ht as GrepGroup, i as ExecMountSpec, in as SandboxProcessOutput, it as ConnectedClient, j as ExecResult, jt as CreateSandboxPortTokenOptions, k as Disk, kt as ExecNetwork, l as CreateSandboxRequest, ln as SandboxProcessStream, lt as DiskResponse, m as Image, mn as DESKTOP_MEMORY_MIB, mt as GCSMount, n as ArchilOptions, nn as SandboxProcess, nt as AzureBlobMount, o as Workspace, on as SandboxProcessResult, ot as CreateDiskRequest, p as BuildImageRequest, pn as DESKTOP_MAX_TTL_SECONDS, pt as ExecRequest, q as PutObjectResult, qt as SandboxStartOptions, r as ExecMount, rn as SandboxProcessConnectOptions, rt as Branch, s as ListTokensOptions, sn as SandboxProcessStartOptions, st as Delegation, t as Archil, tn as SandboxFiles, tt as AwsStsUser, u as ListSandboxesOptions, un as SandboxProcesses, ut as DiskStatus, v as RegistryAuth, vn as DesktopNotInstalledError, vt as GrepStoppedReason, w as CompletedMultipartUpload, wt as S3CompatibleMount, x as Disks, xn as desktopViewerPath, xt as MountResponse, y as CreateDiskResult, yn as DesktopScrollDirection, yt as MountConfig, z as MultipartUpload, zt as SandboxForkOptions } from "./archil-CenIy1WD.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -82,4 +82,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
82
82
|
*/
|
|
83
83
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
84
84
|
//#endregion
|
|
85
|
-
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type Branch, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateBranchOptions, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecNetwork, type ExecOptions, type ExecRequest, type ExecResult, type ExecVmOptions, type FileSystem, type GCSMount, type GrepGroup, type GrepGroupLine, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, type S3User, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutAction, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
85
|
+
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type Branch, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateBranchOptions, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, DESKTOP_IMAGE, DESKTOP_MAX_TTL_SECONDS, DESKTOP_MEMORY_MIB, DESKTOP_PORT, DESKTOP_VCPUS, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, type DesktopMouseButton, DesktopNotInstalledError, type DesktopScrollDirection, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecNetwork, type ExecOptions, type ExecRequest, type ExecResult, type ExecVmOptions, type FileSystem, type GCSMount, type GrepGroup, type GrepGroupLine, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, type S3User, Sandbox, SandboxDesktop, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutAction, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, desktopViewerPath, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { A as ArchilError, C as Disk, D as VERSION, E as USER_AGENT, M as ImageBuildError, N as SandboxFileTransferError, P as SandboxPauseError, S as Disks, T as effectiveUploadPartSize, _ as Sandbox, a as deleteApiKey, b as SandboxProcesses, c as getSandbox, d as listSandboxes, f as workspace, g as Sandboxes, h as Tokens, i as createSandbox, j as ArchilS3Error, k as ArchilApiError, l as listApiKeys, m as Workspace, n as createApiKey, o as exec, p as Archil, r as createDisk, s as getDisk, t as configure, u as listDisks, v as SandboxFiles, w as DiskMultipart, x as Images, y as SandboxProcess } from "./src-
|
|
2
|
-
|
|
1
|
+
import { A as ArchilError, C as Disk, D as VERSION, E as USER_AGENT, M as ImageBuildError, N as SandboxFileTransferError, P as SandboxPauseError, S as Disks, T as effectiveUploadPartSize, _ as Sandbox, a as deleteApiKey, b as SandboxProcesses, c as getSandbox, d as listSandboxes, f as workspace, g as Sandboxes, h as Tokens, i as createSandbox, j as ArchilS3Error, k as ArchilApiError, l as listApiKeys, m as Workspace, n as createApiKey, o as exec, p as Archil, r as createDisk, s as getDisk, t as configure, u as listDisks, v as SandboxFiles, w as DiskMultipart, x as Images, y as SandboxProcess } from "./src-BFPiWUCL.mjs";
|
|
2
|
+
import { a as DESKTOP_VCPUS, c as desktopViewerPath, i as DESKTOP_PORT, n as DESKTOP_MAX_TTL_SECONDS, o as DesktopNotInstalledError, r as DESKTOP_MEMORY_MIB, s as SandboxDesktop, t as DESKTOP_IMAGE } from "./sandbox-desktop-CrvuoiGi.mjs";
|
|
3
|
+
export { Archil, ArchilApiError, ArchilError, ArchilS3Error, DESKTOP_IMAGE, DESKTOP_MAX_TTL_SECONDS, DESKTOP_MEMORY_MIB, DESKTOP_PORT, DESKTOP_VCPUS, DesktopNotInstalledError, Disk, DiskMultipart, Disks, ImageBuildError, Images, Sandbox, SandboxDesktop, SandboxFileTransferError, SandboxFiles, SandboxPauseError, SandboxProcess, SandboxProcesses, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, desktopViewerPath, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sandbox_desktop = require("./sandbox-desktop-DBs8jhKW.cjs");
|
|
2
3
|
const require_paths = require("./paths-1c4QqbOB.cjs");
|
|
3
4
|
let _bufbuild_protobuf = require("@bufbuild/protobuf");
|
|
4
5
|
let _archildata_api_types_process = require("@archildata/api-types/process");
|
|
@@ -290,7 +291,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
290
291
|
}
|
|
291
292
|
//#endregion
|
|
292
293
|
//#region src/version.ts
|
|
293
|
-
const VERSION = "1.
|
|
294
|
+
const VERSION = "1.15.0";
|
|
294
295
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
295
296
|
//#endregion
|
|
296
297
|
//#region src/client.ts
|
|
@@ -2579,6 +2580,8 @@ var Sandbox = class Sandbox {
|
|
|
2579
2580
|
/** @deprecated Use run() and attach(). Removed in the next version. */
|
|
2580
2581
|
processes;
|
|
2581
2582
|
files;
|
|
2583
|
+
/** The sandbox's Linux desktop, for sandboxes created with `desktop: true`. */
|
|
2584
|
+
desktop;
|
|
2582
2585
|
/** @internal */
|
|
2583
2586
|
_client;
|
|
2584
2587
|
_processConnection;
|
|
@@ -2590,6 +2593,7 @@ var Sandbox = class Sandbox {
|
|
|
2590
2593
|
this._processConnection = new ProcessConnection(() => this._connectionEndpoint());
|
|
2591
2594
|
this.processes = new SandboxProcesses(this, () => this._processConnection.disconnect());
|
|
2592
2595
|
this.files = new SandboxFiles(this);
|
|
2596
|
+
this.desktop = new require_sandbox_desktop.SandboxDesktop(this);
|
|
2593
2597
|
}
|
|
2594
2598
|
/** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
|
|
2595
2599
|
_apply(data) {
|
|
@@ -2947,6 +2951,14 @@ var Sandboxes = class {
|
|
|
2947
2951
|
return new Sandbox(await unwrap(retryApiRequest(() => this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: id } } }), "transient")), this._client);
|
|
2948
2952
|
}
|
|
2949
2953
|
async create(request = {}, options = {}) {
|
|
2954
|
+
if (request.desktop) request = {
|
|
2955
|
+
...request.imageId === void 0 && { baseImage: "ghcr.io/archil-data/sandbox-desktop:latest" },
|
|
2956
|
+
vcpuCount: 2,
|
|
2957
|
+
memSizeMiB: require_sandbox_desktop.DESKTOP_MEMORY_MIB,
|
|
2958
|
+
idleTtlSeconds: 0,
|
|
2959
|
+
maxTtlSeconds: require_sandbox_desktop.DESKTOP_MAX_TTL_SECONDS,
|
|
2960
|
+
...Object.fromEntries(Object.entries(request).filter(([, value]) => value !== void 0))
|
|
2961
|
+
};
|
|
2950
2962
|
const body = {
|
|
2951
2963
|
name: request.name,
|
|
2952
2964
|
vcpu_count: request.vcpuCount,
|
|
@@ -3464,12 +3476,19 @@ exports.Archil = Archil;
|
|
|
3464
3476
|
exports.ArchilApiError = ArchilApiError;
|
|
3465
3477
|
exports.ArchilError = ArchilError;
|
|
3466
3478
|
exports.ArchilS3Error = ArchilS3Error;
|
|
3479
|
+
exports.DESKTOP_IMAGE = require_sandbox_desktop.DESKTOP_IMAGE;
|
|
3480
|
+
exports.DESKTOP_MAX_TTL_SECONDS = require_sandbox_desktop.DESKTOP_MAX_TTL_SECONDS;
|
|
3481
|
+
exports.DESKTOP_MEMORY_MIB = require_sandbox_desktop.DESKTOP_MEMORY_MIB;
|
|
3482
|
+
exports.DESKTOP_PORT = require_sandbox_desktop.DESKTOP_PORT;
|
|
3483
|
+
exports.DESKTOP_VCPUS = require_sandbox_desktop.DESKTOP_VCPUS;
|
|
3484
|
+
exports.DesktopNotInstalledError = require_sandbox_desktop.DesktopNotInstalledError;
|
|
3467
3485
|
exports.Disk = Disk;
|
|
3468
3486
|
exports.DiskMultipart = DiskMultipart;
|
|
3469
3487
|
exports.Disks = Disks;
|
|
3470
3488
|
exports.ImageBuildError = ImageBuildError;
|
|
3471
3489
|
exports.Images = Images;
|
|
3472
3490
|
exports.Sandbox = Sandbox;
|
|
3491
|
+
exports.SandboxDesktop = require_sandbox_desktop.SandboxDesktop;
|
|
3473
3492
|
exports.SandboxFileTransferError = SandboxFileTransferError;
|
|
3474
3493
|
exports.SandboxFiles = SandboxFiles;
|
|
3475
3494
|
exports.SandboxPauseError = SandboxPauseError;
|
|
@@ -3485,6 +3504,7 @@ exports.createApiKey = createApiKey;
|
|
|
3485
3504
|
exports.createDisk = createDisk;
|
|
3486
3505
|
exports.createSandbox = createSandbox;
|
|
3487
3506
|
exports.deleteApiKey = deleteApiKey;
|
|
3507
|
+
exports.desktopViewerPath = require_sandbox_desktop.desktopViewerPath;
|
|
3488
3508
|
exports.effectiveUploadPartSize = effectiveUploadPartSize;
|
|
3489
3509
|
exports.exec = exec;
|
|
3490
3510
|
exports.getDisk = getDisk;
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { a as DESKTOP_VCPUS, c as desktopViewerPath, i as DESKTOP_PORT, n as DESKTOP_MAX_TTL_SECONDS, o as DesktopNotInstalledError, r as DESKTOP_MEMORY_MIB, s as SandboxDesktop, t as DESKTOP_IMAGE } from "./sandbox-desktop-CrvuoiGi.mjs";
|
|
1
2
|
import { t as toSegments } from "./paths-Br9snUhy.mjs";
|
|
2
3
|
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
3
4
|
import { ClientFrameSchema, Exit_Status, Limits, ServerFrameSchema, WindowUpdateSchema } from "@archildata/api-types/process";
|
|
@@ -289,7 +290,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
289
290
|
}
|
|
290
291
|
//#endregion
|
|
291
292
|
//#region src/version.ts
|
|
292
|
-
const VERSION = "1.
|
|
293
|
+
const VERSION = "1.15.0";
|
|
293
294
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
294
295
|
//#endregion
|
|
295
296
|
//#region src/client.ts
|
|
@@ -2578,6 +2579,8 @@ var Sandbox = class Sandbox {
|
|
|
2578
2579
|
/** @deprecated Use run() and attach(). Removed in the next version. */
|
|
2579
2580
|
processes;
|
|
2580
2581
|
files;
|
|
2582
|
+
/** The sandbox's Linux desktop, for sandboxes created with `desktop: true`. */
|
|
2583
|
+
desktop;
|
|
2581
2584
|
/** @internal */
|
|
2582
2585
|
_client;
|
|
2583
2586
|
_processConnection;
|
|
@@ -2589,6 +2592,7 @@ var Sandbox = class Sandbox {
|
|
|
2589
2592
|
this._processConnection = new ProcessConnection(() => this._connectionEndpoint());
|
|
2590
2593
|
this.processes = new SandboxProcesses(this, () => this._processConnection.disconnect());
|
|
2591
2594
|
this.files = new SandboxFiles(this);
|
|
2595
|
+
this.desktop = new SandboxDesktop(this);
|
|
2592
2596
|
}
|
|
2593
2597
|
/** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
|
|
2594
2598
|
_apply(data) {
|
|
@@ -2946,6 +2950,14 @@ var Sandboxes = class {
|
|
|
2946
2950
|
return new Sandbox(await unwrap(retryApiRequest(() => this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: id } } }), "transient")), this._client);
|
|
2947
2951
|
}
|
|
2948
2952
|
async create(request = {}, options = {}) {
|
|
2953
|
+
if (request.desktop) request = {
|
|
2954
|
+
...request.imageId === void 0 && { baseImage: "ghcr.io/archil-data/sandbox-desktop:latest" },
|
|
2955
|
+
vcpuCount: 2,
|
|
2956
|
+
memSizeMiB: DESKTOP_MEMORY_MIB,
|
|
2957
|
+
idleTtlSeconds: 0,
|
|
2958
|
+
maxTtlSeconds: DESKTOP_MAX_TTL_SECONDS,
|
|
2959
|
+
...Object.fromEntries(Object.entries(request).filter(([, value]) => value !== void 0))
|
|
2960
|
+
};
|
|
2949
2961
|
const body = {
|
|
2950
2962
|
name: request.name,
|
|
2951
2963
|
vcpu_count: request.vcpuCount,
|
|
@@ -3459,4 +3471,4 @@ function workspace(mounts) {
|
|
|
3459
3471
|
return archil().workspace(mounts);
|
|
3460
3472
|
}
|
|
3461
3473
|
//#endregion
|
|
3462
|
-
export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, ImageBuildError, Images, Sandbox, SandboxFileTransferError, SandboxFiles, SandboxPauseError, SandboxProcess, SandboxProcesses, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
3474
|
+
export { Archil, ArchilApiError, ArchilError, ArchilS3Error, DESKTOP_IMAGE, DESKTOP_MAX_TTL_SECONDS, DESKTOP_MEMORY_MIB, DESKTOP_PORT, DESKTOP_VCPUS, DesktopNotInstalledError, Disk, DiskMultipart, Disks, ImageBuildError, Images, Sandbox, SandboxDesktop, SandboxFileTransferError, SandboxFiles, SandboxPauseError, SandboxProcess, SandboxProcesses, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, desktopViewerPath, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
//#region src/sandbox-desktop.ts
|
|
2
|
+
/**
|
|
3
|
+
* Sandbox desktops: a Linux desktop (Ubuntu, XFCE, Firefox) served over VNC
|
|
4
|
+
* through noVNC on {@link DESKTOP_PORT}, from the image at
|
|
5
|
+
* {@link DESKTOP_IMAGE} (github.com/archil-data/sandbox-desktop). Inside the
|
|
6
|
+
* sandbox, `desktopctl` runs the desktop as supervised services; the noVNC
|
|
7
|
+
* server only connects a viewer that presents the desktop's token.
|
|
8
|
+
*
|
|
9
|
+
* Everything here runs commands through the sandbox process API, so it works
|
|
10
|
+
* wherever the SDK does. To view a private desktop from Node, see
|
|
11
|
+
* `openDesktopTunnel` in `disk/tunnel`.
|
|
12
|
+
*/
|
|
13
|
+
const DESKTOP_IMAGE = "ghcr.io/archil-data/sandbox-desktop:latest";
|
|
14
|
+
const DESKTOP_PORT = 6080;
|
|
15
|
+
/** A browser on the desktop is sluggish with less. */
|
|
16
|
+
const DESKTOP_VCPUS = 2;
|
|
17
|
+
const DESKTOP_MEMORY_MIB = 4096;
|
|
18
|
+
/**
|
|
19
|
+
* Session cap for desktops. Viewer traffic doesn't count as sandbox activity,
|
|
20
|
+
* so desktops run with idle expiry off and this cap instead.
|
|
21
|
+
*/
|
|
22
|
+
const DESKTOP_MAX_TTL_SECONDS = 14400;
|
|
23
|
+
const COMMAND_NOT_FOUND = 127;
|
|
24
|
+
const DISPLAY = "DISPLAY=:1";
|
|
25
|
+
const KEYS = /^[A-Za-z0-9_+ ]+$/;
|
|
26
|
+
/** Path on the desktop's noVNC server that opens the viewer and connects with `token`. */
|
|
27
|
+
function desktopViewerPath(token) {
|
|
28
|
+
return `/vnc.html?${new URLSearchParams({
|
|
29
|
+
autoconnect: "1",
|
|
30
|
+
resize: "remote",
|
|
31
|
+
reconnect: "1",
|
|
32
|
+
path: `websockify?token=${token}`
|
|
33
|
+
})}`;
|
|
34
|
+
}
|
|
35
|
+
var DesktopNotInstalledError = class extends Error {
|
|
36
|
+
constructor(sandboxName) {
|
|
37
|
+
super(`Sandbox '${sandboxName}' doesn't have the Archil desktop installed; create it with desktop: true or from an image based on ${DESKTOP_IMAGE}`);
|
|
38
|
+
this.name = "DesktopNotInstalledError";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/** The desktop of one sandbox: `sandbox.desktop`. */
|
|
42
|
+
var SandboxDesktop = class {
|
|
43
|
+
sandbox;
|
|
44
|
+
/** @internal */
|
|
45
|
+
constructor(sandbox) {
|
|
46
|
+
this.sandbox = sandbox;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Starts the desktop if it isn't running (safe to call repeatedly) and
|
|
50
|
+
* returns the viewer token. Anyone holding the token can view and control
|
|
51
|
+
* the desktop through a link to its port.
|
|
52
|
+
*/
|
|
53
|
+
async start() {
|
|
54
|
+
const { token } = JSON.parse(await this.run("desktopctl up"));
|
|
55
|
+
return { token };
|
|
56
|
+
}
|
|
57
|
+
/** The current viewer token. `rotate` replaces it first; a fork should rotate so it doesn't share its parent's. */
|
|
58
|
+
async token(options = {}) {
|
|
59
|
+
return (await this.run(options.rotate ? "desktopctl token --rotate" : "desktopctl token")).trim();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Publishes the desktop on a public HTTPS hostname and returns a viewer
|
|
63
|
+
* link. Anyone with the link can see and control the desktop until
|
|
64
|
+
* {@link unshare}.
|
|
65
|
+
*/
|
|
66
|
+
async share() {
|
|
67
|
+
const { token } = await this.start();
|
|
68
|
+
return `https://${await this.sandbox.exposePort(DESKTOP_PORT)}${desktopViewerPath(token)}`;
|
|
69
|
+
}
|
|
70
|
+
/** Removes the public hostname, invalidates every existing link, and disconnects current viewers. */
|
|
71
|
+
async unshare() {
|
|
72
|
+
await this.sandbox.unexposePort(DESKTOP_PORT);
|
|
73
|
+
await this.run("desktopctl revoke");
|
|
74
|
+
}
|
|
75
|
+
/** A PNG of the whole screen. */
|
|
76
|
+
async screenshot() {
|
|
77
|
+
return decodeBase64((await this.run(`${DISPLAY} scrot -o /tmp/.archil-desktop-shot.png && base64 -w0 /tmp/.archil-desktop-shot.png`)).trim());
|
|
78
|
+
}
|
|
79
|
+
/** The screen size in pixels. */
|
|
80
|
+
async size() {
|
|
81
|
+
const [width, height] = (await this.run(`${DISPLAY} xdotool getdisplaygeometry`)).trim().split(/\s+/).map(Number);
|
|
82
|
+
return {
|
|
83
|
+
width,
|
|
84
|
+
height
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
async moveMouse(x, y) {
|
|
88
|
+
await this.run(`${DISPLAY} xdotool mousemove ${coordinate(x)} ${coordinate(y)}`);
|
|
89
|
+
}
|
|
90
|
+
async click(x, y, options = {}) {
|
|
91
|
+
const button = {
|
|
92
|
+
left: 1,
|
|
93
|
+
middle: 2,
|
|
94
|
+
right: 3
|
|
95
|
+
}[options.button ?? "left"];
|
|
96
|
+
const repeat = options.double ? " --repeat 2" : "";
|
|
97
|
+
await this.run(`${DISPLAY} xdotool mousemove ${coordinate(x)} ${coordinate(y)} click${repeat} ${button}`);
|
|
98
|
+
}
|
|
99
|
+
async scroll(direction, amount = 3) {
|
|
100
|
+
const button = {
|
|
101
|
+
up: 4,
|
|
102
|
+
down: 5,
|
|
103
|
+
left: 6,
|
|
104
|
+
right: 7
|
|
105
|
+
}[direction];
|
|
106
|
+
await this.run(`${DISPLAY} xdotool click --repeat ${count(amount)} ${button}`);
|
|
107
|
+
}
|
|
108
|
+
/** Types `text` into the focused window. */
|
|
109
|
+
async type(text) {
|
|
110
|
+
await this.run(`${DISPLAY} xdotool type --delay 12 -- "$ARCHIL_DESKTOP_TEXT"`, { ARCHIL_DESKTOP_TEXT: text });
|
|
111
|
+
}
|
|
112
|
+
/** Presses a key or chord in xdotool's syntax, e.g. "Return", "ctrl+l", "ctrl+shift+t". */
|
|
113
|
+
async key(keys) {
|
|
114
|
+
if (!KEYS.test(keys)) throw new Error(`Invalid key '${keys}'; use names like Return, ctrl+l, or alt+F4`);
|
|
115
|
+
await this.run(`${DISPLAY} xdotool key -- $ARCHIL_DESKTOP_KEYS`, { ARCHIL_DESKTOP_KEYS: keys });
|
|
116
|
+
}
|
|
117
|
+
/** Starts a program on the desktop as its user, e.g. `["firefox", "https://archil.com"]`. It keeps running after this returns. */
|
|
118
|
+
async launch(argv) {
|
|
119
|
+
if (argv.length === 0) throw new Error("launch needs a program to run");
|
|
120
|
+
await this.run(`desktopctl launch ${argv.map(shellQuote).join(" ")}`);
|
|
121
|
+
}
|
|
122
|
+
async run(command, env) {
|
|
123
|
+
const result = await this.sandbox.exec(command, env ? { env } : void 0);
|
|
124
|
+
if (result.exitCode === COMMAND_NOT_FOUND) throw new DesktopNotInstalledError(this.sandbox.name);
|
|
125
|
+
if (result.exitCode !== 0) {
|
|
126
|
+
const name = command.split(" ").find((word) => !word.includes("="));
|
|
127
|
+
throw new Error(`${name} failed in sandbox '${this.sandbox.name}': ${(result.stderr || result.stdout).trim()}`);
|
|
128
|
+
}
|
|
129
|
+
return result.stdout;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
function coordinate(value) {
|
|
133
|
+
if (!Number.isFinite(value) || value < 0) throw new Error(`Invalid screen coordinate ${value}`);
|
|
134
|
+
return Math.round(value);
|
|
135
|
+
}
|
|
136
|
+
function count(value) {
|
|
137
|
+
if (!Number.isInteger(value) || value < 1 || value > 100) throw new Error(`Scroll amount must be an integer from 1 to 100`);
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
140
|
+
function shellQuote(value) {
|
|
141
|
+
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
142
|
+
}
|
|
143
|
+
function decodeBase64(text) {
|
|
144
|
+
const binary = atob(text);
|
|
145
|
+
const bytes = new Uint8Array(binary.length);
|
|
146
|
+
for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);
|
|
147
|
+
return bytes;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { DESKTOP_VCPUS as a, desktopViewerPath as c, DESKTOP_PORT as i, DESKTOP_MAX_TTL_SECONDS as n, DesktopNotInstalledError as o, DESKTOP_MEMORY_MIB as r, SandboxDesktop as s, DESKTOP_IMAGE as t };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
//#region src/sandbox-desktop.ts
|
|
2
|
+
/**
|
|
3
|
+
* Sandbox desktops: a Linux desktop (Ubuntu, XFCE, Firefox) served over VNC
|
|
4
|
+
* through noVNC on {@link DESKTOP_PORT}, from the image at
|
|
5
|
+
* {@link DESKTOP_IMAGE} (github.com/archil-data/sandbox-desktop). Inside the
|
|
6
|
+
* sandbox, `desktopctl` runs the desktop as supervised services; the noVNC
|
|
7
|
+
* server only connects a viewer that presents the desktop's token.
|
|
8
|
+
*
|
|
9
|
+
* Everything here runs commands through the sandbox process API, so it works
|
|
10
|
+
* wherever the SDK does. To view a private desktop from Node, see
|
|
11
|
+
* `openDesktopTunnel` in `disk/tunnel`.
|
|
12
|
+
*/
|
|
13
|
+
const DESKTOP_IMAGE = "ghcr.io/archil-data/sandbox-desktop:latest";
|
|
14
|
+
const DESKTOP_PORT = 6080;
|
|
15
|
+
/** A browser on the desktop is sluggish with less. */
|
|
16
|
+
const DESKTOP_VCPUS = 2;
|
|
17
|
+
const DESKTOP_MEMORY_MIB = 4096;
|
|
18
|
+
/**
|
|
19
|
+
* Session cap for desktops. Viewer traffic doesn't count as sandbox activity,
|
|
20
|
+
* so desktops run with idle expiry off and this cap instead.
|
|
21
|
+
*/
|
|
22
|
+
const DESKTOP_MAX_TTL_SECONDS = 14400;
|
|
23
|
+
const COMMAND_NOT_FOUND = 127;
|
|
24
|
+
const DISPLAY = "DISPLAY=:1";
|
|
25
|
+
const KEYS = /^[A-Za-z0-9_+ ]+$/;
|
|
26
|
+
/** Path on the desktop's noVNC server that opens the viewer and connects with `token`. */
|
|
27
|
+
function desktopViewerPath(token) {
|
|
28
|
+
return `/vnc.html?${new URLSearchParams({
|
|
29
|
+
autoconnect: "1",
|
|
30
|
+
resize: "remote",
|
|
31
|
+
reconnect: "1",
|
|
32
|
+
path: `websockify?token=${token}`
|
|
33
|
+
})}`;
|
|
34
|
+
}
|
|
35
|
+
var DesktopNotInstalledError = class extends Error {
|
|
36
|
+
constructor(sandboxName) {
|
|
37
|
+
super(`Sandbox '${sandboxName}' doesn't have the Archil desktop installed; create it with desktop: true or from an image based on ${DESKTOP_IMAGE}`);
|
|
38
|
+
this.name = "DesktopNotInstalledError";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/** The desktop of one sandbox: `sandbox.desktop`. */
|
|
42
|
+
var SandboxDesktop = class {
|
|
43
|
+
sandbox;
|
|
44
|
+
/** @internal */
|
|
45
|
+
constructor(sandbox) {
|
|
46
|
+
this.sandbox = sandbox;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Starts the desktop if it isn't running (safe to call repeatedly) and
|
|
50
|
+
* returns the viewer token. Anyone holding the token can view and control
|
|
51
|
+
* the desktop through a link to its port.
|
|
52
|
+
*/
|
|
53
|
+
async start() {
|
|
54
|
+
const { token } = JSON.parse(await this.run("desktopctl up"));
|
|
55
|
+
return { token };
|
|
56
|
+
}
|
|
57
|
+
/** The current viewer token. `rotate` replaces it first; a fork should rotate so it doesn't share its parent's. */
|
|
58
|
+
async token(options = {}) {
|
|
59
|
+
return (await this.run(options.rotate ? "desktopctl token --rotate" : "desktopctl token")).trim();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Publishes the desktop on a public HTTPS hostname and returns a viewer
|
|
63
|
+
* link. Anyone with the link can see and control the desktop until
|
|
64
|
+
* {@link unshare}.
|
|
65
|
+
*/
|
|
66
|
+
async share() {
|
|
67
|
+
const { token } = await this.start();
|
|
68
|
+
return `https://${await this.sandbox.exposePort(DESKTOP_PORT)}${desktopViewerPath(token)}`;
|
|
69
|
+
}
|
|
70
|
+
/** Removes the public hostname, invalidates every existing link, and disconnects current viewers. */
|
|
71
|
+
async unshare() {
|
|
72
|
+
await this.sandbox.unexposePort(DESKTOP_PORT);
|
|
73
|
+
await this.run("desktopctl revoke");
|
|
74
|
+
}
|
|
75
|
+
/** A PNG of the whole screen. */
|
|
76
|
+
async screenshot() {
|
|
77
|
+
return decodeBase64((await this.run(`${DISPLAY} scrot -o /tmp/.archil-desktop-shot.png && base64 -w0 /tmp/.archil-desktop-shot.png`)).trim());
|
|
78
|
+
}
|
|
79
|
+
/** The screen size in pixels. */
|
|
80
|
+
async size() {
|
|
81
|
+
const [width, height] = (await this.run(`${DISPLAY} xdotool getdisplaygeometry`)).trim().split(/\s+/).map(Number);
|
|
82
|
+
return {
|
|
83
|
+
width,
|
|
84
|
+
height
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
async moveMouse(x, y) {
|
|
88
|
+
await this.run(`${DISPLAY} xdotool mousemove ${coordinate(x)} ${coordinate(y)}`);
|
|
89
|
+
}
|
|
90
|
+
async click(x, y, options = {}) {
|
|
91
|
+
const button = {
|
|
92
|
+
left: 1,
|
|
93
|
+
middle: 2,
|
|
94
|
+
right: 3
|
|
95
|
+
}[options.button ?? "left"];
|
|
96
|
+
const repeat = options.double ? " --repeat 2" : "";
|
|
97
|
+
await this.run(`${DISPLAY} xdotool mousemove ${coordinate(x)} ${coordinate(y)} click${repeat} ${button}`);
|
|
98
|
+
}
|
|
99
|
+
async scroll(direction, amount = 3) {
|
|
100
|
+
const button = {
|
|
101
|
+
up: 4,
|
|
102
|
+
down: 5,
|
|
103
|
+
left: 6,
|
|
104
|
+
right: 7
|
|
105
|
+
}[direction];
|
|
106
|
+
await this.run(`${DISPLAY} xdotool click --repeat ${count(amount)} ${button}`);
|
|
107
|
+
}
|
|
108
|
+
/** Types `text` into the focused window. */
|
|
109
|
+
async type(text) {
|
|
110
|
+
await this.run(`${DISPLAY} xdotool type --delay 12 -- "$ARCHIL_DESKTOP_TEXT"`, { ARCHIL_DESKTOP_TEXT: text });
|
|
111
|
+
}
|
|
112
|
+
/** Presses a key or chord in xdotool's syntax, e.g. "Return", "ctrl+l", "ctrl+shift+t". */
|
|
113
|
+
async key(keys) {
|
|
114
|
+
if (!KEYS.test(keys)) throw new Error(`Invalid key '${keys}'; use names like Return, ctrl+l, or alt+F4`);
|
|
115
|
+
await this.run(`${DISPLAY} xdotool key -- $ARCHIL_DESKTOP_KEYS`, { ARCHIL_DESKTOP_KEYS: keys });
|
|
116
|
+
}
|
|
117
|
+
/** Starts a program on the desktop as its user, e.g. `["firefox", "https://archil.com"]`. It keeps running after this returns. */
|
|
118
|
+
async launch(argv) {
|
|
119
|
+
if (argv.length === 0) throw new Error("launch needs a program to run");
|
|
120
|
+
await this.run(`desktopctl launch ${argv.map(shellQuote).join(" ")}`);
|
|
121
|
+
}
|
|
122
|
+
async run(command, env) {
|
|
123
|
+
const result = await this.sandbox.exec(command, env ? { env } : void 0);
|
|
124
|
+
if (result.exitCode === COMMAND_NOT_FOUND) throw new DesktopNotInstalledError(this.sandbox.name);
|
|
125
|
+
if (result.exitCode !== 0) {
|
|
126
|
+
const name = command.split(" ").find((word) => !word.includes("="));
|
|
127
|
+
throw new Error(`${name} failed in sandbox '${this.sandbox.name}': ${(result.stderr || result.stdout).trim()}`);
|
|
128
|
+
}
|
|
129
|
+
return result.stdout;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
function coordinate(value) {
|
|
133
|
+
if (!Number.isFinite(value) || value < 0) throw new Error(`Invalid screen coordinate ${value}`);
|
|
134
|
+
return Math.round(value);
|
|
135
|
+
}
|
|
136
|
+
function count(value) {
|
|
137
|
+
if (!Number.isInteger(value) || value < 1 || value > 100) throw new Error(`Scroll amount must be an integer from 1 to 100`);
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
140
|
+
function shellQuote(value) {
|
|
141
|
+
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
142
|
+
}
|
|
143
|
+
function decodeBase64(text) {
|
|
144
|
+
const binary = atob(text);
|
|
145
|
+
const bytes = new Uint8Array(binary.length);
|
|
146
|
+
for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);
|
|
147
|
+
return bytes;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
Object.defineProperty(exports, "DESKTOP_IMAGE", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function() {
|
|
153
|
+
return DESKTOP_IMAGE;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "DESKTOP_MAX_TTL_SECONDS", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function() {
|
|
159
|
+
return DESKTOP_MAX_TTL_SECONDS;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, "DESKTOP_MEMORY_MIB", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function() {
|
|
165
|
+
return DESKTOP_MEMORY_MIB;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "DESKTOP_PORT", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function() {
|
|
171
|
+
return DESKTOP_PORT;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, "DESKTOP_VCPUS", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function() {
|
|
177
|
+
return DESKTOP_VCPUS;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, "DesktopNotInstalledError", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function() {
|
|
183
|
+
return DesktopNotInstalledError;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(exports, "SandboxDesktop", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function() {
|
|
189
|
+
return SandboxDesktop;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(exports, "desktopViewerPath", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function() {
|
|
195
|
+
return desktopViewerPath;
|
|
196
|
+
}
|
|
197
|
+
});
|