anyagent 0.0.3

One Rust interface to the coding agents installed on a machine.
Documentation
# anyagent
### For apps that want to use the AI subscriptions a user already pays for. 

[![CI](https://github.com/spotta85/anyagent-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/spotta85/anyagent-rs/actions/workflows/ci.yml)
[![crates.io](https://img.shields.io/crates/v/anyagent.svg)](https://crates.io/crates/anyagent)
[![docs](https://img.shields.io/badge/docs-anyagent.mintlify.site-8B5CF6)](https://anyagent.mintlify.site)
[![docs.rs](https://img.shields.io/docsrs/anyagent)](https://docs.rs/anyagent)
[![license](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](#license)

### One Up-to-date, feature-rich Rust interface to the agents already on a users machine.

Users have Claude Code, Codex, Cursor, Grok, OpenCode, Kiro, Antigravity, and friends on their
machines — each with its own CLI, protocol, and quirks. If you're building an
app on top of them, you end up writing and maintaining a driver per agent.
anyagent is that layer, **once: it finds the agents, speaks each one's protocol
(native or [ACP](https://agentclientprotocol.com)), and gives you one typed
API — `Runtime`, `Session`, and a stream of `Events`**.

#### Your app keeps its own transcript, UI, and policy. anyagent owns the processes, the wires, and the turn rules — every agent behaves the same way through it.
<img width="630" height="346" alt="image" src="https://github.com/user-attachments/assets/45924ad0-2954-4b9f-8a80-11882ed07d7a" />


## Use

```toml
[dependencies]
anyagent = "0.0.3"
```

```rust
use anyagent::{EventKind, Runtime, SessionOptions};
use futures::StreamExt;

let runtime = Runtime::new();
let report = runtime.discover().await;
let agent = report.require("claude")?;
let (session, mut events) = runtime.open(agent, SessionOptions::in_dir(".")).await?;

session.prompt("explain this repo").await?;
while let Some(event) = events.next().await {
    match event?.kind {
        EventKind::TextDelta { text, .. } => print!("{text}"),
        EventKind::TurnEnded { .. } => break,
        _ => {}
    }
}
session.close().await?;
```

That's the whole core flow. Everything else is the same few objects:

## Features

| Capability | API |
|---|---|
| Discover installed agents and check login status | `runtime.discover()`, `runtime.probe(agent)` |
| Plan quota for the logged-in account | `runtime.plan_usage(agent)` |
| One-shot text (titles, commit messages) with no session to manage | `runtime.generate(agent, options, prompt)` |
| Send text, images, slash commands | `session.prompt(input)` |
| Steer or interrupt a running turn | `session.prompt(..)` mid-turn, `session.cancel()` |
| Answer a permission or question the agent raised | `session.answer(id, answer)` |
| Switch model / mode / any advertised option live | `session.configure("model", "sonnet")` |
| Resume, fork, or rewind a conversation | `SessionOptions::resume` / `fork_from`, `session.rollback(..)` |
| Add custom MCP Servers | `SessionOptions::mcp_server(..)` |
| Test your app against a scripted agent, no subprocess | `Runtime::with_mock(script)` (feature `mock`) |

Events cover streamed text and reasoning, typed tool calls with diffs, plans,
token usage, permission requests, subagents, and turn boundaries — the same
`EventKind`s for every agent. Anything provider-specific rides in
`extensions` instead of leaking into the types.

## Try it from a terminal

```bash
cargo install anyagent
anyagent list           # installed agents: login state, models, capabilities
anyagent chat claude    # prompt, stream, permissions allowed, /set model sonnet
```

`anyagent serve` speaks the same API as JSON lines over stdin and stdout,
for apps in other languages. The source of `chat` and `list` is
[`src/bin/anyagent.rs`](src/bin/anyagent.rs);
[`examples/sessions.rs`](examples/sessions.rs) shows several sessions at
once and resuming one by token.

## Supported agents

| Agent | Wire |
|---|---|
| Claude Code | native (stream-json) |
| Codex | native (app-server) |
| Antigravity | native (stream-json), or ACP through its optional server |
| pi | native (pi RPC) |
| opencode | native (HTTP + SSE) |
| Cursor CLI, Grok, Hermes Agent, Kiro CLI, Qwen Code | ACP |

Any other ACP agent works without a catalog entry via
`AgentInstallation::acp(name, path, args)`.

## Docs
**[anyagent.mintlify.site](https://anyagent.mintlify.site)**

Using an AI agent to build on anyagent? Point it at one of these:

| Source | Use |
|---|---|
| [`docs/skill.md`]docs/skill.md | Agent skill: drop into `.claude/skills/anyagent/SKILL.md` (or your agent's skills dir) |
| [llms.txt]https://anyagent.mintlify.site/llms.txt / [llms-full.txt]https://anyagent.mintlify.site/llms-full.txt | Whole docs site as plain text |
| [Context7]https://context7.com/spotta85/anyagent-rs | `use context7` in Cursor, Claude Code, etc. |

| Page | What it covers |
|---|---|
| [Quickstart]https://anyagent.mintlify.site/quickstart | Install, discover, open, prompt, stream |
| [Core API]https://anyagent.mintlify.site/core-api | Runtime, Session, SessionOptions, every EventKind, requests, errors |
| [Features]https://anyagent.mintlify.site/features | Each feature: what, how, what confirms it, what gates it |
| [Agents]https://anyagent.mintlify.site/agents | Catalog, capability matrix, per-agent quirks, custom ACP agents |
| [Building an app]https://anyagent.mintlify.site/building-an-app | Step-by-step chat app: threads, permissions, settings, persistence, usage |
| [Architecture]https://anyagent.mintlify.site/architecture | Layers, the engine/adapter seam, adding an agent |
| [Binary and sidecar]https://anyagent.mintlify.site/sidecar | `anyagent list` / `chat` / `serve`; the JSON-lines protocol and schema for other languages |

Generated API reference, every type and signature: [docs.rs/anyagent](https://docs.rs/anyagent).

## Contributions
Contributions are welcome! Please be sure to open an issue first. Upon approval you may create a pr. Please avoid contributing AI-Slop :) ... unless fable wrote it. Read the [contributing guide](https://anyagent.mintlify.site/contributing) for the test tiers and what a PR needs.

## License

MIT or Apache-2.0.