supercode-interchange 0.5.22

Canonical, provider-neutral session interchange primitives for Volter Harness
Documentation
//! Provider-neutral canonical data for coding-agent session interchange.
//!
//! This crate is the dependency base for Volter Harness's translators, optional
//! reversible reducer, and optional native runtime. During the compatibility
//! migration it first owns canonical messages and their deterministic token
//! estimates; session containers and native codecs move here next without
//! changing their public shapes.

#![warn(missing_docs)]

pub mod catalog;
mod error;
mod message;
mod native_store;
pub mod ontology;
pub mod orchestration;
pub mod session;
pub mod session_tree;
pub mod sidecar;
mod token_estimator;
pub mod watch;
pub mod workflow;

pub use catalog::{
    CodexHistoryTopicIndex, DiscoveryPage, DiscoveryQuery, HarnessCatalog, HarnessHomes, HarnessId,
    SessionDescriptor, SessionLocator, SessionPreviewCandidate, StorageLocator,
};
pub use error::{InterchangeError, InterchangeError as Error, Result};
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,
};
#[doc(hidden)]
pub use native_store::load_native_store_family;
pub use ontology::{
    core_messages, measure_fidelity, messages_equal, messages_equal_multimodal, replay_eligible,
    replay_excluded, ArtifactFidelity, Binding, EndReason, Fidelity, FidelityMetric,
    FidelityResidue, OrchestrationCodec, Residue, SecretRef, Vault,
};
pub use session::{
    CrossSurface, OrchestrationNouns, Recurrence, Session, SessionFormat, SessionMeta,
    SessionSource, SurfaceKey, Trigger, WorkspaceKind, WorkspaceRef,
};
pub use token_estimator::{estimate_tokens, estimate_view_tokens, format_commas};
pub use watch::{SessionFollower, SessionSnapshotReason, SessionWatchEvent};

/// This user's home directory: `HOME` when it is set (every Unix shell, and the
/// shells that set it on Windows), else the operating system's own
/// (`USERPROFILE` on Windows). Where a harness keeps its sessions under the
/// user's home (`~/.claude`, `~/.codex`), this is that home on every platform.
pub fn user_home() -> Option<std::path::PathBuf> {
    std::env::var_os("HOME")
        .filter(|home| !home.is_empty())
        .map(std::path::PathBuf::from)
        .or_else(|| {
            #[allow(deprecated)]
            std::env::home_dir()
        })
}

#[cfg(test)]
mod user_home_tests {
    /// v0.5.8's `user_home` called itself and overflowed the stack on every call.
    #[test]
    fn user_home_returns_instead_of_recursing() {
        let _ = super::user_home();
    }
}