Skip to main content

Crate bob_core

Crate bob_core 

Source
Expand description

§Bob Core

Domain types and port traits for the Bob Agent Framework.

§Overview

This crate defines the hexagonal boundary of the Bob Agent Framework using the ports and adapters (hexagonal) architecture pattern. It contains:

  • Domain Types: Core data structures used throughout the framework
  • Port Traits: Abstract interfaces that adapters must implement
  • Error Types: Comprehensive error definitions for all components

No concrete implementations live here — only contracts.

§Architecture

The crate defines four primary port traits:

  1. ports::LlmPort - Interface for language model interactions
  2. ports::ToolPort - Interface for tool/system operations
  3. ports::SessionStore - Interface for session state persistence
  4. ports::EventSink - Interface for event observation and logging

§Example

use bob_core::{
    ports::LlmPort,
    types::{LlmRequest, LlmResponse},
    error::LlmError,
};
use async_trait::async_trait;

struct MyCustomLlm;

#[async_trait]
impl LlmPort for MyCustomLlm {
    async fn complete(&self, req: LlmRequest) -> Result<LlmResponse, LlmError> {
        // Your implementation here
        todo!("implement LLM completion")
    }

    async fn complete_stream(&self, req: LlmRequest) -> Result<LlmStream, LlmError> {
        // Your implementation here
        todo!("implement streaming completion")
    }
}

§Features

  • Zero-cost abstractions: All traits use async_trait for async support
  • Type-safe: Strong typing throughout with comprehensive error handling
  • Serializable: All domain types implement serde::Serialize and Deserialize
  • Thread-safe: All traits require Send + Sync

Re-exports§

pub use character::Character;
pub use error::AgentError;
pub use error::CostError;
pub use error::LlmError;
pub use error::StoreError;
pub use error::ToolError;
pub use error_classifier::FailoverConfig;
pub use error_classifier::FailoverResult;
pub use error_classifier::classify_agent_error;
pub use error_classifier::classify_llm_error;
pub use instrumenter::Instrumenter;
pub use instrumenter::ModelErrorInfo;
pub use instrumenter::ModelRequestInfo;
pub use instrumenter::ModelResponseInfo;
pub use instrumenter::NoopInstrumenter;
pub use instrumenter::OutputValidationErrorInfo;
pub use instrumenter::RunEndInfo;
pub use instrumenter::RunErrorInfo;
pub use instrumenter::RunStartInfo;
pub use instrumenter::ToolCallInfo;
pub use instrumenter::ToolDiscoveredInfo;
pub use instrumenter::ToolEndInfo;
pub use instrumenter::ToolErrorInfo;
pub use journal::JournalEntry;
pub use journal::ToolJournalPort;
pub use native::NativeLlmPort;
pub use native::NativeSessionStore;
pub use native::NativeToolPort;
pub use ports::AccessControlPort;
pub use ports::ActivityJournalPort;
pub use ports::ApprovalPort;
pub use ports::ArtifactStorePort;
pub use ports::CostMeterPort;
pub use ports::EventSink;
pub use ports::LlmPort;
pub use ports::MessageBusPort;
pub use ports::SessionStore;
pub use ports::SubagentPort;
pub use ports::TapeStorePort;
pub use ports::ToolCatalogPort;
pub use ports::ToolExecutorPort;
pub use ports::ToolPolicyPort;
pub use ports::ToolPort;
pub use ports::TurnCheckpointStorePort;
pub use resilience::CircuitBreaker;
pub use resilience::CircuitBreakerConfig;
pub use resilience::CircuitBreakerError;
pub use resilience::CircuitState;
pub use resilience::ComponentHealth;
pub use resilience::HealthStatus;
pub use resilience::RetryConfig;
pub use tool_policy::intersect_allowlists;
pub use tool_policy::is_tool_allowed;
pub use tool_policy::merge_allowlists;
pub use tool_policy::normalize_tool_list;
pub use tool_policy::tools_match;
pub use typed_tool::ChainedToolPorts;
pub use typed_tool::Complete;
pub use typed_tool::Described;
pub use typed_tool::FilteredToolPort;
pub use typed_tool::Incomplete;
pub use typed_tool::ToolKind;
pub use typed_tool::ToolPortExt;
pub use typed_tool::ToolSource;
pub use typed_tool::TypedToolAdapter;
pub use typed_tool::TypedToolBuilder;
pub use typed_tool::TypedToolExt;
pub use typed_tool::TypedToolPort;
pub use types::*;

Modules§

channel
Channel Abstraction
character
Character / Persona Model
error
Error Types
error_classifier
Error Classifier
instrumenter
Instrumenter Trait
journal
Tool Call Journal
native
Native Async Port Traits
ports
Port Traits
resilience
Resilience Patterns
secrets
Secrets Management
tape
Tape Types
tool_policy
Tool policy helpers shared across runtime and adapter layers.
typed_tool
Typed Tool Abstractions
types
Domain Types