api

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 12 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 FactResponse added in v0.14.0

type FactResponse struct {
	Fact *types.Fact `json:"fact"`
}

FactResponse is the response for GET /api/v1/facts/{id}

type FactsIndexResponse added in v0.14.0

type FactsIndexResponse struct {
	Facts []types.Fact `json:"facts"`
	Count int          `json:"count"`
	Stats FactsStats   `json:"stats"`
}

FactsIndexResponse is the response for GET /api/v1/facts/index

type FactsStats added in v0.14.0

type FactsStats struct {
	TotalFacts int `json:"total_facts"`
	MaxFacts   int `json:"max_facts"`
}

FactsStats provides summary statistics for facts

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 FilesIndexResponse added in v0.14.0

type FilesIndexResponse struct {
	Index *types.FileIndex `json:"index"`
}

FilesIndexResponse is the response for GET /api/v1/files/index

type FilesQueryParams added in v0.14.0

type FilesQueryParams struct {
	Q        string `json:"q,omitempty"`
	Category string `json:"category,omitempty"`
	Days     int    `json:"days,omitempty"`
	Entity   string `json:"entity,omitempty"`
	Tag      string `json:"tag,omitempty"`
	Topic    string `json:"topic,omitempty"`
	Limit    int    `json:"limit"`
}

FilesQueryParams echoes back the query parameters used

type FilesQueryResponse added in v0.14.0

type FilesQueryResponse struct {
	Files []graph.SearchResult `json:"files"`
	Count int                  `json:"count"`
	Query FilesQueryParams     `json:"query"`
}

FilesQueryResponse is the unified response for GET /api/v1/files This replaces POST /api/v1/search, GET /api/v1/files/recent, and GET /api/v1/entities/search

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.FileIndex, 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

	// Semantic provider info
	SemanticEnabled  bool
	SemanticProvider string
	SemanticModel    string

	// 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.FileIndex, error)
}

IndexProvider is an interface for getting the current index

type RebuildHandler

type RebuildHandler interface {
	// Rebuild triggers an immediate index rebuild
	Rebuild() error
	// RebuildWithSync triggers a rebuild and optionally syncs graph with filesystem
	// When sync is true, stale graph nodes (files no longer on disk) are removed
	RebuildWithSync(sync bool) 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 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.FileIndex `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

Jump to

Keyboard shortcuts

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