supercode-harness 0.5.144

The optional native Volter Harness agent and tool harness
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
//! # Volter Harness
//!
//! 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.
pub use supercode_interchange::ontology;
/// The orchestration piece of the ontology: a harness's operational home as one typed value.
pub use supercode_interchange::orchestration;

#[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 channels;
pub mod checkpoint;
pub mod claude_compat;
pub mod claude_peer;
pub mod claude_relay;
pub mod claude_runtime_state;
pub mod codex_peer;
mod config;
pub mod config_schema;
pub mod configfile;
pub mod context_injection;
mod error;
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 hermes_import;
pub mod human_export;
pub mod interop_settings;
pub mod jobs;
pub mod jobs_control;
pub mod jobs_notepad;
pub mod launch_agent;
pub mod live_runtime;
pub mod lsp;
#[cfg(feature = "adapter-api")]
pub mod mail_agent;
#[cfg(feature = "adapter-api")]
pub mod mail_file;
#[cfg(feature = "adapter-api")]
pub mod mail_mcp;
pub mod mail_question;
#[cfg(feature = "adapter-api")]
pub mod mail_route;
#[cfg(feature = "adapter-api")]
pub mod mail_send;
pub mod mail_transcript;
#[cfg(feature = "adapter-api")]
pub mod mail_watch;
pub mod mailbox;
pub mod mcp;
pub mod mcp_oauth;
pub mod memory;
pub mod model_catalog;
pub mod model_change;
pub mod modules;
mod native_materialize;
pub mod orchestration_doors;
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;
#[cfg(feature = "adapter-api")]
pub mod relay_endpoint;
mod residue_store;
pub mod routes;
pub mod runs;
pub mod runtime;
pub mod runtime_lease;
#[cfg(feature = "adapter-api")]
pub mod runtime_mail;
#[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_activity;
pub mod session_index;
pub mod session_journal;
pub mod session_title;
pub mod sessions_control;
pub mod skills;
pub mod skills_control;
pub mod slow_log;
pub mod startup_prompts;
pub mod store;
pub mod subagents;
pub mod support;
pub mod teams;
pub mod tools;
pub mod triggers;
pub mod trust;
pub mod tui;
pub mod turn_record;
pub mod usage_log;
pub mod workflow_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 channels::{
    channel_status, list_channels, ChannelError, ChannelRow, ChannelStatus, CHANNELS_SCHEMA,
    CHANNEL_HARNESSES,
};
pub use claude_peer::{
    read_claude_peer_settings, read_registry as read_claude_peer_registry, resolve_live_session,
    update_claude_peer_settings, user_settings_path as claude_user_settings_path,
    write_claude_peer_settings, ClaudeCrossSessionInbound, ClaudePeerRefusal,
    ClaudePeerRefusalError, ClaudePeerSession, ClaudePeerSettings, ClaudePeerSettingsError,
    ClaudePeerStatus,
};
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 jobs_notepad::{JobNotepad, JobNotepadEntry, JobNotepadRequest};
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, resolve_program,
    service_name, 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 supercode_interchange::catalog::{
    orchestrator_profile_dirs, DiscoveryPage, DiscoveryQuery, HarnessCatalog, HarnessHomes,
    HarnessId, SessionDescriptor, SessionLocator, StorageLocator,
};
pub use teams::{
    connector_service_binary as teams_connector_service_binary,
    connector_service_name as teams_connector_service_name,
    connector_service_status as teams_connector_service_status,
    connector_service_unit as teams_connector_service_unit,
    install_connector_service as install_teams_connector_service,
    install_service as install_teams_service, service_status as teams_service_status,
    service_unit as teams_service_unit, teams_entry, teams_home,
    uninstall_connector_service as uninstall_teams_connector_service,
    uninstall_service as uninstall_teams_service, write_unit as write_teams_unit, TeamsError,
    SERVICE_DIR as TEAMS_SERVICE_DIR, SERVICE_NAME as TEAMS_SERVICE_NAME, TEAMS_ENTRY,
    TEAMS_PACKAGE,
};
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};
#[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::{
    DetachedAnswer, DetachedCall, HarnessSessionService, OpenedRuntime, ReturnedRuntime,
    RuntimeOpen, DETACHED_CALL_DEADLINE, DETACHED_METHODS, HARNESS_SERVICE_VERSION,
    RUNTIME_CONTROL_DEADLINE, RUNTIME_EVENT_METHOD, RUNTIME_OPEN_DEADLINE, RUNTIME_OPEN_METHODS,
    SESSION_ACTIVITY_EVENT_METHOD, SESSION_DISCOVER_DEADLINE, SESSION_EVENT_METHOD,
    SESSION_INDEX_EVENT_METHOD,
};
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_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 supercode_interchange::session::{
    CrossSurface, OrchestrationNouns, Recurrence, Session, SessionFormat, SessionMeta,
    SessionSource, SurfaceKey, Trigger, WorkspaceKind, WorkspaceRef,
};
pub use supercode_interchange::watch::{SessionFollower, SessionSnapshotReason, SessionWatchEvent};
pub use supercode_interchange::{
    core_messages, measure_fidelity, messages_equal, messages_equal_multimodal, replay_eligible,
    Fidelity, FidelityMetric, FidelityResidue,
};
pub use supercode_interchange::{
    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 supercode_runtime::{AgentEvent, EventSink};
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,
};

/// The checkout this binary was built from, when it runs as a build of it. An installed binary (one inside a
/// `node_modules`, where npm and a local install place it) never reads it: on the machine that built it the checkout
/// still exists, and its source tree would resolve its packages against whatever `node_modules` sits above it.
pub fn build_checkout() -> Option<std::path::PathBuf> {
    let exe = std::env::current_exe().ok()?;
    if exe
        .ancestors()
        .any(|dir| dir.file_name().is_some_and(|name| name == "node_modules"))
    {
        return None;
    }
    std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
        .ancestors()
        .nth(2)
        .map(std::path::Path::to_path_buf)
}