openagents_sdk::labs::worker
Signing a computer up to run Lab jobs for an account, and a client that can only run jobs. Requests send once. Retain attempts and finish requests after response loss; observing a started assignment does not grant permission to spawn it again.
| Item | What it does |
|---|---|
Client struct | A client whose credential authorizes only its worker's assigned work. |
CredentialRecord struct | A worker's saved key and the deployment it belongs to. |
MAX_INPUT_FILE const | The largest input file the service returns in one read. |
Client
pub struct Client {}
A client whose credential authorizes only its worker's assigned work. It cannot authenticate as an account, read documents, or choose an executable.
Client::labs_worker
pub fn labs_worker(&self, token: &str) -> Result<Client, Error>
Import a job-only key explicitly. The next worker request checks it with the service; this does not create an account session.
Client::restore_labs_worker
pub fn restore_labs_worker(&self, record: &CredentialRecord) -> Result<Client, Error>
Restores a worker client from a saved credential for this deployment.
Client::worker_ref
pub fn worker_ref(&self, space: &str, id: &str) -> Result<WorkerRef, Error>
Checks a space and ID and returns a worker reference.
Client::enroll_worker
pub async fn enroll_worker(
&self,
request: &Request<Enroll>,
cancel: &CancellationToken,
) -> Result<Enrolled, Error>
Enrolls a worker for the account and returns its job-only key.
Client::revoke_worker
pub async fn revoke_worker(
&self,
worker: &WorkerRef,
cancel: &CancellationToken,
) -> Result<bool, Error>
Revokes a worker's key and returns whether it was revoked.
Client::job_usage
pub async fn job_usage(
&self,
job: &JobRef,
cancel: &CancellationToken,
) -> Result<Vec<Usage>, Error>
Returns the usage that workers recorded for a job.
Client::record
pub fn record(&self) -> CredentialRecord
Returns the credential to save so you can restore this client later.
Client::worker_id
pub fn worker_id(&self) -> &str
Returns this worker's ID.
Client::clear_credential
pub fn clear_credential(&self)
Stop this client's clones locally. Use retire to revoke the remote key,
and remove any caller-owned saved credential separately.
Client::with_timeout
pub fn with_timeout(mut self, timeout: Duration) -> Result<Self, Error>
Sets the request timeout, up to two minutes.
Client::inputs
pub async fn inputs(
&self,
work: &Work,
cancel: &CancellationToken,
) -> Result<Inputs, Error>
What started work may read: its version, the versions it references in its space, and their stored source files. The service checks the key, the space, and the lease again on every call.
Client::input_file
pub async fn input_file(
&self,
work: &Work,
file: &lab_kit::Artifact,
cancel: &CancellationToken,
) -> Result<Vec<u8>, Error>
Read one file inputs listed, checked against its size and checksum.
Client::poll
pub async fn poll(
&self,
request: &Poll,
cancel: &CancellationToken,
) -> Result<Available, Error>
Asks for work, waiting up to 25 seconds for an assignment.
Client::start
pub async fn start(
&self,
request: &Attempt,
cancel: &CancellationToken,
) -> Result<Work, Error>
Marks an assigned attempt as started and returns its work.
Client::heartbeat
pub async fn heartbeat(
&self,
request: &Attempt,
cancel: &CancellationToken,
) -> Result<Work, Error>
Tells the service the attempt is still running and returns its work.
Client::finish
pub async fn finish(
&self,
request: &Finish,
cancel: &CancellationToken,
) -> Result<lab_kit::JobState, Error>
Send a retained finish request once. An identical retry after response loss is safe; a response never grants permission to execute the job again.
Client::retire
pub async fn retire(&self, cancel: &CancellationToken) -> Result<bool, Error>
Revokes this worker's key and stops the client if the revoke succeeds.
CredentialRecord
pub struct CredentialRecord {}
A worker's saved key and the deployment it belongs to.
MAX_INPUT_FILE
pub const MAX_INPUT_FILE: usize = 64 * 1024 * 1024;
The largest input file the service returns in one read.
Re-exported from other crates
Assignmentfromlab_kit::workerCapabilitiesfromlab_kit::workerEffectiveRequirementsfromlab_kit::workerEnrolledfromlab_kit::workerLeasefromlab_kit::workerPlacementfromlab_kit::workerUsagefromlab_kit::workerWorkerfromlab_kit::workerprotocolfromlab_kit::worker