Skip to main content

car_engine/
lib.rs

1//! Core runtime engine for Common Agent Runtime.
2//!
3//! The runtime loop:
4//! 1. Receive a proposal (batch of actions from a model)
5//! 2. Build a DAG from state_dependencies
6//! 3. Execute each level (concurrent if no ABORT actions, sequential otherwise)
7//! 4. Validate, execute with idempotency + timeout + retry, commit
8//! 5. On abort: rollback state to pre-proposal snapshot
9
10pub mod agent_basics;
11pub mod agent_capability;
12pub mod authz;
13pub mod builtin_agents;
14pub mod cache;
15pub mod capabilities;
16pub mod checkpoint;
17mod executor;
18pub mod mcp;
19pub mod rate_limit;
20pub mod registry;
21pub mod scope;
22pub mod subprocess;
23pub mod voice_turn;
24
25pub use agent_basics::entries as agent_basic_entries;
26pub use agent_capability::AgentCapabilityRegistry;
27pub use authz::{
28    AllowAllPermissions, AuthzDecision, AuthzPipeline, AuthzResult, AuthzStage, PermissionHandler,
29    Restriction,
30};
31pub use builtin_agents::{
32    agent_metadata, format_capability_payload, register_builtins, BuiltinAgent,
33    CapabilityPayloadError, BUILTIN_AGENTS,
34};
35pub use cache::ResultCache;
36pub use capabilities::CapabilitySet;
37pub use checkpoint::Checkpoint;
38pub use executor::{
39    format_tool_result, CostBudget, FailedActionSummary, ReplanCallback, ReplanConfig,
40    ReplanContext, Runtime, ToolExecutor, CANCELED_PREFIX,
41};
42pub use mcp::{McpServer, McpServerConfig, McpToolExecutor, McpToolInfo};
43pub use rate_limit::{RateLimit, RateLimiter};
44pub use registry::{ToolEntry, ToolPermission, ToolRegistry, ToolSource};
45pub use scope::RuntimeScope;
46pub use subprocess::{SubprocessTool, SubprocessToolExecutor};
47pub use voice_turn::{
48    dispatch_voice_turn, dispatch_voice_turn_sidecar_only,
49    dispatch_voice_turn_sidecar_only_with_classifier,
50    dispatch_voice_turn_sidecar_only_with_telemetry, dispatch_voice_turn_with_telemetry,
51    DirectDataFetcher, SidecarResult, VoiceTelemetry, VoiceTurnControl, VoiceTurnError,
52    VoiceTurnHandle,
53};
54
55// === Umbrella re-exports (car#205) ===
56//
57// car-engine is one of the published umbrella crates external Rust
58// consumers cargo-add against. Re-exporting the engine-cluster
59// types here lets tokhn (and future consumers) depend on a single
60// crate instead of a dozen internal workspace crates. Internal
61// crates stay separate for compile-time and target-gating reasons
62// (CLAUDE.md forbids cargo feature flags), but they ship via
63// path-deps once the publish-set trim lands in a follow-up.
64//
65// Re-exports are selective (not `pub use car_*::*`) so adding or
66// renaming internal symbols doesn't silently leak to the
67// umbrella's public surface — every type listed here is one the
68// surveyed external consumer (tokhn) actually uses. Adding new
69// re-exports is intentional and visible.
70//
71// The submodule pattern for ir / eventlog mirrors the way
72// consumers reach into existing public submodules of car-memgine
73// (`car_memgine::distill::*`) or car-inference
74// (`car_inference::hardware::*`) — keeps grouping legible.
75
76pub use car_ir::{
77    Action, ActionProposal, ActionType, AgentOutcome, Evidence, EvidenceKind,
78    FailureBehavior, OutcomeMetrics, OutcomeStatus, ProposalResult, ToolSchema,
79};
80pub use car_state::StateStore;
81pub use car_verify::VerifyIssue;
82pub use car_eventlog::{EventKind, EventLog, SpanStatus};
83pub use car_policy::{PolicyCheck, PolicyEngine};
84pub use car_planner::{Planner, PlannerConfig, ToolFeedback};
85// car-sandbox / car-active-planner aren't re-exported here — both
86// depend on car-engine, so the umbrella inclusion would cycle.
87// They stay as their own publishable crates; tokhn keeps
88// `use car_sandbox::*` / `use car_active_planner::*` direct.
89
90#[cfg(test)]
91mod tests;