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, repositories, and the cross-cutting ExtensionError contract. It also hosts the one concrete runtime primitive every layer shares: the BackgroundTasks owner for work that outlives its caller.

§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

  • sqlx — From<sqlx::Error> for RepositoryError, classifying a database error by SQLSTATE. Enabled by systemprompt-database.

Copyright (c) systemprompt.io — Business Source License 1.1. See https://systemprompt.io for licensing details.

Re-exports§

pub use agent_run_launcher::AgentRunLaunch;
pub use agent_run_launcher::AgentRunLaunchError;
pub use agent_run_launcher::AgentRunLauncher;
pub use agent_run_launcher::DynAgentRunLauncher;
pub use background_tasks::BackgroundTasks;
pub use background_tasks::DrainOutcome;
pub use background_tasks::OwnedTask;
pub use content::ContentCatalogStats;
pub use content::DynContentCatalogStats;
pub use runner_service::RunnerService;
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 repository::BoxedSource;
pub use repository::ConstraintKind;
pub use repository::RepositoryError;
pub use ownership::DynOwnerReassignment;
pub use ownership::OwnerReassignment;
pub use ownership::ReassignedRows;
pub use tool_executions::DynToolCallIntentClaims;
pub use tool_executions::DynToolExecutionLookup;
pub use tool_executions::ToolCallIntentClaims;
pub use tool_executions::ToolExecutionLookup;
pub use log_service::LogService;
pub use managed_resources::DynManagedSkillResolver;
pub use managed_resources::ManagedSkillResolver;
pub use managed_resources::ManagedSkillResolverError;
pub use managed_resources::ResolvedManagedSkill;
pub use managed_resources::SkillResolution;
pub use managed_resources::WithheldReason;
pub use context_provider::ContextMaterializer;
pub use context_provider::ContextProvider;
pub use context_provider::ContextProviderError;
pub use context_provider::ContextStats;
pub use context_provider::ContextWithStats;
pub use context_provider::DynContextMaterializer;
pub use context_provider::EnsureContextParams;
pub use validation::MetadataValidation;
pub use validation::MetadataValidationError;
pub use validation::Validate;
pub use validation::ValidationResult;
pub use analytics::ActiveSession;
pub use analytics::AnalyticsProvider;
pub use analytics::AnalyticsProviderError;
pub use analytics::AnalyticsResult;
pub use analytics::AnalyticsSession;
pub use analytics::CreateSessionInput;
pub use analytics::DynSessionUsageCounters;
pub use analytics::ExtractSignals;
pub use analytics::FingerprintProvider;
pub use analytics::SessionAnalytics;
pub use analytics::SessionUsageCounters;
pub use auth::AuthProviderError;
pub use auth::AuthResult;
pub use auth::AuthUser;
pub use auth::FederatedIdentityClaims;
pub use auth::RoleProvider;
pub use auth::SenderIdentity;
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::AiRequestTrace;
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 ai_providers::TraceMessage;
pub use ai_providers::TraceRequestStatus;
pub use ai_providers::TraceRequestUsage;
pub use ai_providers::TraceSample;
pub use ai_providers::TraceSampleFilter;
pub use ai_providers::TraceSampleMode;
pub use registry::AgentInfo;
pub use registry::AgentRegistryProvider;
pub use registry::McpRegistryProvider;
pub use registry::McpServerInfo;
pub use registry::RegistryError;
pub use registry::ServiceOAuthConfig;
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 jwt::AgentJwtClaims;
pub use jwt::DynJwtValidationProvider;
pub use jwt::GenerateTokenParams;
pub use jwt::JwtProviderError;
pub use jwt::JwtResult;
pub use jwt::JwtValidationProvider;
pub use analytics::SessionProvider;
pub use analytics_events::AnalyticsEventRecord;
pub use analytics_events::AnalyticsEventStore;
pub use analytics_events::DynAnalyticsEventStore;
pub use session_store::DynSessionStore;
pub use session_store::SessionStore;

Modules§

agent_run_launcher
AgentRunLauncher: the seam through which the A2A server hands a task to a headless coding-agent run without depending on the crate that runs it.
ai_providers
AI generation file storage and session provider traits.
analytics
Request analytics extraction, session lifecycle, and fingerprint provider traits.
analytics_events
Persistence contract for analytics ingestion into the logging-owned event store.
auth
Authentication and role-management provider traits.
background_tasks
Owned background work: one tracker per process, drained at shutdown.
content
Content provider traits for blog posts, docs, and other published items.
context
Application context, configuration and database handle contracts, and request-context propagation across HTTP boundaries.
context_provider
Conversation context provider trait used by chat and agent surfaces.
domain_config
Per-domain configuration loading and validation.
extension_error
ExtensionError trait and the MCP error wire type.
jwt
JWT validation and generation provider trait.
log_service
Generic log persistence trait.
managed_resources
Runtime resolution of a skill through an installation’s managed-resource authority.
ownership
Owner reassignment across domain repositories.
registry
Registry provider traits for agents and MCP servers.
repository
The workspace’s single repository error type.
runner_service
RunnerService: long-running work an extension runs on a runner node.
session_store
Session repository row and migration-result types.
sso
Browser-redirect single sign-on provider contract.
storage
File storage trait and identifier types.
tool_executions
Seams between the MCP tool-execution ledger and the model’s tool-call intents.
validation
Lightweight value-validation traits used by config and metadata types.
validation_report
Unified validation report types used during startup.

Macros§

submit_job

Structs§

Dependencies
Host handles keyed by concrete type; inserting a second value of a type replaces the first, and get::<Arc<T>>() and get::<T>() are different keys.
JobContext
JobResult
MissingDependency
ModuleInfo
ServerListingFailure
ServiceInfo
ToolCallRequest
ToolCallResult
ToolContext
ToolDefinition
ToolInventory
Tools gathered from every reachable server plus the servers that could not be listed.

Enums§

DbValue
JobScope
Where a job runs when the scheduler has several replicas.
Phase
ProviderError
ServiceState
ServiceType
StartupEvent
ToolContent
ToolProviderError

Traits§

FromDbValue
Job
StartupEventExt
ToDbValue
ToolProvider

Functions§

parse_database_datetime
startup_channel

Type Aliases§

JsonRow
ProviderResult
StartupEventReceiver
StartupEventSender
ToolProviderResult