disk 1.4.0 → 1.5.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 CHANGED
@@ -697,3 +697,36 @@ Archil has two credential types, and the examples above use both:
697
697
  ## Support
698
698
 
699
699
  Questions, feature requests, or issues? Reach us at **support@archil.com**.
700
+
701
+
702
+ To finish selected model requests before pausing, opt in when creating the sandbox:
703
+
704
+ ```ts
705
+ const sandbox = await archil.sandboxes.create({
706
+ network: {
707
+ egress: {
708
+ default: "allow",
709
+ drain_on_pause: [
710
+ "*.anthropic.com",
711
+ "api.openai.com",
712
+ "bedrock-runtime.*.amazonaws.com",
713
+ ],
714
+ },
715
+ },
716
+ });
717
+ await sandbox.pause();
718
+ ```
719
+
720
+ Each entry is a lowercase hostname pattern without a scheme, port, or path.
721
+ `*` works anywhere; `"*"` selects every host. Leading `*.` excludes the apex domain.
722
+ All URL paths on a selected host count. Matching happens before forwarding. Selectors
723
+ do not grant network access. Pausing gates new matches and waits for active HTTP(S)
724
+ responses, including streams, to reach the guest. Requests to other hosts do not delay the drain.
725
+ The drain waits up to ten minutes by default, starting when pause begins. Request errors
726
+ stop counting; expiry proceeds with the snapshot. Requests have no added timeout during
727
+ normal operation.
728
+ HTTP ports 80 and 443 are supported. Clients must trust the sandbox egress CA for HTTPS
729
+ and retry stale connections after resume. Set selectors at creation to cover every
730
+ connection; live network updates cannot intercept existing passthrough connections.
731
+ A snapshot failure leaves the sandbox in `failed` with the failure reason and raises
732
+ `SandboxPauseError` when waiting; `error.latest` contains the resulting sandbox state.
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { O as ArchilApiError, a as deleteApiKey, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks } from "./src-BaAv98od.mjs";
3
- import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-D2ic5Rit.mjs";
2
+ import { O as ArchilApiError, a as deleteApiKey, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks } from "./src-r2oVqVK_.mjs";
3
+ import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-Bi2YnNf6.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { Command } from "commander";
6
6
  //#region bin/cli.ts
@@ -1,4 +1,4 @@
1
- import { D as REGION_URLS, p as Archil } from "./src-BaAv98od.mjs";
1
+ import { D as REGION_URLS, p as Archil } from "./src-r2oVqVK_.mjs";
2
2
  import { Option } from "commander";
3
3
  import { isCancel, password, spinner } from "@clack/prompts";
4
4
  import { chmod, mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";
package/dist/index.cjs CHANGED
@@ -62,6 +62,14 @@ var ArchilApiError = class extends ArchilError {
62
62
  this.name = "ArchilApiError";
63
63
  }
64
64
  };
65
+ var SandboxPauseError = class extends ArchilError {
66
+ latest;
67
+ constructor(latest) {
68
+ super(`Sandbox entered ${latest.status} before it paused${latest.exitReason ? `: ${latest.exitReason}` : ""}`, 409, "SANDBOX_PAUSE_FAILED");
69
+ this.latest = latest;
70
+ this.name = "SandboxPauseError";
71
+ }
72
+ };
65
73
  var SandboxFileTransferError = class extends ArchilError {
66
74
  operation;
67
75
  path;
@@ -145,7 +153,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
145
153
  }
146
154
  //#endregion
147
155
  //#region src/version.ts
148
- const VERSION = "1.4.0";
156
+ const VERSION = "1.5.0";
149
157
  const USER_AGENT = `archil-js/${VERSION}`;
150
158
  //#endregion
151
159
  //#region src/client.ts
@@ -1973,7 +1981,10 @@ var Sandbox = class Sandbox {
1973
1981
  async pause(options = {}) {
1974
1982
  const data = await unwrap(retryApiRequest(() => this._client.POST("/api/sandboxes/{sid}/pause", { params: { path: { sid: this.id } } }), "transient"));
1975
1983
  this._apply(data);
1976
- return options.wait === false ? this : waitWhileSandboxStatus(this, "pausing");
1984
+ if (options.wait === false) return this;
1985
+ await waitWhileSandboxStatus(this, "pausing");
1986
+ if (this.status !== "paused") throw new SandboxPauseError(this);
1987
+ return this;
1977
1988
  }
1978
1989
  /** Resume this sandbox from its preserved CPU and memory state. */
1979
1990
  async resume(options = {}) {
@@ -2578,6 +2589,7 @@ exports.Disks = Disks;
2578
2589
  exports.Sandbox = Sandbox;
2579
2590
  exports.SandboxFileTransferError = SandboxFileTransferError;
2580
2591
  exports.SandboxFiles = SandboxFiles;
2592
+ exports.SandboxPauseError = SandboxPauseError;
2581
2593
  exports.SandboxProcess = SandboxProcess;
2582
2594
  exports.SandboxProcesses = SandboxProcesses;
2583
2595
  exports.Sandboxes = Sandboxes;
package/dist/index.d.cts CHANGED
@@ -196,10 +196,14 @@ declare class SandboxFiles {
196
196
  //#endregion
197
197
  //#region src/sandbox.d.ts
198
198
  type SandboxNetworkAction = components["schemas"]["SandboxNetworkAction"];
199
- type SandboxEgressPolicy = components["schemas"]["SandboxEgressPolicy"];
199
+ type SandboxEgressPolicy = components["schemas"]["SandboxEgressPolicy"] & {
200
+ /** Host patterns supporting * anywhere. All paths count; selectors do not grant network access. */drain_on_pause?: string[];
201
+ };
200
202
  type SandboxEgressRule = components["schemas"]["SandboxEgressRule"];
201
203
  type SandboxEgressTransform = components["schemas"]["SandboxEgressTransform"];
202
- type SandboxNetwork = components["schemas"]["SandboxNetwork"];
204
+ type SandboxNetwork = Omit<components["schemas"]["SandboxNetwork"], "egress"> & {
205
+ egress?: SandboxEgressPolicy;
206
+ };
203
207
  /** @internal */
204
208
  type SandboxWire = components["schemas"]["Sandbox"] & {
205
209
  idle_ttl_seconds?: number;
@@ -307,7 +311,7 @@ declare class Sandbox {
307
311
  /** Stop this sandbox. */
308
312
  stop(options?: SandboxWaitOptions): Promise<Sandbox | this>;
309
313
  /** Pause this sandbox, preserving its CPU and memory state. */
310
- pause(options?: SandboxWaitOptions): Promise<Sandbox | this>;
314
+ pause(options?: SandboxWaitOptions): Promise<this>;
311
315
  /** Resume this sandbox from its preserved CPU and memory state. */
312
316
  resume(options?: SandboxWaitOptions): Promise<Sandbox | this>;
313
317
  /**
@@ -576,6 +580,10 @@ declare class ArchilError extends Error {
576
580
  declare class ArchilApiError extends ArchilError {
577
581
  constructor(message: string, status: number, code?: string);
578
582
  }
583
+ declare class SandboxPauseError extends ArchilError {
584
+ readonly latest: Sandbox;
585
+ constructor(latest: Sandbox);
586
+ }
579
587
  declare class SandboxFileTransferError extends ArchilError {
580
588
  readonly operation: "upload" | "download";
581
589
  readonly path: string;
@@ -632,4 +640,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
632
640
  */
633
641
  declare function workspace(mounts: Record<string, ExecMount>): Workspace;
634
642
  //#endregion
635
- export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, 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 ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, 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 RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxNetwork, type SandboxNetworkAction, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStatus, type SandboxTerminalOptions, 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 };
643
+ export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, 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 ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, 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 RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, 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 SandboxStatus, type SandboxTerminalOptions, 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 };
package/dist/index.d.mts CHANGED
@@ -196,10 +196,14 @@ declare class SandboxFiles {
196
196
  //#endregion
197
197
  //#region src/sandbox.d.ts
198
198
  type SandboxNetworkAction = components["schemas"]["SandboxNetworkAction"];
199
- type SandboxEgressPolicy = components["schemas"]["SandboxEgressPolicy"];
199
+ type SandboxEgressPolicy = components["schemas"]["SandboxEgressPolicy"] & {
200
+ /** Host patterns supporting * anywhere. All paths count; selectors do not grant network access. */drain_on_pause?: string[];
201
+ };
200
202
  type SandboxEgressRule = components["schemas"]["SandboxEgressRule"];
201
203
  type SandboxEgressTransform = components["schemas"]["SandboxEgressTransform"];
202
- type SandboxNetwork = components["schemas"]["SandboxNetwork"];
204
+ type SandboxNetwork = Omit<components["schemas"]["SandboxNetwork"], "egress"> & {
205
+ egress?: SandboxEgressPolicy;
206
+ };
203
207
  /** @internal */
204
208
  type SandboxWire = components["schemas"]["Sandbox"] & {
205
209
  idle_ttl_seconds?: number;
@@ -307,7 +311,7 @@ declare class Sandbox {
307
311
  /** Stop this sandbox. */
308
312
  stop(options?: SandboxWaitOptions): Promise<Sandbox | this>;
309
313
  /** Pause this sandbox, preserving its CPU and memory state. */
310
- pause(options?: SandboxWaitOptions): Promise<Sandbox | this>;
314
+ pause(options?: SandboxWaitOptions): Promise<this>;
311
315
  /** Resume this sandbox from its preserved CPU and memory state. */
312
316
  resume(options?: SandboxWaitOptions): Promise<Sandbox | this>;
313
317
  /**
@@ -576,6 +580,10 @@ declare class ArchilError extends Error {
576
580
  declare class ArchilApiError extends ArchilError {
577
581
  constructor(message: string, status: number, code?: string);
578
582
  }
583
+ declare class SandboxPauseError extends ArchilError {
584
+ readonly latest: Sandbox;
585
+ constructor(latest: Sandbox);
586
+ }
579
587
  declare class SandboxFileTransferError extends ArchilError {
580
588
  readonly operation: "upload" | "download";
581
589
  readonly path: string;
@@ -632,4 +640,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
632
640
  */
633
641
  declare function workspace(mounts: Record<string, ExecMount>): Workspace;
634
642
  //#endregion
635
- export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, 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 ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, 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 RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxNetwork, type SandboxNetworkAction, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStatus, type SandboxTerminalOptions, 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 };
643
+ export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, 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 ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, 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 RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, 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 SandboxStatus, type SandboxTerminalOptions, 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 };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { A as ArchilS3Error, C as DiskMultipart, E as VERSION, O as ArchilApiError, S as Disk, T as USER_AGENT, _ 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 SandboxFileTransferError, k as ArchilError, 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 effectiveUploadPartSize, x as Disks, y as SandboxProcess } from "./src-BaAv98od.mjs";
2
- export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, Sandbox, SandboxFileTransferError, SandboxFiles, SandboxProcess, SandboxProcesses, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
1
+ import { A as ArchilS3Error, C as DiskMultipart, E as VERSION, M as SandboxPauseError, O as ArchilApiError, S as Disk, T as USER_AGENT, _ 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 SandboxFileTransferError, k as ArchilError, 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 effectiveUploadPartSize, x as Disks, y as SandboxProcess } from "./src-r2oVqVK_.mjs";
2
+ export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, 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 };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { O as ArchilApiError, p as Archil } from "./src-BaAv98od.mjs";
3
- import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-D2ic5Rit.mjs";
2
+ import { O as ArchilApiError, p as Archil } from "./src-r2oVqVK_.mjs";
3
+ import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-Bi2YnNf6.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { Command } from "commander";
6
6
  import { spinner } from "@clack/prompts";
@@ -39,6 +39,14 @@ var ArchilApiError = class extends ArchilError {
39
39
  this.name = "ArchilApiError";
40
40
  }
41
41
  };
42
+ var SandboxPauseError = class extends ArchilError {
43
+ latest;
44
+ constructor(latest) {
45
+ super(`Sandbox entered ${latest.status} before it paused${latest.exitReason ? `: ${latest.exitReason}` : ""}`, 409, "SANDBOX_PAUSE_FAILED");
46
+ this.latest = latest;
47
+ this.name = "SandboxPauseError";
48
+ }
49
+ };
42
50
  var SandboxFileTransferError = class extends ArchilError {
43
51
  operation;
44
52
  path;
@@ -122,7 +130,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
122
130
  }
123
131
  //#endregion
124
132
  //#region src/version.ts
125
- const VERSION = "1.4.0";
133
+ const VERSION = "1.5.0";
126
134
  const USER_AGENT = `archil-js/${VERSION}`;
127
135
  //#endregion
128
136
  //#region src/client.ts
@@ -1950,7 +1958,10 @@ var Sandbox = class Sandbox {
1950
1958
  async pause(options = {}) {
1951
1959
  const data = await unwrap(retryApiRequest(() => this._client.POST("/api/sandboxes/{sid}/pause", { params: { path: { sid: this.id } } }), "transient"));
1952
1960
  this._apply(data);
1953
- return options.wait === false ? this : waitWhileSandboxStatus(this, "pausing");
1961
+ if (options.wait === false) return this;
1962
+ await waitWhileSandboxStatus(this, "pausing");
1963
+ if (this.status !== "paused") throw new SandboxPauseError(this);
1964
+ return this;
1954
1965
  }
1955
1966
  /** Resume this sandbox from its preserved CPU and memory state. */
1956
1967
  async resume(options = {}) {
@@ -2545,4 +2556,4 @@ function workspace(mounts) {
2545
2556
  return archil().workspace(mounts);
2546
2557
  }
2547
2558
  //#endregion
2548
- export { ArchilS3Error as A, DiskMultipart as C, REGION_URLS as D, VERSION as E, ArchilApiError as O, Disk as S, USER_AGENT as T, Sandbox as _, deleteApiKey as a, SandboxProcesses as b, getSandbox as c, listSandboxes as d, workspace as f, Sandboxes as g, Tokens as h, createSandbox as i, SandboxFileTransferError as j, ArchilError as k, listApiKeys as l, Workspace as m, createApiKey as n, exec as o, Archil as p, createDisk as r, getDisk as s, configure as t, listDisks as u, SandboxFiles as v, effectiveUploadPartSize as w, Disks as x, SandboxProcess as y };
2559
+ export { ArchilS3Error as A, DiskMultipart as C, REGION_URLS as D, VERSION as E, SandboxPauseError as M, ArchilApiError as O, Disk as S, USER_AGENT as T, Sandbox as _, deleteApiKey as a, SandboxProcesses as b, getSandbox as c, listSandboxes as d, workspace as f, Sandboxes as g, Tokens as h, createSandbox as i, SandboxFileTransferError as j, ArchilError as k, listApiKeys as l, Workspace as m, createApiKey as n, exec as o, Archil as p, createDisk as r, getDisk as s, configure as t, listDisks as u, SandboxFiles as v, effectiveUploadPartSize as w, Disks as x, SandboxProcess as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disk",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Pure-JS client and CLIs for Archil disks and sandboxes",
5
5
  "keywords": [
6
6
  "archil",