@enclave-run/sdk 0.0.0-dev

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 ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 FOUNDRYLABS, INC.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # @enclave-run/sdk
2
+
3
+ JavaScript/TypeScript SDK for [Enclave](https://enclave.run) — secure, isolated cloud sandboxes for AI agents and AI apps.
4
+
5
+ A sandbox is a persistent Linux VM your code can treat as a remote execution target: run shell commands, read and write files, start long-running processes, forward ports, or build templates. Sandboxes start in ~150 ms and hibernate to disk on timeout.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @enclave-run/sdk
11
+ ```
12
+
13
+ Set your API key:
14
+
15
+ ```bash
16
+ export ENCLAVE_API_KEY=enclave_...
17
+ ```
18
+
19
+ Get one from [app.enclave.run](https://app.enclave.run).
20
+
21
+ ## Quick start
22
+
23
+ ```ts
24
+ import { Sandbox } from "@enclave-run/sdk";
25
+
26
+ const sandbox = await Sandbox.create();
27
+
28
+ const result = await sandbox.commands.run("echo hello");
29
+ console.log(result.stdout); // "hello\n"
30
+
31
+ await sandbox.files.write("/tmp/note.txt", "persisted");
32
+ const contents = await sandbox.files.read("/tmp/note.txt");
33
+
34
+ await sandbox.kill();
35
+ ```
36
+
37
+ ## Core surface
38
+
39
+ | Area | API |
40
+ |------|-----|
41
+ | Lifecycle | `Sandbox.create`, `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
+
48
+ ## Runtimes
49
+
50
+ Node.js 20+, Bun, and Deno are supported. The SDK has no Node-specific runtime dependencies in its hot path; platform-specific features (like reading files from disk during a template build) use `node:fs` behind a dynamic import.
51
+
52
+ ## Sandbox region and ownership
53
+
54
+ The SDK uses the launched default region (`yyz`) unless you choose another
55
+ supported region. It sends create directly to that regional API and keeps the
56
+ authoritative API base on the sandbox handle, so pause, resume, timeout,
57
+ snapshot, and kill never take a hidden global round trip.
58
+
59
+ ```ts
60
+ const sandbox = await Sandbox.create("base", { region: "yyz" });
61
+ console.log(sandbox.sandboxRegion); // "yyz"
62
+ ```
63
+
64
+ You can override the client default once with `ENCLAVE_REGION=yyz`. Static
65
+ lifecycle helpers can take `region`; an instance returned by `create` or
66
+ `connect` already carries its owner. SDK releases from before the regional
67
+ default continue through the bounded global compatibility endpoint.
68
+
69
+ Every logical create has an idempotency key (generated by the SDK unless you
70
+ provide one). A timeout or lost response raises `OutcomeUnknownError` with the
71
+ same-region recovery URL. Only an explicit pre-admission capacity rejection can
72
+ be considered for another region; a transport timeout must never be retried
73
+ elsewhere.
74
+
75
+ The chosen region is also part of the sandbox host:
76
+
77
+ ```
78
+ sbx-{id}-{port}.{region}.onenclave.com
79
+ ```
80
+
81
+ ## Env vars
82
+
83
+ | Variable | Purpose | Default |
84
+ |----------|---------|---------|
85
+ | `ENCLAVE_API_KEY` | API authentication | — |
86
+ | `ENCLAVE_DOMAIN` | API/sandbox apex | `onenclave.com` |
87
+ | `ENCLAVE_API_URL` | Override API URL | — |
88
+ | `ENCLAVE_REGION` | Regional API used for create/lifecycle | `yyz` |
89
+ | `ENCLAVE_ACCESS_TOKEN` | Alternative auth (user tokens) | — |
90
+ | `ENCLAVE_DEBUG` | Debug logging | `false` |
91
+
92
+ ## Docs
93
+
94
+ Full reference at [enclave.run/docs](https://enclave.run/docs). Source: [github.com/enclave-run/docs](https://github.com/enclave-run/docs).