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`] / [`Info`] / …),
7//! * the normalized [`RunEvent`] vocabulary every adapter parses into
8//! ([`normalize_process_event`] + [`ParsedLine`]),
9//! * the generic streaming subprocess engine ([`Command`] +
10//! [`Event`] + [`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 ([`claude`]
15//! / [`codex`]), re-exported as [`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;
25pub mod raw;
26pub mod models_dev;
27mod node_cli;
28
29pub use events::{
30 normalize_process_event, run_events_from_parsed, ByteRange, ParsedLine, PlanEntry,
31 PlanEntryPriority, PlanEntryStatus, Question, QuestionOption, RunEvent, SessionInfo,
32 SuggestedEdit, ToolCallEnd, ToolCallStart, ToolKind, ToolLocation, UsageInfo,
33};
34pub use raw::parse_raw_line;
35pub use harness::{
36 run_login_command, Attachment, BoxError, CredentialSpec, Harness, Features, Error,
37 Info, ModelChoice, Readiness, InstallCallback, InstalledModel, InstallHint,
38 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 `Error`'s
46// source back to the typed spawn/cancel error.
47pub use node_cli::{augmented_node_path, probe_version, resolve_program, ResolveCli};
48pub use cli_stream::{
49 hidden_command, InstallEvent, Event, Command,
50 ProcessHandle, StreamError,
51};
52
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::{Claude, Codex}` — each gated behind its feature.
69#[cfg(feature = "claude")]
70pub use claude::{ClaudeHarness as Claude, ClaudeHarness, ClaudeHarnessConfig, CLAUDE_HARNESS_ID, DEFAULT_CLAUDE_COMMAND};
71#[cfg(feature = "codex")]
72pub use codex::{CodexHarness as Codex, CodexHarness, CodexHarnessConfig, CODEX_HARNESS_ID, DEFAULT_CODEX_COMMAND};
73#[cfg(feature = "acp")]
74pub use acp::{AcpHarness, AcpHarnessConfig};
75// The OpenAI-compatible / local-model runtime + its public surface (permission
76// rules, MCP config, named subagents, model pricing, sessions).
77#[cfg(feature = "openai-compatible")]
78pub use openai_compatible::{
79 AgentDef, ApiKey, InstructionSources, McpPrompt, McpPromptArg, McpServer, McpTransport,
80 ModelCost, ModelFacts, OpenHarness, OpenHarnessConfig, Permission, PermissionPrompt,
81 PermissionRequest, PermissionRule, PromptCache, PromptMessage, PromptProfile, SessionRecord,
82};
83// The open registry + convenience constructors over the built-ins.
84pub use registry::{
85 Listing,
86 default_registry, harness_by_id, harness_catalog, Registry, DEFAULT_HARNESS_ID,
87};