1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Enables the `doc_cfg` feature badges on docs.rs only; a no-op on stable.
// wasm32 is single-threaded: `MaybeSend`/`MaybeSync` drop `Send`/`Sync` there
// on purpose (host futures are not `Send`), so an `Arc` of such a value is
// shared within one thread only. Native builds keep the lint.
//! **yoagent** — the agent runtime for Rust.
//!
//! A simple, effective agent loop with tool execution and event streaming:
//! `Prompt → LLM stream → tool execution → loop`. The loop is the product;
//! everything else is optional layers on top of it.
//!
//! # Quick start
//!
//! ```no_run
//! use yoagent::{Agent, provider::ModelConfig, tools};
//!
//! # #[cfg(feature = "native")]
//! # #[tokio::main]
//! # async fn main() {
//! // Provider is selected from the config's protocol; the API key is read
//! // from ANTHROPIC_API_KEY. Call `.with_api_key(...)` to override.
//! let mut agent = Agent::from_config(ModelConfig::claude_sonnet_5())
//! .with_system_prompt("You are a helpful coding assistant.")
//! .with_tools(tools::default_tools());
//!
//! let mut events = agent.prompt("List the files in the current directory").await;
//! while let Some(event) = events.recv().await {
//! // stream text deltas, tool calls, usage — render however you like
//! }
//! agent.finish().await;
//! # }
//! # #[cfg(not(feature = "native"))]
//! # fn main() {}
//! ```
//!
//! # What's in the box
//!
//! - **The loop** ([`agent_loop()`](agent_loop())) — a stateless free function; [`Agent`] is an
//! optional stateful wrapper (history, tool registry, steering queues).
//! - **7 provider protocols, 20+ providers** ([`provider`]) — Anthropic,
//! OpenAI (Completions + Responses), Azure, Gemini, Vertex, Bedrock, plus
//! OpenAI-compatible gateways (Groq, DeepSeek, xAI, OpenCode, Ollama, ...)
//! with per-provider quirk flags.
//! - **Tools** ([`tools`]) — bash, read/write/edit file, search; add your own
//! via the [`AgentTool`] trait. [MCP](mcp) servers and
//! [OpenAPI specs](https://docs.rs/yoagent/latest/yoagent/openapi/index.html)
//! (feature `openapi`) become tools transparently. A [`ToolSource`]
//! supplies tools resolved at the start of every run, for tool sets that
//! change while the agent lives (plugins, reconnecting servers).
//! - **Steering** — inject guidance into a running agent ([`Agent::steer`]);
//! picked up between tool executions (per batch under the default parallel
//! strategy). Queue follow-ups, inspect/edit the queues.
//! - **Structured outputs** ([`Agent::prompt_structured`]) — typed,
//! schema-validated replies, enforced natively where supported (forced
//! tool call / `json_schema` / `responseSchema`).
//! - **Permissions** ([`ToolMiddleware`]) — async approve/deny/modify hooks
//! gating every tool call; the mechanism behind approval prompts and
//! policy engines (yoagent ships no policy — you install it).
//! - **Input filtering** ([`InputFilter`], [`AsyncInputFilter`]) — rewrite or
//! reject user input before it reaches the model (PII redaction,
//! prompt-injection guards).
//! - **Turn hooks** ([`TurnHook`]) — an async hook before every LLM request
//! that may add one transient note to the request's latest user turn.
//! - **Decision models** (feature `decision`) — typed questions (yes/no,
//! choice, score) answered with calibrated probabilities, e.g. TypeSafe's
//! Jev, or any OpenAI-compatible LLM that returns logprobs; fallbacks and
//! calibration; advisory skill/tool hints, and an opt-in, fail-closed tool
//! gate and input guard.
//! Off by default; nothing is sent until you pick a model.
//! - **Sub-agents** ([`SubAgentTool`]) — delegation with per-sub-agent models
//! and [`SharedState`] for passing artifacts by reference.
//! - **GASP** (feature `gasp`) — record runs into a
//! [GASP](https://github.com/yologdev/gasp) agent repo: append-only
//! semantic event log, restore = clone + replay, conformance-checked in CI.
//! - **Session trees** ([`Session`]) — branching conversation history with
//! fork, checkpoints, and JSONL persistence; edit an earlier turn and
//! re-run without losing the original branch.
//! - **Context management** ([`context`]) — token tracking and tiered
//! compaction so long sessions keep running.
//! - **Skills** ([`skills`]) — load `SKILL.md` files per the
//! [AgentSkills](https://agentskills.io) standard.
//! - **Telemetry** — `tracing` spans per loop/LLM-stream/tool with token and
//! cost fields; bridge to OpenTelemetry app-side, negligible cost otherwise.
//! - **Testing** ([`provider::mock::MockProvider`]) — script a whole multi-turn
//! tool-calling conversation with no network. It honours the cancellation
//! token, so abort and steering paths are testable too.
//!
//! The [book](https://yologdev.github.io/yoagent/) covers concepts and
//! provider-specific guides.
pub use ;
pub use ;
pub use ;
pub use ;
pub use LlmCompaction;
pub use RetryConfig;
pub use ;
pub use SharedState;
pub use SkillSet;
pub use SubAgentTool;
pub use ToolSource;
pub use *;