Skip to main content

systemprompt_models/
lib.rs

1//! Foundation data models for systemprompt.io.
2//!
3//! `systemprompt-models` is the shared `shared/*` crate that every
4//! other layer (`infra`, `domain`, `app`, `entry`) depends on for the
5//! plain DTO and configuration shapes that flow across the system.
6//! It owns the wire types of the public HTTP API, the on-disk profile
7//! and services configuration, the A2A and AG-UI protocol shapes, the
8//! MCP metadata helpers, and the typed error enums returned by every
9//! public function in this crate.
10//!
11//! # Module map
12//!
13//! - [`a2a`] — A2A protocol agent card, message, task, and transport types.
14//! - [`agui`] — AG-UI streaming event protocol.
15//! - [`ai`] — LLM request/response shapes plus the [`ai::AiProvider`] trait.
16//! - [`api`] — public HTTP envelopes, error model, pagination, cloud DTOs.
17//! - [`artifacts`] — typed tool-result artifacts.
18//! - [`auth`] — authenticated user, permission, audience, and PKCE types.
19//! - [`config`] — global [`config::Config`] singleton and validation helpers.
20//! - [`content`], [`content_config`] — published content metadata.
21//! - [`errors`] — `thiserror`-derived public error enums.
22//! - [`events`] — analytics, A2A and system event envelopes.
23//! - [`execution`] — request context and execution-step bookkeeping.
24//! - [`extension`] — extension framework manifest types.
25//! - [`mcp`] — MCP protocol metadata helpers.
26//! - [`modules`] — module manifest tree resolution.
27//! - [`oauth`] — OAuth client / server config shapes.
28//! - [`paths`] — well-known directory layout helpers.
29//! - [`profile`] — on-disk profile and bootstrap configuration.
30//! - [`repository`] — repository lifecycle traits and value objects.
31//! - [`routing`] — request routing classification.
32//! - [`secrets`] — secrets document model.
33//! - [`services`] — services manifest (agents, plugins, hooks, MCP, …).
34//! - [`users`] — public user / session summaries.
35//! - [`validators`] — startup configuration validation passes.
36//! - [`wire`] — canonical AI wire types and per-protocol codecs (gateway +
37//!   agent clients).
38//!
39//! # Feature flags
40//!
41//! | Feature | Effect |
42//! | ------- | ------ |
43//! | _default_ | All public DTOs and traits, no axum integration. |
44//! | `web` | Adds `axum::IntoResponse` impls for the API envelopes. |
45//! | `sqlx` | Derives `sqlx::Type` on DB-persisted enums (e.g. [`ContextKind`]). |
46//!
47//! Public functions return `thiserror`-derived enums from [`errors`];
48//! `anyhow::Error` is never used in a public signature.
49
50pub mod macros;
51
52pub mod a2a;
53pub mod admin;
54pub mod agui;
55pub mod ai;
56pub mod api;
57pub mod artifacts;
58pub mod auth;
59pub mod bridge;
60pub mod config;
61pub mod content;
62pub mod content_config;
63pub mod env;
64pub mod errors;
65pub mod events;
66pub mod execution;
67pub mod extension;
68pub mod gateway_hash;
69pub mod mcp;
70pub mod modules;
71pub mod net;
72pub mod oauth;
73pub mod paths;
74pub mod profile;
75pub mod repository;
76pub mod routing;
77pub mod schema;
78pub mod secrets;
79pub mod services;
80pub mod subprocess;
81pub mod text;
82pub mod time_format;
83pub mod users;
84pub mod validators;
85pub mod wire;
86
87pub use a2a::{
88    AgentAuthentication, AgentCapabilities, AgentCard, AgentCardBuilder, AgentCardSignature,
89    AgentExtension, AgentInterface, AgentProvider, AgentSkill, ApiKeyLocation,
90    Artifact as A2aArtifact, ArtifactMetadata, ArtifactSummary, DataPart, FileContent, FilePart,
91    McpServerMetadata, McpToolsParams, Message, MessageMetadata as A2aMessageMetadata,
92    MessageRole as A2aMessageRole, OAuth2Flow, OAuth2Flows, Part, ProtocolBinding, SecurityScheme,
93    Task, TaskMetadata, TaskState, TaskStatus, TextPart, TransportProtocol,
94};
95pub use admin::{
96    ActivityTrend, AnalyticsData as AdminAnalyticsData, BotTrafficStats, BrowserBreakdown,
97    ContentStat, DeviceBreakdown, GeographicBreakdown, LogEntry as AdminLogEntry,
98    LogLevel as AdminLogLevel, RecentConversation, TrafficData as AdminTrafficData, UserInfo,
99    UserMetricsWithTrends,
100};
101pub use agui::{
102    AgUiEvent, AgUiEventBuilder, AgUiEventType, CustomPayload, GenericCustomPayload,
103    JsonPatchOperation, MessageRole as AgUiMessageRole, MessagesSnapshotPayload, RunErrorPayload,
104    RunFinishedPayload, RunStartedPayload, StateDeltaBuilder, StateDeltaPayload,
105    StateSnapshotPayload, StepFinishedPayload, StepStartedPayload, TextMessageContentPayload,
106    TextMessageEndPayload, TextMessageStartPayload, ToolCallArgsPayload, ToolCallEndPayload,
107    ToolCallResultPayload, ToolCallStartPayload,
108};
109pub use ai::{
110    AiContentPart, AiMessage, AiProvider, AiRequest, AiRequestBuilder, AiResponse, CallToolResult,
111    DynAiProvider, McpTool, MessageRole, ModelConfig, ModelHint, ModelPreferences, ProviderConfig,
112    ResponseFormat, SUPPORTED_AUDIO_TYPES, SUPPORTED_IMAGE_TYPES, SUPPORTED_TEXT_TYPES,
113    SUPPORTED_VIDEO_TYPES, SamplingParams, SearchGroundedResponse, StreamChunk,
114    StructuredOutputOptions, ToolCall, ToolExecution, ToolResultFormatter, is_supported_audio,
115    is_supported_image, is_supported_media, is_supported_text, is_supported_video,
116};
117pub use api::{
118    AcceptedResponse, ApiError, ApiErrorExt, ApiQuery, ApiResponse, CheckoutEvent, CheckoutRequest,
119    CheckoutResponse, CloudApiError, CloudApiErrorDetail, CloudApiResponse, CloudCustomerInfo,
120    CloudListResponse, CloudLogEntry, CloudLogsResponse, CloudPlan, CloudPlanInfo,
121    CloudStatusResponse, CloudTenant, CloudTenantInfo, CloudTenantSecrets, CloudTenantStatus,
122    CloudTenantStatusResponse, CloudUserInfo, CollectionResponse, ContextKind,
123    CreateContextRequest, CreatedResponse, DeployResponse, DiscoveryResponse, ErrorCode,
124    ErrorResponse, ExternalDbAccessResponse, Link, ModuleInfo, PaginationInfo, PaginationParams,
125    ParseContextKindError, ProvisioningEvent, ProvisioningEventType, RegistryToken, ResponseLinks,
126    ResponseMeta, SearchQuery, SetExternalDbAccessRequest, SetSecretsRequest, SingleResponse,
127    SortOrder, SortParams, SubscriptionStatus, SuccessResponse, UpdateContextRequest, UserContext,
128    UserContextWithStats, UserMeResponse, ValidationError,
129};
130pub use artifacts::{
131    Alignment, Artifact, ArtifactSchema, ArtifactType, AudioArtifact, AxisType, ChartArtifact,
132    ChartDataset, ChartType, CliArtifact, Column, ColumnType, ExecutionMetadata, ImageArtifact,
133    SortOrder as ArtifactSortOrder, TableArtifact, TableHints, ToolResponse, VideoArtifact,
134};
135pub use auth::{
136    AuthError, AuthenticatedUser, BEARER_PREFIX, BaseRole, BaseRoles, PkceMethod, ResponseType,
137};
138pub use config::{Config, PathNotConfiguredError};
139pub use content::{ContentLink, IngestionReport};
140pub use content_config::{
141    ArticleDefaults, Category, ContentConfigError, ContentConfigErrors, ContentConfigRaw,
142    ContentRouting, ContentSourceConfigRaw, IndexingConfig, Metadata, OrganizationData,
143    ParentRoute, SitemapConfig, SourceBranding, StructuredData,
144};
145pub use env::{contains_placeholder, interpolate, none_if_blank, read_env_optional};
146pub use errors::{RepositoryError, ServiceError};
147pub use events::{
148    A2AEvent, A2AEventBuilder, A2AEventType, AnalyticsEvent, AnalyticsEventBuilder, ContextEvent,
149    ContextSummary, SystemEvent, SystemEventBuilder, SystemEventType,
150};
151pub use execution::{
152    ExecutionStep, PlannedTool, RequestContext, StepContent, StepId, StepStatus, StepType,
153    TrackedStep,
154};
155pub use extension::{
156    BuildType, DiscoveredExtension, Extension, ExtensionManifest, ExtensionType, ManifestRole,
157};
158pub use mcp::{
159    Deployment, DeploymentConfig, DynMcpDeploymentProvider, DynMcpRegistry, DynMcpToolProvider,
160    ERROR as MCP_ERROR, McpAuthState, McpDeploymentProvider, McpProvider, McpRegistry,
161    McpServerConfig, McpServerState, McpToolProvider, OAuthRequirement, RUNNING as MCP_RUNNING,
162    RegistryConfig, STARTING as MCP_STARTING, STOPPED as MCP_STOPPED, Settings,
163};
164pub use modules::{ApiPaths, CliPaths, ServiceCategory};
165pub use oauth::{OAuthClientConfig, OAuthServerConfig};
166pub use paths::{
167    AppPaths, BuildPaths, PathError, StoragePaths, SystemPaths, WebPaths, cloud_container,
168    dir_names, file_names,
169};
170pub use profile::{
171    CloudConfig, CloudValidationMode, ContentNegotiationConfig,
172    DatabaseConfig as ProfileDatabaseConfig, Environment, ExtensionsConfig, LogLevel, OutputFormat,
173    PathsConfig, Profile, ProfileInfo, ProfileStyle, ProfileType, RateLimitsConfig, RuntimeConfig,
174    SecurityConfig, SecurityHeadersConfig, ServerConfig, SiteConfig,
175};
176pub use repository::{ServiceLifecycle, ServiceRecord, WhereClause};
177pub use routing::{ApiCategory, AssetType, RouteClassifier, RouteType};
178pub use secrets::Secrets;
179pub use services::{
180    AGENT_CONFIG_FILENAME, AgentCardConfig, AgentConfig, AgentMetadataConfig, AgentProviderInfo,
181    AgentSummary, AiConfig, AiProviderConfig, CapabilitiesConfig, ComponentFilter, ComponentSource,
182    DEFAULT_AGENT_SYSTEM_PROMPT_FILE, DEFAULT_SKILL_CONTENT_FILE, DiskAgentConfig, DiskHookConfig,
183    DiskSkillConfig, Frontmatter, HOOK_CONFIG_FILENAME, HistoryConfig, HookAction, HookCategory,
184    HookEvent, HookEventsConfig, HookMatcher, HookType, IncludableString, JobConfig,
185    MarketplaceConfig, MarketplaceConfigFile, MarketplaceVisibility, McpConfig,
186    OAuthConfig as AgentOAuthConfig, PluginAuthor, PluginComponentRef, PluginConfig,
187    PluginConfigFile, PluginScript, PluginVariableDef, RuntimeStatus, SKILL_CONFIG_FILENAME,
188    SamplingConfig, SchedulerConfig, ServiceType, ServicesConfig, Settings as ServicesSettings,
189    SkillConfig, SkillsConfig, SystemAdmin, SystemAdminConfig, WebConfig, split_frontmatter,
190    strip_frontmatter,
191};
192pub use systemprompt_identifiers::{AgentId, ContextId, SessionId, TaskId, TraceId, UserId};
193pub use users::{SessionSummary, UserSummary};
194
195pub use systemprompt_provider_contracts::{
196    AnimationConfig, CardConfig, ColorsConfig, FontsConfig, LayoutConfig, LogoConfig, MobileConfig,
197    PathsConfig as WebPathsConfig, RadiusConfig, ScriptConfig, ShadowsConfig, SpacingConfig,
198    TouchTargetsConfig, TypographyConfig, WebConfigError, ZIndexConfig,
199};
200pub use systemprompt_traits::{
201    StartupValidationError, StartupValidationReport, ValidationReport, ValidationWarning,
202};