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