@alineo-labs/sandbox 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +22 -11
- package/dist/index.mjs +6 -3
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BashSession, CheckpointInfo, CommandError, CredentialBinding, CredentialBroker, CredentialBroker as CredentialBroker$1, CredentialResolver, DiagnosticEvent, DiagnosticLog, EnvironmentRecord, EnvironmentRecord as EnvironmentRecord$1, EnvironmentRecord as EnvironmentRecord$2, ExecCodeOptions, ExecConnectionError, ExecHandle, ExecOptions, ExecResult, FileInfo, IStorageAdapter, IStorageAdapter as IStorageAdapter$1, InteractiveExecHandle, LedgerEntry, LedgerEvent, ListSandboxOptions, ListSandboxOptions as ListSandboxOptions$1, Metrics, PendingInteractiveExec, SandboxDetails, SandboxDetails as SandboxDetails$1, SandboxError, SandboxHandle, SandboxHandle as SandboxHandle$1, SandboxHooks, SandboxStatus, StepTimeoutError } from "@alineo-labs/core";
|
|
2
2
|
import { CodeLanguage, CredentialProxyConfig, NetworkPolicy, NetworkPolicy as NetworkPolicy$1, NetworkRule } from "@alineo-labs/opensandbox";
|
|
3
3
|
import { OpenSandboxCredentialBroker } from "@alineo-labs/vault";
|
|
4
|
-
|
|
5
4
|
//#region src/types.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Client-side SDK error carrying an HTTP-style status code, thrown for
|
|
@@ -11,7 +10,7 @@ import { OpenSandboxCredentialBroker } from "@alineo-labs/vault";
|
|
|
11
10
|
* `OpenSandboxError` from `@alineo-labs/opensandbox`, which is never rethrown as a
|
|
12
11
|
* `SandboxClientError`.
|
|
13
12
|
*/
|
|
14
|
-
declare class SandboxClientError extends Error {
|
|
13
|
+
export declare class SandboxClientError extends Error {
|
|
15
14
|
readonly status: number;
|
|
16
15
|
constructor(message: string, status: number);
|
|
17
16
|
}
|
|
@@ -229,13 +228,13 @@ interface EnvironmentSandboxOptions {
|
|
|
229
228
|
* }
|
|
230
229
|
* ```
|
|
231
230
|
*/
|
|
232
|
-
declare class Environment {
|
|
231
|
+
export declare class Environment {
|
|
233
232
|
/** The environment name, as passed to `client.environment()`. */
|
|
234
233
|
readonly name: string;
|
|
235
234
|
private readonly opts;
|
|
236
235
|
private readonly client;
|
|
237
|
-
constructor(
|
|
238
|
-
|
|
236
|
+
constructor(
|
|
237
|
+
/** The environment name, as passed to `client.environment()`. */
|
|
239
238
|
name: string, opts: EnvironmentOptions, client: Sandbox);
|
|
240
239
|
/**
|
|
241
240
|
* Return a sandbox pre-configured with this environment.
|
|
@@ -278,7 +277,7 @@ declare class Environment {
|
|
|
278
277
|
* await sb.close();
|
|
279
278
|
* ```
|
|
280
279
|
*/
|
|
281
|
-
declare class Sandbox {
|
|
280
|
+
export declare class Sandbox {
|
|
282
281
|
private readonly _control;
|
|
283
282
|
private readonly _adapter;
|
|
284
283
|
private readonly _credentialBroker;
|
|
@@ -377,6 +376,12 @@ declare class Sandbox {
|
|
|
377
376
|
/** Default team scope for any later `.fork()` call — see `SandboxOptions.teamId`. Same
|
|
378
377
|
* rationale as `opts.resourceId`. */
|
|
379
378
|
teamId?: string;
|
|
379
|
+
/**
|
|
380
|
+
* Also accept a Paused sandbox. The handle comes back marked paused: `exec()` and friends
|
|
381
|
+
* throw until `resume()` is called. For reconnecting to a sandbox someone paused (e.g. after
|
|
382
|
+
* the process that paused it restarted) without resuming it first.
|
|
383
|
+
*/
|
|
384
|
+
allowPaused?: boolean;
|
|
380
385
|
}): Promise<SandboxHandle$1>;
|
|
381
386
|
/**
|
|
382
387
|
* Create a fresh sandbox from a snapshot ID without exec replay.
|
|
@@ -436,9 +441,13 @@ declare class Sandbox {
|
|
|
436
441
|
* ```
|
|
437
442
|
*/
|
|
438
443
|
readonly sandboxes: {
|
|
439
|
-
/** List all sandbox records across all names, newest first. */
|
|
440
|
-
|
|
441
|
-
|
|
444
|
+
/** List all sandbox records across all names, newest first. */
|
|
445
|
+
list: (opts?: ListSandboxOptions$1) => Promise<SandboxDetails$1[]>;
|
|
446
|
+
/** List sandbox records for a specific name, newest first. */
|
|
447
|
+
listByName: (name: string, opts?: ListSandboxOptions$1) => Promise<SandboxDetails$1[]>;
|
|
448
|
+
/** Return details for a single sandbox record. Returns `null` if not found. */
|
|
449
|
+
get: (name: string, sandboxId: string) => Promise<SandboxDetails$1 | null>;
|
|
450
|
+
/** Delete all ledger events for a sandbox. */
|
|
442
451
|
delete: (name: string, sandboxId: string) => Promise<void>;
|
|
443
452
|
};
|
|
444
453
|
/**
|
|
@@ -478,7 +487,9 @@ declare class Sandbox {
|
|
|
478
487
|
* ```
|
|
479
488
|
*/
|
|
480
489
|
readonly environments: {
|
|
481
|
-
/** Return all environment records, newest first. */
|
|
490
|
+
/** Return all environment records, newest first. */
|
|
491
|
+
list: () => Promise<EnvironmentRecord$1[]>;
|
|
492
|
+
/** Remove the ledger record for a named environment. Does not delete the server-side snapshot. */
|
|
482
493
|
delete: (name: string) => Promise<void>;
|
|
483
494
|
};
|
|
484
495
|
_envInfo(name: string): Promise<EnvironmentRecord$1 | null>;
|
|
@@ -497,4 +508,4 @@ declare class Sandbox {
|
|
|
497
508
|
private _releaseSlot;
|
|
498
509
|
}
|
|
499
510
|
//#endregion
|
|
500
|
-
export { BashSession, type CheckpointInfo, CodeLanguage, CommandError, type CredentialBinding, type CredentialBroker, type CredentialProxyConfig, type DiagnosticEvent, type DiagnosticLog,
|
|
511
|
+
export { BashSession, type CheckpointInfo, CodeLanguage, CommandError, type CredentialBinding, type CredentialBroker, type CredentialProxyConfig, type DiagnosticEvent, type DiagnosticLog, type EnvironmentOptions, type EnvironmentRecord, type EnvironmentSandboxOptions, type ExecCodeOptions, ExecConnectionError, type ExecHandle, type ExecOptions, type ExecResult, type FileInfo, type IStorageAdapter, type InteractiveExecHandle, type LedgerEntry, LedgerEvent, type ListSandboxOptions, type Metrics, type NetworkPolicy, type NetworkRule, OpenSandboxCredentialBroker, type PendingInteractiveExec, type ResumeOptions, type SandboxClientOptions, type SandboxDetails, SandboxError, SandboxHandle, type SandboxOptions, SandboxStatus, StepTimeoutError };
|
package/dist/index.mjs
CHANGED
|
@@ -398,11 +398,12 @@ var Sandbox = class {
|
|
|
398
398
|
*/
|
|
399
399
|
async connect(sandboxId, name, opts) {
|
|
400
400
|
await this._ensureConnected();
|
|
401
|
-
const
|
|
402
|
-
|
|
401
|
+
const state = (await this._control.getSandbox(sandboxId)).status.state;
|
|
402
|
+
const paused = state === SandboxState.Paused;
|
|
403
|
+
if (state !== SandboxState.Running && !(paused && opts?.allowPaused)) throw new SandboxClientError(`SandboxHandle ${sandboxId} is ${state} — can only connect to Running sandboxes` + (paused ? " (pass allowPaused to connect to a Paused one)" : ""), 409);
|
|
403
404
|
await this._acquireSlot();
|
|
404
405
|
const resources = opts?.resources;
|
|
405
|
-
|
|
406
|
+
const handle = new SandboxHandle$1(sandboxId, name, {
|
|
406
407
|
control: this._control,
|
|
407
408
|
adapter: this._adapter,
|
|
408
409
|
credentialBroker: this._credentialBroker,
|
|
@@ -412,6 +413,8 @@ var Sandbox = class {
|
|
|
412
413
|
fork: resources ? (snapshotId, tag, overrideRunId, forkOpts) => this._forkFromSnapshot(snapshotId, name, resources, void 0, overrideRunId ?? opts?.runId, sandboxId, opts?.resourceId, opts?.teamId, forkOpts) : void 0,
|
|
413
414
|
useServerProxy: this._useServerProxy
|
|
414
415
|
});
|
|
416
|
+
if (paused) handle.setPaused(true);
|
|
417
|
+
return handle;
|
|
415
418
|
}
|
|
416
419
|
/**
|
|
417
420
|
* Create a fresh sandbox from a snapshot ID without exec replay.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alineo-labs/sandbox",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"test:watch": "vitest"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@alineo-labs/core": "0.4.
|
|
32
|
+
"@alineo-labs/core": "0.4.1",
|
|
33
33
|
"@alineo-labs/opensandbox": "0.3.0",
|
|
34
|
-
"@alineo-labs/vault": "0.3.
|
|
34
|
+
"@alineo-labs/vault": "0.3.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"bun-types": "1.
|
|
38
|
-
"tsdown": "0.
|
|
37
|
+
"bun-types": "1.4.2",
|
|
38
|
+
"tsdown": "0.23.0",
|
|
39
39
|
"typescript": "6.0.3",
|
|
40
|
-
"vitest": "
|
|
40
|
+
"vitest": "5.0.0"
|
|
41
41
|
}
|
|
42
42
|
}
|