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, CloudApiError,
125    CloudApiErrorDetail, CloudApiResponse, CloudCustomerInfo, CloudListResponse, CloudPlan,
126    CloudPlanInfo, CloudStatusResponse, CloudTenant, CloudTenantInfo, CloudTenantSecrets,
127    CloudTenantStatus, CloudTenantStatusResponse, CloudUserInfo, CollectionResponse, ContextKind,
128    CreateContextRequest, CreatedResponse, DeployResponse, DiscoveryResponse, ErrorCode,
129    ErrorResponse, Link, ModuleInfo, PaginationInfo, PaginationParams, ParseContextKindError,
130    RegistryToken, ResponseLinks, ResponseMeta, SearchQuery, SetSecretsRequest, SingleResponse,
131    SortOrder, SortParams, SubscriptionStatus, SuccessResponse, UpdateContextRequest, UserContext,
132    UserContextWithStats, UserMeResponse, ValidationError,
133};
134pub use artifacts::{
135    Alignment, Artifact, ArtifactSchema, ArtifactType, AudioArtifact, AxisType, ChartArtifact,
136    ChartDataset, ChartType, CliArtifact, Column, ColumnType, ExecutionMetadata, ImageArtifact,
137    SortOrder as ArtifactSortOrder, TableArtifact, TableHints, ToolResponse, VideoArtifact,
138};
139pub use auth::{
140    AuthError, AuthenticatedUser, BEARER_PREFIX, BaseRole, BaseRoles, PkceMethod, ResponseType,
141};
142pub use config::{Config, PathNotConfiguredError};
143pub use content::{ContentLink, IngestionReport};
144pub use content_config::{
145    ArticleDefaults, Category, ContentConfigError, ContentConfigErrors, ContentConfigRaw,
146    ContentRouting, ContentSourceConfigRaw, IndexingConfig, Metadata, OrganizationData,
147    ParentRoute, SitemapConfig, SourceBranding, StructuredData,
148};
149pub use env::{contains_placeholder, interpolate, none_if_blank, read_env_optional};
150pub use errors::{RepositoryError, ServiceError};
151pub use events::{
152    A2AEvent, A2AEventBuilder, A2AEventType, AnalyticsEvent, AnalyticsEventBuilder, ContextEvent,
153    ContextSummary, SystemEvent, SystemEventBuilder, SystemEventType,
154};
155pub use execution::{
156    ExecutionStep, PlannedTool, RequestContext, StepContent, StepId, StepStatus, StepType,
157    TrackedStep,
158};
159pub use extension::{
160    BuildType, DiscoveredExtension, Extension, ExtensionManifest, ExtensionType, ManifestRole,
161};
162pub use mcp::{
163    Deployment, DeploymentConfig, DynMcpDeploymentProvider, DynMcpRegistry, DynMcpToolProvider,
164    ERROR as MCP_ERROR, McpAuthState, McpDeploymentProvider, McpProvider, McpRegistry,
165    McpServerConfig, McpServerState, McpToolProvider, OAuthRequirement, RUNNING as MCP_RUNNING,
166    RegistryConfig, STARTING as MCP_STARTING, STOPPED as MCP_STOPPED, Settings,
167};
168pub use modules::{ApiPaths, CliPaths, ServiceCategory};
169pub use oauth::{OAuthClientConfig, OAuthServerConfig};
170pub use paths::{
171    AppPaths, BuildPaths, PathError, PathResolution, StoragePaths, SystemPaths, WebPaths,
172    cloud_container, dir_names, file_names,
173};
174pub use profile::{
175    CloudConfig, CloudValidationMode, ContentNegotiationConfig,
176    DatabaseConfig as ProfileDatabaseConfig, Environment, ExtensionsConfig, LogLevel, OutputFormat,
177    PathsConfig, Profile, ProfileInfo, ProfileStyle, ProfileType, RateLimitsConfig, RuntimeConfig,
178    SecurityConfig, SecurityHeadersConfig, ServerConfig, SiteConfig,
179};
180pub use repository::{ServiceLifecycle, ServiceRecord, WhereClause};
181pub use routing::{ApiCategory, AssetType, RouteClassifier, RouteType};
182pub use scope::RequestScope;
183pub use secrets::Secrets;
184pub use services::{
185    AGENT_CONFIG_FILENAME, AgentCardConfig, AgentConfig, AgentMetadataConfig, AgentProviderInfo,
186    AgentSummary, AiConfig, AiProviderConfig, CapabilitiesConfig, ComponentFilter, ComponentSource,
187    DEFAULT_AGENT_SYSTEM_PROMPT_FILE, DEFAULT_SKILL_CONTENT_FILE, DiskAgentConfig, DiskHookConfig,
188    DiskSkillConfig, Frontmatter, HOOK_CONFIG_FILENAME, HistoryConfig, HookAction, HookCategory,
189    HookEvent, HookEventsConfig, HookMatcher, HookType, IncludableString, JobConfig,
190    MarketplaceConfig, MarketplaceConfigFile, MarketplaceVisibility, McpConfig,
191    OAuthConfig as AgentOAuthConfig, PluginAuthor, PluginComponentRef, PluginConfig,
192    PluginConfigFile, PluginScript, PluginVariableDef, RuntimeStatus, SKILL_CONFIG_FILENAME,
193    SamplingConfig, SchedulerConfig, ServiceType, ServicesConfig, Settings as ServicesSettings,
194    SkillConfig, SkillsConfig, SystemAdmin, SystemAdminConfig, WebConfig, split_frontmatter,
195    strip_frontmatter,
196};
197pub use systemprompt_identifiers::{AgentId, ContextId, SessionId, TaskId, TraceId, UserId};
198pub use users::{SessionSummary, UserSummary};
199
200pub use systemprompt_provider_contracts::{
201    AnimationConfig, CardConfig, ColorsConfig, FontsConfig, LayoutConfig, LogoConfig, MobileConfig,
202    PathsConfig as WebPathsConfig, RadiusConfig, ScriptConfig, ShadowsConfig, SpacingConfig,
203    TouchTargetsConfig, TypographyConfig, WebConfigError, ZIndexConfig,
204};
205pub use systemprompt_traits::{
206    StartupValidationError, StartupValidationReport, ValidationReport, ValidationWarning,
207};