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