adk_server/lib.rs
1//! # adk-server
2//!
3//! HTTP server and A2A protocol for ADK agents.
4//!
5//! ## Overview
6//!
7//! This crate provides HTTP infrastructure:
8//!
9//! - [`create_app`] - Create the REST API server
10//! - [`create_app_with_a2a`] - Add A2A discovery and JSON-RPC endpoints
11//! - [`ServerBuilder`] - Custom routes, A2A, shutdown, governance, and feature-gated endpoints
12//! - [`RemoteA2aAgent`] - Connect to remote A2A agents
13//! - [`ServerConfig`] / [`SecurityConfig`] - Server configuration
14//!
15//! The server answers only loopback host names and IP addresses by default and allows no
16//! cross-origin access; list public hosts with [`ServerConfig::with_allowed_hosts`] and browser
17//! origins with [`ServerConfig::with_allowed_origins`].
18//!
19//! The `a2a-v1` feature adds the `a2a::v1` module: A2A v1.0.0 JSON-RPC and REST handlers for
20//! all 11 operations, built on [`a2a-protocol-types`](https://crates.io/crates/a2a-protocol-types).
21//!
22//! ## Quick Start
23//!
24//! ```rust,no_run
25//! use std::sync::Arc;
26//!
27//! use adk_core::{Agent, SingleAgentLoader};
28//! use adk_server::{ServerConfig, create_app};
29//! use adk_session::InMemorySessionService;
30//!
31//! async fn serve(agent: Arc<dyn Agent>) -> std::io::Result<()> {
32//! let config = ServerConfig::new(
33//! Arc::new(SingleAgentLoader::new(agent)),
34//! Arc::new(InMemorySessionService::new()),
35//! );
36//! let app = create_app(config);
37//! let listener = tokio::net::TcpListener::bind("127.0.0.1:8080").await?;
38//! axum::serve(listener, app).await
39//! }
40//! ```
41//!
42//! ## A2A Protocol
43//!
44//! [`create_app_with_a2a`] and [`ServerBuilder::with_a2a`] expose an agent over A2A:
45//!
46//! - `GET /.well-known/agent-card.json` (and `/.well-known/agent.json`) - Agent card
47//! - `POST /a2a` - JSON-RPC: `message/send`, `tasks/get`, `tasks/cancel`
48//! - `POST /a2a/stream` - JSON-RPC streaming: `message/stream`, `message/send`
49//!
50//! ## Features
51//!
52//! No feature is on by default; the REST and SSE runtime and the A2A endpoints above need none.
53//! A2A v1.0 (`a2a-v1`, `a2a-interceptors`), background runs and cron (`background`), wake-ups
54//! (`webhook-ingress`, `google-triggers`), the approval inbox (`approvals`), agents over MCP
55//! (`mcp`), `openai-webhooks`, `yaml-agent`, `agent-registry`, Agent Engine (`agent-engine`,
56//! `vertex-remote-engine`) and the AWP agent edge (`awp`, `awp-sqlite`, `awp-postgres`,
57//! `awp-redis`) each have a feature; the
58//! [README](https://github.com/zavora-ai/adk-rust/blob/main/adk-server/README.md#feature-flags)
59//! says what each enables.
60#![allow(clippy::result_large_err)]
61
62pub mod a2a;
63pub mod auth_bridge;
64pub mod config;
65pub mod rest;
66pub mod ui_protocol;
67pub mod ui_types;
68
69#[cfg(feature = "yaml-agent")]
70pub mod yaml_agent;
71
72#[cfg(feature = "agent-registry")]
73pub mod registry;
74
75#[cfg(any(feature = "openai-webhooks", feature = "webhook-ingress"))]
76pub mod webhooks;
77
78#[cfg(feature = "background")]
79pub mod background;
80
81#[cfg(feature = "google-triggers")]
82pub mod google_triggers;
83
84#[cfg(feature = "approvals")]
85pub mod approvals;
86
87#[cfg(feature = "mcp")]
88pub mod mcp;
89
90#[cfg(feature = "awp")]
91pub mod subject_rights;
92
93#[cfg(feature = "agent-engine")]
94pub mod agent_engine;
95
96#[cfg(feature = "awp")]
97pub mod awp;
98
99#[cfg(feature = "agent-engine")]
100pub use agent_engine::{
101 AgentEngineOptions, AgentEngineState, agent_engine_router, build_agent_engine_app,
102 serve_agent_engine,
103};
104
105// Background runs and cron scheduling re-exports
106#[cfg(feature = "background")]
107pub use background::{
108 BackgroundState, DurableScheduler, DurableWorker, DurableWorkerConfig, GovernanceRefusal,
109 ParkReason, RunStatus, RunStatusResponse, SchedulerTick, SubmitRunRequest, SubmitRunResponse,
110 WorkerHandle, WorkerHooks, WorkflowExecutor, WorkflowRegistry, WorkflowRunContext,
111 WorkflowState, background_runs_router, background_runs_router_with_state,
112};
113#[cfg(feature = "background")]
114pub use background::{
115 ConcurrencyPolicy, CreateCronJobRequest, CronJobResponse, CronJobStatus, CronState,
116 RunCronJobNowResponse, cron_jobs_router, cron_jobs_router_with_state, start_cron_scheduler,
117 validate_cron_expression,
118};
119
120pub use a2a::{
121 A2aClient, Executor, ExecutorConfig, RemoteA2aAgent, RemoteA2aAgentBuilder, RemoteA2aConfig,
122 agent_skills_from_index, build_agent_card, build_agent_skills,
123};
124#[cfg(feature = "a2a-v1")]
125pub use a2a::{A2aServer, A2aServerApp, A2aServerBuilder};
126pub use auth_bridge::{
127 AuthenticatedCaller, RequestContext, RequestContextError, RequestContextExtractor,
128};
129pub use config::{ADMIN_SCOPE, DEFAULT_RUN_TIMEOUT, SecurityConfig, ServerConfig};
130pub use rest::{
131 A2aController, A2aTaskRetention, FreezeDelegate, FreezeReport, GovernanceController,
132 GovernanceStatus, RunningRuns, RuntimeController, ServerBuilder, SessionController,
133 ShutdownHandle, create_app, create_app_with_a2a, shutdown_signal,
134};