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 error::AgentError;
pub use error::CostError;
pub use error::LlmError;
pub use error::StoreError;
pub use error::ToolError;
pub use ports::ApprovalPort;
pub use ports::ArtifactStorePort;
pub use ports::CostMeterPort;
pub use ports::EventSink;
pub use ports::LlmPort;
pub use ports::SessionStore;
pub use ports::ToolCatalogPort;
pub use ports::ToolExecutorPort;
pub use ports::ToolPolicyPort;
pub use ports::ToolPort;
pub use ports::TurnCheckpointStorePort;
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 types::*;

Modules§

error
Error Types
ports
Port Traits
tool_policy
Tool policy helpers shared across runtime and adapter layers.
types
Domain Types