Skip to main content

a3s_code_core/
lib.rs

1//! A3S Code Core Library
2//!
3//! Harness-driven runtime for coding agents.
4//!
5//! `Agent` and `AgentSession` are the primary 2.0 API. Lower-level session
6//! runtime state is internal; persistence data flows through `store::SessionData`.
7//!
8//! ## Quick Start
9//!
10//! ```rust,no_run
11//! use a3s_code_core::{Agent, AgentEvent};
12//!
13//! # async fn run() -> anyhow::Result<()> {
14//! // From an ACL-compatible config file path (.acl)
15//! let agent = Agent::new("agent.acl").await?;
16//!
17//! // Create a workspace-bound session
18//! let session = agent.session("/my-project", None)?;
19//!
20//! // Non-streaming
21//! let result = session.send("What files handle auth?", None).await?;
22//! println!("{}", result.text);
23//!
24//! // Streaming (AgentEvent is #[non_exhaustive])
25//! let (mut rx, _handle) = session.stream("Refactor auth", None).await?;
26//! while let Some(event) = rx.recv().await {
27//!     match event {
28//!         AgentEvent::TextDelta { text } => print!("{text}"),
29//!         AgentEvent::End { .. } => break,
30//!         _ => {} // required: #[non_exhaustive]
31//!     }
32//! }
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! ## Architecture
38//!
39//! ```text
40//! Agent (config-driven facade)
41//!   +-- AgentSession (workspace-bound execution API)
42//!       +-- internal turn runner
43//!       +-- ContextAssembler / ContextProvider
44//!       +-- ToolSelector
45//!       +-- ToolExecutor
46//!       +-- ProgramExecutor (PTC)
47//!       +-- SkillRegistry
48//!       +-- Permission / confirmation
49//!       +-- Trace / artifacts / verification evidence
50//!
51//! Advanced infrastructure:
52//!   +-- optional lane queues for explicit external/hybrid dispatch
53//!   +-- Orchestrator for direct SubAgent lifecycle control
54//! ```
55
56pub(crate) mod agent;
57pub(crate) mod agent_api;
58#[cfg(feature = "ahp")]
59pub mod ahp;
60pub mod commands;
61pub(crate) mod compaction;
62pub mod config;
63pub mod context;
64pub mod error;
65pub(crate) mod file_history;
66pub(crate) mod git;
67pub mod hitl;
68pub mod hooks;
69pub mod llm;
70pub mod mcp;
71pub mod memory;
72pub mod orchestrator;
73pub mod permissions;
74pub mod planning;
75pub mod plugin;
76pub mod program;
77pub(crate) mod prompts;
78pub mod queue;
79pub(crate) mod retry;
80pub mod sandbox;
81pub mod security;
82pub(crate) mod session_lane_queue;
83pub mod skills;
84pub mod store;
85pub mod subagent;
86pub mod telemetry;
87#[cfg(feature = "telemetry")]
88pub mod telemetry_otel;
89pub(crate) mod text;
90pub mod tools;
91pub mod trace;
92pub mod verification;
93
94// Re-export key types at crate root for ergonomic usage
95pub use agent::{AgentEvent, AgentResult};
96pub use agent_api::{Agent, AgentSession, BtwResult, SessionOptions, ToolCallResult};
97pub use config::{CodeConfig, ModelConfig, ModelCost, ModelLimit, ModelModalities, ProviderConfig};
98pub use error::{CodeError, Result};
99pub use llm::{
100    clear_http_metrics_callback, set_http_metrics_callback, AnthropicClient, Attachment,
101    ContentBlock, HttpMetricsCallback, HttpMetricsRecord, ImageSource, LlmClient, LlmResponse,
102    Message, OpenAiClient, TokenUsage,
103};
104pub use prompts::{AgentStyle, DetectionConfidence, PlanningMode, SystemPromptSlots};