Skip to main content

Crate serve_macros

Crate serve_macros 

Source
Expand description

Attribute macros for serve, the experimental agent framework in the Everruns ecosystem.

Each attribute keeps the annotated item callable exactly as written and adds a link-time registration (via inventory) that App::builder().discover() collects. Nothing here scans the filesystem: the file layout is a convention, and the source path of every registration (file!()) is carried into the manifest so the host and the dev UI can point back at it.

Applications use the re-exports from serve, never this crate directly.

use serve_macros::{agent, tool};

assert_eq!(stringify!(agent), "agent");
assert_eq!(stringify!(tool), "tool");

Attribute Macros§

agent
Register a function returning serve::Agent as an agent of this app.
channel
Register a function returning a channel driver (such as serve::Slack or serve::Webhook) or a configured serve::Channel. Its inbound webhook is served at POST /v1/channels/{name}. agent = "…" picks the agent that answers; the default agent otherwise. A companion module with the same name is generated so a schedule can post to the channel: slack::channel("C0123ABC").
connection
Register a function whose return value is a connection. Tools read it with cx.connection::<T>(); a serve::McpServer is also attached to every agent as an MCP server. Credentials stay in the connection, never in the model context. Returning Result<T> makes a failure a discovery error.
eval
Register an async function (t: &mut EvalCx) -> Result as an eval. Evals run in-process with cargo run -- eval, or against a deployed URL with cargo run -- eval --against <url>.
schedule
Register an async function (cx: &Cx) -> Result to run on a cron schedule. Five-field cron ("0 9 * * MON") is accepted; a six- or seven-field expression with seconds is passed through.
tool
Register an async function as a tool. The function name is the tool name, the doc comment is its description, and the remaining parameters become the tool’s JSON arguments. An optional first parameter cx: &Cx receives the per-session context.