Copy-paste solutions to common Rust SDK tasks. Complete runnable versions live
in examples/.
use arcp::auth::NoneAuthenticator;
use arcp::messages::Capabilities;
use arcp::runtime::ARCPRuntime;
use arcp::transport::paired;
# async fn make_pair() -> Result<(), Box<dyn std::error::Error>> {
let caps = Capabilities {
anonymous: Some(true),
..Default::default()
};
let runtime = ARCPRuntime::builder()
.with_authenticator(Box::new(NoneAuthenticator::new()))
.with_capabilities(caps)
.build()
.await?;
let (client_transport, runtime_transport) = paired();
let _server = runtime.serve_connection(runtime_transport);
# let _ = client_transport;
# Ok(())
# }cargo run -- serve --bind 127.0.0.1:7777 --bearer tok --principal mePair it with a client or one of the WebSocket examples.
# use arcp::runtime::context::ToolContext;
# async fn call(ctx: &ToolContext) -> Result<(), arcp::ARCPError> {
ctx.charge("cost.llm", 0.03, "USD").await?;
# Ok(())
# }When the matching cost.budget counter is exhausted, the helper returns
BUDGET_EXHAUSTED and the runtime can surface a terminal job failure.
# use arcp::runtime::context::ToolContext;
# async fn call(ctx: &ToolContext) -> Result<(), arcp::ARCPError> {
ctx.enforce_model_use("tier-fast/small").await?;
# Ok(())
# }Use this before calling an LLM gateway when the job lease includes model.use.
Implement CredentialProvisioner when an upstream service needs a short-lived
credential derived from the accepted lease. The runtime redacts credential
values from debug output, subscriptions, and job inventory responses, then
revokes outstanding ids on job termination.
See examples/provisioned_credentials/.
Use a file-backed EventLog and persist (session_id, resume_token, last_event_seq) in your application state. On reconnect, pass that tuple in
the resume handshake and replay events after last_event_seq.