admin

package
v0.34.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigValidateRequest

type ConfigValidateRequest struct {
	ConfigPath string `json:"config_path"`
}

ConfigValidateRequest is the request for POST /admin/v1/config/validate.

type ConfigValidateResponse

type ConfigValidateResponse struct {
	Valid  bool     `json:"valid"`
	Errors []string `json:"errors"`
}

ConfigValidateResponse is the response for POST /admin/v1/config/validate.

type ErrorCode

type ErrorCode string

ErrorCode represents admin API error codes.

const (
	ErrCodeAuthFailed     ErrorCode = "AUTH_FAILED"
	ErrCodeForbidden      ErrorCode = "FORBIDDEN"
	ErrCodeNotFound       ErrorCode = "NOT_FOUND"
	ErrCodeInvalidRequest ErrorCode = "INVALID_REQUEST"
	ErrCodeServerError    ErrorCode = "SERVER_ERROR"
)

type ErrorDetail

type ErrorDetail struct {
	Code    ErrorCode              `json:"code"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
}

ErrorDetail contains error details.

type ErrorResponse

type ErrorResponse struct {
	Error ErrorDetail `json:"error"`
}

ErrorResponse is the standard error response format.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles admin API requests.

func NewHandler

func NewHandler(eng *engine.Engine, startTime time.Time, logger Logger) *Handler

NewHandler creates a new admin handler.

type HealthChecks

type HealthChecks struct {
	Database             bool `json:"database"`
	Config               bool `json:"config"`
	CliAvailable         bool `json:"cli_available"`
	WebsocketConnections int  `json:"websocket_connections"`
}

HealthChecks contains health check results.

type HealthDetailedResponse

type HealthDetailedResponse struct {
	Status  string        `json:"status"`
	Checks  HealthChecks  `json:"checks"`
	Details HealthDetails `json:"details"`
}

HealthDetailedResponse is the response for GET /admin/v1/health/detailed.

type HealthDetails

type HealthDetails struct {
	DatabaseLatencyMs int    `json:"database_latency_ms"`
	CliVersion        string `json:"cli_version"`
	ConfigFile        string `json:"config_file"`
}

HealthDetails contains detailed health information.

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

Logger interface for logging.

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware provides HTTP middleware functions for the admin API.

func NewMiddleware

func NewMiddleware(adminToken string) *Middleware

NewMiddleware creates a new admin middleware.

func (*Middleware) AuthMiddleware

func (m *Middleware) AuthMiddleware(next http.Handler) http.Handler

AuthMiddleware returns an HTTP handler that validates the admin token. If adminToken is empty, authentication is disabled (dev mode).

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the admin HTTP server.

func NewServer

func NewServer(eng *engine.Engine, port, token string, startTime time.Time, logger *slog.Logger) *Server

NewServer creates a new admin server.

func (*Server) ErrChan

func (s *Server) ErrChan() <-chan error

ErrChan returns the channel that receives server errors.

func (*Server) Start

func (s *Server) Start()

Start starts the admin server in a goroutine. Server errors (e.g., port already in use) are sent to ErrCh. Callers should monitor ErrCh after Start() to detect startup failures.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully stops the admin server.

type SessionConfig

type SessionConfig struct {
	Provider string `json:"provider"`
	WorkDir  string `json:"work_dir"`
}

SessionConfig contains session configuration details.

type SessionDeleteResponse

type SessionDeleteResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

SessionDeleteResponse is the response for DELETE /admin/v1/sessions/:id.

type SessionDetailResponse

type SessionDetailResponse struct {
	ID         string        `json:"id"`
	Status     string        `json:"status"`
	CreatedAt  time.Time     `json:"created_at"`
	LastActive time.Time     `json:"last_active"`
	Provider   string        `json:"provider"`
	Config     SessionConfig `json:"config,omitempty"`
	Stats      SessionStats  `json:"stats,omitempty"`
}

SessionDetailResponse is the response for GET /admin/v1/sessions/:id.

type SessionInfo

type SessionInfo struct {
	ID           string    `json:"id"`
	Status       string    `json:"status"`
	CreatedAt    time.Time `json:"created_at"`
	LastActive   time.Time `json:"last_active"`
	Provider     string    `json:"provider"`
	CliVersion   string    `json:"cli_version,omitempty"`
	WorkDir      string    `json:"work_dir,omitempty"`
	InputTokens  int64     `json:"input_tokens,omitempty"`
	OutputTokens int64     `json:"output_tokens,omitempty"`
	DurationSecs int64     `json:"duration_seconds,omitempty"`
}

SessionInfo represents a session in admin API responses.

type SessionListResponse

type SessionListResponse struct {
	Sessions []*SessionInfo `json:"sessions"`
	Total    int            `json:"total"`
}

SessionListResponse is the response for GET /admin/v1/sessions.

type SessionLogsResponse

type SessionLogsResponse struct {
	SessionID    string    `json:"session_id"`
	LogPath      string    `json:"log_path"`
	SizeBytes    int64     `json:"size_bytes"`
	LastModified time.Time `json:"last_modified"`
}

SessionLogsResponse is the response for GET /admin/v1/sessions/:id/logs.

type SessionStats

type SessionStats struct {
	InputTokens  int64 `json:"input_tokens"`
	OutputTokens int64 `json:"output_tokens"`
	DurationSecs int64 `json:"duration_seconds"`
}

SessionStats contains session statistics.

type StatsResponse

type StatsResponse struct {
	TotalSessions   int     `json:"total_sessions"`
	ActiveSessions  int     `json:"active_sessions"`
	StoppedSessions int     `json:"stopped_sessions"`
	Uptime          string  `json:"uptime"`
	MemoryUsageMB   float64 `json:"memory_usage_mb"`
	CpuUsagePercent float64 `json:"cpu_usage_percent"`
}

StatsResponse is the response for GET /admin/v1/stats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL