ailoop_core/lib.rs
1//! Foundation crate for the `ailoop` workspace: shared vocabulary used
2//! by the `ailoop` façade and by every adapter / middleware crate.
3//!
4//! Most application code does not depend on `ailoop-core` directly —
5//! it depends on `ailoop`, which re-exports the types you need to
6//! build a `Conversation` and write a [`ChatMiddleware`]. Reach for
7//! `ailoop-core` when:
8//!
9//! - implementing a new [`CompletionModel`] / [`CompletionClient`]
10//! adapter for a provider HTTP API;
11//! - writing a generic middleware that should be reusable across
12//! façades, examples, or test harnesses;
13//! - building reliability or observability infrastructure on top of
14//! the shared event vocabulary.
15//!
16//! ## Layout
17//!
18//! - [`Message`], [`UserBlock`], [`AssistantBlock`],
19//! [`ToolResultContent`], [`SystemPrompt`] — the wire model
20//! exchanged between the engine and the provider.
21//! - [`ChatRequest`], [`ToolDefinition`], [`ToolChoice`], [`ToolTag`]
22//! — the per-turn request shape adapters lower to the provider.
23//! - [`StreamChunk`], [`FinishReason`], [`Usage`] — the event stream
24//! the engine emits for every run.
25//! - [`ChatMiddleware`], [`HookAction`], [`ToolDecision`] — the
26//! extension point for transforms, gating, and observation.
27//! - [`CompletionClient`], [`CompletionModel`] — the contract every
28//! provider adapter implements.
29//! - [`RetryingModel`], [`Retryable`], [`RetryConfig`] — backoff
30//! decorator that wraps any [`CompletionModel`].
31
32#![deny(missing_docs)]
33
34pub mod config;
35pub mod ids;
36pub mod message;
37pub mod middleware;
38pub mod request;
39pub mod retry;
40pub mod stream;
41#[cfg(any(test, feature = "testing"))]
42pub mod testing;
43mod tokenizer;
44mod traits;
45
46pub use config::RunConfig;
47pub use ids::{RunId, StepId};
48pub use message::{
49 AssistantBlock, CacheControl, Message, Source, SystemBlock, SystemPrompt, ToolResultBlock,
50 ToolResultContent, UserBlock,
51};
52pub use middleware::{ChatMiddleware, HookAction, ToolDecision};
53pub use request::{ChatRequest, ToolChoice, ToolDefinition, ToolTag};
54pub use retry::{RetryClassification, RetryConfig, Retryable, RetryingModel};
55pub use stream::{FinishReason, StreamChunk, Usage};
56pub use tokenizer::{CharTokenizer, Tokenizer};
57pub use traits::{CompletionClient, CompletionModel};
58
59pub use tokio_util::sync::CancellationToken;