heyo-sdk
Rust SDK for the Heyo cloud sandbox API. Mirrors the TypeScript SDK
(sdk-ts/ → @heyocomputer/sdk) so the same patterns translate across
languages.
use ;
async
Surface
Sandbox— VM lifecycle (create,connect,list,info,wait_for_ready,kill,stop/start/restart,set_ttl,resize,checkpoint/restore,replace_mount,bind_port,shell).Sandbox::commands()—.run(cmd, opts)against/sandbox/:id/exec.Sandbox::files()—.read/.writeagainst/sandbox/:id/read-file//write-file(base64 over the wire, exposed asVec<u8>/String).ShellSession— persistent interactive shell over the WebSocket protocol, withoutput()andevents()streams, auto-reconnect, and gracefulclose().Database— cloud sqlite (create,connect,list,regions,info,exec,batch,connect_token,connection_info,list_connections,revoke_connection,checkout,checkin,delete).archive_dir(path, opts)— tar+gz a local directory, presign + PUT + finalize.
Errors
Everything returns Result<T, HeyoError>. Notable variants:
Authentication— no API key.InvalidArgument(String)— 400/422.NotFound(String)— 404.Api { status, message, body }— 5xx and friends.Timeout(Duration, String)—wait_for_*budget exceeded.SandboxFailed { sandbox_id, reason }— provisioning ended infailed.CheckinConflict { expected, current }— optimistic concurrency onDatabase::checkin.SessionExpired { session_id },Connection(String),ShellExit(i32)— shell session failures.
Configuration
HeyoClient::new(HeyoClientOptions { .. }) (or any high-level
Sandbox::create / Database::create etc. that takes a HeyoClientOptions)
resolves config in this order:
- Fields set on
HeyoClientOptionswin. HEYO_API_KEYenv var suppliesapi_keywhen unset.base_urldefaults tohttps://server.heyo.computer.timeoutdefaults to 60s.
Running integration tests
All tests under tests/ are marked #[ignore] because they need a live
cloud API + an API key. Set up .env next to Cargo.toml:
HEYO_API_KEY=heyo_api_xxxxxxxxxxxx
# optional — defaults to localhost:4445 ("local")
HEYO_ENV=local
# or HEYO_BASE_URL=http://localhost:4445
Then run individual tests:
HEYO_DB_ID=db-xxxx
HEYO_DB_ID=db-xxxx
Tests skip cleanly with an eprintln! message when required env is missing,
so plain cargo test (no --ignored) is a no-op.
Status / limitations
archive_dirv0 excludes a fixed deny-list (.git,node_modules,target, …) plus any caller-supplied directory names..gitignoreparsing is a follow-up.Sandbox::list_public_imagesmatches the TS surface but the underlying/public-imagesendpoint may not be wired everywhere; expect 404s on older clouds.- The shell test exercises open / IO / resize / close. Forced-reconnect testing exists in the TS SDK by reaching into a private socket field; Rust integration tests rely on natural disconnects rather than poking internals.