dvm_run/lib.rs
1//! dvm.run's Rust SDK: sandboxes whose every run replays.
2//!
3//! A sandbox is a VM made from an image: your agent sends it commands and
4//! files until it stops it. Everything it ran is its execution, which
5//! replays, the same, once it ends.
6//!
7//! ```no_run
8//! # async fn example() -> dvm_run::Result<()> {
9//! use std::time::Duration;
10//!
11//! let client = dvm_run::Client::from_env()?;
12//! let sbx = client.create_sandbox("python:3.12").seed(7).await?;
13//! sbx.files().write("/app/main.py", "print(1 + 1)\n").await?;
14//! let r = sbx
15//! .commands()
16//! .run("python main.py")
17//! .cwd("/app")
18//! .timeout(Duration::from_secs(60))
19//! .await?;
20//! println!("{} {}", r.stdout, r.exit_code);
21//!
22//! let server = sbx.commands().spawn(["python", "-m", "http.server"]).await?;
23//! server.kill().await?;
24//! server.wait().await?;
25//! sbx.stop().await?;
26//!
27//! let verdict = client.execution(sbx.id()).await?.replay().await?.wait().await?;
28//! assert!(verdict.is_same());
29//! # Ok(())
30//! # }
31//! ```
32//!
33//! [`Client::from_env`] takes dvm.run's address from `DVM_API_URL`, else
34//! `https://sandbox.dvm.run`, and its key from `DVM_API_KEY`, else the one
35//! `dvm-run login` saved for that address. The API's types are
36//! [`dvm_api`]'s, here as [`api`].
37
38mod client;
39mod commands;
40mod credentials;
41mod error;
42mod execution;
43mod files;
44mod login;
45mod sandbox;
46
47pub use client::{Client, DEFAULT_API_URL};
48pub use commands::{
49 Background, CommandBuilder, CommandHandle, CommandResult, Commands, Foreground, OutputCallback,
50 WaitForCommand,
51};
52pub use credentials::{credentials_path, save_key};
53pub use dvm_api as api;
54pub use error::{Error, Result};
55pub use execution::{Execution, Replay, ReplayBuilder};
56pub use files::Files;
57pub use login::{LoggedIn, login};
58pub use sandbox::{Sandbox, SandboxBuilder};