Skip to main content

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
28pub use events::{
29    normalize_process_event, run_events_from_parsed, ByteRange, ParsedLine, Question,
30    QuestionOption, RunEvent, SessionInfo, SuggestedEdit, ToolCallEnd, ToolCallStart, ToolKind,
31    UsageInfo,
32};
33pub use raw::parse_raw_line;
34pub use harness::{
35    run_login_command, BoxError, CredentialSpec, Harness, HarnessCapabilities, HarnessError,
36    HarnessInfo, HarnessModel, HarnessReadiness, InstallCallback, ReasoningEffort, RunCallback,
37    RunControl, RunHandle, RunMode, RunRequest, RunTuning,
38};
39// The generic subprocess engine + the install/process event shapes live in
40// the `cli-stream` leaf; re-export them so adapters + consumers reach them
41// through the framework (e.g. `use harness::spawn_streaming`). `StreamError`
42// is re-exported too so a consumer can `downcast_ref` a `HarnessError`'s
43// source back to the typed spawn/cancel error.
44pub use cli_stream::{
45    augmented_node_path, spawn_streaming, InstallEvent, ProcessEvent, ProcessHandle, StreamError,
46};
47
48#[cfg(feature = "bob")]
49pub mod bob;
50#[cfg(feature = "claude")]
51pub mod claude;
52#[cfg(feature = "codex")]
53pub mod codex;
54pub mod registry;
55
56// The built-in adapters, re-exported as short names so consumers write
57// `use harness::{Bob, Claude, Codex}` — each gated behind its feature.
58#[cfg(feature = "bob")]
59pub use bob::{bob_tool_kind, normalize_bob_event, BobHarness as Bob, BOB_HARNESS_ID};
60// bob's typed error, re-exported so a consumer can `downcast_ref` a bob
61// `HarnessError`'s source (install / keychain / spawn) back to `BobError`.
62#[cfg(feature = "bob")]
63pub use bob_rs::BobError;
64#[cfg(feature = "claude")]
65pub use claude::{ClaudeHarness as Claude, CLAUDE_HARNESS_ID};
66#[cfg(feature = "codex")]
67pub use codex::{CodexHarness as Codex, CODEX_HARNESS_ID};
68// The open registry + convenience constructors over the built-ins.
69pub use registry::{
70    default_registry, harness_by_id, harness_catalog, Registry, DEFAULT_HARNESS_ID,
71};