adam/lib.rs
1#![doc = include_str!("../README.md")]
2#![warn(missing_docs)]
3
4pub use adam_agent_fs as agent_fs;
5pub use adam_assembly as assembly;
6pub use adam_assembly::{
7 AGENT_DIR_ENV, AgentDef, AgentFolder, AgentInfo, AliasProblem, Assembly, BoundDef,
8 EXTRA_MCP_FILE_ENV, Error as AssemblyError, IntoManifest, Origin, RemoteInfo, TemplateProblem,
9 agent_dir, agent_dir_from_env, extra_mcp_file_from_env,
10};
11// Dev reload, only with the feature `dev`: the agent directory watched and swapped when a file
12// changes. See `adam_assembly::LiveAssembly`.
13#[cfg(feature = "dev")]
14pub use adam_assembly::{LiveAssembly, LiveBuilder, ReloadError, Reloaded};
15pub use adam_core as core;
16pub use adam_error as error;
17pub use adam_llm_agent::*;
18// `adam_llm_agent` also exports an `ArtifactRef` (the model's reference: id, name, media type,
19// byte count), which this glob re-exports as `adam::ArtifactRef`. The runtime's view type is
20// `adam_runtime::ArtifactRef` (a file is a `FileRef`), reachable as `adam::runtime::ArtifactRef`.
21// They are different types; do not conflate them.
22// `mcp.json` tools, only with the feature `mcp`: the MCP client (`McpPolicy`, `Env`,
23// `McpServers`) that `AgentDef::connect_mcp` uses.
24#[cfg(feature = "mcp")]
25pub use adam_mcp as mcp;
26pub use adam_model as model;
27pub use adam_runtime as runtime;
28
29/// The paths the code generated by `#[tool]` refers to. Not part of the API.
30#[doc(hidden)]
31pub use adam_llm_agent::__private;
32
33/// `#[tool]`: an `async fn` becomes a [`Tool`]. See the [crate docs](crate).
34#[cfg(feature = "macros")]
35pub use adam_macros::tool;
36
37/// Include the agent that `build.rs` embedded: `adam::include_agent!();` at module level.
38///
39/// `build.rs` calls `adam_agent_fs::build("agent").emit()`, which writes `OUT_DIR/adam_agent.rs`;
40/// this macro includes it. The module then has `AGENTS` (a slice of
41/// [`EmbeddedAgent`](agent_fs::EmbeddedAgent)), `AGENT` (the agent of an `agent/` package) and
42/// `PACKAGE` (an [`EmbeddedPackage`](agent_fs::EmbeddedPackage), which is a
43/// [`ManifestSource`](agent_fs::ManifestSource)). See the [crate docs](crate).
44#[macro_export]
45macro_rules! include_agent {
46 () => {
47 ::core::include!(::core::concat!(::core::env!("OUT_DIR"), "/adam_agent.rs"));
48 };
49}
50
51/// What an agent's source file usually wants: `use adam::prelude::*;`.
52pub mod prelude {
53 #[cfg(feature = "macros")]
54 pub use crate::tool;
55 pub use crate::{
56 AgentDef, Assembly, AssemblyError, BoundDef, BuildError, FnTool, IntoToolOutput,
57 IntoToolResult, Json, Limits, LlmAgent, State, Tool, ToolCtx, ToolError, ToolOutput,
58 ToolSet, tools,
59 };
60}
61
62/// Without the feature `dev` nothing here can watch the agent directory and reload it. (Reading a
63/// folder once, at startup, needs no feature: [`AgentFolder`].)
64///
65/// ```compile_fail,E0432
66/// use adam::LiveAssembly;
67/// ```
68#[cfg(not(feature = "dev"))]
69mod dev_is_off {}
70
71/// Without the feature `mcp` there is no MCP client: a build cannot start an MCP server, or reach one,
72/// unless it opts in.
73///
74/// ```compile_fail,E0432
75/// use adam::mcp::McpPolicy;
76/// ```
77#[cfg(not(feature = "mcp"))]
78mod mcp_is_off {}