Skip to main content

Crate harness

Crate harness 

Source
Expand description

Compose’s neutral agent-harness core.

The library you depend on to drive — or build — an agent harness, independent of any specific backend. It provides:

The built-in per-CLI adapters live here as modules (claude / codex), re-exported as Claude / Codex. The Registry is open: a third party adds their own provider by implementing Harness in their crate and registering it — no fork.

Wire shapes derive Serialize so every transport emits identical JSON — keep their field names stable; the TypeScript front-end consumes them verbatim.

Re-exports§

pub use events::normalize_process_event;
pub use events::run_events_from_parsed;
pub use events::ByteRange;
pub use events::ParsedLine;
pub use events::PlanEntry;
pub use events::PlanEntryPriority;
pub use events::PlanEntryStatus;
pub use events::Question;
pub use events::QuestionOption;
pub use events::RunEvent;
pub use events::SessionInfo;
pub use events::SuggestedEdit;
pub use events::ToolCallEnd;
pub use events::ToolCallStart;
pub use events::ToolKind;
pub use events::ToolLocation;
pub use events::UsageInfo;
pub use raw::parse_raw_line;
pub use harness::run_login_command;
pub use harness::Attachment;
pub use harness::BoxError;
pub use harness::CredentialSpec;
pub use harness::Harness;
pub use harness::Features;
pub use harness::Error;
pub use harness::Info;
pub use harness::ModelChoice;
pub use harness::Readiness;
pub use harness::InstallCallback;
pub use harness::InstalledModel;
pub use harness::InstallHint;
pub use harness::ModelManagement;
pub use harness::PullProgress;
pub use harness::PullProgressAggregator;
pub use harness::PullProgressCallback;
pub use harness::ReasoningEffort;
pub use harness::RunCallback;
pub use harness::RunControl;
pub use harness::RunHandle;
pub use harness::RunMode;
pub use harness::RunRequest;
pub use harness::RunTuning;
pub use claude::ClaudeHarness as Claude;
pub use claude::ClaudeHarness;
pub use claude::ClaudeHarnessConfig;
pub use claude::CLAUDE_HARNESS_ID;
pub use claude::DEFAULT_CLAUDE_COMMAND;
pub use codex::CodexHarness as Codex;
pub use codex::CodexHarness;
pub use codex::CodexHarnessConfig;
pub use codex::CODEX_HARNESS_ID;
pub use codex::DEFAULT_CODEX_COMMAND;
pub use acp::AcpHarness;
pub use acp::AcpHarnessConfig;
pub use openai_compatible::AgentDef;
pub use openai_compatible::ApiKey;
pub use openai_compatible::InstructionSources;
pub use openai_compatible::McpPrompt;
pub use openai_compatible::McpPromptArg;
pub use openai_compatible::McpServer;
pub use openai_compatible::McpTransport;
pub use openai_compatible::ModelCost;
pub use openai_compatible::ModelFacts;
pub use openai_compatible::OpenHarness;
pub use openai_compatible::OpenHarnessConfig;
pub use openai_compatible::Permission;
pub use openai_compatible::PermissionPrompt;
pub use openai_compatible::PermissionRequest;
pub use openai_compatible::PermissionRule;
pub use openai_compatible::PromptCache;
pub use openai_compatible::PromptMessage;
pub use openai_compatible::PromptProfile;
pub use openai_compatible::SessionRecord;
pub use registry::Listing;
pub use registry::default_registry;
pub use registry::harness_by_id;
pub use registry::harness_catalog;
pub use registry::Registry;
pub use registry::DEFAULT_HARNESS_ID;

Modules§

acp
The ACP-client adapter (drives an external Agent Client Protocol agent: OpenCode, Gemini, Goose, …). ACP-client adapter: drive an external Agent Client Protocol agent (OpenCode, Gemini CLI, Goose, …) over JSON-RPC/stdio and normalize its session/update stream into crate::RunEvents — the third adapter archetype (the CLI-wrapping adapters parse a stdout stream; the OpenAI-compatible adapter owns the loop; this one relays an ACP agent).
claude
Claude Code (claude) as a Harness.
codex
OpenAI Codex (codex) as a Harness.
events
Normalized run events — the one shape the UI consumes regardless of which harness produced them.
harness
The neutral harness contract: the Harness trait, the run-control handle, the neutral request/metadata types, and the shared interactive-login helper.
models_dev
models.dev catalog lookup for Harness::list_models.
openai_compatible
The OpenAI-compatible / local-model runtime (“we are the agent” — owns the loop + tool surface, unlike the CLI/ACP adapters that wrap an external agent). A direct-model harness: it speaks the OpenAI-compatible chat API over HTTP and runs the agent loop in Rust — owning the read/write tool surface — instead of wrapping a CLI. One adapter serves every OpenAI-compatible endpoint (local Ollama, OpenRouter, vLLM, LM Studio, …); the vendor is configuration, not a type, so OpenHarness::ollama and OpenHarness::custom are constructors, not separate structs.
raw
The raw passthrough tier — a harness’s stdout line decoded as untyped JSON, for consumers that want to interpret a harness’s output themselves instead of the neutral crate::RunEvent vocabulary.
registry
The harness registry — an open builder so consumers compose their own set of harnesses (the built-ins and/or their own custom impl Harness), plus convenience constructors over the built-in adapters for hosts that just want “all of them”.

Structs§

Command
What to spawn. Named fields rather than six positional arguments, so a call site says which string is the program and which is the run id, and a new knob is a field with a default instead of a break.
ProcessHandle
Handle to an in-flight streaming run. Caller stores it (e.g. in a runId-keyed map) so a later cancel() can find it.

Enums§

Event
Raw events emitted to the caller’s callback during a streaming run. JSON-tagged so axum SSE and Tauri Channel render identical payloads on the wire. Harness-neutral: a process-backed adapter parses the Stdout lines into a normalized event vocabulary (e.g. agent-harness’s RunEvent).
InstallEvent
StreamError
Why Command::stream or ProcessHandle::cancel failed.

Traits§

ResolveCli
Resolving an agent’s CLI before running it.

Functions§

augmented_node_path
A PATH that resolves Node-based CLIs (bob, claude, codex) even from a process launched by Finder/Launchpad, which inherits only the minimal launchd PATH (/usr/bin:/bin:/usr/sbin:/sbin) rather than the user’s shell PATH.
hidden_command
probe_version
Ask a CLI for its version, on the augmented PATH. None when it cannot be run, exits non-zero, or says nothing — each of which means the same thing to a caller: this is not an installed, working CLI.
resolve_program
Resolve a bare program name (bob, claude) to its absolute path on the augmented PATH, so the spawn and the node pairing agree on one location.