Skip to main content

AgentVm

Struct AgentVm 

Source
pub struct AgentVm { /* private fields */ }
Expand description

One VM with coding agents in it: the Sandbox plus the specs it was built for.

Runtime-checked, like the sandbox it wraps, and for the same reason: one object is what the bindings can hold.

Implementations§

Source§

impl AgentVm

Source

pub fn new(sandbox: Sandbox, specs: Vec<AgentSpec>) -> Result<AgentVm, Error>

Wraps a sandbox for specs. Refuses an empty or repeated set.

Source

pub async fn adopt( control: ControlPlane, specs: Vec<AgentSpec>, microvm_id: impl Into<String>, endpoint: impl Into<String>, agent_token: impl Into<String>, ) -> Result<AgentVm, Error>

An agent VM for a VM another process launched; see Sandbox::adopt.

AgentVm::from_name and AgentVm::adopt_in, which resolve credentials for a region, are in microvms_core::prelude.

The specs are the caller’s statement of what the VM carries, checked like AgentVm::new checks them. Read installed_agents first when the adopting process does not know.

Source

pub fn detach(&mut self) -> Result<Detached, Error>

Hands the VM off to another process; see Sandbox::detach. The adopter passes the same specs to AgentVm::adopt.

Source

pub fn into_parts(self) -> (Sandbox, Vec<AgentSpec>)

The sandbox and specs, for a binding that holds them separately.

Source

pub fn claude_code(sandbox: Sandbox) -> AgentVm

A VM for Claude Code with the profile’s defaults.

Source

pub fn codex(sandbox: Sandbox) -> AgentVm

A VM for Codex with the profile’s defaults.

Source

pub fn specs(&self) -> Vec<AgentSpec>

The specs this VM carries, in profile order.

Source

pub fn sandbox(&self) -> &Sandbox

Source

pub fn sandbox_mut(&mut self) -> &mut Sandbox

Source

pub fn session(&self) -> Option<&Session>

The session, once AgentVm::launch has run.

Source

pub fn image_name(&self, request: &CreateImageRequest) -> String

The image name for these specs and this binary: the stem plus the first twelve hex characters of ensure’s identity over the artifact, the base and the size, so an unchanged binary, spec set and size name the image AgentVm::ensure_image would find (AGENT-3).

Source

pub fn image_request( &self, binary: Vec<u8>, build_role_arn: impl Into<String>, size: SizeClass, ) -> Result<CreateImageRequest, Error>

The create request for this VM’s image, named per AgentVm::image_name.

code_artifact_uri is left empty for the caller to fill: the upload is theirs (this path does not upload), and the key they choose is usually derived from the name this method just computed. Sandbox::preflight refuses a request whose URI is still blank.

Source

pub async fn build( &mut self, request: CreateImageRequest, ) -> Result<&Image, Error>

Builds the image. The caller has uploaded the artifact to the request’s URI.

Source

pub async fn ensure_image( &mut self, binary: Vec<u8>, build_role_arn: impl Into<String>, size: SizeClass, s3_bucket: impl Into<String>, s3_key_prefix: Option<String>, ) -> Result<EnsuredImage, Error>

Builds or reuses this VM’s image through Sandbox::ensure_image (#258): named per AgentVm::image_name, reused when ready, waited on while building, rebuilt when failed, and uploaded to s3://<s3_bucket>/<s3_key_prefix>/<name>/artifact.zip only when a build is needed.

Source

pub fn launch_request( &self, image_identifier: impl Into<String>, execution_role_arn: Option<String>, ) -> RunRequest

The launch request: egress on (AGENT-9), because neither agent reaches Bedrock without it, and the token label set to the image name.

Source

pub async fn launch(&mut self, request: RunRequest) -> Result<&Session, Error>

Launches and waits for the daemon to answer, which Sandbox::run does.

Source

pub async fn install_access(&self, access: &BedrockAccess) -> Result<(), Error>

install_access on this VM’s session.

Source

pub async fn prompt( &self, agent: Agent, task: &str, options: &PromptOptions, ) -> Result<ExecHandle, Error>

prompt on this VM’s session, for one of the agents it carries.

Source

pub async fn prompt_sync( &self, agent: Agent, task: &str, options: &PromptOptions, ) -> Result<ExecResult, Error>

prompt_sync on this VM’s session, for one of the agents it carries.

Source

pub async fn terminate(&mut self, opts: TeardownOpts) -> TeardownReport

Tears the VM down; see Sandbox::terminate.

Trait Implementations§

Source§

impl AgentVmExt for AgentVm

Source§

async fn from_name( store: &dyn NameStore, specs: Vec<AgentSpec>, name: &str, region: Option<Region>, port: Option<u16>, ) -> Result<Self, Error>

Adopts the VM registered as name in store; see Sandbox::from_name (SandboxExt::from_name).
Source§

fn adopt_in( region: Region, specs: Vec<AgentSpec>, microvm_id: impl Into<String>, endpoint: impl Into<String>, agent_token: impl Into<String>, port: Option<u16>, ) -> impl Future<Output = Result<Self, Error>> + Send

AgentVm::adopt over a plane resolved for region; the bindings’ entry point.
Source§

impl Debug for AgentVm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more