Skip to main content

Crate arcp

Crate arcp 

Source
Expand description

§arcp — Agent Runtime Control Protocol (reference implementation)

Umbrella crate that re-exports the three primary ARCP crates:

  • arcp_core — wire-format envelopes, message payloads, error taxonomy, IDs, transport trait + in-memory transport, authenticator trait.
  • arcp_clientARCPClient / type-state Session.
  • arcp_runtimeARCPRuntime, job machinery, SQLite store, bearer / JWT / none auth validators.

See CONFORMANCE.md for per-section RFC status and docs/ for narrative guides.

§Scope

The crate implements the protocol fundamentals: envelopes, sessions and authentication (bearer, signed_jwt, none), capability negotiation, jobs, streams, permissions, leases, subscriptions, artifacts, the canonical error taxonomy, observability primitives, and the WebSocket, stdio, and in-memory transports.

Out-of-scope items (HTTP/2, QUIC, mTLS, OAuth2, sidecar binary frames, scheduled jobs, multi-agent delegation, workflows, trust elevation, checkpoint-based resume) return ARCPError::Unimplemented when invoked.

§Cargo features

  • client (default) — pulls in arcp-client.
  • runtime (default) — pulls in arcp-runtime.
  • transport-ws, transport-stdio (default) — transport implementations.

To slim builds, opt out of the side you don’t need:

arcp = { version = "2", default-features = false, features = ["client", "transport-ws"] }

§Example

use std::sync::Arc;

use arcp::auth::BearerAuthenticator;
use arcp::messages::{AuthScheme, Capabilities, ClientIdentity, Credentials};
use arcp::runtime::{ARCPRuntime, ToolContext, ToolHandler, ToolRegistryBuilder};
use arcp::transport::paired;
use arcp::ARCPClient;
use async_trait::async_trait;

struct Echo;

#[async_trait]
impl ToolHandler for Echo {
    fn name(&self) -> &'static str { "echo" }
    async fn invoke(
        &self,
        input: serde_json::Value,
        _ctx: ToolContext,
    ) -> Result<serde_json::Value, arcp::ARCPError> {
        Ok(input)
    }
}

let tools = ToolRegistryBuilder::new().with(Arc::new(Echo)).build();
let runtime = ARCPRuntime::builder()
    .with_authenticator(Box::new(BearerAuthenticator::new().with_token("tok", "alice")))
    .with_tools(tools)
    .build()
    .await?;
let (server_t, client_t) = paired();
let _server = runtime.serve_connection(server_t);
let session = ARCPClient::new(client_t)
    .open()?
    .authenticate(
        Credentials { scheme: AuthScheme::Bearer, token: Some("tok".into()) },
        ClientIdentity {
            kind: "demo".into(), version: "1.0".into(),
            fingerprint: None, principal: None,
        },
        Capabilities::default(),
    )
    .await?;
let result = session.invoke("echo", serde_json::json!({"hi": "arcp"})).await?.join().await?;
assert_eq!(result["hi"], "arcp");

Modules§

auth
Authentication scheme adapters (RFC §8.2).
client
Reference client (consumer side). Re-export of arcp_client::api. ARCPClient and the type-state Session<S> (RFC §4.6, §8).
envelope
Canonical message envelope (RFC §6.1).
error
Canonical error model (RFC §18).
extensions
Extension namespace registry and unknown-message classification (RFC §21).
ids
Newtype wrappers for the protocol’s identifier fields (RFC §6.1.1).
messages
Wire-level message payload types (RFC §6.2).
runtime
Reference runtime (server side). Re-export of arcp_runtime::runtime. ARCP runtime — the server side of the protocol.
store
SQLite-backed event log and credential ledger. Re-export of arcp_runtime::store. Persistent storage primitives.
transport
Transport abstraction (RFC §22).

Structs§

ARCPClient
Client-side entry point.
ARCPRuntime
The ARCP runtime. Cheap to clone; share across tasks.
Capabilities
Negotiated capability set (RFC §7).
Envelope
Typed protocol envelope (RFC §6.1).
ExtensionRegistry
Per-session/runtime registry of advertised extension names (§7, §21.2).
RawEnvelope
Untyped envelope used at the transport boundary.

Enums§

ARCPError
In-process error type returned from library APIs.
ErrorCode
Canonical wire-level error code (RFC §18.2).
MessageType
Tagged enum of every protocol message payload (RFC §6.2).
Priority
Message priority class (RFC §6.5).
TypeClassification
What a receiver should do with a wire-level message type string.

Constants§

IMPL_KIND
Implementation kind reported in runtime.kind / client.kind blocks (RFC §8.2, §8.3).
IMPL_VERSION
Implementation version of this crate, derived from Cargo.toml. Sibling crates in this workspace move in lockstep, so this constant also reflects the runtime / client / umbrella version.
PROTOCOL_VERSION
Protocol version implemented by this crate, as carried in the arcp field of every envelope (RFC §6.1).