api

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Error   string `json:"error"`
	Code    string `json:"code,omitempty"`
	Details string `json:"details,omitempty"`
}

APIError represents an error response

type EntitySearchResponse

type EntitySearchResponse struct {
	Results []graph.SearchResult `json:"results"`
	Count   int                  `json:"count"`
}

EntitySearchResponse is the response for GET /api/v1/entities/search

type FileMetadataResponse

type FileMetadataResponse struct {
	File *types.FileEntry `json:"file"`
}

FileMetadataResponse is the response for GET /api/v1/files/{path} Uses the new graph-native FileEntry format which includes related files

type HTTPServer

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

HTTPServer manages the daemon's unified HTTP API

func NewHTTPServer

func NewHTTPServer(hub *SSEHub, metrics HealthMetricsProvider, graphManager *graph.Manager, memoryRoot string, logger *slog.Logger) *HTTPServer

NewHTTPServer creates a new unified HTTP server

func (*HTTPServer) GetIndex

func (s *HTTPServer) GetIndex(ctx context.Context) (*types.GraphIndex, error)

GetIndex exports the current index (for SSE hub to include in events)

func (*HTTPServer) SetRebuildHandler

func (s *HTTPServer) SetRebuildHandler(handler RebuildHandler)

SetRebuildHandler sets the rebuild handler for the API

func (*HTTPServer) Start

func (s *HTTPServer) Start(port int) error

Start starts the HTTP server on the specified port If a server is already running, it will be stopped first (supports hot-reload)

func (*HTTPServer) Stop

func (s *HTTPServer) Stop() error

Stop gracefully shuts down the HTTP server

type HealthMetricsProvider

type HealthMetricsProvider interface {
	GetSnapshot() HealthSnapshot
}

HealthMetricsProvider provides health metrics for the health endpoint

type HealthSnapshot

type HealthSnapshot struct {
	StartTime        time.Time
	Uptime           string
	UptimeSeconds    float64
	FilesProcessed   int
	APICalls         int
	CacheHits        int
	Errors           int
	LastBuildTime    time.Time
	LastBuildSuccess bool
	IndexFileCount   int
	WatcherActive    bool

	// Cache versioning stats
	CacheVersion       string
	CacheTotalEntries  int
	CacheLegacyEntries int
	CacheTotalSize     int64
}

HealthSnapshot contains health metrics data

type IndexProvider

type IndexProvider interface {
	GetIndex(ctx context.Context) (*types.GraphIndex, error)
}

IndexProvider is an interface for getting the current index

type IndexResponse

type IndexResponse struct {
	Index *types.GraphIndex `json:"index"`
}

IndexResponse is the response for GET /api/v1/index

type RebuildHandler

type RebuildHandler interface {
	// Rebuild triggers an immediate index rebuild
	Rebuild() error
	// ClearGraph clears all data from the graph
	ClearGraph() error
	// IsRebuilding returns true if a rebuild is in progress
	IsRebuilding() bool
}

RebuildHandler provides rebuild functionality from the daemon

type RebuildResponse

type RebuildResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

RebuildResponse is the response for POST /api/v1/rebuild

type RecentFilesResponse

type RecentFilesResponse struct {
	Files []graph.SearchResult `json:"files"`
	Count int                  `json:"count"`
}

RecentFilesResponse is the response for GET /api/v1/files/recent

type RelatedFilesResponse

type RelatedFilesResponse struct {
	Files []graph.RelatedFile `json:"files"`
	Count int                 `json:"count"`
}

RelatedFilesResponse is the response for GET /api/v1/files/related

type SSEClient

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

SSEClient represents a connected SSE client

type SSEEvent

type SSEEvent struct {
	Type      string            `json:"type"`
	Timestamp string            `json:"timestamp"`
	Data      *types.GraphIndex `json:"data,omitempty"`
}

SSEEvent represents an SSE event with typed data

type SSEHub

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

SSEHub manages Server-Sent Events broadcasting for index updates

func NewSSEHub

func NewSSEHub(logger *slog.Logger) *SSEHub

NewSSEHub creates a new SSE broadcast hub

func (*SSEHub) BroadcastIndexUpdate

func (h *SSEHub) BroadcastIndexUpdate()

BroadcastIndexUpdate sends index update notification to all connected clients

func (*SSEHub) ClientCount

func (h *SSEHub) ClientCount() int

ClientCount returns the number of connected SSE clients

func (*SSEHub) HandleSSE

func (h *SSEHub) HandleSSE(w http.ResponseWriter, r *http.Request)

HandleSSE handles SSE stream requests from MCP servers

func (*SSEHub) SetIndexProvider

func (h *SSEHub) SetIndexProvider(provider IndexProvider)

SetIndexProvider sets the index provider for including index data in events

type SearchRequest

type SearchRequest struct {
	Query    string `json:"query"`
	Limit    int    `json:"limit,omitempty"`
	Category string `json:"category,omitempty"`
}

SearchRequest is the request body for POST /api/v1/search

type SearchResponse

type SearchResponse struct {
	Results []graph.SearchResult `json:"results"`
	Count   int                  `json:"count"`
}

SearchResponse is the response for search endpoints

Jump to

Keyboard shortcuts

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