@brimble/sandbox 0.1.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/CODEX.md +188 -0
- package/PLAN.md +364 -0
- package/README.md +147 -0
- package/dist/package.json +23 -0
- package/dist/src/client.d.ts +23 -0
- package/dist/src/client.js +46 -0
- package/dist/src/constants.d.ts +14 -0
- package/dist/src/constants.js +21 -0
- package/dist/src/enums/code-language.d.ts +4 -0
- package/dist/src/enums/code-language.js +8 -0
- package/dist/src/enums/destroy-reason.d.ts +8 -0
- package/dist/src/enums/destroy-reason.js +12 -0
- package/dist/src/enums/destroy-timeout.d.ts +8 -0
- package/dist/src/enums/destroy-timeout.js +12 -0
- package/dist/src/enums/index.d.ts +7 -0
- package/dist/src/enums/index.js +17 -0
- package/dist/src/enums/sandbox-status.d.ts +9 -0
- package/dist/src/enums/sandbox-status.js +13 -0
- package/dist/src/enums/snapshot-mode.d.ts +4 -0
- package/dist/src/enums/snapshot-mode.js +8 -0
- package/dist/src/enums/snapshot-status.d.ts +5 -0
- package/dist/src/enums/snapshot-status.js +9 -0
- package/dist/src/enums/volume-type.d.ts +3 -0
- package/dist/src/enums/volume-type.js +7 -0
- package/dist/src/errors/index.d.ts +2 -0
- package/dist/src/errors/index.js +9 -0
- package/dist/src/errors/sandbox-api-error.d.ts +29 -0
- package/dist/src/errors/sandbox-api-error.js +48 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +40 -0
- package/dist/src/resources/exec.d.ts +19 -0
- package/dist/src/resources/exec.js +45 -0
- package/dist/src/resources/files.d.ts +16 -0
- package/dist/src/resources/files.js +41 -0
- package/dist/src/resources/index.d.ts +8 -0
- package/dist/src/resources/index.js +20 -0
- package/dist/src/resources/path.d.ts +7 -0
- package/dist/src/resources/path.js +19 -0
- package/dist/src/resources/sandbox-handle.d.ts +78 -0
- package/dist/src/resources/sandbox-handle.js +151 -0
- package/dist/src/resources/sandboxes.d.ts +64 -0
- package/dist/src/resources/sandboxes.js +224 -0
- package/dist/src/resources/scoped-sandbox.d.ts +39 -0
- package/dist/src/resources/scoped-sandbox.js +51 -0
- package/dist/src/resources/snapshots.d.ts +26 -0
- package/dist/src/resources/snapshots.js +88 -0
- package/dist/src/resources/stats.d.ts +11 -0
- package/dist/src/resources/stats.js +26 -0
- package/dist/src/resources/volumes.d.ts +21 -0
- package/dist/src/resources/volumes.js +80 -0
- package/dist/src/transport/auth.d.ts +2 -0
- package/dist/src/transport/auth.js +7 -0
- package/dist/src/transport/http.d.ts +73 -0
- package/dist/src/transport/http.js +354 -0
- package/dist/src/transport/pagination.d.ts +3 -0
- package/dist/src/transport/pagination.js +11 -0
- package/dist/src/types/exec.d.ts +34 -0
- package/dist/src/types/exec.js +2 -0
- package/dist/src/types/files.d.ts +1 -0
- package/dist/src/types/files.js +2 -0
- package/dist/src/types/index.d.ts +9 -0
- package/dist/src/types/index.js +2 -0
- package/dist/src/types/pagination.d.ts +14 -0
- package/dist/src/types/pagination.js +2 -0
- package/dist/src/types/region.d.ts +17 -0
- package/dist/src/types/region.js +2 -0
- package/dist/src/types/sandbox.d.ts +90 -0
- package/dist/src/types/sandbox.js +2 -0
- package/dist/src/types/snapshot.d.ts +15 -0
- package/dist/src/types/snapshot.js +2 -0
- package/dist/src/types/stats.d.ts +31 -0
- package/dist/src/types/stats.js +2 -0
- package/dist/src/types/template.d.ts +5 -0
- package/dist/src/types/template.js +2 -0
- package/dist/src/types/volume.d.ts +24 -0
- package/dist/src/types/volume.js +2 -0
- package/package.json +26 -0
- package/src/client.ts +61 -0
- package/src/constants.ts +17 -0
- package/src/enums/code-language.ts +4 -0
- package/src/enums/destroy-reason.ts +8 -0
- package/src/enums/destroy-timeout.ts +8 -0
- package/src/enums/index.ts +7 -0
- package/src/enums/sandbox-status.ts +9 -0
- package/src/enums/snapshot-mode.ts +4 -0
- package/src/enums/snapshot-status.ts +5 -0
- package/src/enums/volume-type.ts +3 -0
- package/src/errors/index.ts +2 -0
- package/src/errors/sandbox-api-error.ts +54 -0
- package/src/index.ts +71 -0
- package/src/resources/exec.ts +56 -0
- package/src/resources/files.ts +46 -0
- package/src/resources/index.ts +8 -0
- package/src/resources/path.ts +16 -0
- package/src/resources/sandbox-handle.ts +215 -0
- package/src/resources/sandboxes.ts +297 -0
- package/src/resources/scoped-sandbox.ts +65 -0
- package/src/resources/snapshots.ts +104 -0
- package/src/resources/stats.ts +30 -0
- package/src/resources/volumes.ts +95 -0
- package/src/transport/auth.ts +4 -0
- package/src/transport/http.ts +501 -0
- package/src/transport/pagination.ts +10 -0
- package/src/types/exec.ts +42 -0
- package/src/types/files.ts +1 -0
- package/src/types/index.ts +23 -0
- package/src/types/pagination.ts +16 -0
- package/src/types/region.ts +19 -0
- package/src/types/sandbox.ts +103 -0
- package/src/types/snapshot.ts +17 -0
- package/src/types/stats.ts +35 -0
- package/src/types/template.ts +5 -0
- package/src/types/volume.ts +26 -0
- package/test/integration/sandbox.integration.test.ts +269 -0
- package/test/unit/client.test.ts +87 -0
- package/test/unit/sandboxes.test.ts +69 -0
- package/test/unit/transport.test.ts +126 -0
- package/test/unit/volumes.test.ts +122 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +12 -0
- package/vitest.integration.config.ts +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# @brimble/sandbox
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the Brimble Sandbox API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @brimble/sandbox
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Testing
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Unit tests (mocked transport, no API key required)
|
|
15
|
+
npm run test
|
|
16
|
+
|
|
17
|
+
# Live integration test (creates a sandbox, runs a command, then destroys it)
|
|
18
|
+
BRIMBLE_SANDBOX_KEY=your_key_here npm run test:integration
|
|
19
|
+
|
|
20
|
+
# Run both
|
|
21
|
+
BRIMBLE_SANDBOX_KEY=your_key_here npm run test:all
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quickstart
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { CodeLanguage, SandboxClient } from '@brimble/sandbox';
|
|
28
|
+
|
|
29
|
+
const client = new SandboxClient();
|
|
30
|
+
|
|
31
|
+
const sandbox = await client.sandboxes.createReady({
|
|
32
|
+
template: 'node-22',
|
|
33
|
+
persistent: true,
|
|
34
|
+
persistentDiskGB: 20,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await sandbox.exec({ cmd: 'node -v' });
|
|
38
|
+
|
|
39
|
+
await sandbox.putFile('tmp/notes.txt', Buffer.from('hello sandbox'));
|
|
40
|
+
const stream = await sandbox.getFile('tmp/notes.txt');
|
|
41
|
+
|
|
42
|
+
await sandbox.runCode({
|
|
43
|
+
language: CodeLanguage.Node,
|
|
44
|
+
code: 'console.log(1 + 1)',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Handle-first lifecycle on existing sandboxes.
|
|
48
|
+
const existingSandbox = await client.sandboxes.get(sandbox.id);
|
|
49
|
+
await existingSandbox.destroy();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Set `BRIMBLE_SANDBOX_KEY` in your environment.
|
|
53
|
+
If needed, pass `apiKey` explicitly in the constructor; explicit value wins over env.
|
|
54
|
+
|
|
55
|
+
## Ergonomic helpers
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// 1) Create + wait in one call
|
|
59
|
+
const created = await client.sandboxes.createReady({ template: 'node-22' });
|
|
60
|
+
|
|
61
|
+
// 2) Get + wait in one call
|
|
62
|
+
const loaded = await client.sandboxes.getReady(created.id);
|
|
63
|
+
|
|
64
|
+
// 3) Create a volume + attach in one call
|
|
65
|
+
const withVolume = await client.sandboxes.withVolume({
|
|
66
|
+
sandbox: { template: 'node-22' },
|
|
67
|
+
volume: { name: 'workspace-disk', sizeGB: 20 },
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// 4) Auto-wait at runtime call sites
|
|
71
|
+
await withVolume.exec({ cmd: 'npm -v' }, { waitUntilReady: true });
|
|
72
|
+
|
|
73
|
+
// Streaming SSE output (stream: true returns ReadableStream<Uint8Array>)
|
|
74
|
+
const sse = await withVolume.exec({ cmd: 'for i in 1 2 3; do echo $i; done', stream: true });
|
|
75
|
+
|
|
76
|
+
// 5) List templates/regions
|
|
77
|
+
const templates = await client.sandboxes.listTemplates();
|
|
78
|
+
const nodeTemplate = await client.sandboxes.getTemplate('node-22');
|
|
79
|
+
const { regions } = await client.sandboxes.listRegions();
|
|
80
|
+
|
|
81
|
+
// 6) Async iterators for pagination
|
|
82
|
+
for await (const sandbox of client.sandboxes.iterate({ teamId: '<team>' })) {
|
|
83
|
+
console.log(sandbox.id, sandbox.status);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Handle composition
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
const sandbox = await client.sandboxes.get('<sandbox-id>');
|
|
91
|
+
|
|
92
|
+
await sandbox.snapshots.create({ name: 'before-migration' });
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Volume attachment is create-time only.
|
|
96
|
+
Use `client.sandboxes.create({ ..., volumeId })` or `client.sandboxes.withVolume(...)`.
|
|
97
|
+
|
|
98
|
+
## Retry, timeouts, and idempotency
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const client = new SandboxClient({
|
|
102
|
+
timeoutMs: 30_000,
|
|
103
|
+
retry: {
|
|
104
|
+
maxAttempts: 3,
|
|
105
|
+
baseDelayMs: 250,
|
|
106
|
+
maxDelayMs: 2_000,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
await client.sandboxes.create(
|
|
111
|
+
{ template: 'node-22' },
|
|
112
|
+
{ idempotencyKey: 'create-sandbox-123' },
|
|
113
|
+
);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
If `region` is omitted, the SDK resolves the first available sandbox region automatically.
|
|
117
|
+
|
|
118
|
+
## Resources
|
|
119
|
+
|
|
120
|
+
- `client.sandboxes`
|
|
121
|
+
- `create`, `createReady`, `withVolume`, `list`, `iterate`, `get`, `getReady`, `listRegions`, `listTemplates`, `getTemplate`, `destroy`, `pause`, `resume`, `quickstartNode`, `quickstartPython`, `use`
|
|
122
|
+
- `sandbox` handle (returned from `create/get/list`)
|
|
123
|
+
- `waitUntilReady`, `refresh`, `destroy`, `pause`, `resume`, `exec`, `runCode`, `putFile`, `getFile`, `stats`, `createSnapshot`, `listSnapshots`, `snapshots.create`, `snapshots.list`
|
|
124
|
+
- `client.sandboxes.use(id)`
|
|
125
|
+
- `exec`, `runCode`, `putFile`, `getFile`, `stats`, `createSnapshot`, `listSnapshots`
|
|
126
|
+
- `client.snapshots`
|
|
127
|
+
- `listAll`, `iterateAll`, `delete`
|
|
128
|
+
- `client.volumes`
|
|
129
|
+
- `list`, `iterate`, `create`, `get`, `delete`
|
|
130
|
+
|
|
131
|
+
## Errors
|
|
132
|
+
|
|
133
|
+
HTTP errors throw typed errors:
|
|
134
|
+
|
|
135
|
+
- `AuthError`
|
|
136
|
+
- `ValidationError`
|
|
137
|
+
- `NotFoundError`
|
|
138
|
+
- `RateLimitError`
|
|
139
|
+
- `SandboxApiError`
|
|
140
|
+
|
|
141
|
+
All include:
|
|
142
|
+
|
|
143
|
+
- `status`
|
|
144
|
+
- `message`
|
|
145
|
+
- `endpoint`
|
|
146
|
+
- `responseBody`
|
|
147
|
+
- `requestId`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@brimble/sandbox",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for the Brimble Sandbox API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "rm -rf dist && tsc -p .",
|
|
9
|
+
"test": "vitest run --config vitest.config.ts",
|
|
10
|
+
"test:watch": "vitest --config vitest.config.ts",
|
|
11
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
12
|
+
"test:all": "npm run test && npm run test:integration"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20.19.0",
|
|
20
|
+
"typescript": "^5.9.3",
|
|
21
|
+
"vitest": "^3.2.4"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SandboxesResource, SnapshotsResource, VolumesResource } from './resources';
|
|
2
|
+
import type { RetryOptions } from './transport/http';
|
|
3
|
+
export type SandboxClientOptions = {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
retry?: RetryOptions;
|
|
8
|
+
fetchImpl?: typeof fetch;
|
|
9
|
+
};
|
|
10
|
+
export declare class SandboxClient {
|
|
11
|
+
/** Access sandbox lifecycle and per-sandbox scoped operations. */
|
|
12
|
+
readonly sandboxes: SandboxesResource;
|
|
13
|
+
/** Access account-level snapshot operations. */
|
|
14
|
+
readonly snapshots: SnapshotsResource;
|
|
15
|
+
/** Access volume lifecycle operations. */
|
|
16
|
+
readonly volumes: VolumesResource;
|
|
17
|
+
private readonly transport;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a client instance for the Brimble Sandbox API.
|
|
20
|
+
* Pass `apiKey` directly or set `BRIMBLE_SANDBOX_KEY` in your environment.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options?: SandboxClientOptions);
|
|
23
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxClient = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const resources_1 = require("./resources");
|
|
6
|
+
const http_1 = require("./transport/http");
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the API key from the constructor options first,
|
|
9
|
+
* then falls back to BRIMBLE_SANDBOX_KEY.
|
|
10
|
+
*/
|
|
11
|
+
function resolveApiKey(options) {
|
|
12
|
+
if (options.apiKey) {
|
|
13
|
+
return options.apiKey;
|
|
14
|
+
}
|
|
15
|
+
const apiKeyFromEnv = process.env[constants_1.SANDBOX_API_KEY_ENV_NAME];
|
|
16
|
+
if (apiKeyFromEnv) {
|
|
17
|
+
return apiKeyFromEnv;
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`Sandbox API key is required. Pass "apiKey" explicitly or set ${constants_1.SANDBOX_API_KEY_ENV_NAME} in your environment.`);
|
|
20
|
+
}
|
|
21
|
+
class SandboxClient {
|
|
22
|
+
/** Access sandbox lifecycle and per-sandbox scoped operations. */
|
|
23
|
+
sandboxes;
|
|
24
|
+
/** Access account-level snapshot operations. */
|
|
25
|
+
snapshots;
|
|
26
|
+
/** Access volume lifecycle operations. */
|
|
27
|
+
volumes;
|
|
28
|
+
transport;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a client instance for the Brimble Sandbox API.
|
|
31
|
+
* Pass `apiKey` directly or set `BRIMBLE_SANDBOX_KEY` in your environment.
|
|
32
|
+
*/
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
this.transport = new http_1.HttpTransport({
|
|
35
|
+
apiKey: resolveApiKey(options),
|
|
36
|
+
baseUrl: options.baseUrl ?? constants_1.DEFAULT_BASE_URL,
|
|
37
|
+
timeoutMs: options.timeoutMs ?? constants_1.DEFAULT_TIMEOUT_MS,
|
|
38
|
+
retry: options.retry,
|
|
39
|
+
fetchImpl: options.fetchImpl,
|
|
40
|
+
});
|
|
41
|
+
this.sandboxes = new resources_1.SandboxesResource(this.transport);
|
|
42
|
+
this.snapshots = new resources_1.SnapshotsResource(this.transport);
|
|
43
|
+
this.volumes = new resources_1.VolumesResource(this.transport);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.SandboxClient = SandboxClient;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const DEFAULT_BASE_URL = "https://sandbox.brimble.io";
|
|
2
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
3
|
+
export declare const SANDBOX_API_KEY_ENV_NAME = "BRIMBLE_SANDBOX_KEY";
|
|
4
|
+
export declare const SDK_PACKAGE_VERSION: string;
|
|
5
|
+
export declare const DEFAULT_PAGE = 1;
|
|
6
|
+
export declare const DEFAULT_PAGE_LIMIT = 15;
|
|
7
|
+
export declare const MAX_PAGE_LIMIT = 100;
|
|
8
|
+
export declare const MIN_VOLUME_SIZE_GB = 10;
|
|
9
|
+
export declare const DEFAULT_SANDBOX_READY_TIMEOUT_MS = 60000;
|
|
10
|
+
export declare const DEFAULT_SANDBOX_READY_POLL_INTERVAL_MS = 2000;
|
|
11
|
+
export declare const DEFAULT_RETRY_MAX_ATTEMPTS = 1;
|
|
12
|
+
export declare const DEFAULT_RETRY_BASE_DELAY_MS = 300;
|
|
13
|
+
export declare const DEFAULT_RETRY_MAX_DELAY_MS = 3000;
|
|
14
|
+
export declare const DEFAULT_RETRY_STATUSES: readonly [408, 429, 500, 502, 503, 504];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_RETRY_STATUSES = exports.DEFAULT_RETRY_MAX_DELAY_MS = exports.DEFAULT_RETRY_BASE_DELAY_MS = exports.DEFAULT_RETRY_MAX_ATTEMPTS = exports.DEFAULT_SANDBOX_READY_POLL_INTERVAL_MS = exports.DEFAULT_SANDBOX_READY_TIMEOUT_MS = exports.MIN_VOLUME_SIZE_GB = exports.MAX_PAGE_LIMIT = exports.DEFAULT_PAGE_LIMIT = exports.DEFAULT_PAGE = exports.SDK_PACKAGE_VERSION = exports.SANDBOX_API_KEY_ENV_NAME = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_BASE_URL = void 0;
|
|
7
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
8
|
+
exports.DEFAULT_BASE_URL = 'https://sandbox.brimble.io';
|
|
9
|
+
exports.DEFAULT_TIMEOUT_MS = 30_000;
|
|
10
|
+
exports.SANDBOX_API_KEY_ENV_NAME = 'BRIMBLE_SANDBOX_KEY';
|
|
11
|
+
exports.SDK_PACKAGE_VERSION = package_json_1.default.version;
|
|
12
|
+
exports.DEFAULT_PAGE = 1;
|
|
13
|
+
exports.DEFAULT_PAGE_LIMIT = 15;
|
|
14
|
+
exports.MAX_PAGE_LIMIT = 100;
|
|
15
|
+
exports.MIN_VOLUME_SIZE_GB = 10;
|
|
16
|
+
exports.DEFAULT_SANDBOX_READY_TIMEOUT_MS = 60_000;
|
|
17
|
+
exports.DEFAULT_SANDBOX_READY_POLL_INTERVAL_MS = 2_000;
|
|
18
|
+
exports.DEFAULT_RETRY_MAX_ATTEMPTS = 1;
|
|
19
|
+
exports.DEFAULT_RETRY_BASE_DELAY_MS = 300;
|
|
20
|
+
exports.DEFAULT_RETRY_MAX_DELAY_MS = 3_000;
|
|
21
|
+
exports.DEFAULT_RETRY_STATUSES = [408, 429, 500, 502, 503, 504];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeLanguage = void 0;
|
|
4
|
+
var CodeLanguage;
|
|
5
|
+
(function (CodeLanguage) {
|
|
6
|
+
CodeLanguage["Python"] = "python";
|
|
7
|
+
CodeLanguage["Node"] = "node";
|
|
8
|
+
})(CodeLanguage || (exports.CodeLanguage = CodeLanguage = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DestroyReason = void 0;
|
|
4
|
+
var DestroyReason;
|
|
5
|
+
(function (DestroyReason) {
|
|
6
|
+
DestroyReason["User"] = "user";
|
|
7
|
+
DestroyReason["IdleTtl"] = "idle_ttl";
|
|
8
|
+
DestroyReason["MaxLifetime"] = "max_lifetime";
|
|
9
|
+
DestroyReason["OneShotStopped"] = "one_shot_stopped";
|
|
10
|
+
DestroyReason["Failed"] = "failed";
|
|
11
|
+
DestroyReason["PausedTooLong"] = "paused_too_long";
|
|
12
|
+
})(DestroyReason || (exports.DestroyReason = DestroyReason = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DestroyTimeout = void 0;
|
|
4
|
+
var DestroyTimeout;
|
|
5
|
+
(function (DestroyTimeout) {
|
|
6
|
+
DestroyTimeout["ThirtyMinutes"] = "30m";
|
|
7
|
+
DestroyTimeout["OneHour"] = "1h";
|
|
8
|
+
DestroyTimeout["ThreeHours"] = "3h";
|
|
9
|
+
DestroyTimeout["SixHours"] = "6h";
|
|
10
|
+
DestroyTimeout["TwelveHours"] = "12h";
|
|
11
|
+
DestroyTimeout["EighteenHours"] = "18h";
|
|
12
|
+
})(DestroyTimeout || (exports.DestroyTimeout = DestroyTimeout = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { CodeLanguage } from './code-language';
|
|
2
|
+
export { DestroyReason } from './destroy-reason';
|
|
3
|
+
export { DestroyTimeout } from './destroy-timeout';
|
|
4
|
+
export { SandboxStatus } from './sandbox-status';
|
|
5
|
+
export { SnapshotMode } from './snapshot-mode';
|
|
6
|
+
export { SnapshotStatus } from './snapshot-status';
|
|
7
|
+
export { VolumeType } from './volume-type';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolumeType = exports.SnapshotStatus = exports.SnapshotMode = exports.SandboxStatus = exports.DestroyTimeout = exports.DestroyReason = exports.CodeLanguage = void 0;
|
|
4
|
+
var code_language_1 = require("./code-language");
|
|
5
|
+
Object.defineProperty(exports, "CodeLanguage", { enumerable: true, get: function () { return code_language_1.CodeLanguage; } });
|
|
6
|
+
var destroy_reason_1 = require("./destroy-reason");
|
|
7
|
+
Object.defineProperty(exports, "DestroyReason", { enumerable: true, get: function () { return destroy_reason_1.DestroyReason; } });
|
|
8
|
+
var destroy_timeout_1 = require("./destroy-timeout");
|
|
9
|
+
Object.defineProperty(exports, "DestroyTimeout", { enumerable: true, get: function () { return destroy_timeout_1.DestroyTimeout; } });
|
|
10
|
+
var sandbox_status_1 = require("./sandbox-status");
|
|
11
|
+
Object.defineProperty(exports, "SandboxStatus", { enumerable: true, get: function () { return sandbox_status_1.SandboxStatus; } });
|
|
12
|
+
var snapshot_mode_1 = require("./snapshot-mode");
|
|
13
|
+
Object.defineProperty(exports, "SnapshotMode", { enumerable: true, get: function () { return snapshot_mode_1.SnapshotMode; } });
|
|
14
|
+
var snapshot_status_1 = require("./snapshot-status");
|
|
15
|
+
Object.defineProperty(exports, "SnapshotStatus", { enumerable: true, get: function () { return snapshot_status_1.SnapshotStatus; } });
|
|
16
|
+
var volume_type_1 = require("./volume-type");
|
|
17
|
+
Object.defineProperty(exports, "VolumeType", { enumerable: true, get: function () { return volume_type_1.VolumeType; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxStatus = void 0;
|
|
4
|
+
var SandboxStatus;
|
|
5
|
+
(function (SandboxStatus) {
|
|
6
|
+
SandboxStatus["Starting"] = "starting";
|
|
7
|
+
SandboxStatus["Ready"] = "ready";
|
|
8
|
+
SandboxStatus["Pausing"] = "pausing";
|
|
9
|
+
SandboxStatus["Paused"] = "paused";
|
|
10
|
+
SandboxStatus["Resuming"] = "resuming";
|
|
11
|
+
SandboxStatus["Failed"] = "failed";
|
|
12
|
+
SandboxStatus["Destroyed"] = "destroyed";
|
|
13
|
+
})(SandboxStatus || (exports.SandboxStatus = SandboxStatus = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnapshotMode = void 0;
|
|
4
|
+
var SnapshotMode;
|
|
5
|
+
(function (SnapshotMode) {
|
|
6
|
+
SnapshotMode["Manual"] = "manual";
|
|
7
|
+
SnapshotMode["Automatic"] = "automatic";
|
|
8
|
+
})(SnapshotMode || (exports.SnapshotMode = SnapshotMode = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnapshotStatus = void 0;
|
|
4
|
+
var SnapshotStatus;
|
|
5
|
+
(function (SnapshotStatus) {
|
|
6
|
+
SnapshotStatus["Creating"] = "creating";
|
|
7
|
+
SnapshotStatus["Ready"] = "ready";
|
|
8
|
+
SnapshotStatus["Failed"] = "failed";
|
|
9
|
+
})(SnapshotStatus || (exports.SnapshotStatus = SnapshotStatus = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = exports.SandboxApiError = exports.RateLimitError = exports.NotFoundError = exports.AuthError = void 0;
|
|
4
|
+
var sandbox_api_error_1 = require("./sandbox-api-error");
|
|
5
|
+
Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return sandbox_api_error_1.AuthError; } });
|
|
6
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return sandbox_api_error_1.NotFoundError; } });
|
|
7
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return sandbox_api_error_1.RateLimitError; } });
|
|
8
|
+
Object.defineProperty(exports, "SandboxApiError", { enumerable: true, get: function () { return sandbox_api_error_1.SandboxApiError; } });
|
|
9
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return sandbox_api_error_1.ValidationError; } });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type SandboxApiErrorArgs = {
|
|
2
|
+
status: number;
|
|
3
|
+
message: string;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
responseBody: unknown;
|
|
6
|
+
requestId?: string | null;
|
|
7
|
+
};
|
|
8
|
+
export declare class SandboxApiError extends Error {
|
|
9
|
+
readonly status: number;
|
|
10
|
+
readonly endpoint: string;
|
|
11
|
+
readonly responseBody: unknown;
|
|
12
|
+
readonly requestId: string | null;
|
|
13
|
+
constructor(args: SandboxApiErrorArgs);
|
|
14
|
+
}
|
|
15
|
+
export declare class AuthError extends SandboxApiError {
|
|
16
|
+
constructor(args: SandboxApiErrorArgs);
|
|
17
|
+
}
|
|
18
|
+
export declare class ValidationError extends SandboxApiError {
|
|
19
|
+
constructor(args: SandboxApiErrorArgs);
|
|
20
|
+
}
|
|
21
|
+
export declare class NotFoundError extends SandboxApiError {
|
|
22
|
+
constructor(args: SandboxApiErrorArgs);
|
|
23
|
+
}
|
|
24
|
+
export declare class RateLimitError extends SandboxApiError {
|
|
25
|
+
readonly retryAfterSeconds: number | null;
|
|
26
|
+
constructor(args: SandboxApiErrorArgs & {
|
|
27
|
+
retryAfterSeconds?: number | null;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RateLimitError = exports.NotFoundError = exports.ValidationError = exports.AuthError = exports.SandboxApiError = void 0;
|
|
4
|
+
class SandboxApiError extends Error {
|
|
5
|
+
status;
|
|
6
|
+
endpoint;
|
|
7
|
+
responseBody;
|
|
8
|
+
requestId;
|
|
9
|
+
constructor(args) {
|
|
10
|
+
super(args.message);
|
|
11
|
+
this.name = 'SandboxApiError';
|
|
12
|
+
this.status = args.status;
|
|
13
|
+
this.endpoint = args.endpoint;
|
|
14
|
+
this.responseBody = args.responseBody;
|
|
15
|
+
this.requestId = args.requestId ?? null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.SandboxApiError = SandboxApiError;
|
|
19
|
+
class AuthError extends SandboxApiError {
|
|
20
|
+
constructor(args) {
|
|
21
|
+
super(args);
|
|
22
|
+
this.name = 'AuthError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.AuthError = AuthError;
|
|
26
|
+
class ValidationError extends SandboxApiError {
|
|
27
|
+
constructor(args) {
|
|
28
|
+
super(args);
|
|
29
|
+
this.name = 'ValidationError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ValidationError = ValidationError;
|
|
33
|
+
class NotFoundError extends SandboxApiError {
|
|
34
|
+
constructor(args) {
|
|
35
|
+
super(args);
|
|
36
|
+
this.name = 'NotFoundError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.NotFoundError = NotFoundError;
|
|
40
|
+
class RateLimitError extends SandboxApiError {
|
|
41
|
+
retryAfterSeconds;
|
|
42
|
+
constructor(args) {
|
|
43
|
+
super(args);
|
|
44
|
+
this.name = 'RateLimitError';
|
|
45
|
+
this.retryAfterSeconds = args.retryAfterSeconds ?? null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.RateLimitError = RateLimitError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { DEFAULT_BASE_URL, DEFAULT_PAGE, DEFAULT_PAGE_LIMIT, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_RETRY_STATUSES, DEFAULT_TIMEOUT_MS, MAX_PAGE_LIMIT, SANDBOX_API_KEY_ENV_NAME, } from './constants';
|
|
2
|
+
export { SandboxClient } from './client';
|
|
3
|
+
export type { SandboxClientOptions } from './client';
|
|
4
|
+
export { AuthError, NotFoundError, RateLimitError, SandboxApiError, ValidationError } from './errors';
|
|
5
|
+
export type { SandboxApiErrorArgs } from './errors';
|
|
6
|
+
export { CodeLanguage, DestroyReason, DestroyTimeout, SandboxStatus, SnapshotMode, SnapshotStatus, VolumeType, } from './enums';
|
|
7
|
+
export { ExecResource, FilesResource, SandboxHandle, SandboxesResource, ScopedSandboxResource, SnapshotScopeResource, SnapshotsResource, StatsResource, VolumesResource, } from './resources';
|
|
8
|
+
export type { AckMessage, CodeInput, CreateSandboxInput, CreateSandboxResult, CreateSnapshotInput, CreateVolumeInput, ExecInput, ExecResult, ExecStreamFrame, FileUploadBody, Paginated, Pagination, RegionSummary, SandboxRegion, SandboxRegionsResult, Sandbox, SandboxSpecs, Snapshot, Stats, StatsAverageNetwork, StatsAverageNumeric, StatsQuery, StatsTimelinePoint, TeamScopedPagination, WaitUntilReadyOptions, Volume, } from './types';
|
|
9
|
+
export type { RequestOptions } from './transport/http';
|
|
10
|
+
export type { RetryOptions } from './transport/http';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolumesResource = exports.StatsResource = exports.SnapshotsResource = exports.SnapshotScopeResource = exports.ScopedSandboxResource = exports.SandboxesResource = exports.SandboxHandle = exports.FilesResource = exports.ExecResource = exports.VolumeType = exports.SnapshotStatus = exports.SnapshotMode = exports.SandboxStatus = exports.DestroyTimeout = exports.DestroyReason = exports.CodeLanguage = exports.ValidationError = exports.SandboxApiError = exports.RateLimitError = exports.NotFoundError = exports.AuthError = exports.SandboxClient = exports.SANDBOX_API_KEY_ENV_NAME = exports.MAX_PAGE_LIMIT = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_RETRY_STATUSES = exports.DEFAULT_RETRY_MAX_DELAY_MS = exports.DEFAULT_RETRY_MAX_ATTEMPTS = exports.DEFAULT_RETRY_BASE_DELAY_MS = exports.DEFAULT_PAGE_LIMIT = exports.DEFAULT_PAGE = exports.DEFAULT_BASE_URL = void 0;
|
|
4
|
+
var constants_1 = require("./constants");
|
|
5
|
+
Object.defineProperty(exports, "DEFAULT_BASE_URL", { enumerable: true, get: function () { return constants_1.DEFAULT_BASE_URL; } });
|
|
6
|
+
Object.defineProperty(exports, "DEFAULT_PAGE", { enumerable: true, get: function () { return constants_1.DEFAULT_PAGE; } });
|
|
7
|
+
Object.defineProperty(exports, "DEFAULT_PAGE_LIMIT", { enumerable: true, get: function () { return constants_1.DEFAULT_PAGE_LIMIT; } });
|
|
8
|
+
Object.defineProperty(exports, "DEFAULT_RETRY_BASE_DELAY_MS", { enumerable: true, get: function () { return constants_1.DEFAULT_RETRY_BASE_DELAY_MS; } });
|
|
9
|
+
Object.defineProperty(exports, "DEFAULT_RETRY_MAX_ATTEMPTS", { enumerable: true, get: function () { return constants_1.DEFAULT_RETRY_MAX_ATTEMPTS; } });
|
|
10
|
+
Object.defineProperty(exports, "DEFAULT_RETRY_MAX_DELAY_MS", { enumerable: true, get: function () { return constants_1.DEFAULT_RETRY_MAX_DELAY_MS; } });
|
|
11
|
+
Object.defineProperty(exports, "DEFAULT_RETRY_STATUSES", { enumerable: true, get: function () { return constants_1.DEFAULT_RETRY_STATUSES; } });
|
|
12
|
+
Object.defineProperty(exports, "DEFAULT_TIMEOUT_MS", { enumerable: true, get: function () { return constants_1.DEFAULT_TIMEOUT_MS; } });
|
|
13
|
+
Object.defineProperty(exports, "MAX_PAGE_LIMIT", { enumerable: true, get: function () { return constants_1.MAX_PAGE_LIMIT; } });
|
|
14
|
+
Object.defineProperty(exports, "SANDBOX_API_KEY_ENV_NAME", { enumerable: true, get: function () { return constants_1.SANDBOX_API_KEY_ENV_NAME; } });
|
|
15
|
+
var client_1 = require("./client");
|
|
16
|
+
Object.defineProperty(exports, "SandboxClient", { enumerable: true, get: function () { return client_1.SandboxClient; } });
|
|
17
|
+
var errors_1 = require("./errors");
|
|
18
|
+
Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return errors_1.AuthError; } });
|
|
19
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_1.NotFoundError; } });
|
|
20
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
21
|
+
Object.defineProperty(exports, "SandboxApiError", { enumerable: true, get: function () { return errors_1.SandboxApiError; } });
|
|
22
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
|
|
23
|
+
var enums_1 = require("./enums");
|
|
24
|
+
Object.defineProperty(exports, "CodeLanguage", { enumerable: true, get: function () { return enums_1.CodeLanguage; } });
|
|
25
|
+
Object.defineProperty(exports, "DestroyReason", { enumerable: true, get: function () { return enums_1.DestroyReason; } });
|
|
26
|
+
Object.defineProperty(exports, "DestroyTimeout", { enumerable: true, get: function () { return enums_1.DestroyTimeout; } });
|
|
27
|
+
Object.defineProperty(exports, "SandboxStatus", { enumerable: true, get: function () { return enums_1.SandboxStatus; } });
|
|
28
|
+
Object.defineProperty(exports, "SnapshotMode", { enumerable: true, get: function () { return enums_1.SnapshotMode; } });
|
|
29
|
+
Object.defineProperty(exports, "SnapshotStatus", { enumerable: true, get: function () { return enums_1.SnapshotStatus; } });
|
|
30
|
+
Object.defineProperty(exports, "VolumeType", { enumerable: true, get: function () { return enums_1.VolumeType; } });
|
|
31
|
+
var resources_1 = require("./resources");
|
|
32
|
+
Object.defineProperty(exports, "ExecResource", { enumerable: true, get: function () { return resources_1.ExecResource; } });
|
|
33
|
+
Object.defineProperty(exports, "FilesResource", { enumerable: true, get: function () { return resources_1.FilesResource; } });
|
|
34
|
+
Object.defineProperty(exports, "SandboxHandle", { enumerable: true, get: function () { return resources_1.SandboxHandle; } });
|
|
35
|
+
Object.defineProperty(exports, "SandboxesResource", { enumerable: true, get: function () { return resources_1.SandboxesResource; } });
|
|
36
|
+
Object.defineProperty(exports, "ScopedSandboxResource", { enumerable: true, get: function () { return resources_1.ScopedSandboxResource; } });
|
|
37
|
+
Object.defineProperty(exports, "SnapshotScopeResource", { enumerable: true, get: function () { return resources_1.SnapshotScopeResource; } });
|
|
38
|
+
Object.defineProperty(exports, "SnapshotsResource", { enumerable: true, get: function () { return resources_1.SnapshotsResource; } });
|
|
39
|
+
Object.defineProperty(exports, "StatsResource", { enumerable: true, get: function () { return resources_1.StatsResource; } });
|
|
40
|
+
Object.defineProperty(exports, "VolumesResource", { enumerable: true, get: function () { return resources_1.VolumesResource; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CodeInput, ExecInput, ExecResult } from '../types';
|
|
2
|
+
import type { RequestOptions } from '../transport/http';
|
|
3
|
+
import { HttpTransport } from '../transport/http';
|
|
4
|
+
export declare class ExecResource {
|
|
5
|
+
private readonly transport;
|
|
6
|
+
private readonly sandboxId;
|
|
7
|
+
/** @internal Create the exec/code runner wrapper for one sandbox. */
|
|
8
|
+
constructor(transport: HttpTransport, sandboxId: string);
|
|
9
|
+
/** Run a shell command in the sandbox. */
|
|
10
|
+
exec(input: ExecInput & {
|
|
11
|
+
stream: true;
|
|
12
|
+
}, options?: RequestOptions): Promise<ReadableStream<Uint8Array>>;
|
|
13
|
+
exec(input: ExecInput, options?: RequestOptions): Promise<ExecResult>;
|
|
14
|
+
/** Run a code snippet in the sandbox. */
|
|
15
|
+
runCode(input: CodeInput & {
|
|
16
|
+
stream: true;
|
|
17
|
+
}, options?: RequestOptions): Promise<ReadableStream<Uint8Array>>;
|
|
18
|
+
runCode(input: CodeInput, options?: RequestOptions): Promise<ExecResult>;
|
|
19
|
+
}
|