# openalice-agent-protocol-rs

> Rust half of the polyglot agent-protocol pair (TS half is openalice-agent-protocol). Wire contract for ConnectorEvent / ToolCall + AgentRuntime trait used by every OpenAlice Rust service. JSON shape kept identical with the TS mirror; changes must land in both repos same commit window.

## At a glance
| field | value |
|---|---|
| kind | `service` |
| priority | `—` |
| default branch | `mvp` |
| last activity | 2026-06-02T10:33:50+00:00 |
| features catalogued | **6** |
| runtime deps declared | **0** |

## Manifest
`.atlas-deps.yml` — parsed cleanly: **yes**

### Exposes
- `cargo_crate` — openalice-agent-protocol-rs

## Features (6)

### agent-protocol-rs/core
- **`agent-protocol-rs.core.wire-contract`** — Rust mirror of `@openalicelabs/agent-protocol`. Provides all shared types (`ConnectorEvent`, `ToolCall`), the `AgentRuntime` trait, `CooldownMiddleware`, `ProductDispatcher`, and the optional `fetch_agent_config` helper so every Rust service (live-control, social-api, voice, chat-bridge) shares one wire contract with zero translation overhead against the TypeScript twin.  
  *src/lib.rs:17*

### agent-protocol-rs/dispatcher
- **`agent-protocol-rs.dispatcher.product-dispatcher`** — Generic per-broadcast event → action pipeline shared by all OpenAlice products. `dispatch(event)` builds `AgentTurnInput`, calls `AgentRuntime::turn`, applies `CooldownMiddleware` per `(channel_id, tool_name)`, and invokes the product-supplied `ToolHandler` for every allowed call. Returns the count of executed calls for metrics. Products pass their own slug and `ToolHandler` closure; the turn loop, cooldown filtering, and `AgentContext` construction are identical for all products.  
  *src/dispatcher.rs:31*

### agent-protocol-rs/events
- **`agent-protocol-rs.events.connector-event`** — Inbound event envelope for all connector-originated signals. Six variants: `ChatMessage`, `ChatFeed`, `VoiceUtterance`, `PresenceChange`, `ViewerMetrics`, `System`. The `kind` field is the serde tag discriminator — identical to the TS package so JSON round-trips with no translation between TypeScript connectors and Rust service consumers. [derive(Debug, Clone, Serialize, Deserialize)] [serde(tag = "kind", rename_all = "snake_case")]  
  *src/events.rs:133*

### agent-protocol-rs/fetch
- **`agent-protocol-rs.fetch.fetch-agent-config`** — Canonical single-source fetcher for `auth /internal/users/{id}/agent-config` (behind the `fetch` cargo feature). Replaces identical copies that previously lived in live-control, voice, and social-api. Authenticates via `X-Internal-Secret`, projects the wire shape onto `AgentRuntimeConfig`, and propagates HTTP errors verbatim for operator observability. Gate with `#[cfg(feature = "fetch")]` — consumers that only use types (chat-bridge) do not pull reqwest + uuid.  
  *src/fetch.rs:54*

### agent-protocol-rs/runtime
- **`agent-protocol-rs.runtime.agent-runtime`** — Core integration contract for all OpenAlice agent backends. Every product (live, social, voice, world) drives the agent through `init → reconfigure → turn*`. `turn` receives the batched `AgentTurnInput` (events + prior tool results) and returns an `AgentTurnOutput` (list of `ToolCall`s to execute). `shutdown` is optional — default impl is a no-op. The trait is `Send + Sync` so a single `Arc<dyn AgentRuntime>` can be shared across `ProductDispatcher` instances. [async_trait]  
  *src/runtime.rs:132*

### agent-protocol-rs/tools
- **`agent-protocol-rs.tools.tool-call`** — Outbound action envelope produced by an `AgentRuntime::turn`. All 15 variants share a `call_id` (for result correlation) and an optional `ToolRouting` (product / platform / channel overrides). The `ToolCall::name()` and `call_id()` helpers are stable for metrics and observability without a match. Wire shape is identical to the TS `@openalicelabs/agent-protocol` package. [derive(Debug, Clone, Serialize, Deserialize)] [serde(tag = "name", rename_all = "snake_case")]  
  *src/tools.rs:33*

---

*Generated by [openalice-atlas](https://atlas.blal.pro) — single source of truth for the openalicelabs ecosystem.*
