Expand description
§solari-sdk
Rust binding for the Solari sandbox SDK (core surface). Talks the same wire
protocol as the reference @solarisdk/core TypeScript package:
- REST to the gateway for session lifecycle (create/connect/get/kill) and
the one-shot
/execfast path. - Control WebSocket (newline-delimited JSON-RPC) for everything a live
session does:
commands,files,code.run, and the client-sidegitnamespace.
use solari::{Client, ClientOptions, CreateOptions, RunOptions};
let client = Client::new(ClientOptions::with_api_key("slr_live_…"))?;
let sbx = client.create(CreateOptions { template: Some("base".into()), ..Default::default() }).await?;
let out = sbx.commands().run("echo", RunOptions::new().args(["hello"])).await?;
println!("exit={} stdout={}", out.exit_code, out.stdout);
let status = sbx.git().status(Some("/repo")).await?;
println!("branch={} clean={}", status.branch, status.clean);Structs§
- Async
Frame - A v2 async STREAM frame delivered to a registered handler.
- Chart
- Structured representation of a matplotlib figure.
elementsis kept as raw JSON so new chart types don’t require an SDK bump. - Chart
Axis - One axis of a 2D chart.
- Client
- Talks the SDK ⇆ Gateway
/sandboxesREST API and hands backSandboxes. - Client
Options - Options for constructing a
Client. - Code
- The ergonomic
codeaccessor returned bySandbox::code(). - Code
Result Item - One rich result object from
code.run. - Command
Handle - A started command handle (
commands.start). - Command
Io - A cloneable handle on a running command’s input side: write or close stdin and send signals while another task is
blocked in
CommandHandle::wait(which consumes the handle). Get one withCommandHandle::io. - Command
Result - Terminal result of
commands.run(also the/execfast-path response). - Commands
- The ergonomic
commandsaccessor returned bySandbox::commands(). - Control
Channel - The shared control-WS transport. Construct one per live session handle.
- Create
Options - Options accepted by
POST /sandboxes(headless sandbox flavour). - Create
Sandbox Request - Wire body for
POST /sandboxes. Null/unset fields are omitted. - Create
Sandbox Response 201response fromPOST /sandboxes.- Files
- The ergonomic
filesaccessor returned bySandbox::files(). - FsEntry
- One directory entry (
fs.list). Matches the referencetypes.tsFsEntry: the wire field isdir(bool), NOTisDir; there is no path/mode/modTime. - FsStat
- File metadata (
fs.stat). Matches the referencetypes.tsFsStat: fieldsdir(bool),mode(int), andmodTimeMs(unix-millis). - Gateway
Error Body - Shape gateway error bodies may take.
- Git
- The ergonomic
gitaccessor returned bySandbox::git(). - GitBranch
- One branch entry (
git.branches). - GitClone
Options - Options for
git.clone. - GitCommit
- One commit record (
git.log). - GitCommit
Options - Options for
git.commit. - GitLog
Options - Options for
git.log. - GitRemote
Options - Options for
git.push/git.pull. - GitStatus
- Working-tree status (
git.status). - Http
Options - Options for constructing an
HttpTransport. - Http
Transport - Lifecycle
- Idle lifecycle policy (pause/kill on timeout; optional auto-resume).
- Resume
Response POST /sandboxes/:id/resumereply. The gateway may hand back a freshcontrolUrl(the session lands on a new slot, so the old one is stale);Client::resumederives one when it does not.- RunCode
Options - Options for
code.run. - RunCode
Result - Result of
code.run, with the client-sidechartsconvenience view. - RunOptions
- Options for
commands.run/commands.start. - Sandbox
- A live sandbox handle. Exposes the core namespaces.
- Sandbox
View GET /sandboxes/:idresponse (subset used byconnect).- Start
Response POST /sandboxes/:id/startreply.control_urlis a fresh URL (the sandbox was cold-booted);already_runningis set when it was already running.- Volume
Attachment - One attach-at-create instruction: a persistent volume and the absolute in-guest path to mount it at. The mount happens host-side before the guest starts, and survives pause/resume and recreate.
Enums§
- Chart
Type - Kind of a structured chart extracted from a matplotlib figure.
- Solari
Error - Every error raised by the SDK. Corresponds to the
SolariErrorhierarchy in the TypeScript reference (AuthError / PlanError / ConcurrencyLimitError / NoCapacityError / GatewayError / ActionError / TimeoutError / ConnectionError).
Constants§
- DEFAULT_
BASE_ URL - The hosted Solari API, used when
ClientOptions::base_urlis empty.
Traits§
- GitRunner
- The seam the git namespace runs commands through.
Sandboximplements it by delegating tocommands.run("git", …); tests implement a recording stub.
Functions§
- new_
idempotency_ key - A fresh idempotency key. Not a real UUID (no
uuiddep) but unique + opaque, which is all the gateway requires. Format resembles a v4 UUID.
Type Aliases§
- Output
Callback - A streamed-output callback (
stdout/stderr).Fn(&str).