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//! ```
54
55pub(crate) mod agent;
56pub(crate) mod agent_api;
57#[cfg(feature = "ahp")]
58pub mod ahp;
59pub mod commands;
60pub(crate) mod compaction;
61pub mod config;
62pub mod context;
63pub mod error;
64pub(crate) mod file_history;
65pub(crate) mod git;
66pub mod hitl;
67pub mod hooks;
68pub mod llm;
69pub mod mcp;
70pub mod memory;
71pub mod permissions;
72pub mod planning;
73pub mod program;
74pub(crate) mod prompts;
75pub mod queue;
76pub(crate) mod retry;
77pub mod run;
78pub mod sandbox;
79pub mod security;
80pub(crate) mod session_lane_queue;
81pub mod skills;
82pub mod store;
83pub mod subagent;
84pub mod telemetry;
85#[cfg(feature = "telemetry")]
86pub mod telemetry_otel;
87pub(crate) mod text;
88pub mod tools;
89pub mod trace;
90pub mod verification;
91
92// Re-export key types at crate root for ergonomic usage
93pub use agent::{AgentEvent, AgentResult};
94pub use agent_api::{Agent, AgentSession, BtwResult, SessionOptions, ToolCallResult};
95pub use config::{CodeConfig, ModelConfig, ModelCost, ModelLimit, ModelModalities, ProviderConfig};
96pub use error::{CodeError, Result};
97pub use llm::{
98    clear_http_metrics_callback, set_http_metrics_callback, AnthropicClient, Attachment,
99    ContentBlock, HttpMetricsCallback, HttpMetricsRecord, ImageSource, LlmClient, LlmResponse,
100    Message, OpenAiClient, TokenUsage,
101};
102pub use prompts::{AgentStyle, DetectionConfidence, PlanningMode, SystemPromptSlots};
103pub use run::{InMemoryRunStore, RunEventRecord, RunHandle, RunRecord, RunSnapshot, RunStatus};