api

package
v0.0.0-...-ed100b9 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package api provides HTTP API handlers for TARSy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertResponse

type AlertResponse struct {
	SessionID string `json:"session_id"`
	Status    string `json:"status"`
	Message   string `json:"message"`
}

AlertResponse is returned by POST /api/v1/alerts.

type AlertTypeInfo

type AlertTypeInfo struct {
	Type        string `json:"type"`
	ChainID     string `json:"chain_id"`
	Description string `json:"description"`
}

AlertTypeInfo describes a single alert type and its associated chain.

type AlertTypesResponse

type AlertTypesResponse struct {
	AlertTypes       []AlertTypeInfo `json:"alert_types"`
	DefaultChainID   string          `json:"default_chain_id"`
	DefaultAlertType string          `json:"default_alert_type"`
}

AlertTypesResponse is returned by GET /api/v1/alert-types.

type CancelResponse

type CancelResponse struct {
	SessionID string `json:"session_id"`
	Message   string `json:"message"`
}

CancelResponse is returned by POST /api/v1/sessions/:id/cancel.

type DefaultToolsResponse

type DefaultToolsResponse struct {
	AlertType   string          `json:"alert_type,omitempty"`
	MCPServers  []string        `json:"mcp_servers"`
	NativeTools map[string]bool `json:"native_tools"`
}

DefaultToolsResponse is returned by GET /api/v1/system/default-tools.

type FilterOptionsResponse

type FilterOptionsResponse struct {
	AlertTypes []string `json:"alert_types"`
	ChainIDs   []string `json:"chain_ids"`
	Statuses   []string `json:"statuses"`
}

FilterOptionsResponse is returned by GET /api/v1/sessions/filter-options.

type HealthCheck

type HealthCheck struct {
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
}

HealthCheck represents the status of a single health check component.

type HealthResponse

type HealthResponse struct {
	Status  string                 `json:"status"`
	Version string                 `json:"version"`
	Checks  map[string]HealthCheck `json:"checks"`
}

HealthResponse is returned by GET /health.

type MCPServerStatus

type MCPServerStatus struct {
	ID        string        `json:"id"`
	Healthy   bool          `json:"healthy"`
	LastCheck string        `json:"last_check"`
	ToolCount int           `json:"tool_count"`
	Tools     []MCPToolInfo `json:"tools"`
	Error     *string       `json:"error"`
}

MCPServerStatus describes the health and tools of a single MCP server.

type MCPServersResponse

type MCPServersResponse struct {
	Servers []MCPServerStatus `json:"servers"`
}

MCPServersResponse is returned by GET /api/v1/system/mcp-servers.

type MCPToolInfo

type MCPToolInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

MCPToolInfo describes a single tool from an MCP server.

type ScoreSessionResponse

type ScoreSessionResponse struct {
	ScoreID string `json:"score_id"`
}

ScoreSessionResponse is the HTTP response for POST /sessions/:id/score.

type SendChatMessageRequest

type SendChatMessageRequest struct {
	Content string `json:"content"`
}

SendChatMessageRequest is the HTTP request body for POST /sessions/:id/chat/messages.

type SendChatMessageResponse

type SendChatMessageResponse struct {
	ChatID    string `json:"chat_id"`
	MessageID string `json:"message_id"`
	StageID   string `json:"stage_id"`
}

SendChatMessageResponse is the HTTP response for POST /sessions/:id/chat/messages.

type Server

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

Server is the HTTP API server.

func NewServer

func NewServer(
	cfg *config.Config,
	dbClient *database.Client,
	alertService *services.AlertService,
	sessionService *services.SessionService,
	workerPool *queue.WorkerPool,
	connManager *events.ConnectionManager,
) *Server

NewServer creates a new API server with Echo v5.

func (*Server) SetCancelNotifier

func (s *Server) SetCancelNotifier(cn events.SessionCancelNotifier)

SetCancelNotifier sets the cross-pod cancel notifier for session cancellation.

func (*Server) SetChatExecutor

func (s *Server) SetChatExecutor(executor *queue.ChatMessageExecutor)

SetChatExecutor sets the chat message executor for follow-up chat processing.

func (*Server) SetChatService

func (s *Server) SetChatService(svc *services.ChatService)

SetChatService sets the chat service for follow-up chat endpoints.

func (*Server) SetDashboardDir

func (s *Server) SetDashboardDir(dir string)

SetDashboardDir sets the path to the dashboard build directory and registers static file serving routes. When set and the directory contains an index.html, assets are served from /assets/* and a SPA fallback is registered for all non-API routes.

Must be called after NewServer (which registers API routes first) so that API routes take priority over the wildcard SPA fallback.

func (*Server) SetEventPublisher

func (s *Server) SetEventPublisher(pub agent.EventPublisher)

SetEventPublisher sets the event publisher for real-time event delivery.

func (*Server) SetHealthMonitor

func (s *Server) SetHealthMonitor(monitor *mcp.HealthMonitor)

SetHealthMonitor sets the MCP health monitor for the health endpoint.

func (*Server) SetInteractionService

func (s *Server) SetInteractionService(svc *services.InteractionService)

SetInteractionService sets the interaction service for trace endpoints.

func (*Server) SetMemoryService

func (s *Server) SetMemoryService(svc *memory.Service)

SetMemoryService sets the memory service for memory CRUD endpoints and review-triggered refinement.

func (*Server) SetRunbookService

func (s *Server) SetRunbookService(rs *runbook.Service)

SetRunbookService sets the runbook service for the runbook listing endpoint.

func (*Server) SetScoringExecutor

func (s *Server) SetScoringExecutor(executor *queue.ScoringExecutor)

SetScoringExecutor sets the scoring executor for the re-score endpoint.

func (*Server) SetScoringService

func (s *Server) SetScoringService(svc *services.ScoringService)

SetScoringService sets the scoring service for score read endpoints.

func (*Server) SetStageService

func (s *Server) SetStageService(svc *services.StageService)

SetStageService sets the stage service for trace endpoints.

func (*Server) SetTimelineService

func (s *Server) SetTimelineService(svc *services.TimelineService)

SetTimelineService sets the timeline service for the timeline endpoint.

func (*Server) SetWarningsService

func (s *Server) SetWarningsService(svc *services.SystemWarningsService)

SetWarningsService sets the system warnings service for the health endpoint.

func (*Server) Shutdown

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

Shutdown gracefully shuts down the HTTP server.

func (*Server) Start

func (s *Server) Start(addr string) error

Start starts the HTTP server on the given address (non-blocking).

func (*Server) StartWithListener

func (s *Server) StartWithListener(ln net.Listener) error

StartWithListener starts the HTTP server on a pre-created listener. Used by test infrastructure to serve on a random OS-assigned port.

func (*Server) ValidateWiring

func (s *Server) ValidateWiring() error

ValidateWiring checks that all required services have been wired via their Set* methods. Call this after all Set* calls and before Start/StartWithListener. Returns an error listing every missing service so that wiring gaps are caught at startup rather than surfacing as 503s at request time.

Services that are legitimately optional (e.g. healthMonitor / warningService when MCP is disabled) are NOT checked here.

type SubmitAlertRequest

type SubmitAlertRequest struct {
	AlertType               string                     `json:"alert_type"`
	Runbook                 string                     `json:"runbook,omitempty"`
	Data                    string                     `json:"data"`
	MCP                     *models.MCPSelectionConfig `json:"mcp,omitempty"`
	SlackMessageFingerprint string                     `json:"slack_message_fingerprint,omitempty"`
}

SubmitAlertRequest is the HTTP request body for POST /api/v1/alerts.

type SystemWarningItem

type SystemWarningItem struct {
	ID        string `json:"id"`
	Category  string `json:"category"`
	Message   string `json:"message"`
	Details   string `json:"details"`
	ServerID  string `json:"server_id,omitempty"`
	CreatedAt string `json:"created_at"`
}

SystemWarningItem is a single system warning.

type SystemWarningsResponse

type SystemWarningsResponse struct {
	Warnings []SystemWarningItem `json:"warnings"`
}

SystemWarningsResponse is returned by GET /api/v1/system/warnings.

Jump to

Keyboard shortcuts

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