Skip to main content

Crate a3s_ahp

Crate a3s_ahp 

Source
Expand description

Agent Harness Protocol (AHP) v2.4

Universal, transport-agnostic protocol for supervising autonomous AI agents.

§Overview

AHP provides a framework-agnostic interface for supervising, controlling, and auditing AI agents. Unlike traditional monitoring solutions tightly coupled to specific frameworks, AHP works with any agent system through a standardized JSON-RPC 2.0 protocol.

§Features

  • Framework-agnostic — Works with any agent system
  • Language-neutral — Harness servers can be written in any language
  • Transport-flexible — Supports stdio, HTTP, WebSocket, and Unix sockets; gRPC is reserved as a feature placeholder
  • Bidirectional — Agents can query the harness for guidance
  • Secure — Built-in authentication and encryption support

§Quick Start

use a3s_ahp::{AhpClient, Transport, EventType, Decision};

// Create client with stdio transport
let client = AhpClient::new(Transport::Stdio {
    program: "python3".into(),
    args: vec!["harness.py".into()],
}).await?;

// Send handshake
let handshake = client.handshake(Vec::new()).await?;
println!("Connected to: {}", handshake.harness_info.name);

// Send pre-action event
let decision = client.send_event_decision(EventType::PreAction, serde_json::json!({
    "action_type": "tool_call",
    "tool_name": "bash",
    "arguments": { "command": "ls -la" }
})).await?;

match decision {
    Decision::Allow { .. } => println!("Action allowed"),
    Decision::Block { reason, .. } => println!("Action blocked: {}", reason),
    _ => {}
}

Re-exports§

pub use auth::AuthConfig;
pub use auth::AuthMethod;
pub use client::AhpClient;
pub use error::AhpError;
pub use error::Result;
pub use protocol::AgentInfo;
pub use protocol::AhpErrorObject;
pub use protocol::AhpEvent;
pub use protocol::AhpNotification;
pub use protocol::AhpRequest;
pub use protocol::AhpResponse;
pub use protocol::ArtifactRef;
pub use protocol::BatchRequest;
pub use protocol::BatchResponse;
pub use protocol::ConfirmationDecision;
pub use protocol::ConfirmationEvent;
pub use protocol::ConfirmationType;
pub use protocol::ContextPerceptionDecision;
pub use protocol::ContextPerceptionEvent;
pub use protocol::Decision;
pub use protocol::EventContext;
pub use protocol::EventType;
pub use protocol::EvidenceRef;
pub use protocol::Fact;
pub use protocol::FileContentSnippet;
pub use protocol::HandshakeRequest;
pub use protocol::HandshakeResponse;
pub use protocol::HarnessConfig;
pub use protocol::HarnessInfo;
pub use protocol::HeartbeatEvent;
pub use protocol::HistoryItem;
pub use protocol::IdleDecision;
pub use protocol::IdleEvent;
pub use protocol::InjectedContext;
pub use protocol::IntentDetectionDecision;
pub use protocol::IntentDetectionEvent;
pub use protocol::MemoryRecallDecision;
pub use protocol::MemoryRecallEvent;
pub use protocol::MemorySummary;
pub use protocol::PerceptionConstraints;
pub use protocol::PerceptionContext;
pub use protocol::PerceptionDomain;
pub use protocol::PerceptionFreshness;
pub use protocol::PerceptionIntent;
pub use protocol::PerceptionModality;
pub use protocol::PerceptionTarget;
pub use protocol::PerceptionUrgency;
pub use protocol::PlanningDecision;
pub use protocol::PlanningEvent;
pub use protocol::PlanningStrategy;
pub use protocol::ProjectSummary;
pub use protocol::QueryRequest;
pub use protocol::QueryResponse;
pub use protocol::RateLimitDecision;
pub use protocol::RateLimitEvent;
pub use protocol::RateLimitType;
pub use protocol::ReasoningDecision;
pub use protocol::ReasoningEvent;
pub use protocol::ReasoningType;
pub use protocol::RunLifecycleEvent;
pub use protocol::RunStatus;
pub use protocol::SessionStats;
pub use protocol::SuccessEvent;
pub use protocol::TargetHints;
pub use protocol::TaskItem;
pub use protocol::TaskListEvent;
pub use protocol::TaskStatus;
pub use protocol::TimeRange;
pub use protocol::VerificationCheck;
pub use protocol::VerificationEvent;
pub use protocol::VerificationStatus;
pub use server::AhpServer;
pub use transport::Transport;
pub use transport::TransportConfig;

Modules§

auth
Authentication and authorization
client
AHP client implementation
error
Error types for AHP
protocol
AHP protocol message definitions.
server
AHP server implementation
transport
Transport layer abstractions

Constants§

DEFAULT_BATCH_SIZE
Default batch size
DEFAULT_TIMEOUT_MS
Default timeout for blocking requests (milliseconds)
PROTOCOL_VERSION
Protocol version