Expand description
A3S Code Core Library
Embeddable AI agent library with tool execution capabilities. This crate contains all business logic extracted from the A3S Code agent, enabling direct Rust API usage as an embedded library.
§Quick Start
use a3s_code_core::{Agent, AgentEvent};
// From a config file path (.hcl or .json)
let agent = Agent::new("agent.hcl").await?;
// Create a workspace-bound session
let session = agent.session("/my-project", None)?;
// Non-streaming
let result = session.send("What files handle auth?", None).await?;
println!("{}", result.text);
// Streaming (AgentEvent is #[non_exhaustive])
let (mut rx, _handle) = session.stream("Refactor auth", None).await?;
while let Some(event) = rx.recv().await {
match event {
AgentEvent::TextDelta { text } => print!("{text}"),
AgentEvent::End { .. } => break,
_ => {} // required: #[non_exhaustive]
}
}§Architecture
Agent (facade — config-driven, workspace-independent)
+-- LlmClient (Anthropic / OpenAI)
+-- CodeConfig (HCL / JSON)
+-- SessionManager (multi-session support)
|
+-- AgentSession (workspace-bound)
+-- AgentLoop (core execution engine)
| +-- ToolExecutor (14 tools: 11 builtin + 3 skill discovery)
| +-- LlmPlanner (JSON-structured planning)
| +-- HITL Confirmation
+-- HookEngine (8 lifecycle events)
+-- Security (sanitizer, taint, injection detection, audit)
+-- Memory (episodic, semantic, procedural, working)
+-- MCP (JSON-RPC 2.0, stdio + HTTP+SSE)
+-- Cost Tracking / TelemetryRe-exports§
pub use agent::AgentConfig;pub use agent::AgentEvent;pub use agent::AgentLoop;pub use agent::AgentResult;pub use agent_api::Agent;pub use agent_api::AgentSession;pub use agent_api::SessionOptions;pub use agent_api::ToolCallResult;pub use config::CodeConfig;pub use config::ModelConfig;pub use config::ModelCost;pub use config::ModelLimit;pub use config::ModelModalities;pub use config::ProviderConfig;pub use error::CodeError;pub use error::Result;pub use hooks::HookEngine;pub use llm::AnthropicClient;pub use llm::ContentBlock;pub use llm::LlmClient;pub use llm::LlmResponse;pub use llm::Message;pub use llm::OpenAiClient;pub use llm::TokenUsage;pub use queue::ExternalTask;pub use queue::ExternalTaskResult;pub use queue::LaneHandlerConfig;pub use queue::SessionLane;pub use queue::SessionQueueConfig;pub use queue::SessionQueueStats;pub use queue::TaskHandlerMode;pub use session::SessionConfig;pub use session::SessionManager;pub use session::SessionState;pub use session_lane_queue::SessionLaneQueue;pub use skills::builtin_skills;pub use skills::Skill;pub use skills::SkillKind;pub use tools::ToolContext;pub use tools::ToolExecutor;pub use tools::ToolResult;
Modules§
- agent
- Agent Loop Implementation
- agent_
api - Agent Facade API
- config
- Configuration module for A3S Code
- context
- Context Provider Extension Point
- error
- Typed error enum for A3S Code Core
- file_
history - File version history tracking
- hitl
- Human-in-the-Loop (HITL) confirmation mechanism
- hooks
- Hooks System for A3S Code Agent
- llm
- LLM client abstraction layer
- mcp
- MCP (Model Context Protocol) Support
- memory
- Memory and learning system for the agent
- permissions
- Permission system for tool execution control
- planning
- Planning, Goal Tracking, and Task Management
- queue
- Per-session command queue with lane-based priority scheduling
- security
- Security Module
- session
- Session management
- session_
lane_ queue - Session Lane Queue - a3s-lane backed command queue
- skills
- Skill System
- store
- Session persistence layer
- telemetry
- Telemetry Module (Core)
- tools
- Extensible Tool System