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:
ports::LlmPort- Interface for language model interactionsports::ToolPort- Interface for tool/system operationsports::SessionStore- Interface for session state persistenceports::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_traitfor async support - Type-safe: Strong typing throughout with comprehensive error handling
- Serializable: All domain types implement
serde::SerializeandDeserialize - Thread-safe: All traits require
Send + Sync
§Related Crates
bob_runtime- Runtime orchestration layerbob_adapters- Concrete adapter implementations
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