Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,45 @@ consumer that only runs local sandboxes does not need a remote provider SDK.
Adapters for providers that publish no JavaScript SDK speak their HTTP API
directly and add no dependency at all; they take an injectable `fetch` instead.

### Provider constraints

Each adapter inherits its provider SDK's requirements, and they are not all the
same as this package's:

| Adapter | Peer dependency | Requirements beyond this package's |
| --- | --- | --- |
| `DaytonaRuntime` | `@daytonaio/sdk` | — |
| `E2BSandboxRuntime` | `e2b` | — |
| `MicrosandboxRuntime` | `microsandbox` | **Node.js 22+**, a platform-specific native addon (macOS arm64, Linux x64/arm64, Windows x64/arm64), and — for its `local` backend — hardware virtualization: KVM on Linux, Apple Silicon on macOS, or WHP on Windows 10+ |
| `LocalSandboxRuntime` | — | A reachable local sandbox service |

The package itself keeps a Node 20 floor, because a consumer that never touches
the microsandbox adapter never loads that SDK: it is imported lazily, at first
use, and a load failure is reported with the constraint that most often
explains it.

### Microsandbox capabilities are backend-sensitive

`MicrosandboxRuntime.capabilities` is derived from the backend the instance is
bound to, not reported as a single process-wide constant:

| Capability | `local` | `cloud` | Why |
| --- | --- | --- | --- |
| `snapshots` | `true` | `false` | A snapshot is a host-local artifact: the installed SDK's typings describe `Snapshot` as an artifact on disk and resolve one under `~/.microsandbox/snapshots/<name>/`. This adapter consumes such an artifact from the calling host and never transfers it, so a create issued against a remote backend has nothing to resolve. Configuring `snapshot` with a cloud backend is refused in the constructor, before any SDK call. |
| `isolation` | `'strong'` | `'unknown'` | Locally the SDK boots a microVM with its own guest kernel on a virtualization-capable host, and the installed package states that requirement itself, so `'strong'` rests on something checkable here. This adapter observes and measures nothing about the cloud backend's isolation. |

Both values describe what this package has **established**, not what any
provider documents. `'unknown'` is not a synonym for weak and is not a claim
that the guarantee is missing — it means this package has not established one,
so a caller that requires a specific guarantee must decide for itself rather
than read an unverified `'strong'`.

Cloud region placement and resource enforcement are likewise not represented as
measured facts. Custom or published **ports are not supported**: the SDK builder
exposes `port()`/`portBind()`, but the ports this package targets have no
public-port surface, so the adapter never calls them and never implies a
reachable port.

## Design

Two pieces, deliberately kept apart:
Expand Down Expand Up @@ -123,7 +162,8 @@ npm run typecheck
npm test # node:test
```

Requires Node.js 20 or newer.
Requires Node.js 20 or newer. The microsandbox adapter's own tests need Node 22+
to load the real SDK; without it, its SDK-contract checks skip rather than fail.

## Releasing

Expand Down
113 changes: 112 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@
},
"peerDependencies": {
"@daytonaio/sdk": ">=0.205.0 <0.206.0",
"e2b": ">=2.35.0 <3.0.0"
"e2b": ">=2.35.0 <3.0.0",
"microsandbox": ">=0.6.11 <0.7.0"
},
"peerDependenciesMeta": {
"@daytonaio/sdk": {
"optional": true
},
"e2b": {
"optional": true
},
"microsandbox": {
"optional": true
}
},
"devDependencies": {
"@daytonaio/sdk": "^0.205.1",
"@types/node": "^22",
"e2b": "^2.35.0",
"microsandbox": "^0.6.11",
"tsx": "^4.20.6",
"typescript": "^5.9.3"
},
Expand Down
23 changes: 23 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,29 @@ export type {
E2BUploadBundleOptions,
} from "./e2b/runtime.js";

export {
MicrosandboxBackendBusyError,
MicrosandboxBackendPoisonedError,
MicrosandboxCreateTimeoutError,
MicrosandboxLogReadError,
MicrosandboxLookupTimeoutError,
MicrosandboxNameTooLongError,
MicrosandboxPaginationError,
MicrosandboxRunLostError,
MicrosandboxRunNotFinishedError,
MicrosandboxRunTimeoutUnsupportedError,
MicrosandboxRuntime,
MicrosandboxSessionConflictError,
MicrosandboxStatusProbeError,
MicrosandboxUnknownOutcomeError,
} from "./microsandbox/runtime.js";
export type {
MicrosandboxBackend,
MicrosandboxRuntimeOptions,
MicrosandboxSdk,
MicrosandboxStatus,
} from "./microsandbox/runtime.js";

export {
AGENT37_COMMAND_CAP_MS,
Agent37CommandTimeoutUnsupportedError,
Expand Down
Loading
Loading