Skip to main content

Crate a3s_code_core

Crate a3s_code_core 

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

Re-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 agent_teams::AgentTeam;
pub use agent_teams::TeamConfig;
pub use agent_teams::TeamMember;
pub use agent_teams::TeamMessage;
pub use agent_teams::TeamRole;
pub use agent_teams::TeamTaskBoard;
pub use commands::CommandAction;
pub use commands::CommandContext;
pub use commands::CommandOutput;
pub use commands::CommandRegistry;
pub use commands::SlashCommand;
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::Attachment;
pub use llm::ContentBlock;
pub use llm::ImageSource;
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 sandbox::SandboxConfig;
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 tool_search::ToolIndex;
pub use tool_search::ToolMatch;
pub use tool_search::ToolSearchConfig;
pub use tools::ToolContext;
pub use tools::ToolExecutor;
pub use tools::ToolResult;

Modules§

agent
Agent Loop Implementation
agent_api
Agent Facade API
agent_teams
Agent Teams — Peer-to-peer multi-agent coordination
commands
Slash Commands — Interactive session commands
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
sandbox
Sandbox integration for bash tool execution.
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)
tool_search
Tool Search — Semantic tool matching for dynamic MCP tool loading
tools
Extensible Tool System

Structs§

SystemPromptSlots
Slot-based system prompt customization.