Documentation
¶
Overview ¶
Package chronosos provides the ChronosOS control plane server.
Index ¶
- type Option
- func WithAPIKeyAuth(cfg auth.APIKeyConfig) Option
- func WithApproval(svc *approval.Service) Option
- func WithAuthMiddleware(mw func(http.Handler) http.Handler) Option
- func WithCORS(cfg middleware.CORSConfig) Option
- func WithJWTAuth(cfg auth.JWTConfig) Option
- func WithLogger(l *log.Logger) Option
- func WithMaxBodyBytes(n int64) Option
- func WithMaxHeaderBytes(n int) Option
- func WithRBAC(enabled bool) Option
- func WithRateLimit(cfg middleware.RateLimitConfig) Option
- func WithRateLimiter(l middleware.Limiter) Option
- func WithScheduler(r scheduler.Runner) Option
- func WithStructuredLogging(l *logging.Logger) Option
- func WithSwagger(enabled bool) Option
- func WithTimeouts(read, readHeader, write, idle time.Duration) Option
- func WithoutCORS() Option
- func WithoutRateLimit() Option
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v0.4.0
type Option func(*Server)
Option configures a Server during construction. Options are applied by NewWithOptions before routes are registered.
func WithAPIKeyAuth ¶ added in v0.4.0
func WithAPIKeyAuth(cfg auth.APIKeyConfig) Option
WithAPIKeyAuth enables API-key authentication using the given config. Health and metrics endpoints are always exempt.
func WithApproval ¶ added in v0.4.0
WithApproval injects a preconfigured approval service (e.g. store-backed and authorized via approval.WithStore/WithAuthorizer). The default is an in-memory service.
func WithAuthMiddleware ¶ added in v0.4.0
WithAuthMiddleware installs a custom authentication middleware. Passing a nil middleware disables authentication (the default).
func WithCORS ¶ added in v0.4.0
func WithCORS(cfg middleware.CORSConfig) Option
WithCORS overrides the CORS configuration.
func WithJWTAuth ¶ added in v0.4.0
WithJWTAuth enables JWT bearer-token authentication using the given config. Health and metrics endpoints are always exempt.
func WithLogger ¶ added in v0.4.0
WithLogger sets the request logger. A nil logger disables request logging.
func WithMaxBodyBytes ¶ added in v0.4.0
WithMaxBodyBytes overrides the maximum JSON request body size enforced via http.MaxBytesReader.
func WithMaxHeaderBytes ¶ added in v0.4.0
WithMaxHeaderBytes overrides the maximum request header size.
func WithRBAC ¶ added in v0.9.1
WithRBAC enforces role-based authorization on /api/* routes when authentication is enabled: read requests (GET/HEAD) require the viewer role, mutating requests require the user role. Roles come from the authenticated principal's claims. It is a no-op when authentication is disabled (there is no principal to authorize) and defaults to off.
func WithRateLimit ¶ added in v0.4.0
func WithRateLimit(cfg middleware.RateLimitConfig) Option
WithRateLimit overrides the rate-limit configuration.
func WithRateLimiter ¶ added in v0.4.0
func WithRateLimiter(l middleware.Limiter) Option
WithRateLimiter selects the rate-limit backend. Passing a store-backed middleware.Limiter shares limits across replicas; nil keeps the per-process default.
func WithScheduler ¶ added in v0.4.0
WithScheduler injects a scheduler implementation. The default is the in-process scheduler; pass a store-backed scheduler.StoreScheduler for exactly-once firing across replicas.
func WithStructuredLogging ¶ added in v0.4.0
WithStructuredLogging installs structured JSON request logging (with a per-request correlation id) as the outermost middleware. A nil logger leaves structured logging disabled.
func WithSwagger ¶ added in v0.9.1
WithSwagger enables or disables the Swagger UI and OpenAPI spec endpoints (/swagger, /swagger/, /swagger/doc.json). It defaults to enabled. Disable it on hardened production control planes where the API schema and interactive console should not be exposed anonymously.
func WithTimeouts ¶ added in v0.4.0
WithTimeouts overrides the http.Server timeouts. A zero value for any timeout leaves it unbounded (use with care).
func WithoutCORS ¶ added in v0.4.0
func WithoutCORS() Option
WithoutCORS disables the CORS middleware.
func WithoutRateLimit ¶ added in v0.4.0
func WithoutRateLimit() Option
WithoutRateLimit disables the rate-limit middleware.
type Server ¶
type Server struct {
Addr string
Store storage.Storage
Broker *stream.Broker
Auth *auth.Service
Trace *trace.Collector
Approval *approval.Service
Metrics *metrics.Registry
Scheduler scheduler.Runner
ShutdownTimeout time.Duration
// contains filtered or unexported fields
}
Server is the ChronosOS control plane.
To feed the Metrics registry from execution, add hooks.NewPrometheusHook(s.Metrics) to the hook chain of the agents you run (agents live outside the control plane, so this is wired at agent construction). The registry is exposed at /metrics regardless.
func New ¶
New creates a new ChronosOS server with safe defaults: no authentication, CORS and rate limiting enabled, panic recovery enabled, and hardened http.Server timeouts. The signature is stable; use NewWithOptions to customize behavior.
@title Chronos ChronosOS API @version 1.0 @description Control plane HTTP API for the Chronos agentic framework: sessions, traces, live event streaming, human-in-the-loop approvals, schedules, health, and metrics. @BasePath / @securityDefinitions.apikey BearerAuth @in header @name Authorization @description JWT bearer token. Send as "Authorization: Bearer <token>". @securityDefinitions.apikey ApiKeyAuth @in header @name X-Api-Key @description Static API key sent in the X-Api-Key header.
func NewWithOptions ¶ added in v0.4.0
NewWithOptions creates a new ChronosOS server, applying the given options after defaults are set and before routes are registered.
func (*Server) Handler ¶ added in v0.4.0
Handler composes the middleware chain around the mux. Requests flow through the chain in the order: recovery -> request-logging -> CORS -> rate-limit -> auth, then reach the route handlers.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apidocs Code generated by swaggo/swag.
|
Package apidocs Code generated by swaggo/swag. |
|
Package approval provides human-in-the-loop approval workflows for the ChronosOS control plane.
|
Package approval provides human-in-the-loop approval workflows for the ChronosOS control plane. |
|
Package auth provides authentication and RBAC for ChronosOS.
|
Package auth provides authentication and RBAC for ChronosOS. |
|
interfaces
|
|
|
discord
Package discord provides a Discord bot interface for Chronos agents.
|
Package discord provides a Discord bot interface for Chronos agents. |
|
slack
Package slack provides a Slack bot interface for Chronos agents.
|
Package slack provides a Slack bot interface for Chronos agents. |
|
telegram
Package telegram provides a Telegram bot interface for Chronos agents.
|
Package telegram provides a Telegram bot interface for Chronos agents. |
|
Package logging provides structured JSON-line logging with correlation and tenant identifiers carried through context.
|
Package logging provides structured JSON-line logging with correlation and tenant identifiers carried through context. |
|
Package metrics provides Prometheus-format metrics collection and export.
|
Package metrics provides Prometheus-format metrics collection and export. |
|
Package middleware provides HTTP middleware for ChronosOS.
|
Package middleware provides HTTP middleware for ChronosOS. |
|
Package scheduler provides cron-based scheduling for agent runs.
|
Package scheduler provides cron-based scheduling for agent runs. |
|
Package trace provides execution tracing and audit logging.
|
Package trace provides execution tracing and audit logging. |
|
Package webhook provides a generic webhook interface for receiving external events.
|
Package webhook provides a generic webhook interface for receiving external events. |