supercode-harness 0.4.16

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")]
/// The supercode ontology (`docs/ONTOLOGY.md`): the one model under sessions and the
/// orchestration world.
pub use supercode_interchange::ontology;
/// The world piece of the ontology: a harness's operational home as one typed value.
pub use supercode_interchange::world;

#[cfg(feature = "adapter-acp")]
pub mod acp_frontend;
#[cfg(feature = "adapter-acp")]
pub mod acp_server;
mod agent;
pub mod agent_package;
pub mod approvals;
pub mod audit;
pub mod background;
pub mod browser;
pub mod catalog;
pub mod channels;
pub mod checkpoint;
pub mod claude_compat;
pub mod claude_peer;
pub mod claude_runtime_state;
pub mod codex_peer;
mod config;
pub mod config_schema;
pub mod configfile;
pub mod context_injection;
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;
pub mod goals;
pub mod harness_auth;
pub mod harness_command;
#[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 jobs;
pub mod jobs_control;
pub mod live_runtime;
pub mod lsp;
pub mod mcp;
pub mod mcp_oauth;
pub mod memory;
mod message;
pub mod model_catalog;
pub mod model_change;
pub mod modules;
pub mod orchestrator;
pub mod orchestrator_door;
pub mod output_style;
pub mod parity;
pub mod path_rules;
pub mod permissions;
pub mod plugins;
pub mod presets;
pub mod pricing;
pub mod pricing_ref;
pub mod profiles;
pub mod profiles_control;
mod provider;
pub mod reduce;
pub mod routes;
pub mod runs;
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_journal;
pub mod session_title;
pub mod session_tree;
pub mod sessions_control;
pub mod sidecar;
pub mod skills;
pub mod skills_control;
pub mod store;
pub mod subagents;
pub mod support;
pub mod tokens;
pub mod tools;
pub mod triggers;
pub mod trust;
pub mod tui;
pub mod turn_record;
pub mod usage_log;
pub mod watch;
pub mod world_doors;

#[cfg(feature = "adapter-acp")]
pub use acp_frontend::{AcpFrontendCheckpoint, AcpFrontendConnectOptions, AcpFrontendRuntime};
pub use agent::{Agent, ContextUsage};
pub use approvals::{
    approval_harnesses, lists_approvals, plan_reply, ApprovalChoice, ApprovalDecision,
    ApprovalDoor, ApprovalKind, ApprovalOption, ApprovalRegistry, ApprovalResolution,
    ApprovalResolveError, ApprovalRow, ApprovalStatus, ApprovalsQuery, ApprovalsResolveParams,
};
pub use catalog::{
    orchestrator_profile_dirs, DiscoveryPage, DiscoveryQuery, HarnessCatalog, HarnessHomes,
    HarnessId, SessionDescriptor, SessionLocator, StorageLocator,
};
pub use channels::{
    channel_status, list_channels, ChannelError, ChannelRow, ChannelStatus, CHANNELS_SCHEMA,
    CHANNEL_HARNESSES,
};
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_state::{
    ClaudeBackgroundChild, ClaudeBackgroundState, ClaudeCronJob, ClaudeQueueState,
    ClaudeRuntimeManifest, ClaudeRuntimePosture, ClaudeRuntimeResidue, ClaudeWakeup,
    CLAUDE_RUNTIME_MANIFEST_VERSION,
};
pub use config::{
    project_root_for, ApprovalPolicy, CachePlan, Config, ConfigBuilder, ConfigFile, ConfigProfile,
    ContextInjectionBlock, HookDecision, LifecycleEvent, LifecycleHook, PreToolOutcome,
    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 jobs::{
    get_job, list_jobs, supports_jobs, JobDeliver, JobPayload, JobSchedule, JobScope, JobSource,
    JobsListing, JobsQuery, ScheduledJob, CLAUDE_SESSION_SCAN_LIMIT, JOB_HARNESSES,
};
pub use jobs_control::{
    harness_program, mutate, supports_job_control, JobControlError, JobDeliverSpec, JobMutation,
    JobMutationOutcome, JobPayloadSpec, JobScheduleSpec, JobVerb, CONTROLLED_JOB_HARNESSES,
};
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 memory::{
    search_memory, show_memory, supports_memory, MemoryDocument, MemoryError, MemoryMatch,
    MemoryQuery, MemoryScope, MemorySearchQuery, MEMORY_HARNESSES, MEMORY_SCHEMA,
};
pub use modules::{ModuleActivation, ModuleId};
pub use orchestrator::{
    clear_lease, daemon_entry, install_service, live_lease, lock_path, read_lease, service_status,
    service_unit, uninstall_service, write_lease, write_unit, Lease, OrchestratorError,
    ServiceState, ServiceUnit, DAEMON_ENTRY, LOCK_FILE, SERVICE_DIR, SERVICE_NAME,
};
pub use orchestrator_door::{
    daemon_is_live, socket_path, Door, DoorAnswer, DoorError, NODE_BIN_ENV, SOCKET_FILE,
};
pub use profiles::{
    get_profile, list_profiles, ProfileError, ProfileKind, ProfileRow, HERMES_DEFAULT_PROFILE,
    PROFILES_SCHEMA, PROFILE_HARNESSES,
};
pub use profiles_control::{
    supports_profile_control, ProfileControlError, ProfileMutation, ProfileMutationOutcome,
    ProfileVerb, CONTROLLED_PROFILE_HARNESSES,
};
pub use routes::{list_routes, RouteError, RouteMatch, RouteRow, ROUTES_SCHEMA, ROUTE_HARNESSES};
pub use runs::{
    get_run, list_runs, supports_runs, HarnessRun, RunDelivery, RunSource, RunsListing, RunsQuery,
    RUN_HARNESSES,
};
pub use sessions_control::{
    controlled_verbs, supports_session_control, SessionControlError, SessionDoor, SessionMutation,
    SessionMutationOutcome, SessionVerb, CONTROLLED_SESSION_HARNESSES,
};
pub use triggers::{
    list_triggers, TriggerError, TriggerKind, TriggerRow, TRIGGERS_SCHEMA, TRIGGER_HARNESSES,
};

/// 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_auth::{
    harness_authentication_methods, harness_authentication_plan, inspect_harness_authentication,
    HarnessAuthenticationEnvironment, HarnessAuthenticationError, HarnessAuthenticationInteraction,
    HarnessAuthenticationLaunch, HarnessAuthenticationMethod, HarnessAuthenticationMethodId,
    HarnessAuthenticationPlan, HarnessAuthenticationReport, HarnessAuthenticationState,
    HarnessBrowserBehavior, HARNESS_AUTHENTICATION_SCHEMA,
};
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, RetryLog,
    RetryNotice, ToolSchema, Usage, SERVED_MODEL_KEY, UNKNOWN_MODEL_CONTEXT_FLOOR,
};
#[cfg(feature = "adapter-api")]
pub use runtime::SupercodeHttpRuntimeBackend;
pub use runtime::{
    AcpRuntimeBackend, BearerToken, ClaudeCodeRuntimeBackend, CodexRuntimeBackend, HarnessEvent,
    McpServerLaunch, OpenCodeRuntimeBackend, PiRuntimeBackend, ResolvedRuntimeConnection,
    RuntimeAttachRequest, RuntimeBackend, RuntimeCapabilities, RuntimeConnectLaunch,
    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, show_model_input, 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::{
    CrossSurface, OrchestrationNouns, Recurrence, Session, SessionFormat, SessionMeta,
    SessionSource, SurfaceKey, Trigger, WorkspaceKind, WorkspaceRef,
};
pub use session_activity::{
    SessionActivity, SessionActivityEvidence, SessionPresence, SessionTurnState,
};
pub use session_index::{SessionIndexChange, SessionIndexDelta, SessionIndexKey};
pub use skills::{
    declared_skill_name, list_skills, skill_roots, writable_skill_roots, SkillHomes, SkillRow,
    SkillScope, SkillsQuery, SKILL_HARNESSES,
};
pub use skills_control::{
    mutate_skill, supports_skill_control, SkillControlError, SkillMutation, SkillMutationOutcome,
    SkillVerb, CONTROLLED_SKILL_HARNESSES,
};
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};