oino_acp/lib.rs
1//! `oino-acp`: Oino as an [Agent Client Protocol](https://agentclientprotocol.com) v1 agent
2//! (`oino --mode acp`, modes.md §6).
3//!
4//! The adapter sits on the in-process [`oino_client::InProcessBackend`] of one
5//! `AgentSessionRuntime` per ACP session — never on RPC JSON (research-acp §9.1) — and speaks
6//! ACP through the official `agent-client-protocol` SDK. Nothing else in the workspace sees ACP
7//! types.
8//!
9//! # Method coverage
10//!
11//! | ACP | Oino |
12//! |---|---|
13//! | `initialize` | capabilities of research-acp §5 (+ `sessionCapabilities.fork`), client caps recorded |
14//! | `authenticate`, `logout` | accepted (no auth methods: provider auth is extension-owned) |
15//! | `session/new`, `session/load` (replay), `session/resume`, `session/fork` | one runtime per session ([`SessionFactory`]) |
16//! | `session/list`, `session/close`, `session/delete` | `SessionManager` listing, dispose, move to `<agent>/trash/` |
17//! | `session/prompt`, `session/cancel` | `prompt` (follow-up while streaming) resolved on `agent_settled`; `abort` |
18//! | `session/set_config_option`, `session/set_mode` | model, thinking, queue modes, auto-compaction/retry; mode = thinking level |
19//! | `_oino/rpc`, `_oino/<command>` | any RPC command on the session's backend |
20//!
21//! Agent → client: `session/update` (message/thought chunks, tool calls with kinds, locations,
22//! diffs and terminals, plans, usage, compaction, notices, commands, config, session info),
23//! `session/request_permission` (approval dialogs, `confirm` during a tool call),
24//! `elicitation/create` (select/input/editor/confirm/multiSelect), `fs/*` and `terminal/*`
25//! through [`AcpEnv`], `_oino/queue_update`, `_oino/run_state`, `_oino/extension_ui`.
26//!
27//! # API map
28//!
29//! | Module | Contents |
30//! |---|---|
31//! | [`agent`] | [`AcpAgent`]: request dispatch, [`AgentInfo`] |
32//! | [`factory`] | [`SessionFactory`], [`CoreSessionFactory`], [`SessionDefaults`] |
33//! | [`mod@env`] | [`AcpEnv`]: client-hosted files and terminals |
34//! | [`client`] | [`ClientLink`], [`ClientCaps`]: typed agent → client calls |
35//! | [`tools`], [`convert`], [`config`], [`commands`], [`ui`] | event, prompt, config, slash-command and dialog mappings |
36//! | [`error`] | [`AcpError`] |
37
38#![forbid(unsafe_code)]
39#![cfg_attr(
40 test,
41 allow(
42 clippy::unwrap_used,
43 clippy::expect_used,
44 clippy::panic,
45 reason = "tests assert by unwrapping"
46 )
47)]
48
49pub mod agent;
50pub mod client;
51pub mod commands;
52pub mod config;
53pub mod convert;
54pub mod env;
55pub mod error;
56pub mod factory;
57mod session;
58pub mod tools;
59pub mod ui;
60
61use std::path::PathBuf;
62use std::sync::Arc;
63
64pub use agent::{AcpAgent, AgentInfo};
65pub use client::{ClientCaps, ClientLink};
66pub use env::AcpEnv;
67pub use error::AcpError;
68pub use factory::{
69 CoreSessionFactory, ModelChoice, ModelResolver, SessionDefaults, SessionFactory, SessionRequest,
70};
71
72/// Serves ACP on stdin/stdout until the client closes stdin (`oino --mode acp`).
73///
74/// # Errors
75///
76/// Transport and protocol failures reported by the SDK.
77pub async fn serve_stdio(
78 factory: Arc<dyn SessionFactory>,
79 info: AgentInfo,
80 default_cwd: PathBuf,
81) -> Result<(), agent_client_protocol::Error> {
82 AcpAgent::new(factory, info, default_cwd)
83 .serve(agent_client_protocol::Stdio::new())
84 .await
85}