runtime_protocol/
runtime_protocol.rs1use axllm::{agent, AxResult, ProcessCodeRuntime};
2use serde_json::json;
3use std::env;
4
5fn main() -> AxResult<()> {
6 let repo_root = env::var("AXIR_REPO_ROOT")
7 .map_err(|_| axllm::AxError::runtime("AXIR_REPO_ROOT is required"))?;
8 let server = env::var("AXIR_AXJS_RUNTIME_SERVER")
9 .map_err(|_| axllm::AxError::runtime("AXIR_AXJS_RUNTIME_SERVER is required"))?;
10 let mut runtime =
11 ProcessCodeRuntime::new(["node".to_string(), "--import=tsx".to_string(), server]);
12 env::set_current_dir(repo_root).map_err(axllm::AxError::from)?;
13 let mut runner = agent("question:string -> answer:string")?;
14 let step = runner.execute_actor_step(
15 &mut runtime,
16 "answer = inputs.question; await final({ answer })",
17 json!({"question": "protocol"}),
18 json!({}),
19 )?;
20 assert_eq!(step.payload["kind"], "final");
21 runtime.shutdown()?;
22 println!("rust-runtime-protocol-ok");
23 Ok(())
24}