Skip to main content

everruns_contracts/
lib.rs

1#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
2//! Shared contracts for the [Everruns](https://everruns.com) framework and hosts.
3//!
4//! Provider and driver boundaries, capability definitions, model profiles,
5//! typed IDs, and shared runtime contracts live here. The default build omits
6//! HTTP transport; enable `http` for the shared protocol drivers and clients.
7//! Application authors normally use the same types through `everruns`.
8//!
9//! ```
10//! use everruns_contracts::{CapabilityRef, ModelSpec};
11//! let model = ModelSpec::on("company-gateway", "assistant-v2");
12//! let capability = CapabilityRef::new("vendor.search");
13//! assert_eq!(model.provider.as_str(), "company-gateway");
14//! assert_eq!(capability.id(), "vendor.search");
15//! ```
16
17/// Capability identity, configuration, and code-defined authoring.
18// Lets moved runtime code and its doctests name this crate by its package name.
19extern crate self as everruns_contracts;
20
21pub mod capability;
22/// Model profile metadata and the offline registry, keyed by provider wire ID.
23pub mod model_profile_data;
24#[cfg(feature = "runtime")]
25pub mod runtime;
26
27#[cfg(feature = "definition")]
28pub use async_trait::async_trait;
29pub use capability::{
30    ActivationSet, CapabilityError, CapabilityId, CapabilityIdIndex, CapabilityRef, CapabilitySpec,
31    CapabilitySpecParts, GENERIC_HARNESS_NAME, IntoCapability, PLUGIN_CAPABILITY_PREFIX,
32    RESERVED_CAPABILITY_ID_NAMESPACE, generic_capabilities, is_plugin_capability,
33    parse_plugin_capability_id, plugin_capability_id, validate_capability_config,
34    validate_capability_id,
35};
36#[cfg(feature = "definition")]
37pub use capability::{Definition, json_schema_for};
38#[cfg(feature = "definition")]
39pub use schemars;
40pub use serde;
41pub use serde_json;
42
43pub mod background_call;
44pub mod compact;
45pub mod credential_provider;
46pub mod credential_schema;
47#[cfg(feature = "http")]
48pub mod driver_helpers;
49mod driver_oauth;
50pub mod driver_registry;
51pub mod error;
52pub mod execution_phase;
53pub mod form_elicitation_types;
54pub mod hosted_mcp;
55mod llm_call_config_builder;
56pub mod llm_error;
57pub mod llm_retry;
58pub mod llm_telemetry;
59pub mod message;
60pub mod model;
61pub mod model_discovery;
62pub mod model_profiles;
63pub mod model_spec;
64pub mod native_async;
65pub mod native_computer;
66pub mod openai_compat;
67pub mod openai_computer;
68#[cfg(feature = "http")]
69pub mod openai_errors;
70pub mod openai_hosted_tools;
71#[cfg(feature = "http")]
72mod openai_message_convert;
73#[cfg(feature = "http")]
74pub mod openai_protocol;
75#[cfg(feature = "http")]
76mod openai_types;
77pub mod openai_wire;
78#[cfg(feature = "http")]
79pub mod openresponses_protocol;
80pub mod openresponses_types;
81pub mod provider;
82mod provider_managed;
83pub mod reasoning;
84pub mod rt;
85pub mod runtime_provider;
86pub mod secret_scrub;
87pub mod stream_accumulator;
88mod stream_error;
89pub mod stream_event;
90#[cfg(feature = "http")]
91pub mod stream_reconnect;
92pub mod structured_output;
93pub mod tool_approval_types;
94pub mod tool_schema_compat;
95pub mod tool_types;
96pub mod turn_collector;
97pub mod typed_id;
98pub mod url_validation;
99pub mod user_facing_error;
100
101// ============================================================================
102// Convenience root re-exports
103//
104// These root exports are the canonical low-level provider API. `everruns-core`
105// consumes a narrow subset privately and deliberately does not mirror them.
106// ============================================================================
107
108pub use compact::{
109    CompactContent, CompactContentPart, CompactInputItem, CompactOutputItem, CompactRequest,
110    CompactResponse, CompactUsage, messages_to_compact_input,
111};
112pub use credential_provider::{CredentialProvider, EnvCredentialProvider, ProviderCredentials};
113pub use credential_schema::{
114    CredentialFormSchema, assemble_credential_document, parse_credential_document,
115};
116pub use driver_registry::{
117    BoxedChatDriver, BoxedEmbeddingsDriver, ChatDriver, DiscoveredModel, DriverDescriptor,
118    DriverFactory, DriverId, DriverOAuthConfig, DriverOAuthFlow, DriverRegistry, EmbedRequest,
119    EmbedResponse, EmbeddingsDriver, EmbeddingsDriverError, EmbeddingsDriverFactory, LlmCallConfig,
120    LlmCallConfigBuilder, LlmCompletionMetadata, LlmContentPart, LlmResponse, LlmResponseStream,
121    LlmStreamError, LlmStreamEvent, Message, MessageContent, MessageRole, ProviderConfig,
122    ProviderMetadata, ProviderOpaqueContext, ServiceKind, fold_system_messages,
123};
124// Pre-0.31 names, kept as deprecated aliases.
125pub use error::{
126    AgentLoopError, BillingPressureReason, FileSystemError, FileSystemErrorClass, LlmError,
127    LlmErrorKind, Result, StoreResultExt, classify_fs_error, from_json, json_val,
128};
129pub use execution_phase::{ExecutionPhase, PhaseSource};
130pub use llm_error::RejectedProviderCapability;
131pub use llm_retry::{LlmRetryConfig, RateLimitInfo, RateLimitType, RetryMetadata};
132pub use message::ProviderOpaqueContent;
133#[allow(deprecated)]
134pub use message::{LlmMessage, LlmMessageContent, LlmMessageRole};
135pub use model::{
136    CostTier, Modality, ModelCost, ModelLimits, ModelModalities, ModelProfile, ModelVendor,
137    ReasoningEffort, ReasoningEffortConfig, ReasoningEffortValue,
138};
139#[cfg(feature = "http")]
140pub use model_discovery::list_openai_compatible_models;
141pub use model_discovery::{
142    DiscoveredProviderModel, ModelSearchMatch, ModelSearchResult, RankedDiscoveredModels,
143    discover_provider_models, enrich_with_profiles, match_models, normalize_and_enrich,
144    rank_discovered_models, search_provider_models,
145};
146pub use model_profiles::{
147    ModelProfileEntry, all_profile_entries, all_profiles, get_model_profile, get_model_vendor,
148    profile_entries_for_provider, profiles_for_provider, selected_profiles,
149    selected_profiles_for_provider,
150};
151pub use model_spec::{ModelSpec, UnknownProvider};
152#[cfg(feature = "http")]
153pub use openai_protocol::OpenAIProtocolChatDriver;
154pub use openai_wire::OpenAiWireError;
155#[cfg(feature = "http")]
156pub use openresponses_protocol::{
157    OPENAI_BACKGROUND_OPTION, OPENAI_WEBSOCKET_OPTION, OpenResponsesProtocolChatDriver,
158    OpenResponsesRequestExtension,
159};
160pub use provider::ProviderTraceConfig;
161pub use reasoning::{ReasoningContentPart, ReasoningText};
162pub use runtime_provider::{
163    BearerAuth, Provider, ProviderAuth, ProviderAuthRequest, ProviderEndpoint, ProviderKey,
164    ProviderRegistry, ResolvedProviderRequest, RuntimeProvider, RuntimeProviderRegistry,
165    StaticHeaderAuth,
166};
167pub use tool_approval_types::{
168    APPROVE_TOOL_CALL_TOOL, TOOL_APPROVAL_CALL_ID_PREFIX, TOOL_APPROVAL_REQUIRED_CODE,
169    TOOL_ARGUMENTS_PREVIEW_BYTES, ToolApprovalRequired, preview_tool_arguments,
170};
171pub use tool_types::{
172    ASK_USER_TOOL_NAME, BuiltinTool, CONFIRM_URL_ELICITATION_TOOL, ClientSideTool,
173    ConnectionRequired, ConnectionRequiredSubject, DeferrablePolicy,
174    FORM_ELICITATION_CALL_ID_PREFIX, FORM_ELICITATION_REQUIRED_CODE, FormElicitationRequired,
175    MCP_ELICITATION_ARGUMENT, SideEffectClass, ToolCall, ToolDefinition, ToolHints, ToolPolicy,
176    ToolResult, ToolResultImage, URL_ELICITATION_REQUIRED_CODE, UrlElicitationRequired,
177    unattended_ask_user_result,
178};
179pub use turn_collector::{CollectedTurn, TurnLimits, TurnTiming, collect_turn, limit_stream};
180pub use url_validation::{
181    UrlValidationError, is_blocked_ip, validate_safe_url, validate_url_dns_pinned,
182};
183pub use user_facing_error::{
184    ErrorDisclosure, UserFacingError, UserFacingErrorContext, UserFacingErrorFields,
185    classify_runtime_error_message, codes as user_facing_error_codes, is_provider_quota_message,
186    is_usage_limit_message, metadata_keys as user_facing_error_metadata_keys,
187    parse_usage_limit_reset_at, trim_error_chain_prefixes,
188};
189
190/// Select the workspace crypto backend as the process-wide rustls provider.
191///
192/// The backend is a build-time choice — the workspace standardises on
193/// `aws-lc-rs` (EVE-924), so only one is ever linked. Products still call this
194/// once during startup, before constructing TLS clients, because rustls refuses
195/// to pick a default implicitly when a crate in the graph could install another.
196/// Repeated and concurrent calls are safe: rustls accepts the first
197/// installation and later calls are no-ops.
198#[cfg(feature = "tls-aws-lc-rs")]
199pub fn install_default_crypto_provider() {
200    let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
201}
202
203pub mod reasoning_updates;
204
205pub mod connector;
206pub mod knowledge_store;
207pub mod session_sqldb;
208pub mod vector_store;
209
210pub mod sandbox_checkpoint;
211pub mod session_sandbox;
212pub mod tools;
213
214/// Session-bound Slack effects; credentials stay with the control plane.
215pub mod slack_action;
216
217pub mod decision_driver;
218pub mod decisions;