dvm-run
dvm.run's Rust SDK, on tokio.
&&
dvm-run login opens dvm.run in your browser, where you approve an API key
for this machine; it saves the key in ~/.config/dvm/credentials.json, where
the SDK finds it (the Python and JS SDKs too). Over SSH, open the link it
prints wherever you like. Where no one is there to approve one, such as CI,
make a key on dvm.run's API keys page and
set DVM_API_KEY.
A sandbox is a VM made from an image: your agent sends it commands and files until it stops it. Everything it ran is its execution, which replays, the same, once it ends.
use Duration;
let client = from_env?;
let sbx = client.create_sandbox.seed.await?;
sbx.files.write.await?;
let r = sbx
.commands
.run
.cwd
.timeout
.await?;
println!;
let server = sbx.commands.spawn.await?;
server.kill.await?;
server.wait.await?;
sbx.stop.await?;
let verdict = client.execution.await?.replay.await?.wait.await?;
assert!;
Client::from_env takes dvm.run's address from DVM_API_URL, else
https://sandbox.dvm.run, and its key from DVM_API_KEY, else the one
dvm-run login saved for that address; Client::new takes both.
- A
&strruns in the sandbox's shell (/bin/bash -lc, or/bin/sh -cin an image without bash); an array runs as it is. - A command's exit code is never an error. A sandbox that ended is
Error::SandboxEnded(Error::SandboxFailed, with dvm's reason, if it failed) on the next call. .timeout()kills the command once it passes; its result says so, with code 137 and signal 9. Arundropped before its command exits kills it too; a droppedwait()only stops waiting.- Dropping a sandbox doesn't stop it: call
stop(), which returns once its log is in, so its execution replays. - The API's types are
dvm-api's, asdvm_run::api.