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