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
// SPDX-License-Identifier: AGPL-3.0-only
//! agentd — a minimal, MCP-native, reactive agent runtime.
//!
//! One binary that is CLI, daemon, and subagent re-exec. A **supervisor**
//! owns lifecycle, triggers, and the process tree but never reasons; the
//! **agentic loop** lives only inside subagent processes. Tools come only
//! from MCP servers; reactivity comes from MCP resource subscriptions;
//! agentd is itself an MCP server so agents compose with one protocol.
//!
//! The split is deliberate: because only subagent processes reason, a wedged
//! or runaway model can never take the supervisor down with it, and the
//! supervisor's kill/reap/budget guarantees hold no matter what a model does.
//!
//! Module map below. `agentloop` is named to avoid the `loop` keyword.
// A2A surface: principals/roles/authorization + durable tasks
// agent-side AAuth signing for AAuth-protected MCP endpoints
// the in-child ReAct loop + terminal-status state machine
// endpoint credential providers + durable token cache: OAuth, AWS SigV4, SPIFFE
// CEL expression seam (feature `cel`; always compiled, fail-closed without it)
// precedence (built-in<file<env<flag) + validate-at-startup; config::{file,yaml,paths,watch}
// durable transcripts, plan, memory, compaction, skills
// workflow engine: graph model, templates, durable runs + scheduler
// the public exit-code table + terminal-status -> code map
// token governor: windowed durable budgets + shedding tactics
// instance identity from the Kubernetes downward API (env-only)
// intelligence client + provider adapters
// dependency-free JSON Schema subset validator (tool contracts, workflow schemas)
// JSON-RPC 2.0 codec + framing lives in the reusable `mcp` crate; re-exported
// so `crate::json::*` resolves (MCP + the supervisor<->subagent channel).
pub use rpc as json;
// MCP client (to servers) + self-MCP server + registry/config
// Transport primitives live in the reusable `net` crate; re-exported so
// `crate::net::*` resolves across the runtime (MCP transport + intelligence).
pub use net;
// logging, health, tracing, metrics
// tool registry: internal > code > MCP, contracts, overrides, grants
// the runtime: event loop, turn workers, lifecycle
// secrets, tool-scope, gated exec
// dependency-free SHA-256 (content identity: workflow hashes, skill bodies, artifacts)
// sigaction + self-pipe wakeup; SIGTERM/INT/CHLD/PIPE/HUP latches
// durable state model: entities, manifest, inbox, timers, restore
// remote state store adapters: a 4-op contract over MCP tools / HTTP / memory
// supervisor<->subagent control protocol
// the reactor, process tree, spawn/reap/liveness/kill/restart
// CODE-REGISTERED tools — the embedder seam
// execution modes + reactive routing + timers
// MCP + intelligence wire types
/// Crate version, surfaced in logs (`agentd_build_info`) and `--version`.
pub const VERSION: &str = env!;
/// Announce a bound loopback listener's address through `addr_file` — the
/// discovery handshake for the built-in test mocks (`--internal-mock-llm`,
/// `--internal-mock-mcp-http`): the harness passes a fresh path, waits for the
/// file to exist, then reads `host:port` from it. Written atomically (tmp +
/// rename) so a waiter never observes a half-written address.