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
impl AgentVm
Sourcepub fn new(sandbox: Sandbox, specs: Vec<AgentSpec>) -> Result<AgentVm, Error>
pub fn new(sandbox: Sandbox, specs: Vec<AgentSpec>) -> Result<AgentVm, Error>
Wraps a sandbox for specs. Refuses an empty or repeated set.
Sourcepub 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>
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.
Sourcepub fn detach(&mut self) -> Result<Detached, Error>
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.
Sourcepub fn into_parts(self) -> (Sandbox, Vec<AgentSpec>)
pub fn into_parts(self) -> (Sandbox, Vec<AgentSpec>)
The sandbox and specs, for a binding that holds them separately.
Sourcepub fn claude_code(sandbox: Sandbox) -> AgentVm
pub fn claude_code(sandbox: Sandbox) -> AgentVm
A VM for Claude Code with the profile’s defaults.
pub fn sandbox(&self) -> &Sandbox
pub fn sandbox_mut(&mut self) -> &mut Sandbox
Sourcepub fn session(&self) -> Option<&Session>
pub fn session(&self) -> Option<&Session>
The session, once AgentVm::launch has run.
Sourcepub fn image_name(&self, request: &CreateImageRequest) -> String
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).
Sourcepub fn image_request(
&self,
binary: Vec<u8>,
build_role_arn: impl Into<String>,
size: SizeClass,
) -> Result<CreateImageRequest, Error>
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.
Sourcepub async fn build(
&mut self,
request: CreateImageRequest,
) -> Result<&Image, Error>
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.
Sourcepub 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>
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.
Sourcepub fn launch_request(
&self,
image_identifier: impl Into<String>,
execution_role_arn: Option<String>,
) -> RunRequest
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.
Sourcepub async fn launch(&mut self, request: RunRequest) -> Result<&Session, Error>
pub async fn launch(&mut self, request: RunRequest) -> Result<&Session, Error>
Launches and waits for the daemon to answer, which Sandbox::run does.
Sourcepub async fn install_access(&self, access: &BedrockAccess) -> Result<(), Error>
pub async fn install_access(&self, access: &BedrockAccess) -> Result<(), Error>
install_access on this VM’s session.
Sourcepub async fn prompt(
&self,
agent: Agent,
task: &str,
options: &PromptOptions,
) -> Result<ExecHandle, Error>
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.
Sourcepub async fn prompt_sync(
&self,
agent: Agent,
task: &str,
options: &PromptOptions,
) -> Result<ExecResult, Error>
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.
Sourcepub async fn terminate(&mut self, opts: TeardownOpts) -> TeardownReport
pub async fn terminate(&mut self, opts: TeardownOpts) -> TeardownReport
Tears the VM down; see Sandbox::terminate.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AgentVm
impl !UnwindSafe for AgentVm
impl Freeze for AgentVm
impl Send for AgentVm
impl Sync for AgentVm
impl Unpin for AgentVm
impl UnsafeUnpin for AgentVm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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