Skip to main content

quickstart/
quickstart.rs

1use agentledger::{simple_run, AgentContext, Result, State, Value};
2
3fn hello(_ctx: &mut AgentContext, input: State) -> Result<Option<Value>> {
4    let mut output = State::new();
5    output.insert("message".to_string(), Value::String("hello from rust".to_string()));
6    output.insert("input".to_string(), input.get("input").cloned().unwrap_or(Value::Null));
7    Ok(Some(Value::Object(output)))
8}
9
10fn main() -> Result<()> {
11    let mut input = State::new();
12    input.insert("input".to_string(), "world".into());
13    let result = simple_run(hello, input)?;
14    println!("{}", result.run_id);
15    Ok(())
16}