Skip to main content

auth_cloudflare/
lib.rs

1//! auth-cloudflare - Cloudflare Workers AI auth provider core.
2//!
3//! Account/token resolution, Workers AI endpoint construction, model catalog
4//! normalization types, and account-scoped cache path helpers. The Hermes
5//! integration crate (`auth-hermes-cloudflare`) and the Python plugin both
6//! build on this crate so the endpoint/auth logic has exactly one source of
7//! truth.
8//!
9//! Scope: direct Cloudflare-hosted `@cf/...` Workers AI text-generation
10//! models over the OpenAI-compatible Chat Completions surface. AI Gateway
11//! third-party models, non-chat modalities, and Cloudflare MCP operations are
12//! explicitly out of scope for this package.
13
14pub mod auth;
15pub mod cache;
16pub mod capabilities;
17pub mod catalog;
18pub mod config;
19pub mod error;
20pub mod fallback_catalog;
21pub mod fetch;
22pub mod health;
23pub mod observability;
24pub mod policy;
25pub mod schema;
26pub mod tool_loop;
27pub mod verify;
28
29pub use auth::{AccountCredentials, AuthProvider};
30pub use cache::{cache_dir_for_account, cache_is_stale, read_catalog_cache, write_catalog_cache, CatalogCacheMeta};
31pub use capabilities::infer_from_id;
32pub use catalog::{CapabilityState, ModelRecord, ModelRole};
33pub use error::CloudflareError;
34pub use fallback_catalog::{experimental_models, fallback_models};
35pub use health::{
36	CONFORMANCE_SUITE_VERSION, FailureClass, FailureEvidence, ModelHealthRecord, ModelVerification,
37	VerificationConfidence, VerificationStatus,
38};
39pub use observability::{
40	debug_protocol_enabled, redact, Event, EventLog, DEBUG_PROTOCOL_ENV, EVENT_LOG_ENV, OBSERVABILITY_ENV,
41};
42pub use policy::{
43	ranking_score, ModelPolicy, ModelStatus, PolicyEntry, RankingBreakdown, REFERENCE_CONTEXT_TOKENS,
44	REFERENCE_LATENCY_MS, REFERENCE_PRICE_PER_MILLION, WEIGHT_CONTEXT, WEIGHT_DELIVERY, WEIGHT_LATENCY, WEIGHT_PRICE,
45	WEIGHT_TOOL_LOOP,
46};
47pub use schema::{VersionInfo, CATALOG_SCHEMA_VERSION, PROTOCOL_VERSION};
48pub use tool_loop::{
49	all_arguments_valid, execute_tool, find_duplicates, fixture_source, run_tool_loop, tool_schemas, validate_ordering,
50	ToolCallObservation, ToolLoopOutcome, TOOL_LOOP_MAX_TURNS, TOOL_LOOP_SYSTEM_PROMPT, TOOL_LOOP_USER_PROMPT,
51};
52pub use verify::{HealthStore, SmokeRunReport, SuiteKind, MAX_COST_ENV};
53
54/// crate version, from Cargo.toml.
55pub const VERSION: &str = env!("CARGO_PKG_VERSION");
56
57/// Default inference model - the project's development default.
58///
59/// DeepSeek V4 Flash is the default because it has demonstrated reliable
60/// delivery in the local Hermes tool-use workflow. GLM-5.3 Flash remains
61/// available but is experimental pending conformance tests.
62///
63/// Single source of truth: adapters MUST read this (or the policy JSON
64/// contract), never duplicate it.
65pub const DEFAULT_MODEL: &str = "@cf/deepseek-ai/deepseek-v4-flash-0731";
66
67/// Premium coding model (higher capability tier).
68pub const PREMIUM_CODING_MODEL: &str = "@cf/moonshotai/kimi-k2.7-code";
69
70/// Premium reasoning model (higher capability tier).
71pub const PREMIUM_REASONING_MODEL: &str = "@cf/deepseek-ai/deepseek-v4-pro-0813";
72
73/// Experimental model - available but not default (delivery reliability not
74/// yet validated; requires passing conformance suite).
75pub const EXPERIMENTAL_MODEL: &str = "@cf/zai-org/glm-5.3-flash";