supercode-harness 0.4.12

The optional native Supercode agent and tool harness
Documentation
//! # supercode
//!
//! A lightweight, fully-customizable AI coding-agent SDK in Rust.
//!
//! `supercode` is a native agent loop — it talks directly to any model through
//! [OpenRouter](https://openrouter.ai) (or any other OpenAI-compatible endpoint),
//! drives a configurable set of tools, and is designed to be a superset of what
//! tools like Claude Code and Codex can do: every prompt, every tool description,
//! and every tool's on/off state is yours to control.
//!
//! ## Quick start
//!
//! ```no_run
//! use supercode_harness::{Agent, Config};
//!
//! # async fn run() -> supercode_harness::Result<()> {
//! // Reads OPENROUTER_API_KEY from the environment by default.
//! let config = Config::builder()
//!     .model("anthropic/claude-opus-4-8")
//!     .system_prompt("You are a terse, expert pair programmer.")
//!     .build();
//!
//! let mut agent = Agent::new(config)?;
//! let reply = agent.send("List the files in the current directory.").await?;
//! println!("{reply}");
//! # Ok(())
//! # }
//! ```
//!
//! ## Design
//!
//! - [`Config`] — the single knob box: model, endpoint, credentials, sampling,
//!   the system prompt, and per-tool overrides (enable/disable + custom
//!   descriptions).
//! - [`Provider`] — the model transport. [`OpenAiProvider`] speaks the
//!   OpenAI chat-completions wire format and defaults to OpenRouter, so it
//!   reaches Claude, GPT, Gemini, Llama, and anything else OpenRouter exposes.
//! - [`Tool`] / [`ToolRegistry`] — the capability surface. Built-ins cover
//!   file read/write/edit, directory listing, glob, content search, and shell
//!   execution. Register your own to extend it.
//! - [`Agent`] — the loop that ties it together: it streams a turn, runs any
//!   tool calls the model requests, feeds results back, and repeats until the
//!   model produces a final answer.

#![warn(missing_docs)]

#[cfg(feature = "adapter-acp")]
pub mod acp_frontend;
#[cfg(feature = "adapter-acp")]
pub mod acp_server;
mod agent;
pub mod audit;
pub mod background;
pub mod catalog;
pub mod checkpoint;
pub mod claude_compat;
pub mod claude_peer;
pub mod claude_runtime_scheduler;
pub mod claude_runtime_state;
pub mod codex_peer;
mod config;
pub mod configfile;
mod error;
mod event;
pub mod fidelity;
pub mod formatters;
#[cfg(feature = "adapter-api")]
pub mod frontend;
#[cfg(not(feature = "adapter-api"))]
#[allow(dead_code)]
mod frontend;
#[allow(missing_docs)]
mod frontend_contract_generated;
pub mod git_metadata;
#[cfg(feature = "adapter-api")]
pub mod harness_service;
#[cfg(not(feature = "adapter-api"))]
#[allow(dead_code)]
mod harness_service;
pub mod human_export;
pub mod interop_settings;
pub mod live_runtime;
pub mod lsp;
pub mod mcp;
pub mod mcp_oauth;
mod message;
pub mod model_catalog;
pub mod model_change;
pub mod modules;
pub mod permissions;
pub mod plugins;
pub mod presets;
pub mod pricing_ref;
mod provider;
pub mod reduce;
pub mod runtime;
pub mod runtime_lease;
#[cfg(feature = "adapter-api")]
pub mod runtime_registry;
mod safe_path;
pub mod sandbox;
pub mod schema;
pub mod sdk;
#[cfg(feature = "adapter-api")]
pub mod server;
#[cfg(not(feature = "adapter-api"))]
#[allow(dead_code, unused_imports)]
mod server;
pub mod session;
pub mod session_activity;
pub mod session_index;
pub mod session_title;
pub mod session_tree;
pub mod sidecar;
pub mod store;
pub mod subagents;
pub mod support;
pub mod tokens;
pub mod tools;
pub mod tui;
pub mod usage_log;
pub mod watch;

#[cfg(feature = "adapter-acp")]
pub use acp_frontend::{AcpFrontendCheckpoint, AcpFrontendConnectOptions, AcpFrontendRuntime};
pub use agent::Agent;
pub use catalog::{
    DiscoveryPage, DiscoveryQuery, HarnessCatalog, HarnessHomes, HarnessId, SessionDescriptor,
    SessionLocator, StorageLocator,
};
pub use claude_peer::{
    message_claude_peer, read_claude_peer_settings, read_registry as read_claude_peer_registry,
    update_claude_peer_settings, user_settings_path as claude_user_settings_path,
    write_claude_peer_settings, ClaudeCrossSessionInbound, ClaudePeerDelivery, ClaudePeerEndpoint,
    ClaudePeerRefusal, ClaudePeerRefusalError, ClaudePeerSession, ClaudePeerSettings,
    ClaudePeerSettingsError, ClaudePeerStatus, CourierRunner, ProcessCourierRunner,
};
pub use claude_runtime_scheduler::{
    ClaudeCronScheduleState, ClaudeRuntimeDeliveryState, ClaudeRuntimeSchedulerState,
    ClaudeRuntimeTrigger, ClaudeRuntimeTriggerKind, ClaudeWakeupScheduleState,
};
pub use claude_runtime_state::{
    ClaudeBackgroundChild, ClaudeBackgroundState, ClaudeCronJob, ClaudeQueueState,
    ClaudeRuntimeExecutionState, ClaudeRuntimeManifest, ClaudeRuntimePosture, ClaudeRuntimeResidue,
    ClaudeWakeup, CLAUDE_RUNTIME_MANIFEST_VERSION,
};
pub use config::{
    ApprovalPolicy, CachePlan, Config, ConfigBuilder, ConfigFile, ConfigProfile,
    ContextInjectionBlock, SteeringMode, StopGateHook, ToolAdvertising, ToolOverride,
    ToolOverrideProfile, DEFAULT_SYSTEM_PROMPT,
};
pub use configfile::HarnessConfig;
pub use interop_settings::{
    configure_harness_interop_settings, inspect_harness_interop_settings, HarnessAdvisorySeverity,
    HarnessInteropAdvisory, HarnessInteropControl, HarnessInteropSettingsError,
    HarnessInteropSettingsReport, HarnessSettingChange, HarnessSettingChoice,
    HarnessSettingRecommendation, HarnessSettingScope, CLAUDE_CROSS_SESSION_INBOUND_KEY,
    HARNESS_INTEROP_SETTINGS_SCHEMA,
};
pub use live_runtime::{
    discover_live_runtime, find_live_runtime, forget_live_runtime, list_live_runtimes,
    register_live_runtime, register_live_runtime_with_metadata, resolve_live_runtime,
    LiveRuntimeEndpoint, LiveRuntimeMetadata, LiveRuntimeReceiptError, LiveRuntimeRecord,
    LiveRuntimeRegistration, LiveRuntimeSource, LiveRuntimeSupervisor, ResolvedLiveRuntime,
};
pub use modules::{ModuleActivation, ModuleId};

/// Format an agent's final reply for output. `json` wraps it as
/// `{"result": "..."}`; otherwise the reply is returned as-is. The
/// stream-json form is the live [`AgentEvent`] stream via an [`EventSink`].
pub fn format_reply(reply: &str, json: bool) -> String {
    if json {
        serde_json::json!({ "result": reply }).to_string()
    } else {
        reply.to_string()
    }
}
pub use error::{Error, Result};
pub use event::{AgentEvent, EventSink};
pub use fidelity::{
    core_messages, measure_fidelity, messages_equal, messages_equal_multimodal, replay_eligible,
    Fidelity, FidelityMetric, FidelityResidue,
};
#[cfg(feature = "adapter-api")]
pub use frontend::HttpFrontendRuntime;
pub use frontend::{
    FrontendActions, FrontendApprovalDecision, FrontendAttachSnapshot, FrontendAttachment,
    FrontendCommandDescriptor, FrontendConnectionState, FrontendDisplayCapabilities,
    FrontendElicitationAction, FrontendEvent, FrontendOperationDescriptor,
    FrontendOperationInvocation, FrontendOperationKind, FrontendOperationResult, FrontendRequest,
    FrontendRequestKind, FrontendResponse, FrontendRuntime, FrontendRuntimeDescriptor,
    FrontendRuntimeError, FrontendRuntimeMetadata, FrontendTurnState, FRONTEND_REPLAY_CAPACITY,
    FRONTEND_RUNTIME_SCHEMA_VERSION,
};
pub use frontend_contract_generated::{
    FrontendFacadeMethod, FrontendFacadeTransport, GeneratedFrontendClient,
};
pub use harness_service::{
    HarnessSessionService, HARNESS_SERVICE_VERSION, RUNTIME_EVENT_METHOD,
    SESSION_ACTIVITY_EVENT_METHOD, SESSION_EVENT_METHOD, SESSION_INDEX_EVENT_METHOD,
};
pub use message::{
    is_tool_error, mark_tool_error, mark_tool_outcome_unknown, tool_outcome, ChatMessage,
    FunctionCall, Role, ToolCall, ToolOutcome, TOOL_ERROR_METADATA_KEY,
    TOOL_OUTCOME_UNKNOWN_METADATA_KEY,
};
pub use provider::{
    model_context_limit, ChatRequest, OpenAiProvider, PromptTokensDetails, Provider, ToolSchema,
    Usage, UNKNOWN_MODEL_CONTEXT_FLOOR,
};
#[cfg(feature = "adapter-api")]
pub use runtime::SupercodeHttpRuntimeBackend;
pub use runtime::{
    AcpRuntimeBackend, ClaudeCodeRuntimeBackend, CodexRuntimeBackend, HarnessEvent,
    OpenCodeRuntimeBackend, PiRuntimeBackend, RuntimeAttachRequest, RuntimeBackend,
    RuntimeCapabilities, RuntimeConnection, RuntimeEndpoint, RuntimeHandle, RuntimeInput,
    RuntimeLaunch, RuntimeStartRequest,
};
pub use runtime_lease::{
    CoordinatedRuntime, CoordinatedRuntimeClient, RuntimeAuthorization, RuntimeClientId,
    RuntimeControllerLease, RuntimeLeaseCoordinator, RuntimeLeaseError, RuntimeLeaseSnapshot,
    RuntimeObserverLease, RuntimePermission, DEFAULT_RUNTIME_LEASE_TTL_MS,
};
#[cfg(feature = "adapter-api")]
pub use runtime_registry::{
    LocalRuntimeRegistry, RuntimeRegistryEntry, RuntimeRegistryEvent, RuntimeRegistryOwner,
    RuntimeRegistryQuery, RuntimeRegistryState, RuntimeRegistryWatch,
};
pub use sandbox::{landlock_available, netns_available, SandboxEnvPolicy, SandboxEscalation};
pub use sdk::{
    create_agent, discover_session_page, discover_sessions, load_session, load_session_path,
    resume_agent, submit_agent, submit_agent_with_images, RuntimeSubmitError, SdkAgent,
    SdkCapabilities, SdkError, SdkErrorCode, SdkEvent, SdkOperation, SdkPromptSource, SdkRequest,
    SdkRuntime, SdkRuntimeEvent, SdkService, SDK_SCHEMA_VERSION,
};
pub use server::RpcEngine;
pub use session::{Session, SessionFormat, SessionMeta, SessionSource};
pub use session_activity::{
    SessionActivity, SessionActivityEvidence, SessionPresence, SessionTurnState,
};
pub use session_index::{SessionIndexChange, SessionIndexDelta, SessionIndexKey};
pub use store::{SessionInfo, SessionStore};
pub use support::{
    harness_support, harness_support_registry, HarnessSupportDescriptor, ImplementationKind,
    NativeSupport, RuntimeSupport, SupportRegistryReport, SUPPORT_REGISTRY_SCHEMA,
};
pub use tools::{
    shell_sandbox_unenforceable, SandboxPolicy, SchemaTier, Tool, ToolContext, ToolRegistry,
    WriteObserver,
};
pub use watch::{SessionFollower, SessionSnapshotReason, SessionWatchEvent};