flashmind-types 0.3.0

Shared types for the Flashmind AI agent framework
Documentation
//! Shared types for the Flashmind AI agent framework.
//!
//! This crate defines the traits, wire types, and event structures shared by all
//! Flashmind crates. It is the foundation that both library consumers and provider
//! implementations depend on.
//!
//! # Core traits
//!
//! | Trait | Purpose |
//! |-------|---------|
//! | [`LlmProvider`] | Streaming completions from any LLM backend |
//! | [`Tool`] | Function-calling tools the agent can invoke |
//! | [`MemoryProvider`] | Store/search/forget long-term memories |
//!
//! # Modules
//!
//! | Module | Types |
//! |--------|-------|
//! | [`event`] | [`AgentEvent`], [`AgentInput`], [`TurnStatus`], [`TurnUsage`] — telemetry |
//! | [`llm`] | [`LlmProvider`], [`CompletionRequest`], [`StreamEvent`], [`FinishReason`] |
//! | [`memory`] | [`MemoryEntry`], [`MemoryMetadata`], [`MemoryProvider`] |
//! | [`message`] | [`Message`], [`Role`], [`ToolCall`], [`ContentPart`] — LLM wire format |
//! | [`model`] | [`Model`], [`Provider`], [`SamplingParams`], [`ReasoningLevel`] |
//! | [`tool`] | [`Tool`], [`ToolRegistry`], [`ToolContext`], [`ToolResult`](tool::ToolResult) |
//! | [`stream`] | [`AgentStream`], [`Outcome`] — stream-with-final-result pattern |
//! | [`utils`] | UTF-8-safe string truncation helpers |
//!
//! # Example: implementing a provider
//!
//! ```rust
//! use async_trait::async_trait;
//! use flashmind_types::{
//!     CompletionRequest, CompletionStream, LlmProvider, Provider, StreamEvent, FinishReason,
//! };
//!
//! struct MyProvider;
//!
//! #[async_trait]
//! impl LlmProvider for MyProvider {
//!     fn name(&self) -> &str { "my-provider" }
//!     fn provider(&self) -> Provider { Provider::OpenAi }
//!
//!     fn complete(&self, _request: CompletionRequest) -> CompletionStream {
//!         Box::pin(async_stream::stream! {
//!             yield Ok(StreamEvent::ContentDelta("Hello!".into()));
//!             yield Ok(StreamEvent::Finished(FinishReason::Stop));
//!         })
//!     }
//! }
//! ```

pub mod credits;
pub mod error;
pub mod event;
pub mod humanize;
pub mod interaction_mode;
pub mod llm;
pub mod memory;
pub mod message;
pub mod model;
pub mod reasoning;
pub mod session;
pub mod stream;
pub mod tool;
pub mod utils;
pub use credits::{CreditBalance, CreditScope, CreditUnit};
pub use error::{LlmError, LlmErrorKind, ParseError};
pub use event::{
    AgentEvent, AgentInput, CompactionReason, Source, TurnResult, TurnStatus, TurnUsage,
};
pub use interaction_mode::InteractionMode;
pub use llm::{
    AudioFormat, AudioOutputConfig, CompletionRequest, CompletionResponse, CompletionStream,
    FinishReason, FrameImage, ImageEditRequest, ImageGenConfig, ImageGenRequest, ImageOutputFormat,
    LlmProvider, Modality, ModelCapabilities, ModelCategory, ModelInfo, ModelPricing,
    NativeCompaction, ProviderRegistry, StreamEvent, SttRequest, TokenUsage, ToolDefinition,
    TtsRequest, VideoGenRequest, Voice, mime_from_extension,
};
pub use memory::{MemoryEntry, MemoryMetadata, MemoryProvider};
pub use message::{ContentPart, Message, Role, ToolCall, ToolResult};
pub use model::{
    AgentLlmConfig, AliasedModel, Model, Provider, ProviderPreferences, ProviderSort, Quantization,
    ReasoningLevel, SamplingParams,
};
pub use reasoning::{NativeReasoningFormat, ReasoningDetails};
pub use session::{SessionId, SessionIdError, SessionUsage};
pub use stream::{AgentStream, Outcome};
pub use tool::{
    ForbiddenCmd, GateAnswer, GateAsk, GateDecision, Tool, ToolContext, ToolGate, ToolRegistry,
};

/// Minimum length for a secret value to be redacted from output.
///
/// Secrets shorter than this are left as-is to avoid false positives.
pub const MIN_SECRET_REDACT_LEN: usize = 8;