@enclave-run/sdk 0.0.0-dev.4 → 0.0.0-dev.5
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 +51 -18
- package/dist/index.d.mts +372 -17
- package/dist/index.d.ts +372 -17
- package/dist/index.js +526 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +524 -90
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -36,14 +36,14 @@ await sandbox.kill();
|
|
|
36
36
|
|
|
37
37
|
## Core surface
|
|
38
38
|
|
|
39
|
-
| Area
|
|
40
|
-
|
|
41
|
-
| Lifecycle
|
|
42
|
-
| Filesystem | `sandbox.files.{read, write, list, exists, remove, makeDir, watch}`
|
|
43
|
-
| Commands
|
|
44
|
-
| PTY
|
|
45
|
-
| Snapshots
|
|
46
|
-
| Templates
|
|
39
|
+
| Area | API |
|
|
40
|
+
| ---------- | ----------------------------------------------------------------------------------------- |
|
|
41
|
+
| Lifecycle | `Sandbox.create`, `Sandbox.inRegion`, `sandbox.connect`, `sandbox.pause`, `sandbox.kill` |
|
|
42
|
+
| Filesystem | `sandbox.files.{read, write, list, exists, remove, makeDir, watch}` |
|
|
43
|
+
| Commands | `sandbox.commands.{run, start, list, kill, sendStdin}` |
|
|
44
|
+
| PTY | `sandbox.pty.{create, sendInput, resize}` |
|
|
45
|
+
| Snapshots | `Sandbox.createSnapshot`, `Sandbox.list` |
|
|
46
|
+
| Templates | `Template().fromImage(...).copy(...)`, `Template.build`, `Template.exists` |
|
|
47
47
|
|
|
48
48
|
## Runtimes
|
|
49
49
|
|
|
@@ -61,10 +61,30 @@ const sandbox = await Sandbox.create("base", { region: "yyz" });
|
|
|
61
61
|
console.log(sandbox.sandboxRegion); // "yyz"
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
For several operations in one region, create an immutable regional scope once:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const yyz = Sandbox.inRegion("yyz");
|
|
68
|
+
|
|
69
|
+
const sandbox = await yyz.create("base");
|
|
70
|
+
const sameSandbox = await yyz.connect(sandbox.sandboxId);
|
|
71
|
+
await yyz.pause(sandbox.sandboxId);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Persist `sandbox.ref` when a later process needs to reconnect without relying
|
|
75
|
+
on a configured default:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
await save(sandbox.ref); // { sandboxId: "sbx-...", region: "yyz" }
|
|
79
|
+
const sameSandbox = await Sandbox.connect(await load());
|
|
80
|
+
```
|
|
81
|
+
|
|
64
82
|
You can override the client default once with `ENCLAVE_REGION=yyz`. Static
|
|
65
83
|
lifecycle helpers can take `region`; an instance returned by `create` or
|
|
66
|
-
`connect` already carries its owner.
|
|
67
|
-
|
|
84
|
+
`connect` already carries its owner. A saved reference is authoritative; a
|
|
85
|
+
conflicting regional scope or explicit option fails locally. SDK releases from
|
|
86
|
+
before the regional default continue through the bounded global compatibility
|
|
87
|
+
endpoint.
|
|
68
88
|
|
|
69
89
|
Every logical create has an idempotency key (generated by the SDK unless you
|
|
70
90
|
provide one). A timeout or lost response raises `OutcomeUnknownError` with the
|
|
@@ -72,6 +92,19 @@ same-region recovery URL. Only an explicit pre-admission capacity rejection can
|
|
|
72
92
|
be considered for another region; a transport timeout must never be retried
|
|
73
93
|
elsewhere.
|
|
74
94
|
|
|
95
|
+
Recover without rebuilding or resending the original create request:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
try {
|
|
99
|
+
return await Sandbox.create("base", { idempotencyKey: "job-123" })
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error instanceof OutcomeUnknownError) {
|
|
102
|
+
return Sandbox.recoverCreate(error.recovery)
|
|
103
|
+
}
|
|
104
|
+
throw error
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
75
108
|
The chosen region is also part of the sandbox host:
|
|
76
109
|
|
|
77
110
|
```
|
|
@@ -80,14 +113,14 @@ sbx-{id}-{port}.{region}.onenclave.com
|
|
|
80
113
|
|
|
81
114
|
## Env vars
|
|
82
115
|
|
|
83
|
-
| Variable
|
|
84
|
-
|
|
85
|
-
| `ENCLAVE_API_KEY`
|
|
86
|
-
| `ENCLAVE_DOMAIN`
|
|
87
|
-
| `ENCLAVE_API_URL`
|
|
88
|
-
| `ENCLAVE_REGION`
|
|
89
|
-
| `ENCLAVE_ACCESS_TOKEN` | Alternative auth (user tokens)
|
|
90
|
-
| `ENCLAVE_DEBUG`
|
|
116
|
+
| Variable | Purpose | Default |
|
|
117
|
+
| ---------------------- | -------------------------------------- | --------------- |
|
|
118
|
+
| `ENCLAVE_API_KEY` | API authentication | — |
|
|
119
|
+
| `ENCLAVE_DOMAIN` | API/sandbox apex | `onenclave.com` |
|
|
120
|
+
| `ENCLAVE_API_URL` | Override API URL | — |
|
|
121
|
+
| `ENCLAVE_REGION` | Regional API used for create/lifecycle | `yyz` |
|
|
122
|
+
| `ENCLAVE_ACCESS_TOKEN` | Alternative auth (user tokens) | — |
|
|
123
|
+
| `ENCLAVE_DEBUG` | Debug logging | `false` |
|
|
91
124
|
|
|
92
125
|
## Docs
|
|
93
126
|
|