Skip to main content

agent_line/
lib.rs

1//! A batteries-included Rust library for building agent workflows.
2//!
3//! Define agents, wire them into workflows, and let the runner execute them.
4//! Agents communicate through shared context ([`Ctx`]) and control flow with
5//! outcomes like [`Outcome::Continue`], [`Outcome::Next`], [`Outcome::Retry`],
6//! and [`Outcome::Done`].
7//!
8//! # Quick start
9//!
10//! ```rust
11//! use agent_line::{Agent, Ctx, Outcome, Runner, StepResult, Workflow};
12//!
13//! #[derive(Clone)]
14//! struct State { n: i32 }
15//!
16//! struct AddOne;
17//! impl Agent<State> for AddOne {
18//!     fn name(&self) -> &'static str { "add_one" }
19//!     fn run(&mut self, state: State, _ctx: &mut Ctx) -> StepResult<State> {
20//!         Ok((State { n: state.n + 1 }, Outcome::Done))
21//!     }
22//! }
23//!
24//! let mut ctx = Ctx::new();
25//! let wf = Workflow::builder("demo")
26//!     .register(AddOne)
27//!     .build()
28//!     .unwrap();
29//!
30//! let result = Runner::new(wf).run(State { n: 0 }, &mut ctx).unwrap();
31//! assert_eq!(result.n, 1);
32//! ```
33
34mod agent;
35mod ctx;
36mod runner;
37pub mod tools;
38mod workflow;
39
40pub use agent::{Agent, Outcome, RetryHint, StepError, StepResult};
41pub use ctx::Ctx;
42pub use runner::{ErrorEvent, Runner, StepEvent};
43pub use workflow::{Workflow, WorkflowBuilder, WorkflowError};