Skip to content

openagents_sdk::work

Issue work and a computer's granted cloud pool over a caller-supplied connection. The host owns execution and budgets; this client never reads local credentials or substitutes the website's separate work-host queue.

ItemWhat it does
Error structA refusal preserves the owner's exact command across the connection.
LandMode enumWhere a verified change goes.
Placement enumThe explicitly requested computer.
Pool structThe connected host's granted pool, with spend attributed to one saved agent.
PoolStatus structThe connected pool's hosts, slot capacity, and current compute spend.
Reply typeOne asynchronous response from a caller-supplied host connection.
Transport traitThe public Work/Pool connection boundary.
Work structA client for issue work on one connected host, usable by any harness.
WorkEvents structA bounded page of progress.
WorkRequest structOne issue to run on an explicitly selected host under a saved agent budget.
WorkRun structThe host's saved run identity, state, and latest outcome.
identifier fnWhether an identifier is a bounded path-free name accepted by this client.
CANCEL constRequest that the host stop a run.
EVENTS constRead a bounded page of run progress.
LIST constList issue runs on the connected host.
POOL_DOWN constStop the connected host pool.
POOL_STATUS constRead the granted pool and its compute budget.
POOL_UP constGrow an existing pool within the saved agent budget.
START constStart an issue run with a caller-chosen request ID.

Error

pub struct Error {
    pub code: String,
    pub message: String,
    pub owner_command: Option<String>,
}

A refusal preserves the owner's exact command across the connection.

Error::invalid

pub fn invalid(message: impl Into<String>) -> Self

Build a refusal for invalid request parameters.

Error::refused

pub fn refused(message: impl Into<String>) -> Self

Build a host or connection refusal.

Error::cancelled

pub fn cancelled() -> Self

Build the typed result for a canceled client call.

LandMode

pub enum LandMode {
    Queue,
    Pr,
    None,
}

Where a verified change goes. Direct pushes to main are not an option.

Placement

pub enum Placement {
    Gce,
    Boat,
    Computer(String),
}

The explicitly requested computer. A host must refuse an unavailable placement rather than silently sending work somewhere else.

Pool

pub struct Pool<'a> {}

The connected host's granted pool, with spend attributed to one saved agent.

Pool::new

pub fn new(transport: &'a dyn Transport, agent: &'a str) -> Result<Self, Error>

Borrow the connection with the saved agent ID used for budget checks.

Pool::status

pub async fn status(&self, cancel: &CancellationToken) -> Result<PoolStatus, Error>

Read hosts, activity, and spend for this saved agent.

Pool::up

pub async fn up(
    &self,
    hosts: u32,
    cancel: &CancellationToken,
) -> Result<PoolStatus, Error>

Reach the requested host count within an existing owner grant.

Pool::down

pub async fn down(&self, cancel: &CancellationToken) -> Result<(), Error>

Stop the connected pool without deleting its saved run records.

PoolStatus

pub struct PoolStatus {
    pub pool: Option<String>,
    pub granted: bool,
    pub hosts: Vec<Value>,
    pub activity: Vec<Value>,
    pub slots: u64,
    pub spent_usd: f64,
    pub daily_usd: f64,
    pub agent_spent_usd: Option<f64>,
    pub agent_daily_usd: Option<f64>,
}

The connected pool's hosts, slot capacity, and current compute spend.

Reply

pub type Reply<'a> = Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + 'a>>;

One asynchronous response from a caller-supplied host connection.

Transport

pub trait Transport: Send + Sync {
    fn request<'a>(
        &'a self,
        method: &'static str,
        params: Value,
        cancel: &'a CancellationToken,
    ) -> Reply<'a>;
}

The public Work/Pool connection boundary. A remote connection supplies authentication and timeouts; the receiver checks grants on every mutation.

Transport::request

fn request<'a>(
    &'a self,
    method: &'static str,
    params: Value,
    cancel: &'a CancellationToken,
) -> Reply<'a>

Send one named operation, preserving typed refusals and cancellation.

Work

pub struct Work<'a> {}

A client for issue work on one connected host, usable by any harness.

Work::new

pub fn new(transport: &'a dyn Transport) -> Self

Borrow an authenticated host connection without adopting local credentials.

Work::start

pub async fn start(
    &self,
    request_id: &str,
    request: WorkRequest,
    cancel: &CancellationToken,
) -> Result<WorkRun, Error>

Reuse the same request ID and body after response loss. The host must return the original run, or refuse a changed body under the same ID.

Work::list

pub async fn list(&self, cancel: &CancellationToken) -> Result<Vec<WorkRun>, Error>

List runs saved by the connected host.

Work::events

pub async fn events(
    &self,
    id: &str,
    after: u64,
    cancel: &CancellationToken,
) -> Result<WorkEvents, Error>

Read progress after a saved cursor without changing execution.

Work::cancel

pub async fn cancel(&self, id: &str, cancel: &CancellationToken) -> Result<(), Error>

Ask the host to stop the run; subsequent reads report its outcome.

WorkEvents

pub struct WorkEvents {
    pub run: WorkRun,
    pub events: Vec<Value>,
    pub next: u64,
    pub complete: bool,
}

A bounded page of progress. Save next and pass it as after on the next call. Canceling a read never cancels execution on the host.

WorkRequest

pub struct WorkRequest {
    pub repo: String,
    pub issue: u64,
    pub land: LandMode,
    pub engine: Option<String>,
    pub on: Option<Placement>,
    pub agent: String,
}

One issue to run on an explicitly selected host under a saved agent budget.

WorkRequest::validate

pub fn validate(&self) -> Result<(), Error>

Check identifiers and options before contacting the host.

WorkRun

pub struct WorkRun {
    pub id: String,
    pub request: WorkRequest,
    pub state: String,
    pub created_unix: u64,
    pub updated_unix: u64,
    pub host: Option<String>,
    pub result: Option<Value>,
    pub error: Option<String>,
    pub usage: Option<Value>,
}

The host's saved run identity, state, and latest outcome.

identifier

pub fn identifier(value: &str) -> bool

Whether an identifier is a bounded path-free name accepted by this client.

CANCEL

pub const CANCEL: &str = "work.cancel";

Request that the host stop a run.

EVENTS

pub const EVENTS: &str = "work.events";

Read a bounded page of run progress.

LIST

pub const LIST: &str = "work.list";

List issue runs on the connected host.

POOL_DOWN

pub const POOL_DOWN: &str = "pool.down";

Stop the connected host pool.

POOL_STATUS

pub const POOL_STATUS: &str = "pool.status";

Read the granted pool and its compute budget.

POOL_UP

pub const POOL_UP: &str = "pool.up";

Grow an existing pool within the saved agent budget.

START

pub const START: &str = "work.start";

Start an issue run with a caller-chosen request ID.