Documentation
¶
Overview ¶
Package server provides the HTTP API for Engram.
This is how external clients (OpenCode plugin, Claude Code hooks, any agent) communicate with the memory engine. Simple JSON REST API.
Index ¶
- type SemanticPromptBuilder
- type SemanticRunnerFactory
- type Server
- func (s *Server) Close() error
- func (s *Server) Handler() http.Handler
- func (s *Server) SetOnWrite(fn func())
- func (s *Server) SetPromptBuilder(fn SemanticPromptBuilder)
- func (s *Server) SetRunnerFactory(fn SemanticRunnerFactory)
- func (s *Server) SetSocketPath(path string)
- func (s *Server) SetSyncStatus(provider SyncStatusProvider)
- func (s *Server) SetVersion(v string)
- func (s *Server) Start() error
- type SyncStatus
- type SyncStatusProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SemanticPromptBuilder ¶
type SemanticPromptBuilder func(a, b store.ObservationSnippet) string
SemanticPromptBuilder constructs the LLM prompt for a given pair of observation snippets. Injected from cmd/engram/main.go alongside SemanticRunnerFactory.
type SemanticRunnerFactory ¶
type SemanticRunnerFactory func(name string) (store.SemanticRunner, error)
SemanticRunnerFactory is a function that resolves a store.SemanticRunner by name. It is injected from cmd/engram/main.go so that internal/server does not depend on internal/llm directly (preserving the import-cycle boundary).
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Close ¶
Close stops the active listener and removes only the socket created by this server. It is safe to call repeatedly.
func (*Server) SetOnWrite ¶
func (s *Server) SetOnWrite(fn func())
SetOnWrite configures a callback invoked after every successful local write. This is used to notify autosync.Manager via NotifyDirty().
func (*Server) SetPromptBuilder ¶
func (s *Server) SetPromptBuilder(fn SemanticPromptBuilder)
SetPromptBuilder configures the LLM prompt builder for semantic scan pairs. When not set, an empty-string builder is used (valid for tests, not production).
func (*Server) SetRunnerFactory ¶
func (s *Server) SetRunnerFactory(fn SemanticRunnerFactory)
SetRunnerFactory configures the semantic runner factory used by POST /conflicts/scan when semantic=true. When not set, semantic=true requests fail with 500.
func (*Server) SetSocketPath ¶
SetSocketPath configures an exclusive POSIX Unix-domain socket listener. An empty path preserves the default loopback TCP listener.
func (*Server) SetSyncStatus ¶
func (s *Server) SetSyncStatus(provider SyncStatusProvider)
SetSyncStatus configures the sync status provider for the /sync/status endpoint.
func (*Server) SetVersion ¶
SetVersion sets the release version reported by GET /health.
type SyncStatus ¶
type SyncStatus struct {
Enabled bool `json:"enabled"`
Phase string `json:"phase"`
LastError string `json:"last_error,omitempty"`
ConsecutiveFailures int `json:"consecutive_failures"`
BackoffUntil *time.Time `json:"backoff_until,omitempty"`
LastSyncAt *time.Time `json:"last_sync_at,omitempty"`
ReasonCode string `json:"reason_code,omitempty"`
ReasonMessage string `json:"reason_message,omitempty"`
UpgradeStage string `json:"upgrade_stage,omitempty"`
UpgradeReasonCode string `json:"upgrade_reason_code,omitempty"`
UpgradeReasonMessage string `json:"upgrade_reason_message,omitempty"`
// Phase 2: deferred relation retry counts surfaced from sync_apply_deferred.
DeferredCount int `json:"deferred_count"`
DeadCount int `json:"dead_count"`
}
SyncStatus mirrors autosync.Status to avoid a direct import cycle.
type SyncStatusProvider ¶
type SyncStatusProvider interface {
Status(project string) SyncStatus
}
SyncStatusProvider returns the current sync status. This is implemented by autosync.Manager and injected from cmd/engram/main.go.