Skip to main content

Crate systemprompt_traits

Crate systemprompt_traits 

Source
Expand description

§systemprompt-traits

Trait-first interface contracts for the systemprompt.io platform.

This crate defines the abstractions every other layer (infra, domain, app, entry) implements or consumes: configuration, database handle, analytics, authentication, JWT, file storage, MCP services, repositories, schedulers, and the cross-cutting ExtensionError contract.

§Layering

systemprompt-traits lives in the shared layer and depends only on systemprompt-identifiers and systemprompt-provider-contracts. Concrete implementations live in their respective domain or infra crates and are wired together at the entry layer.

§Errors

Each provider trait pairs with a typed thiserror-derived error enum (e.g. AnalyticsProviderError, AuthProviderError, JwtProviderError, FileStorageError, ContextPropagationError). The crate also defines the cross-cutting ExtensionError trait which downstream errors implement so the API and MCP transports can render them uniformly.

§Async traits

Most provider traits are exposed as Arc<dyn TraitName> (see the Dyn* aliases). Until trait dispatch supports native async fn on dyn traits, these continue to rely on #[async_trait]. Each trait whose contract requires it is annotated with that rationale.

§Feature flags

FeatureEffect
defaultNo optional features.
webEnables the ApiModule trait and pulls in axum for HTTP routing.

Re-exports§

pub use context::AppContext;
pub use context::ConfigProvider;
pub use context::ContextPropagation;
pub use context::ContextPropagationError;
pub use context::ContextPropagationResult;
pub use context::DatabaseHandle;
pub use context::InjectContextHeaders;
pub use context::Module;
pub use context::ModuleRegistry;
pub use context::ApiModule;
pub use repository::RepositoryError;
pub use service::AsyncService;
pub use service::Service;
pub use log_service::LogService;
pub use context_provider::ContextProvider;
pub use context_provider::ContextProviderError;
pub use context_provider::ContextWithStats;
pub use context_provider::DynContextProvider;
pub use artifact::ArtifactSupport;
pub use artifact::schemas;
pub use validation::MetadataValidation;
pub use validation::Validate;
pub use validation::ValidationError;
pub use validation::ValidationResult;
pub use events::AnalyticsEvent;
pub use events::AnalyticsEventPublisher;
pub use events::LogEventData;
pub use events::LogEventLevel;
pub use events::LogEventPublisher;
pub use events::UserEvent;
pub use events::UserEventPublisher;
pub use analytics::AnalyticsProvider;
pub use analytics::AnalyticsProviderError;
pub use analytics::AnalyticsResult;
pub use analytics::AnalyticsSession;
pub use analytics::CreateSessionInput;
pub use analytics::DynAnalyticsProvider;
pub use analytics::DynFingerprintProvider;
pub use analytics::FingerprintProvider;
pub use analytics::SessionAnalytics;
pub use auth::AuthProviderError;
pub use auth::AuthResult;
pub use auth::AuthUser;
pub use auth::DynRoleProvider;
pub use auth::DynUserProvider;
pub use auth::RoleProvider;
pub use auth::UserProvider;
pub use storage::FileStorage;
pub use storage::FileStorageError;
pub use storage::FileStorageResult;
pub use storage::StoredFileId;
pub use storage::StoredFileMetadata;
pub use ai_providers::AiFilePersistenceProvider;
pub use ai_providers::AiGeneratedFile;
pub use ai_providers::AiProviderError;
pub use ai_providers::AiProviderResult;
pub use ai_providers::AiSessionProvider;
pub use ai_providers::CreateAiSessionParams;
pub use ai_providers::DynAiFilePersistenceProvider;
pub use ai_providers::DynAiSessionProvider;
pub use ai_providers::ImageGenerationInfo;
pub use ai_providers::ImageMetadata;
pub use ai_providers::ImageStorageConfig;
pub use ai_providers::InsertAiFileParams;
pub use scheduler::JobStatus;
pub use registry::AgentInfo;
pub use registry::AgentRegistryProvider;
pub use registry::DynAgentRegistryProvider;
pub use registry::DynMcpRegistryProvider;
pub use registry::McpRegistryProvider;
pub use registry::McpServerInfo;
pub use registry::RegistryError;
pub use registry::ServiceOAuthConfig;
pub use extension_error::ApiError;
pub use extension_error::ExtensionError;
pub use extension_error::McpErrorData;
pub use domain_config::DomainConfig;
pub use domain_config::DomainConfigError;
pub use domain_config::DomainConfigRegistry;
pub use validation_report::StartupValidationError;
pub use validation_report::StartupValidationReport;
pub use validation_report::ValidationReport;
pub use validation_report::ValidationWarning;
pub use file_upload::DynFileUploadProvider;
pub use file_upload::FileUploadInput;
pub use file_upload::FileUploadProvider;
pub use file_upload::FileUploadProviderError;
pub use file_upload::FileUploadResult;
pub use file_upload::UploadedFileInfo;
pub use jwt::AgentJwtClaims;
pub use jwt::DynJwtValidationProvider;
pub use jwt::GenerateTokenParams;
pub use jwt::JwtProviderError;
pub use jwt::JwtResult;
pub use jwt::JwtValidationProvider;
pub use mcp_service::DynMcpServiceProvider;
pub use mcp_service::McpServerMetadata;
pub use mcp_service::McpServiceProvider;
pub use mcp_service::McpServiceProviderError;
pub use mcp_service::McpServiceResult;
pub use process::DynProcessCleanupProvider;
pub use process::ProcessCleanupProvider;
pub use process::ProcessProviderError;
pub use process::ProcessResult;
pub use session_analytics::DynSessionAnalyticsProvider;
pub use session_analytics::SessionAnalyticsProvider;
pub use session_analytics::SessionAnalyticsProviderError;
pub use session_analytics::SessionAnalyticsResult;

Modules§

ai_providers
AI generation file storage and session provider traits.
analytics
Session analytics and fingerprinting provider traits.
artifact
Artifact schema trait and built-in JSON Schema helpers.
auth
Authentication and role-management provider traits.
content
Content provider traits for blog posts, docs, and other published items.
context
Application context, module registry, and request-context propagation.
context_provider
Conversation context provider trait used by chat and agent surfaces.
domain_config
Per-domain configuration loading and validation.
events
Cross-cutting event publisher traits (logs, user activity, analytics).
extension_error
ExtensionError trait and HTTP/MCP error wire types.
file_upload
File upload provider trait used by chat surfaces and agent IO.
jwt
JWT validation and generation provider trait.
log_service
Generic log persistence trait.
mcp_service
MCP service registry trait used by callers that need to resolve servers.
module
Compile-time module registration macro.
process
Process and port management provider trait.
registry
Registry provider traits for agents and MCP servers.
repository
Generic repository error type used by domain crates.
scheduler
Scheduler traits for triggering jobs and inspecting their status.
service
Long-running service lifecycle traits.
session_analytics
Session-scoped analytics counter trait.
storage
File storage trait and identifier types.
validation
Lightweight value-validation traits used by config and metadata types.
validation_report
Unified validation report types used during startup.

Macros§

register_module
submit_job

Structs§

ChatMessage
ChatRequest
ChatResponse
JobContext
JobResult
ModuleInfo
SamplingParameters
ServiceInfo
TokenUsage
ToolCallRequest
ToolCallResult
ToolContext
ToolDefinition
ToolExecutionContext

Enums§

ChatRole
DbValue
LlmProviderError
Phase
ProviderError
ServiceState
ServiceType
StartupEvent
ToolContent
ToolProviderError

Traits§

FromDbValue
Job
LlmProvider
OptionalStartupEventExt
StartupEventExt
ToDbValue
ToolExecutor
ToolProvider

Functions§

parse_database_datetime
startup_channel

Type Aliases§

ChatStream
JsonRow
LlmProviderResult
ProviderResult
Result
StartupEventReceiver
StartupEventSender
ToolProviderResult