agent_sdk_toolkit/testing/protocol/
isolation.rs1use agent_sdk_core::{
6 AgentError, EffectIntent, ExecutionEnvironment, IsolatedProcessSpec, IsolationCapabilityReport,
7 IsolationRuntime, ProcessStartRequest, ProcessStartResult,
8};
9
10use crate::protocol::JsonRpcLineEndpoint;
11
12#[derive(Clone, Debug)]
13pub struct IsolatedJsonRpcProcess {
16 pub host_endpoint: JsonRpcLineEndpoint,
18 pub process_endpoint: JsonRpcLineEndpoint,
20 pub capability_report: IsolationCapabilityReport,
22 pub start_result: ProcessStartResult,
24}
25
26impl IsolatedJsonRpcProcess {
27 pub fn start(
31 runtime: &dyn IsolationRuntime,
32 environment: ExecutionEnvironment,
33 process: IsolatedProcessSpec,
34 effect_intent: EffectIntent,
35 ) -> Result<Self, AgentError> {
36 let capability_report = runtime.capability_report()?;
37 let start_result = runtime.start_process(ProcessStartRequest {
38 environment,
39 process,
40 effect_intent,
41 })?;
42 let (host_endpoint, process_endpoint) =
43 JsonRpcLineEndpoint::pair("host", "isolated-process");
44 Ok(Self {
45 host_endpoint,
46 process_endpoint,
47 capability_report,
48 start_result,
49 })
50 }
51}