repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

smith-core/src/lib.rs

Raw
File outline
//! Provider-independent Smith agent core.
//!
//! Session persistence, CBOR framing, configurable runtime, replay traces,
//! and tool lifecycle events.

#![forbid(unsafe_code)]

/// Provider-independent agent loop.
pub mod agent;
/// Bounded, cancellable shell execution.
pub mod bash;
/// Checksummed session framing.
pub mod frame;
/// Branching session state.
pub mod session;
/// Durable session storage.
pub mod store;
/// Tool registry, validation, and recorded effects.
pub mod tools;
/// Provider-free replay evidence.
pub mod trace;

pub use agent::{
    Agent, AgentEvent, CompactionSummary, Delivery, QueuedInput, SecretProxy, TurnOutcome,
};
pub use bash::{BashResult, execute};
pub use frame::{Frame, Recovery, encode_entry, read_frames, write_frame};
pub use session::{
    Branch, COMPACTION_KIND, Entry, EntryContent, EntryContentRef, EntryFrame, EntryKind, Session,
    SessionHeader, Span,
};
pub use store::{
    OpenSession, SessionWriter, create_session, fork_session, load_session, open_session,
    repair_session,
};
pub use tools::{ToolOutcome, ToolRegistry, ToolSession};
pub use trace::{TraceKind, TraceRecord, replay};

#[cfg(test)]
mod tests {
    use super::*;
    use smith::message::{Message, Role};

    #[test]
    fn session_creates_and_appends() {
        let mut session = Session::new();
        let msg = Message::with_text(Role::User, "hello");
        let entry = *session.append(&EntryContent::Message(msg)).unwrap();
        assert_eq!(session.active_branch().entries(), vec![entry]);
        assert_eq!(session.selected_id(), Some(entry.id));
    }
}