a3s-code-core 0.9.0

A3S Code Core - Embeddable AI agent library with tool execution
Documentation

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};

# async fn run() -> anyhow::Result<()> {
// 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]
    }
}
# Ok(())
# }

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 / Telemetry