Rivet and OpenOrange
Back my Rivet Actor's agent harness with Hermitbox.
Run a Rivet Actor’s agent harness on Hermitbox sandboxes, and keep the harness’s own hooks. The
TypeScript SDK exports hermitboxProvider from hermitbox/provider, which implements Rivet’s
published SandboxProvider contract. An OpenOrange Sandbox binding can use the same provider
once a prepared patch is applied.
Install the SDK alongside your existing adapter, and set HERMITBOX_API_URL and
HERMITBOX_API_KEY in the actor runner’s environment. The key stays there: it never belongs in a
Worker response or a sandbox environment.
Agent harness in a Rivet Actor
- Install
hermitboxalongside your harness. - Set the install’s
HERMITBOX_API_URLandHERMITBOX_API_KEYon the runner. - Use this factory for the harness’s sandbox provider. Keep its existing
create/connect,suspendanddestroyhooks; the Actor stores the sandbox id as before.
import { hermitboxProvider } from 'hermitbox/provider'
export const sandboxProvider = hermitboxProvider()bun examples/rivet-provider.ts runs the complete lifecycle example, with no model key. The
provider holds no per-Actor state.
What each hook does:
createreturns an id.connectstarts stopped compute or wakes a sleeping sandbox. On a deleted or expired sandbox it returnsundefined; authentication, placement and transport failures throw.suspendputs the sandbox to sleep with its data kept.destroydeletes it.
On a missing sandbox, suspend and destroy do nothing. Mutations are sent once.
OpenOrange sandbox binding
OpenOrange 1.0.2 has a closed list of provider names and no API to register a custom provider, so an unmodified release can’t select Hermitbox. The prepared patch adds that registration; it isn’t part of the published OpenOrange package. With the patch applied:
- Install
hermitboxnext to OpenOrange. - Set
HERMITBOX_API_URL,HERMITBOX_API_KEYandORANGE_SANDBOX_PROVIDER=hermitboxon the runner. - The provider registration below backs the existing Sandbox binding; Worker code keeps
its existing
getSandbox()calls. The prepared patch supplies the native file/preview bridge.
import { hermitboxProvider, hermitboxPortAddress } from 'hermitbox/provider'
export const sandboxProvider = hermitboxProvider()
export const portAddress = (id: string, port: number) =>
hermitboxPortAddress(id, port)Files and options
The binding works in the connected sandbox’s persistent directory: /data on mounted tiers, or
the agent’s data directory on the process tier. Native file paths must stay inside that root.
The host’s default tier applies. A caller can pass { tier, template, require } to the factory,
with optional url and key overrides. The provider doesn’t pass require to the API: it refuses
every nonempty require with missing_guarantee and the names, before creation, so no
requirement is silently dropped. Unavailable tiers and templates keep the API’s reason.
With no template named, container creation uses the project’s configured repoImage. A template
used with this provider must mount its persistent storage at /data on mounted tiers. Use
sandbox.cwd to resolve file paths and execution directories. The provider learns the process
directory when connecting and leaves the optional provider-level cwd unset.
Commands
Exec accepts an absolute cwd, an explicit environment, a millisecond timeout and an
AbortSignal. An undefined or zero timeout adds no provider deadline; the install’s execution
ceiling still applies.
- A timeout kills the process group and returns
timedOut: trueandexitCode: null. - An abort kills it and rejects with
Error('aborted'), including an abort during process startup. onDatareceives stdout and stderr as they arrive; final output keeps the streams separate.- Nonzero exits are results.
- Output above the SDK’s capture budget throws
output_truncated. - A lost connection keeps the SDK’s unknown-outcome error and never replays the command.
Previews
hermitboxPortAddress(id, port) publishes a port through Hermitbox’s own edge and returns its
preview URL. It never returns a sandbox IP or a direct host listener, and capacity and host
policy refusals stay visible. The prepared binding patch sends preview requests through that
address.
What stays unsupported
OpenOrange’s other partial and unsupported methods behave as its
Sandbox binding
documents: its session/code-context methods throw, inactivity timeout does nothing, container
images and custom entrypoints are not run, and PTY/stdin, interception, container snapshots and
inspection are unsupported. Full Files.stat/lstat metadata isn’t available through this bridge.
Browser rendering
Hermitbox’s browser can’t serve as OpenOrange’s Browser Rendering endpoint, and no persistent
browser compatibility is claimed. OpenOrange reads one ORANGE_BROWSER_CDP_URL, opens a new
connection to it for each launch, and has no callback to refresh it. Its Browser Rendering
rules
need a URL that accepts each new connection.
Hermitbox’s browser access is short-lived. box.browser() mints a capability URL that
expires within five minutes. Minting another rotates access, and sleep or recreation also
invalidates old access. Don’t put a minted Hermitbox browser URL in ORANGE_BROWSER_CDP_URL; use
the browser through Hermitbox’s own SDK.
Pinned interfaces
sandbox-adapter 0.5.6, Apache-2.0, from the integrity-pinned npm package; OpenOrange
1.0.2, Apache-2.0, commit 1cabf2e9db300361c9f0b751c7723da7eb706f5e.
The published adapter declares abort as Error('aborted'), timeout as a null exit and a flag,
and missing connections as undefined. Its Docker provider stops and restarts on suspend and
connect; normal command failures remain results. The declarations are a development dependency
only.
How this is tested
CI typechecks this version on every change and the newest published version weekly. Acceptance against a real Hermitbox deployment exercises every provider method, cancellation, streaming, sleep/wake persistence, missing connections and edge preview. Both pages’ blocks and the complete example run in the same job.
$curl -fsSL https://hbx.sh | shInstall Hermitbox and set it up for me