Skip to main content

trusty_code/provider/
mod.rs

1//! Provider abstraction and per-agent model routing.
2//!
3//! Why: trusty-code routes each agent to its own model, which may live behind
4//! different backends (OpenRouter today, AWS Bedrock later). The agent loop must
5//! not branch on the backend; it depends on the [`Provider`] trait and asks a
6//! factory for the right implementation given a model slug. This module is that
7//! seam (#1021) and the precedence resolver for which slug to use.
8//! What: Re-exports the [`Provider`] trait and [`ToolChoice`] enum, the five
9//! concrete providers ([`OpenRouterProvider`], [`BedrockProvider`],
10//! [`FireworksProvider`], [`TogetherProvider`], [`AtlasCloudProvider`]), the
11//! [`provider_for`] factory, the [`resolve_model`] precedence function plus
12//! its [`DEFAULT_MODEL`] constant, the [`resolve_max_tokens`] precedence
13//! function plus its [`DEFAULT_MAX_TOKENS`] constant, and (#2207) the
14//! [`resolve_deadline_secs`] precedence function plus its
15//! [`DEFAULT_RUN_DEADLINE_SECS`] constant and [`RUN_DEADLINE_ENV_VAR`] name,
16//! and (#2308) the [`resolve_context_window`] precedence function plus its
17//! [`DEFAULT_CONTEXT_WINDOW`] constant.
18//! Test: submodule `tests` in each file; routing/adapter coverage in
19//! `routing.rs` and `adapter.rs`.
20
21mod adapter;
22mod atlascloud;
23mod bedrock;
24mod fireworks;
25mod openrouter;
26mod routing;
27mod together;
28mod traits;
29
30pub use adapter::provider_for;
31pub use atlascloud::AtlasCloudProvider;
32pub use bedrock::BedrockProvider;
33pub use fireworks::FireworksProvider;
34pub use openrouter::OpenRouterProvider;
35pub use routing::{
36    DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_TOKENS, DEFAULT_MODEL, DEFAULT_RUN_DEADLINE_SECS,
37    RUN_DEADLINE_ENV_VAR, resolve_context_window, resolve_deadline_secs, resolve_max_tokens,
38    resolve_model,
39};
40pub use together::TogetherProvider;
41pub use traits::{Provider, ToolChoice};