harness/lib.rs
1//! Compose's neutral agent-harness core.
2//!
3//! The library you depend on to drive — or build — an agent harness,
4//! independent of any specific backend. It provides:
5//! * the [`Harness`] trait + the neutral request/metadata types
6//! ([`RunRequest`] / [`RunTuning`] / [`HarnessInfo`] / …),
7//! * the normalized [`RunEvent`] vocabulary every adapter parses into
8//! ([`normalize_process_event`] + [`ParsedLine`]),
9//! * the generic streaming subprocess engine ([`spawn_streaming`] +
10//! [`ProcessEvent`] + [`ProcessHandle`]) + the install/login event
11//! shape ([`InstallEvent`]), and
12//! * the shared interactive-login helper ([`run_login_command`]).
13//!
14//! The built-in per-CLI adapters live here as modules ([`bob`] / [`claude`]
15//! / [`codex`]), re-exported as [`Bob`] / [`Claude`] / [`Codex`]. The
16//! [`Registry`] is open: a third party adds their own provider by
17//! implementing [`Harness`] in their crate and registering it — no fork.
18//!
19//! Wire shapes derive `Serialize` so every transport emits identical
20//! JSON — keep their field names stable; the TypeScript front-end
21//! consumes them verbatim.
22
23pub mod events;
24pub mod harness;
25/// The untyped raw passthrough tier, harness-agnostic (any JSONL CLI).
26pub mod raw;
27/// models.dev catalog lookup for `list_models` (opt-in `models-dev` feature).
28pub mod models_dev;
29
30pub use events::{
31 normalize_process_event, run_events_from_parsed, ByteRange, ParsedLine, PlanEntry,
32 PlanEntryPriority, PlanEntryStatus, Question, QuestionOption, RunEvent, SessionInfo,
33 SuggestedEdit, ToolCallEnd, ToolCallStart, ToolKind, ToolLocation, UsageInfo,
34};
35pub use raw::parse_raw_line;
36pub use harness::{
37 run_login_command, BoxError, CredentialSpec, Harness, HarnessCapabilities, HarnessError,
38 HarnessInfo, HarnessModel, HarnessReadiness, InstallCallback, InstalledModel, ModelManagement,
39 PullProgress, PullProgressAggregator, PullProgressCallback, ReasoningEffort, RunCallback,
40 RunControl, RunHandle, RunMode, RunRequest, RunTuning,
41};
42// The generic subprocess engine + the install/process event shapes live in
43// the `cli-stream` leaf; re-export them so adapters + consumers reach them
44// through the framework (e.g. `use harness::spawn_streaming`). `StreamError`
45// is re-exported too so a consumer can `downcast_ref` a `HarnessError`'s
46// source back to the typed spawn/cancel error.
47pub use cli_stream::{
48 augmented_node_path, spawn_streaming, InstallEvent, ProcessEvent, ProcessHandle, StreamError,
49};
50
51#[cfg(feature = "bob")]
52pub mod bob;
53#[cfg(feature = "claude")]
54pub mod claude;
55#[cfg(feature = "codex")]
56pub mod codex;
57/// The ACP-client adapter (drives an external Agent Client Protocol agent:
58/// OpenCode, Gemini, Goose, …).
59#[cfg(feature = "acp")]
60pub mod acp;
61/// The OpenAI-compatible / local-model runtime ("we are the agent" — owns the
62/// loop + tool surface, unlike the CLI/ACP adapters that wrap an external agent).
63#[cfg(feature = "openai-compatible")]
64pub mod openai_compatible;
65pub mod registry;
66
67// The built-in adapters, re-exported as short names so consumers write
68// `use harness::{Bob, Claude, Codex}` — each gated behind its feature.
69#[cfg(feature = "bob")]
70pub use bob::{bob_tool_kind, normalize_bob_event, BobHarness as Bob, BOB_HARNESS_ID};
71// bob's typed error, re-exported so a consumer can `downcast_ref` a bob
72// `HarnessError`'s source (install / keychain / spawn) back to `BobError`.
73#[cfg(feature = "bob")]
74pub use bob_rs::BobError;
75#[cfg(feature = "claude")]
76pub use claude::{ClaudeHarness as Claude, CLAUDE_HARNESS_ID};
77#[cfg(feature = "codex")]
78pub use codex::{CodexHarness as Codex, CODEX_HARNESS_ID};
79#[cfg(feature = "acp")]
80pub use acp::{AcpHarness, AcpHarnessConfig};
81// The OpenAI-compatible / local-model runtime + its public surface (permission
82// rules, MCP config, named subagents, model pricing, sessions).
83#[cfg(feature = "openai-compatible")]
84pub use openai_compatible::{
85 AgentDef, McpPrompt, McpPromptArg, McpServer, McpTransport, ModelCost, OpenHarness,
86 OpenHarnessConfig, Permission, PermissionPrompt, PermissionRequest, PermissionRule,
87 PromptMessage, SessionRecord,
88};
89// The open registry + convenience constructors over the built-ins.
90pub use registry::{
91 default_registry, harness_by_id, harness_catalog, Registry, DEFAULT_HARNESS_ID,
92};