sandbox0 0.7.6 → 0.7.7
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 +19 -0
- package/dist/apispec/src/apis/ObservabilityApi.d.ts +4 -4
- package/dist/apispec/src/apis/ObservabilityApi.js +4 -4
- package/dist/apispec/src/apis/SandboxRootfsApi.d.ts +6 -2
- package/dist/apispec/src/apis/SandboxRootfsApi.d.ts.map +1 -1
- package/dist/apispec/src/apis/SandboxRootfsApi.js +6 -2
- package/dist/apispec/src/models/CreateSandboxRootFSSnapshotRequest.d.ts +2 -0
- package/dist/apispec/src/models/CreateSandboxRootFSSnapshotRequest.d.ts.map +1 -1
- package/dist/apispec/src/models/CreateSandboxVolumeS3Config.d.ts +6 -6
- package/dist/apispec/src/models/CreateSandboxVolumeS3Config.d.ts.map +1 -1
- package/dist/apispec/src/models/CreateSandboxVolumeS3Config.js +6 -2
- package/dist/apispec/src/models/ForkSandboxRequest.d.ts +2 -0
- package/dist/apispec/src/models/ForkSandboxRequest.d.ts.map +1 -1
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +34 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/models.d.ts +10 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/resources/sandboxes.d.ts +13 -1
- package/dist/resources/sandboxes.d.ts.map +1 -1
- package/dist/resources/sandboxes.js +106 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,25 @@ for (const mount of sandbox.bootstrapMounts) {
|
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
## Wait For Lifecycle Changes
|
|
89
|
+
|
|
90
|
+
Pause is accepted before its rootfs checkpoint is fully committed. Use the
|
|
91
|
+
waiting helpers when the next operation depends on committed lifecycle state:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const paused = await client.sandboxes.pauseAndWait(sandbox.id, {
|
|
95
|
+
timeoutMs: 120_000,
|
|
96
|
+
signal: abortController.signal,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const resumed = await client.sandboxes.resumeAndWait(paused.id);
|
|
100
|
+
console.log(resumed.status, resumed.runtimeGeneration);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`waitForLifecycle()` is available for other committed-state conditions. Aborting
|
|
104
|
+
a wait stops polling locally; it does not undo a pause or resume already accepted
|
|
105
|
+
by Sandbox0.
|
|
106
|
+
|
|
88
107
|
## Links
|
|
89
108
|
|
|
90
109
|
- [Documentation](https://sandbox0.ai/docs)
|
|
@@ -48,12 +48,12 @@ export interface ApiV1SandboxesIdObservabilityMetricsGetRequest {
|
|
|
48
48
|
*/
|
|
49
49
|
export declare class ObservabilityApi extends runtime.BaseAPI {
|
|
50
50
|
/**
|
|
51
|
-
* Queries the asynchronous per-sandbox observability projection for lifecycle, network audit, and runtime stats events. This endpoint does not expose backend SQL and
|
|
51
|
+
* Queries the asynchronous per-sandbox observability projection for lifecycle, network audit, and runtime stats events. This endpoint does not expose backend SQL and reads tables that are separate from the metering usage ledger.
|
|
52
52
|
* Query historical sandbox observability events
|
|
53
53
|
*/
|
|
54
54
|
apiV1SandboxesIdObservabilityEventsGetRaw(requestParameters: ApiV1SandboxesIdObservabilityEventsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SuccessSandboxObservabilityEventsResponse>>;
|
|
55
55
|
/**
|
|
56
|
-
* Queries the asynchronous per-sandbox observability projection for lifecycle, network audit, and runtime stats events. This endpoint does not expose backend SQL and
|
|
56
|
+
* Queries the asynchronous per-sandbox observability projection for lifecycle, network audit, and runtime stats events. This endpoint does not expose backend SQL and reads tables that are separate from the metering usage ledger.
|
|
57
57
|
* Query historical sandbox observability events
|
|
58
58
|
*/
|
|
59
59
|
apiV1SandboxesIdObservabilityEventsGet(requestParameters: ApiV1SandboxesIdObservabilityEventsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessSandboxObservabilityEventsResponse>;
|
|
@@ -68,12 +68,12 @@ export declare class ObservabilityApi extends runtime.BaseAPI {
|
|
|
68
68
|
*/
|
|
69
69
|
apiV1SandboxesIdObservabilityLogsGet(requestParameters: ApiV1SandboxesIdObservabilityLogsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessSandboxObservabilityLogsResponse>;
|
|
70
70
|
/**
|
|
71
|
-
* Queries the asynchronous per-sandbox metric sample projection. This endpoint is separate from platform service metrics and
|
|
71
|
+
* Queries the asynchronous per-sandbox metric sample projection. This endpoint is separate from platform service metrics and metering usage truth.
|
|
72
72
|
* Query historical sandbox metric samples
|
|
73
73
|
*/
|
|
74
74
|
apiV1SandboxesIdObservabilityMetricsGetRaw(requestParameters: ApiV1SandboxesIdObservabilityMetricsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SuccessSandboxObservabilityMetricsResponse>>;
|
|
75
75
|
/**
|
|
76
|
-
* Queries the asynchronous per-sandbox metric sample projection. This endpoint is separate from platform service metrics and
|
|
76
|
+
* Queries the asynchronous per-sandbox metric sample projection. This endpoint is separate from platform service metrics and metering usage truth.
|
|
77
77
|
* Query historical sandbox metric samples
|
|
78
78
|
*/
|
|
79
79
|
apiV1SandboxesIdObservabilityMetricsGet(requestParameters: ApiV1SandboxesIdObservabilityMetricsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessSandboxObservabilityMetricsResponse>;
|
|
@@ -18,7 +18,7 @@ import { SuccessSandboxObservabilityEventsResponseFromJSON, SuccessSandboxObserv
|
|
|
18
18
|
*/
|
|
19
19
|
export class ObservabilityApi extends runtime.BaseAPI {
|
|
20
20
|
/**
|
|
21
|
-
* Queries the asynchronous per-sandbox observability projection for lifecycle, network audit, and runtime stats events. This endpoint does not expose backend SQL and
|
|
21
|
+
* Queries the asynchronous per-sandbox observability projection for lifecycle, network audit, and runtime stats events. This endpoint does not expose backend SQL and reads tables that are separate from the metering usage ledger.
|
|
22
22
|
* Query historical sandbox observability events
|
|
23
23
|
*/
|
|
24
24
|
async apiV1SandboxesIdObservabilityEventsGetRaw(requestParameters, initOverrides) {
|
|
@@ -69,7 +69,7 @@ export class ObservabilityApi extends runtime.BaseAPI {
|
|
|
69
69
|
return new runtime.JSONApiResponse(response, (jsonValue) => SuccessSandboxObservabilityEventsResponseFromJSON(jsonValue));
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Queries the asynchronous per-sandbox observability projection for lifecycle, network audit, and runtime stats events. This endpoint does not expose backend SQL and
|
|
72
|
+
* Queries the asynchronous per-sandbox observability projection for lifecycle, network audit, and runtime stats events. This endpoint does not expose backend SQL and reads tables that are separate from the metering usage ledger.
|
|
73
73
|
* Query historical sandbox observability events
|
|
74
74
|
*/
|
|
75
75
|
async apiV1SandboxesIdObservabilityEventsGet(requestParameters, initOverrides) {
|
|
@@ -133,7 +133,7 @@ export class ObservabilityApi extends runtime.BaseAPI {
|
|
|
133
133
|
return await response.value();
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
* Queries the asynchronous per-sandbox metric sample projection. This endpoint is separate from platform service metrics and
|
|
136
|
+
* Queries the asynchronous per-sandbox metric sample projection. This endpoint is separate from platform service metrics and metering usage truth.
|
|
137
137
|
* Query historical sandbox metric samples
|
|
138
138
|
*/
|
|
139
139
|
async apiV1SandboxesIdObservabilityMetricsGetRaw(requestParameters, initOverrides) {
|
|
@@ -184,7 +184,7 @@ export class ObservabilityApi extends runtime.BaseAPI {
|
|
|
184
184
|
return new runtime.JSONApiResponse(response, (jsonValue) => SuccessSandboxObservabilityMetricsResponseFromJSON(jsonValue));
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
|
-
* Queries the asynchronous per-sandbox metric sample projection. This endpoint is separate from platform service metrics and
|
|
187
|
+
* Queries the asynchronous per-sandbox metric sample projection. This endpoint is separate from platform service metrics and metering usage truth.
|
|
188
188
|
* Query historical sandbox metric samples
|
|
189
189
|
*/
|
|
190
190
|
async apiV1SandboxesIdObservabilityMetricsGet(requestParameters, initOverrides) {
|
|
@@ -53,11 +53,13 @@ export declare class SandboxRootfsApi extends runtime.BaseAPI {
|
|
|
53
53
|
*/
|
|
54
54
|
apiV1SandboxRootfsSnapshotsSnapshotIdGet(requestParameters: ApiV1SandboxRootfsSnapshotsSnapshotIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessSandboxRootFSSnapshotResponse>;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Forks the source sandbox writable rootfs into a new paused sandbox. A paused source is forked from its current rootfs head. A running source is briefly barriered and checkpointed first; the source sandbox remains running after the fork operation completes.
|
|
57
|
+
* Fork sandbox rootfs
|
|
57
58
|
*/
|
|
58
59
|
apiV1SandboxesIdForkPostRaw(requestParameters: ApiV1SandboxesIdForkPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SuccessForkSandboxResponse>>;
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
+
* Forks the source sandbox writable rootfs into a new paused sandbox. A paused source is forked from its current rootfs head. A running source is briefly barriered and checkpointed first; the source sandbox remains running after the fork operation completes.
|
|
62
|
+
* Fork sandbox rootfs
|
|
61
63
|
*/
|
|
62
64
|
apiV1SandboxesIdForkPost(requestParameters: ApiV1SandboxesIdForkPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessForkSandboxResponse>;
|
|
63
65
|
/**
|
|
@@ -77,10 +79,12 @@ export declare class SandboxRootfsApi extends runtime.BaseAPI {
|
|
|
77
79
|
*/
|
|
78
80
|
apiV1SandboxesIdSnapshotsGet(requestParameters: ApiV1SandboxesIdSnapshotsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessSandboxRootFSSnapshotListResponse>;
|
|
79
81
|
/**
|
|
82
|
+
* Creates an immutable snapshot record from the source sandbox writable rootfs. A paused source is snapshotted from its current rootfs head. A running source is briefly barriered and checkpointed first; the source sandbox remains running after the snapshot operation completes.
|
|
80
83
|
* Create sandbox rootfs snapshot
|
|
81
84
|
*/
|
|
82
85
|
apiV1SandboxesIdSnapshotsPostRaw(requestParameters: ApiV1SandboxesIdSnapshotsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SuccessSandboxRootFSSnapshotResponse>>;
|
|
83
86
|
/**
|
|
87
|
+
* Creates an immutable snapshot record from the source sandbox writable rootfs. A paused source is snapshotted from its current rootfs head. A running source is briefly barriered and checkpointed first; the source sandbox remains running after the snapshot operation completes.
|
|
84
88
|
* Create sandbox rootfs snapshot
|
|
85
89
|
*/
|
|
86
90
|
apiV1SandboxesIdSnapshotsPost(requestParameters: ApiV1SandboxesIdSnapshotsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessSandboxRootFSSnapshotResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxRootfsApi.d.ts","sourceRoot":"","sources":["../../../../src/apispec/src/apis/SandboxRootfsApi.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EACV,kCAAkC,EAElC,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,mCAAmC,EACnC,wCAAwC,EACxC,oCAAoC,EACrC,MAAM,iBAAiB,CAAC;AAsBzB,MAAM,WAAW,kDAAkD;IAC/D,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,+CAA+C;IAC5D,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,+BAA+B;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAED,MAAM,WAAW,wCAAwC;IACrD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WAAW,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,oCAAoC,CAAC;CAK1M"}
|
|
@@ -84,7 +84,8 @@ export class SandboxRootfsApi extends runtime.BaseAPI {
|
|
|
84
84
|
return await response.value();
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
87
|
+
* Forks the source sandbox writable rootfs into a new paused sandbox. A paused source is forked from its current rootfs head. A running source is briefly barriered and checkpointed first; the source sandbox remains running after the fork operation completes.
|
|
88
|
+
* Fork sandbox rootfs
|
|
88
89
|
*/
|
|
89
90
|
async apiV1SandboxesIdForkPostRaw(requestParameters, initOverrides) {
|
|
90
91
|
if (requestParameters['id'] == null) {
|
|
@@ -112,7 +113,8 @@ export class SandboxRootfsApi extends runtime.BaseAPI {
|
|
|
112
113
|
return new runtime.JSONApiResponse(response, (jsonValue) => SuccessForkSandboxResponseFromJSON(jsonValue));
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
115
|
-
*
|
|
116
|
+
* Forks the source sandbox writable rootfs into a new paused sandbox. A paused source is forked from its current rootfs head. A running source is briefly barriered and checkpointed first; the source sandbox remains running after the fork operation completes.
|
|
117
|
+
* Fork sandbox rootfs
|
|
116
118
|
*/
|
|
117
119
|
async apiV1SandboxesIdForkPost(requestParameters, initOverrides) {
|
|
118
120
|
const response = await this.apiV1SandboxesIdForkPostRaw(requestParameters, initOverrides);
|
|
@@ -190,6 +192,7 @@ export class SandboxRootfsApi extends runtime.BaseAPI {
|
|
|
190
192
|
return await response.value();
|
|
191
193
|
}
|
|
192
194
|
/**
|
|
195
|
+
* Creates an immutable snapshot record from the source sandbox writable rootfs. A paused source is snapshotted from its current rootfs head. A running source is briefly barriered and checkpointed first; the source sandbox remains running after the snapshot operation completes.
|
|
193
196
|
* Create sandbox rootfs snapshot
|
|
194
197
|
*/
|
|
195
198
|
async apiV1SandboxesIdSnapshotsPostRaw(requestParameters, initOverrides) {
|
|
@@ -218,6 +221,7 @@ export class SandboxRootfsApi extends runtime.BaseAPI {
|
|
|
218
221
|
return new runtime.JSONApiResponse(response, (jsonValue) => SuccessSandboxRootFSSnapshotResponseFromJSON(jsonValue));
|
|
219
222
|
}
|
|
220
223
|
/**
|
|
224
|
+
* Creates an immutable snapshot record from the source sandbox writable rootfs. A paused source is snapshotted from its current rootfs head. A running source is briefly barriered and checkpointed first; the source sandbox remains running after the snapshot operation completes.
|
|
221
225
|
* Create sandbox rootfs snapshot
|
|
222
226
|
*/
|
|
223
227
|
async apiV1SandboxesIdSnapshotsPost(requestParameters, initOverrides) {
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
+
* Optional snapshot metadata. The source sandbox may be running or paused;
|
|
14
|
+
* running sources are checkpointed before the snapshot record is created.
|
|
13
15
|
*
|
|
14
16
|
* @export
|
|
15
17
|
* @interface CreateSandboxRootFSSnapshotRequest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateSandboxRootFSSnapshotRequest.d.ts","sourceRoot":"","sources":["../../../../src/apispec/src/models/CreateSandboxRootFSSnapshotRequest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH
|
|
1
|
+
{"version":3,"file":"CreateSandboxRootFSSnapshotRequest.d.ts","sourceRoot":"","sources":["../../../../src/apispec/src/models/CreateSandboxRootFSSnapshotRequest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH;;;;;;GAMG;AACH,MAAM,WAAW,kCAAkC;IAC/C;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,4CAA4C,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,kCAAkC,CAEvH;AAED,wBAAgB,0CAA0C,CAAC,IAAI,EAAE,GAAG,GAAG,kCAAkC,CAExG;AAED,wBAAgB,+CAA+C,CAAC,IAAI,EAAE,GAAG,EAAE,mBAAmB,EAAE,OAAO,GAAG,kCAAkC,CAU3I;AAED,wBAAgB,wCAAwC,CAAC,IAAI,EAAE,GAAG,GAAG,kCAAkC,CAEtG;AAED,wBAAgB,6CAA6C,CAAC,KAAK,CAAC,EAAE,kCAAkC,GAAG,IAAI,EAAE,mBAAmB,GAAE,OAAe,GAAG,GAAG,CAW1J"}
|
|
@@ -34,29 +34,29 @@ export interface CreateSandboxVolumeS3Config {
|
|
|
34
34
|
*/
|
|
35
35
|
prefix?: string;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* AWS region for the target bucket. Required for provider aws unless endpoint_url is provided.
|
|
38
38
|
* @type {string}
|
|
39
39
|
* @memberof CreateSandboxVolumeS3Config
|
|
40
40
|
*/
|
|
41
41
|
region?: string;
|
|
42
42
|
/**
|
|
43
|
-
* Optional endpoint override. Required for ali and r2.
|
|
43
|
+
* Optional endpoint override. Required for ali and r2. For aws, endpoint_url can be used instead of region for S3-compatible endpoints.
|
|
44
44
|
* @type {string}
|
|
45
45
|
* @memberof CreateSandboxVolumeS3Config
|
|
46
46
|
*/
|
|
47
47
|
endpointUrl?: string;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Access key for this S3 backend volume. Required with secret_key. Stored encrypted and omitted from API responses.
|
|
50
50
|
* @type {string}
|
|
51
51
|
* @memberof CreateSandboxVolumeS3Config
|
|
52
52
|
*/
|
|
53
|
-
accessKey
|
|
53
|
+
accessKey: string;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* Secret key for this S3 backend volume. Required with access_key. Stored encrypted and omitted from API responses.
|
|
56
56
|
* @type {string}
|
|
57
57
|
* @memberof CreateSandboxVolumeS3Config
|
|
58
58
|
*/
|
|
59
|
-
secretKey
|
|
59
|
+
secretKey: string;
|
|
60
60
|
/**
|
|
61
61
|
* Optional temporary credential session token.
|
|
62
62
|
* @type {string}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateSandboxVolumeS3Config.d.ts","sourceRoot":"","sources":["../../../../src/apispec/src/models/CreateSandboxVolumeS3Config.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IACxC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,uCAAuC,CAAC;IACnD;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,SAAS,
|
|
1
|
+
{"version":3,"file":"CreateSandboxVolumeS3Config.d.ts","sourceRoot":"","sources":["../../../../src/apispec/src/models/CreateSandboxVolumeS3Config.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IACxC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,uCAAuC,CAAC;IACnD;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAGD;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;CAI1C,CAAC;AACX,MAAM,MAAM,uCAAuC,GAAG,OAAO,uCAAuC,CAAC,MAAM,OAAO,uCAAuC,CAAC,CAAC;AAG3J;;GAEG;AACH,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,2BAA2B,CAKzG;AAED,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,GAAG,GAAG,2BAA2B,CAE1F;AAED,wBAAgB,wCAAwC,CAAC,IAAI,EAAE,GAAG,EAAE,mBAAmB,EAAE,OAAO,GAAG,2BAA2B,CAe7H;AAED,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,GAAG,GAAG,2BAA2B,CAExF;AAED,wBAAgB,sCAAsC,CAAC,KAAK,CAAC,EAAE,2BAA2B,GAAG,IAAI,EAAE,mBAAmB,GAAE,OAAe,GAAG,GAAG,CAgB5I"}
|
|
@@ -25,6 +25,10 @@ export const CreateSandboxVolumeS3ConfigProviderEnum = {
|
|
|
25
25
|
export function instanceOfCreateSandboxVolumeS3Config(value) {
|
|
26
26
|
if (!('bucket' in value) || value['bucket'] === undefined)
|
|
27
27
|
return false;
|
|
28
|
+
if (!('accessKey' in value) || value['accessKey'] === undefined)
|
|
29
|
+
return false;
|
|
30
|
+
if (!('secretKey' in value) || value['secretKey'] === undefined)
|
|
31
|
+
return false;
|
|
28
32
|
return true;
|
|
29
33
|
}
|
|
30
34
|
export function CreateSandboxVolumeS3ConfigFromJSON(json) {
|
|
@@ -40,8 +44,8 @@ export function CreateSandboxVolumeS3ConfigFromJSONTyped(json, ignoreDiscriminat
|
|
|
40
44
|
'prefix': json['prefix'] == null ? undefined : json['prefix'],
|
|
41
45
|
'region': json['region'] == null ? undefined : json['region'],
|
|
42
46
|
'endpointUrl': json['endpoint_url'] == null ? undefined : json['endpoint_url'],
|
|
43
|
-
'accessKey': json['access_key']
|
|
44
|
-
'secretKey': json['secret_key']
|
|
47
|
+
'accessKey': json['access_key'],
|
|
48
|
+
'secretKey': json['secret_key'],
|
|
45
49
|
'sessionToken': json['session_token'] == null ? undefined : json['session_token'],
|
|
46
50
|
};
|
|
47
51
|
}
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
import type { ForkSandboxConfig } from './ForkSandboxConfig.js';
|
|
13
13
|
/**
|
|
14
14
|
* Optional fork overrides. Omit config to inherit the source sandbox configuration.
|
|
15
|
+
* The source sandbox may be running or paused; running sources are checkpointed
|
|
16
|
+
* before the paused child sandbox is created.
|
|
15
17
|
*
|
|
16
18
|
* @export
|
|
17
19
|
* @interface ForkSandboxRequest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForkSandboxRequest.d.ts","sourceRoot":"","sources":["../../../../src/apispec/src/models/ForkSandboxRequest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQ7D
|
|
1
|
+
{"version":3,"file":"ForkSandboxRequest.d.ts","sourceRoot":"","sources":["../../../../src/apispec/src/models/ForkSandboxRequest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQ7D;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;OAIG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,kBAAkB,CAEvF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,GAAG,GAAG,kBAAkB,CAExE;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,GAAG,EAAE,mBAAmB,EAAE,OAAO,GAAG,kBAAkB,CAQ3G;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,GAAG,GAAG,kBAAkB,CAEtE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,CAAC,EAAE,kBAAkB,GAAG,IAAI,EAAE,mBAAmB,GAAE,OAAe,GAAG,GAAG,CAS1H"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { Sandbox } from "./apispec/src/models/index.js";
|
|
2
|
+
export declare const CLAIM_START_THROTTLED_CODE = "claim_start_throttled";
|
|
1
3
|
export declare class APIError extends Error {
|
|
2
4
|
statusCode: number;
|
|
3
5
|
code?: string;
|
|
4
6
|
details?: unknown;
|
|
5
7
|
requestId?: string;
|
|
6
8
|
body?: string;
|
|
9
|
+
retryAfter?: number;
|
|
7
10
|
constructor(params: {
|
|
8
11
|
statusCode: number;
|
|
9
12
|
message: string;
|
|
@@ -11,8 +14,20 @@ export declare class APIError extends Error {
|
|
|
11
14
|
details?: unknown;
|
|
12
15
|
requestId?: string;
|
|
13
16
|
body?: string;
|
|
17
|
+
retryAfter?: number;
|
|
14
18
|
});
|
|
15
19
|
}
|
|
20
|
+
export declare class SandboxWaitTimeoutError extends Error {
|
|
21
|
+
readonly sandboxId: string;
|
|
22
|
+
readonly timeoutMs: number;
|
|
23
|
+
readonly lastSandbox?: Sandbox;
|
|
24
|
+
constructor(params: {
|
|
25
|
+
sandboxId: string;
|
|
26
|
+
timeoutMs: number;
|
|
27
|
+
lastSandbox?: Sandbox;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export declare function isClaimStartThrottled(error: unknown): error is APIError;
|
|
16
31
|
export declare function apiErrorFromResponse(response: Response): Promise<APIError>;
|
|
17
32
|
export declare function wrapApiCall<T>(fn: () => Promise<T>): Promise<T>;
|
|
18
33
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGzE,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAElE,qBAAa,QAAS,SAAQ,KAAK;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;gBAER,MAAM,EAAE;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;CAUF;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;gBAEnB,MAAM,EAAE;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB;CAOF;AAuBD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAIvE;AAED,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkChF;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CASrE"}
|
package/dist/errors.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { runtime } from "./apispec_compat.js";
|
|
2
|
+
export const CLAIM_START_THROTTLED_CODE = "claim_start_throttled";
|
|
2
3
|
export class APIError extends Error {
|
|
3
4
|
statusCode;
|
|
4
5
|
code;
|
|
5
6
|
details;
|
|
6
7
|
requestId;
|
|
7
8
|
body;
|
|
9
|
+
retryAfter;
|
|
8
10
|
constructor(params) {
|
|
9
11
|
super(params.message);
|
|
10
12
|
this.name = "APIError";
|
|
@@ -13,6 +15,19 @@ export class APIError extends Error {
|
|
|
13
15
|
this.details = params.details;
|
|
14
16
|
this.requestId = params.requestId;
|
|
15
17
|
this.body = params.body;
|
|
18
|
+
this.retryAfter = params.retryAfter;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class SandboxWaitTimeoutError extends Error {
|
|
22
|
+
sandboxId;
|
|
23
|
+
timeoutMs;
|
|
24
|
+
lastSandbox;
|
|
25
|
+
constructor(params) {
|
|
26
|
+
super(`timed out waiting for sandbox ${params.sandboxId} after ${params.timeoutMs}ms`);
|
|
27
|
+
this.name = "SandboxWaitTimeoutError";
|
|
28
|
+
this.sandboxId = params.sandboxId;
|
|
29
|
+
this.timeoutMs = params.timeoutMs;
|
|
30
|
+
this.lastSandbox = params.lastSandbox;
|
|
16
31
|
}
|
|
17
32
|
}
|
|
18
33
|
function getRequestId(response) {
|
|
@@ -20,9 +35,27 @@ function getRequestId(response) {
|
|
|
20
35
|
response.headers.get("x-requestid") ??
|
|
21
36
|
undefined);
|
|
22
37
|
}
|
|
38
|
+
function getRetryAfter(response) {
|
|
39
|
+
const value = response.headers.get("retry-after");
|
|
40
|
+
if (!value) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const trimmed = value.trim();
|
|
44
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const seconds = Number.parseInt(trimmed, 10);
|
|
48
|
+
return Number.isFinite(seconds) && seconds >= 0 ? seconds : undefined;
|
|
49
|
+
}
|
|
50
|
+
export function isClaimStartThrottled(error) {
|
|
51
|
+
return error instanceof APIError
|
|
52
|
+
&& error.statusCode === 429
|
|
53
|
+
&& error.code === CLAIM_START_THROTTLED_CODE;
|
|
54
|
+
}
|
|
23
55
|
export async function apiErrorFromResponse(response) {
|
|
24
56
|
const statusCode = response.status;
|
|
25
57
|
const requestId = getRequestId(response);
|
|
58
|
+
const retryAfter = getRetryAfter(response);
|
|
26
59
|
let bodyText = "";
|
|
27
60
|
let code = "unexpected_response";
|
|
28
61
|
let message = response.statusText || "request failed";
|
|
@@ -50,6 +83,7 @@ export async function apiErrorFromResponse(response) {
|
|
|
50
83
|
details,
|
|
51
84
|
requestId,
|
|
52
85
|
body: bodyText || undefined,
|
|
86
|
+
retryAfter,
|
|
53
87
|
});
|
|
54
88
|
}
|
|
55
89
|
export async function wrapApiCall(fn) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Client, type ClientOptions, DEFAULT_BASE_URL } from "./client.js";
|
|
2
2
|
export { Sandbox } from "./sandbox.js";
|
|
3
|
-
export { APIError } from "./errors.js";
|
|
3
|
+
export { APIError, SandboxWaitTimeoutError } from "./errors.js";
|
|
4
4
|
export { verifyWebhookSignature } from "./webhook_signature.js";
|
|
5
5
|
export * from "./template_helpers.js";
|
|
6
6
|
export * from "./models.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,iBAAiB,CAAC;AACzB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Client, DEFAULT_BASE_URL } from "./client.js";
|
|
2
2
|
export { Sandbox } from "./sandbox.js";
|
|
3
|
-
export { APIError } from "./errors.js";
|
|
3
|
+
export { APIError, SandboxWaitTimeoutError } from "./errors.js";
|
|
4
4
|
export { verifyWebhookSignature } from "./webhook_signature.js";
|
|
5
5
|
export * from "./template_helpers.js";
|
|
6
6
|
export * from "./models.js";
|
package/dist/models.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObservabilityEventSource, SandboxAppServiceView, SandboxObservabilityEventType, SandboxObservabilityEventsResponse, SandboxObservabilityLogStream, SandboxObservabilityLogsResponse, SandboxObservabilityMetricsResponse, SandboxObservabilityOutcome, SandboxObservabilityWatchLine, SandboxSummary } from "./apispec/src/models/index.js";
|
|
1
|
+
import type { ObservabilityEventSource, SandboxAppServiceView, SandboxObservabilityEventType, SandboxObservabilityEventsResponse, SandboxObservabilityLogStream, SandboxObservabilityLogsResponse, SandboxObservabilityMetricsResponse, SandboxObservabilityOutcome, SandboxObservabilityWatchLine, Sandbox, SandboxSummary } from "./apispec/src/models/index.js";
|
|
2
2
|
export interface RunResult {
|
|
3
3
|
sandboxId: string;
|
|
4
4
|
contextId: string;
|
|
@@ -101,4 +101,13 @@ export interface SandboxListResult {
|
|
|
101
101
|
count: number;
|
|
102
102
|
hasMore: boolean;
|
|
103
103
|
}
|
|
104
|
+
export interface SandboxLifecycleWaitOptions {
|
|
105
|
+
/** Maximum polling duration. Defaults to 60 seconds. */
|
|
106
|
+
timeoutMs?: number;
|
|
107
|
+
/** Delay between observations. Defaults to 500 milliseconds. */
|
|
108
|
+
pollIntervalMs?: number;
|
|
109
|
+
/** Stops waiting locally. It does not roll back a lifecycle request already accepted by the server. */
|
|
110
|
+
signal?: AbortSignal;
|
|
111
|
+
}
|
|
112
|
+
export type SandboxLifecyclePredicate = (sandbox: Sandbox) => boolean | Promise<boolean>;
|
|
104
113
|
//# sourceMappingURL=models.d.ts.map
|
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,6BAA6B,EAC7B,kCAAkC,EAClC,6BAA6B,EAC7B,gCAAgC,EAChC,mCAAmC,EACnC,2BAA2B,EAC3B,6BAA6B,EAC7B,cAAc,EACf,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,O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AC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uGAAuG;IACvG,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,yBAAyB,GAAG,CACtC,OAAO,EAAE,OAAO,KACb,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClaimMountRequest, CreateSandboxRootFSSnapshotRequest, ForkSandboxRequest, ForkSandboxResponse, PauseSandboxResponse, RestoreSandboxRootFSRequest, RestoreSandboxRootFSResponse, SandboxRefreshRequest, RefreshResponse, ResumeSandboxResponse, Sandbox, SandboxConfig, SandboxRootFSSnapshot, SandboxStatus, SandboxUpdateRequest, SuccessMessageResponse, SuccessDeletedResponse } from "../apispec/src/models/index.js";
|
|
2
|
-
import type { SandboxListOptions, SandboxListResult } from "../models.js";
|
|
2
|
+
import type { SandboxLifecyclePredicate, SandboxLifecycleWaitOptions, SandboxListOptions, SandboxListResult } from "../models.js";
|
|
3
3
|
import type { Client } from "../client.js";
|
|
4
4
|
import { Sandbox as SandboxHandle } from "../sandbox.js";
|
|
5
5
|
import { SandboxSession } from "../sessions.js";
|
|
@@ -16,12 +16,24 @@ export declare class Sandboxes {
|
|
|
16
16
|
list(options?: SandboxListOptions): Promise<SandboxListResult>;
|
|
17
17
|
open(template: string, options?: SandboxConfig | ClaimSandboxOptions): Promise<SandboxSession>;
|
|
18
18
|
get(sandboxId: string): Promise<Sandbox>;
|
|
19
|
+
private getWithSignal;
|
|
20
|
+
/**
|
|
21
|
+
* Polls committed sandbox details until the predicate matches.
|
|
22
|
+
*
|
|
23
|
+
* Abort stops the local wait but cannot undo a lifecycle request that the
|
|
24
|
+
* server has already accepted.
|
|
25
|
+
*/
|
|
26
|
+
waitForLifecycle(sandboxId: string, predicate: SandboxLifecyclePredicate, options?: SandboxLifecycleWaitOptions): Promise<Sandbox>;
|
|
19
27
|
update(sandboxId: string, request: SandboxUpdateRequest): Promise<Sandbox>;
|
|
20
28
|
updateMemory(sandboxId: string, memory: string): Promise<Sandbox>;
|
|
21
29
|
delete(sandboxId: string): Promise<SuccessMessageResponse>;
|
|
22
30
|
status(sandboxId: string): Promise<SandboxStatus>;
|
|
23
31
|
pause(sandboxId: string): Promise<PauseSandboxResponse>;
|
|
32
|
+
/** Requests a pause and waits for its durable checkpoint to commit. */
|
|
33
|
+
pauseAndWait(sandboxId: string, options?: SandboxLifecycleWaitOptions): Promise<Sandbox>;
|
|
24
34
|
resume(sandboxId: string): Promise<ResumeSandboxResponse>;
|
|
35
|
+
/** Requests a resume and waits for the committed running generation. */
|
|
36
|
+
resumeAndWait(sandboxId: string, options?: SandboxLifecycleWaitOptions): Promise<Sandbox>;
|
|
25
37
|
refresh(sandboxId: string, request?: SandboxRefreshRequest): Promise<RefreshResponse>;
|
|
26
38
|
createRootFSSnapshot(sandboxId: string, request?: CreateSandboxRootFSSnapshotRequest): Promise<SandboxRootFSSnapshot>;
|
|
27
39
|
listRootFSSnapshots(sandboxId: string): Promise<SandboxRootFSSnapshot[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxes.d.ts","sourceRoot":"","sources":["../../src/resources/sandboxes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,kCAAkC,EAClC,kBAAkB,EAClB,mBAAmB,EAEnB,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,OAAO,EACP,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sandboxes.d.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AE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IASzE,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,4BAA4B,CAAC;IAUlC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUzF,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa;CAG1C"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ensureData, ensureModel } from "../response.js";
|
|
2
|
-
import { wrapApiCall } from "../errors.js";
|
|
2
|
+
import { SandboxWaitTimeoutError, wrapApiCall } from "../errors.js";
|
|
3
3
|
import { Sandbox as SandboxHandle } from "../sandbox.js";
|
|
4
4
|
import { SandboxSession } from "../sessions.js";
|
|
5
|
+
const DEFAULT_LIFECYCLE_TIMEOUT_MS = 60_000;
|
|
6
|
+
const DEFAULT_LIFECYCLE_POLL_INTERVAL_MS = 500;
|
|
5
7
|
function isClaimSandboxOptions(value) {
|
|
6
8
|
return !!value && typeof value === "object" && ("config" in value ||
|
|
7
9
|
"mounts" in value ||
|
|
@@ -74,9 +76,39 @@ export class Sandboxes {
|
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
async get(sandboxId) {
|
|
77
|
-
|
|
79
|
+
return this.getWithSignal(sandboxId);
|
|
80
|
+
}
|
|
81
|
+
async getWithSignal(sandboxId, signal) {
|
|
82
|
+
const response = await wrapApiCall(() => this.client.apispec.sandboxes.apiV1SandboxesIdGet({ id: sandboxId }, signal ? { signal } : undefined));
|
|
78
83
|
return ensureData(response, "get sandbox returned empty response");
|
|
79
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Polls committed sandbox details until the predicate matches.
|
|
87
|
+
*
|
|
88
|
+
* Abort stops the local wait but cannot undo a lifecycle request that the
|
|
89
|
+
* server has already accepted.
|
|
90
|
+
*/
|
|
91
|
+
async waitForLifecycle(sandboxId, predicate, options = {}) {
|
|
92
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_LIFECYCLE_TIMEOUT_MS;
|
|
93
|
+
const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_LIFECYCLE_POLL_INTERVAL_MS;
|
|
94
|
+
validateWaitDuration("timeoutMs", timeoutMs, true);
|
|
95
|
+
validateWaitDuration("pollIntervalMs", pollIntervalMs, false);
|
|
96
|
+
const startedAt = Date.now();
|
|
97
|
+
let lastSandbox;
|
|
98
|
+
while (true) {
|
|
99
|
+
throwIfAborted(options.signal);
|
|
100
|
+
lastSandbox = await this.getWithSignal(sandboxId, options.signal);
|
|
101
|
+
throwIfAborted(options.signal);
|
|
102
|
+
if (await predicate(lastSandbox)) {
|
|
103
|
+
return lastSandbox;
|
|
104
|
+
}
|
|
105
|
+
const remainingMs = timeoutMs - (Date.now() - startedAt);
|
|
106
|
+
if (remainingMs <= 0) {
|
|
107
|
+
throw new SandboxWaitTimeoutError({ sandboxId, timeoutMs, lastSandbox });
|
|
108
|
+
}
|
|
109
|
+
await sleepWithSignal(Math.min(pollIntervalMs, remainingMs), options.signal);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
80
112
|
async update(sandboxId, request) {
|
|
81
113
|
const response = await wrapApiCall(() => this.client.apispec.sandboxes.apiV1SandboxesIdPut({
|
|
82
114
|
id: sandboxId,
|
|
@@ -103,10 +135,29 @@ export class Sandboxes {
|
|
|
103
135
|
const response = await wrapApiCall(() => this.client.apispec.sandboxes.apiV1SandboxesIdPausePost({ id: sandboxId }));
|
|
104
136
|
return ensureData(response, "pause sandbox returned empty response");
|
|
105
137
|
}
|
|
138
|
+
/** Requests a pause and waits for its durable checkpoint to commit. */
|
|
139
|
+
async pauseAndWait(sandboxId, options) {
|
|
140
|
+
throwIfAborted(options?.signal);
|
|
141
|
+
await this.pause(sandboxId);
|
|
142
|
+
return this.waitForLifecycle(sandboxId, (sandbox) => sandbox.status === "paused" && sandbox.paused, options);
|
|
143
|
+
}
|
|
106
144
|
async resume(sandboxId) {
|
|
107
145
|
const response = await wrapApiCall(() => this.client.apispec.sandboxes.apiV1SandboxesIdResumePost({ id: sandboxId }));
|
|
108
146
|
return ensureData(response, "resume sandbox returned empty response");
|
|
109
147
|
}
|
|
148
|
+
/** Requests a resume and waits for the committed running generation. */
|
|
149
|
+
async resumeAndWait(sandboxId, options) {
|
|
150
|
+
throwIfAborted(options?.signal);
|
|
151
|
+
const before = await this.getWithSignal(sandboxId, options?.signal);
|
|
152
|
+
throwIfAborted(options?.signal);
|
|
153
|
+
await this.resume(sandboxId);
|
|
154
|
+
const minimumRuntimeGeneration = before.paused || before.status === "paused"
|
|
155
|
+
? before.runtimeGeneration + 1
|
|
156
|
+
: before.runtimeGeneration;
|
|
157
|
+
return this.waitForLifecycle(sandboxId, (sandbox) => (sandbox.status === "running"
|
|
158
|
+
&& !sandbox.paused
|
|
159
|
+
&& sandbox.runtimeGeneration >= minimumRuntimeGeneration), options);
|
|
160
|
+
}
|
|
110
161
|
async refresh(sandboxId, request) {
|
|
111
162
|
const params = request
|
|
112
163
|
? { id: sandboxId, sandboxRefreshRequest: request }
|
|
@@ -156,3 +207,56 @@ export class Sandboxes {
|
|
|
156
207
|
return new SandboxHandle({ id: sandboxId, client: this.client });
|
|
157
208
|
}
|
|
158
209
|
}
|
|
210
|
+
function validateWaitDuration(name, value, allowZero) {
|
|
211
|
+
if (!Number.isFinite(value) || (allowZero ? value < 0 : value <= 0)) {
|
|
212
|
+
const requirement = allowZero ? "a finite number >= 0" : "a finite number > 0";
|
|
213
|
+
throw new RangeError(`${name} must be ${requirement}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function throwIfAborted(signal) {
|
|
217
|
+
if (!signal?.aborted) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
throw abortReason(signal);
|
|
221
|
+
}
|
|
222
|
+
function abortReason(signal) {
|
|
223
|
+
if (signal.reason !== undefined) {
|
|
224
|
+
return signal.reason;
|
|
225
|
+
}
|
|
226
|
+
const error = new Error("sandbox lifecycle wait was aborted");
|
|
227
|
+
error.name = "AbortError";
|
|
228
|
+
return error;
|
|
229
|
+
}
|
|
230
|
+
function sleepWithSignal(durationMs, signal) {
|
|
231
|
+
return new Promise((resolve, reject) => {
|
|
232
|
+
if (signal?.aborted) {
|
|
233
|
+
reject(abortReason(signal));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
let settled = false;
|
|
237
|
+
let timer;
|
|
238
|
+
const onAbort = () => {
|
|
239
|
+
if (settled) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
settled = true;
|
|
243
|
+
if (timer !== undefined) {
|
|
244
|
+
clearTimeout(timer);
|
|
245
|
+
}
|
|
246
|
+
signal?.removeEventListener("abort", onAbort);
|
|
247
|
+
reject(signal ? abortReason(signal) : new Error("sandbox lifecycle wait was aborted"));
|
|
248
|
+
};
|
|
249
|
+
timer = setTimeout(() => {
|
|
250
|
+
if (settled) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
settled = true;
|
|
254
|
+
signal?.removeEventListener("abort", onAbort);
|
|
255
|
+
resolve();
|
|
256
|
+
}, durationMs);
|
|
257
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
258
|
+
if (signal?.aborted) {
|
|
259
|
+
onAbort();
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|