Skip to main content

rig_agent/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![deny(missing_docs)]
3#![cfg_attr(
4    test,
5    allow(
6        clippy::expect_used,
7        clippy::indexing_slicing,
8        clippy::panic,
9        clippy::unwrap_used,
10        clippy::unreachable
11    )
12)]
13//! Rig's classic agent runtime: builders, serializable run state, hooks, tools,
14//! and typed extraction.
15//!
16//! Portable contracts live in `rig_core`; recording accepts
17//! [`rig_core::serve::Recorder`], with concrete replay adapters in `rig-cassette`.
18//! Native and browser WASM targets are supported; WASI is not. MCP integration
19//! is provided by the native-only `rig-rmcp` crate.
20
21extern crate self as rig;
22
23#[doc(hidden)]
24pub use rig_core as __core;
25
26pub mod agent;
27pub mod completion;
28pub mod extractor;
29pub mod handlers;
30/// Ready-made integrations: the CLI chatbot.
31pub mod integrations;
32pub(crate) use rig_core::json_utils;
33pub mod prelude;
34pub mod run;
35pub mod streaming;
36#[cfg(any(test, feature = "test-utils"))]
37#[cfg_attr(docsrs, doc(cfg(feature = "test-utils")))]
38pub mod test_utils;
39pub mod tool;
40
41pub use agent::TypedPromptResponse;
42pub use agent::{
43    Agent, AgentBuilder, AgentHook, AgentRun, AgentRunner, HookContext, ModelHandle, ModelRef,
44    ModelSelection, ModelSelectionAction,
45};
46
47#[cfg(feature = "derive")]
48#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
49pub use rig_derive::rig_tool;
50
51// Compile-time thread-safety contract: the agent surface must be safe to hold
52// in shared host state (worker pools, ECS resources) on native targets.
53#[cfg(not(target_family = "wasm"))]
54const _: fn() = || {
55    fn assert_send_sync_static<T: Send + Sync + 'static>() {}
56    assert_send_sync_static::<Agent>();
57    assert_send_sync_static::<AgentRunner>();
58    assert_send_sync_static::<ModelHandle>();
59    assert_send_sync_static::<agent::MultiTurnStreamItem>();
60    assert_send_sync_static::<agent::RunEvents>();
61    assert_send_sync_static::<agent::PromptResponse>();
62    assert_send_sync_static::<tool::server::ToolServerHandle>();
63    assert_send_sync_static::<tool::ToolSet>();
64    assert_send_sync_static::<tool::ToolCatalog>();
65};