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 bridge manifest, the
7//! A2A and AG-UI protocol shapes, the MCP metadata helpers, and the typed
8//! error enums returned by every public function in this crate. The services
9//! manifest and the on-disk profile live in `systemprompt-manifest`; the
10//! provider wire codecs in `systemprompt-wire`.
11//!
12//! # Module map
13//!
14//! - [`a2a`] — A2A protocol agent card, message, task, and transport types.
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//! - [`attribution`] — scope attribution of an AI request (one value per
20//!   registered subject dimension, plus the API key).
21//! - [`auth`] — authenticated user, permission, audience, and PKCE types.
22//! - [`bridge`] — bridge wire formats (signed manifest, plugin bundles,
23//!   telemetry).
24//! - [`content`], [`content_config`] — published content metadata.
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//! - [`hooks`] — hook lifecycle events and categories.
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//! - [`origin`] — client attribution of an AI request (client kind, attestation
38//!   tier, evidence).
39//! - [`plugin`] — plugin component references carried in the bridge manifest.
40//! - [`providers`] — the client-facing API surface of an upstream provider.
41//! - [`routing`] — request routing classification.
42//! - [`scope`] — per-request scoping identity for scoped DB transactions.
43//! - [`subprocess`] — identity contract for supervised child processes.
44//! - [`text`], [`time_format`] — display formatting helpers.
45//! - [`users`] — public user / session summaries.
46//!
47//! No module here spawns processes or opens sockets: process spawning lives
48//! in `systemprompt-loader` and outbound HTTP in `systemprompt-client`.
49//!
50//! # Feature flags
51//!
52//! | Feature | Effect |
53//! | ------- | ------ |
54//! | _default_ | All public DTOs and traits, no axum integration. |
55//! | `web` | Adds `axum::IntoResponse` impls for the API envelopes. |
56//! | `sqlx` | Derives `sqlx::Type` on DB-persisted enums (e.g. [`ContextKind`]). |
57//!
58//! Public functions return `thiserror`-derived enums from [`errors`];
59//! `anyhow::Error` is never used in a public signature.
60//!
61//! Copyright (c) systemprompt.io — Business Source License 1.1.
62//! See <https://systemprompt.io> for licensing details.
63
64pub mod macros;
65
66pub mod a2a;
67pub mod agui;
68pub mod ai;
69pub mod api;
70pub mod artifacts;
71pub mod attribution;
72pub mod auth;
73pub mod bridge;
74pub mod content;
75pub mod content_config;
76pub mod errors;
77pub mod events;
78pub mod execution;
79pub mod extension;
80pub mod feedback;
81pub mod hooks;
82pub mod managed;
83pub mod mcp;
84pub mod mime;
85pub mod modules;
86pub mod net;
87pub mod oauth;
88pub mod origin;
89pub mod plugin;
90pub mod providers;
91pub mod routing;
92pub mod scope;
93pub mod subprocess;
94pub mod text;
95pub mod time_format;
96pub mod users;
97
98pub use a2a::{
99    AgentCapabilities, AgentCard, AgentExtension, AgentProvider, Artifact as A2aArtifact,
100    ArtifactMetadata, DataPart, FileContent, FilePart, Part, Task, TaskMetadata, TaskState,
101    TaskStatus, TextPart,
102};
103pub use agui::{
104    AgUiEvent, AgUiEventBuilder, AgUiEventType, CustomPayload, GenericCustomPayload,
105    JsonPatchOperation, MessageRole as AgUiMessageRole, MessagesSnapshotPayload, RunErrorPayload,
106    RunFinishedPayload, RunStartedPayload, StateDeltaBuilder, StateDeltaPayload,
107    StateSnapshotPayload,
108};
109pub use ai::{
110    AiContentPart, AiMessage, AiProvider, AiRequest, CallToolResult, McpTool, MessageRole,
111    ProviderConfig, SamplingParams, StreamChunk, ToolCall, ToolResultFormatter, is_supported_audio,
112    is_supported_image, is_supported_text, is_supported_video,
113};
114pub use api::{
115    AcceptedResponse, ApiError, ApiErrorExt, ApiResponse, CollectionResponse, ContextKind,
116    CreateContextRequest, CreatedResponse, ErrorCode, PaginationInfo, PaginationParams,
117    SearchQuery, SingleResponse, SortOrder, SortParams, SuccessResponse, UpdateContextRequest,
118    UserContext, UserContextWithStats, ValidationError,
119};
120pub use artifacts::{
121    Alignment, ArtifactType, AxisType, ChartType, CliArtifact, ColumnType, TableArtifact,
122};
123pub use auth::{AuthRequestError, BaseRoles};
124pub use content::IngestionReport;
125pub use content_config::{
126    Category, ContentConfigError, ContentConfigErrors, ContentConfigRaw, ContentRouting,
127    ContentSourceConfigRaw, IndexingConfig, Metadata, ParentRoute, SitemapConfig, SourceBranding,
128};
129pub use events::{
130    A2AEvent, A2AEventBuilder, A2AEventType, AnalyticsEvent, AnalyticsEventBuilder, ContextEvent,
131    SystemEvent, SystemEventBuilder, SystemEventType,
132};
133pub use execution::{
134    ExecutionStep, PlannedTool, RequestContext, StepContent, StepId, StepStatus, StepType,
135    TrackedStep,
136};
137pub use extension::{BuildType, DiscoveredExtension, ExtensionManifest};
138pub use mcp::{Deployment, McpServerConfig};
139pub use modules::{ApiPaths, CliPaths};
140pub use routing::{RouteClassifier, RouteType};
141pub use scope::RequestScope;
142pub use systemprompt_identifiers::{ContextId, SessionId, TaskId, UserId};
143
144pub use systemprompt_provider_contracts::WebConfigError;