@computesdk/sandbox0 1.0.1
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/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/index.d.mts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +22806 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +22785 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 computesdk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @computesdk/sandbox0
|
|
2
|
+
|
|
3
|
+
[Sandbox0](https://sandbox0.ai) provider for ComputeSDK. Create fast persistent sandboxes, run shell commands, and use native filesystem operations through the official Sandbox0 JavaScript SDK.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install computesdk @computesdk/sandbox0
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Create a team API key and export it:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
export SANDBOX0_TOKEN=your_sandbox0_token
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`SANDBOX0_BASE_URL` is optional and defaults to the public Sandbox0 API at
|
|
20
|
+
`https://api.sandbox0.ai`. For automated team workloads, set it to the team's
|
|
21
|
+
home-region endpoint so requests go directly to the regional gateway.
|
|
22
|
+
|
|
23
|
+
An interactive access token can also be used by setting both
|
|
24
|
+
`SANDBOX0_TOKEN` and `SANDBOX0_TEAM_ID`.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { compute } from 'computesdk';
|
|
30
|
+
import { sandbox0 } from '@computesdk/sandbox0';
|
|
31
|
+
|
|
32
|
+
compute.setConfig({
|
|
33
|
+
provider: sandbox0({
|
|
34
|
+
token: process.env.SANDBOX0_TOKEN,
|
|
35
|
+
hardTtl: 600,
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const sandbox = await compute.sandbox.create({
|
|
40
|
+
templateId: 'coding-agent',
|
|
41
|
+
memory: 256,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const result = await sandbox.runCommand('node --version');
|
|
45
|
+
console.log(result.stdout);
|
|
46
|
+
|
|
47
|
+
await sandbox.filesystem.writeFile('/tmp/hello.txt', 'Hello from Sandbox0');
|
|
48
|
+
console.log(await sandbox.filesystem.readFile('/tmp/hello.txt'));
|
|
49
|
+
|
|
50
|
+
await sandbox.destroy();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
| Option | Environment variable | Default | Description |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| `token` | `SANDBOX0_TOKEN` or `SANDBOX0_API_KEY` | required | Team API key, or an access token when `teamId` is set |
|
|
58
|
+
| `teamId` | `SANDBOX0_TEAM_ID` | none | Team ID required with access-token authentication |
|
|
59
|
+
| `baseUrl` | `SANDBOX0_BASE_URL` | SDK default | Sandbox0 API endpoint |
|
|
60
|
+
| `templateId` | `SANDBOX0_TEMPLATE` | `coding-agent` | Template used for new sandboxes |
|
|
61
|
+
| `ttl` | - | platform default | Soft runtime TTL in seconds |
|
|
62
|
+
| `hardTtl` | - | platform default | Hard sandbox TTL in seconds |
|
|
63
|
+
| `memory` | - | template default | Memory in MiB or a quantity such as `1Gi` |
|
|
64
|
+
| `envs` | - | none | Default environment variables |
|
|
65
|
+
| `commandTimeout` | - | none | Default command timeout in milliseconds |
|
|
66
|
+
|
|
67
|
+
Per-create `templateId`, `snapshotId`, `memory`, `envs`, `ttl`, `hardTtl`, and `autoResume` options override provider defaults where applicable. Numeric memory values are interpreted as MiB.
|
|
68
|
+
|
|
69
|
+
## Feature support
|
|
70
|
+
|
|
71
|
+
| Feature | Supported |
|
|
72
|
+
|---|---|
|
|
73
|
+
| Create / getById / list / destroy | Yes |
|
|
74
|
+
| Shell commands | Yes, through `sh -lc` |
|
|
75
|
+
| Command `cwd`, environment, timeout, and background mode | Yes |
|
|
76
|
+
| Filesystem | Yes, through Sandbox0's native file API |
|
|
77
|
+
| Public URLs | Yes, for public services already configured on the sandbox |
|
|
78
|
+
| Restore from snapshot | Yes, with `snapshotId` at create time |
|
|
79
|
+
| Snapshot management | Use the native Sandbox0 SDK |
|
|
80
|
+
|
|
81
|
+
`destroy` is idempotent and retries short-lived throttling or server failures. Setting `hardTtl` is still recommended for automated workloads so a failed client cannot leave a sandbox indefinitely.
|
|
82
|
+
|
|
83
|
+
For Sandbox0-specific capabilities such as pause/resume, services, snapshots, volumes, and observability, call `sandbox.getInstance()` to access the native `sandbox0` SDK handle.
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as _computesdk_provider from '@computesdk/provider';
|
|
2
|
+
import { Sandbox } from 'sandbox0';
|
|
3
|
+
export { Sandbox as Sandbox0Sandbox } from 'sandbox0';
|
|
4
|
+
|
|
5
|
+
interface Sandbox0Config {
|
|
6
|
+
/** Team API key, or an access token when teamId is set. */
|
|
7
|
+
token?: string;
|
|
8
|
+
/** Team ID for access-token authentication. Falls back to SANDBOX0_TEAM_ID. */
|
|
9
|
+
teamId?: string;
|
|
10
|
+
/** API endpoint. Falls back to SANDBOX0_BASE_URL, then the SDK default. */
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
/** Default template for new sandboxes. Falls back to SANDBOX0_TEMPLATE, then `coding-agent`. */
|
|
13
|
+
templateId?: string;
|
|
14
|
+
/** Default soft runtime TTL in seconds. */
|
|
15
|
+
ttl?: number;
|
|
16
|
+
/** Default hard sandbox TTL in seconds. */
|
|
17
|
+
hardTtl?: number;
|
|
18
|
+
/** Default memory limit as MiB or a Kubernetes quantity such as `1Gi`. */
|
|
19
|
+
memory?: number | string;
|
|
20
|
+
/** Default environment variables for new sandboxes. */
|
|
21
|
+
envs?: Record<string, string>;
|
|
22
|
+
/** Default command timeout in milliseconds. */
|
|
23
|
+
commandTimeout?: number;
|
|
24
|
+
}
|
|
25
|
+
declare const sandbox0: (config?: Sandbox0Config) => _computesdk_provider.Provider<Sandbox, any, any>;
|
|
26
|
+
|
|
27
|
+
export { type Sandbox0Config, sandbox0 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as _computesdk_provider from '@computesdk/provider';
|
|
2
|
+
import { Sandbox } from 'sandbox0';
|
|
3
|
+
export { Sandbox as Sandbox0Sandbox } from 'sandbox0';
|
|
4
|
+
|
|
5
|
+
interface Sandbox0Config {
|
|
6
|
+
/** Team API key, or an access token when teamId is set. */
|
|
7
|
+
token?: string;
|
|
8
|
+
/** Team ID for access-token authentication. Falls back to SANDBOX0_TEAM_ID. */
|
|
9
|
+
teamId?: string;
|
|
10
|
+
/** API endpoint. Falls back to SANDBOX0_BASE_URL, then the SDK default. */
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
/** Default template for new sandboxes. Falls back to SANDBOX0_TEMPLATE, then `coding-agent`. */
|
|
13
|
+
templateId?: string;
|
|
14
|
+
/** Default soft runtime TTL in seconds. */
|
|
15
|
+
ttl?: number;
|
|
16
|
+
/** Default hard sandbox TTL in seconds. */
|
|
17
|
+
hardTtl?: number;
|
|
18
|
+
/** Default memory limit as MiB or a Kubernetes quantity such as `1Gi`. */
|
|
19
|
+
memory?: number | string;
|
|
20
|
+
/** Default environment variables for new sandboxes. */
|
|
21
|
+
envs?: Record<string, string>;
|
|
22
|
+
/** Default command timeout in milliseconds. */
|
|
23
|
+
commandTimeout?: number;
|
|
24
|
+
}
|
|
25
|
+
declare const sandbox0: (config?: Sandbox0Config) => _computesdk_provider.Provider<Sandbox, any, any>;
|
|
26
|
+
|
|
27
|
+
export { type Sandbox0Config, sandbox0 };
|