server

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package server exposes yaad over the network: the REST API, the MCP server, and the browser dashboard, all backed by the same engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PollStale added in v0.1.1

func PollStale(broadcaster *SSEBroadcaster, store storage.Storage, g interface {
	Impact(string, int) ([]string, error)
}, interval time.Duration,
)

PollStale periodically checks for stale memories and broadcasts events. Runs until the context is cancelled. interval controls how often to check.

func ServeDashboard

func ServeDashboard(mux *http.ServeMux)

ServeDashboard serves the graph visualization dashboard at /yaad/ui.

Types

type MCPServer

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

MCPServer wraps the MCP protocol server for Hawk integration.

func NewMCPServer

func NewMCPServer(eng *engine.Engine) *MCPServer

NewMCPServer creates an MCP server with all yaad tools registered.

func (*MCPServer) ServeHTTP added in v0.1.1

func (s *MCPServer) ServeHTTP(addr string) error

ServeHTTP starts the MCP server on a streamable HTTP endpoint. The default endpoint path is /mcp. Clients connect to http://<addr>/mcp.

func (*MCPServer) ServeHTTPWithShutdown added in v0.1.1

func (s *MCPServer) ServeHTTPWithShutdown(addr string) (*mcpserver.StreamableHTTPServer, error)

ServeHTTPWithShutdown starts the MCP server on a streamable HTTP endpoint and returns the server so the caller can invoke Shutdown for graceful teardown.

func (*MCPServer) ServeStdio

func (s *MCPServer) ServeStdio() error

ServeStdio starts the MCP server on stdin/stdout.

type MemoryEvent

type MemoryEvent struct {
	Type      MemoryEventType `json:"type"`
	NodeID    string          `json:"node_id"`
	Content   string          `json:"content,omitempty"`
	Timestamp int64           `json:"timestamp"`
}

MemoryEvent is a real-time notification about a memory change.

type MemoryEventType added in v0.1.1

type MemoryEventType string

MemoryEventType describes the kind of memory event.

const (
	MemoryEventCreated MemoryEventType = "created"
	MemoryEventUpdated MemoryEventType = "updated"
	MemoryEventDeleted MemoryEventType = "deleted"
)

type RESTServer

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

RESTServer serves the HTTP API.

func NewRESTServer

func NewRESTServer(eng *engine.Engine, addr string) *RESTServer

NewRESTServer creates a REST server.

func (*RESTServer) ListenAndServe

func (s *RESTServer) ListenAndServe() error

ListenAndServe starts the HTTP server with middleware.

func (*RESTServer) RegisterRoutes

func (s *RESTServer) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers all routes on the given mux (useful for testing).

func (*RESTServer) Shutdown added in v0.1.1

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

Shutdown gracefully shuts down the REST server with a timeout.

func (*RESTServer) WithAPIKey added in v0.1.1

func (s *RESTServer) WithAPIKey(key string) *RESTServer

WithAPIKey sets the API key required for authenticated requests (Bearer / X-API-Key).

func (*RESTServer) WithBroadcaster added in v0.1.1

func (s *RESTServer) WithBroadcaster(b *SSEBroadcaster) *RESTServer

WithBroadcaster attaches an SSE broadcaster to the REST server.

func (*RESTServer) WithEmbedder

func (s *RESTServer) WithEmbedder(p embeddings.Provider) *RESTServer

WithEmbedder sets the embedding provider for vector search.

func (*RESTServer) WithProjectDir added in v0.1.1

func (s *RESTServer) WithProjectDir(dir string) *RESTServer

WithProjectDir sets the project directory for git-based staleness detection.

func (*RESTServer) WithTLS

func (s *RESTServer) WithTLS(cfg *stdtls.Config) *RESTServer

WithTLS sets TLS config on the server.

type SSEBroadcaster added in v0.1.1

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

SSEBroadcaster manages Server-Sent Event connections for streaming memory and staleness notifications. Provides the same streaming semantics as the gRPC WatchMemories and WatchStale RPCs defined in yaad.proto, but over HTTP/SSE for broad client compatibility.

func NewSSEBroadcaster added in v0.1.1

func NewSSEBroadcaster(eng *engine.Engine) *SSEBroadcaster

NewSSEBroadcaster creates a new SSE broadcaster.

func (*SSEBroadcaster) BroadcastMemoryEvent added in v0.1.1

func (b *SSEBroadcaster) BroadcastMemoryEvent(evt MemoryEvent)

BroadcastMemoryEvent sends a memory event to all connected memory subscribers.

func (*SSEBroadcaster) BroadcastStaleEvent added in v0.1.1

func (b *SSEBroadcaster) BroadcastStaleEvent(evt StaleEvent)

BroadcastStaleEvent sends a stale event to all connected stale subscribers.

func (*SSEBroadcaster) Start added in v0.1.1

func (b *SSEBroadcaster) Start(ctx context.Context)

Start subscribes the broadcaster to the engine's in-process memory event bus and forwards every Remember/Forget mutation to connected SSE memory subscribers. It runs until ctx is cancelled (then unsubscribes from the engine). Call it once, typically in a goroutine, after constructing the broadcaster. Safe to call with a nil engine (it becomes a no-op).

type StaleEvent added in v0.1.1

type StaleEvent struct {
	NodeID   string `json:"node_id"`
	Reason   string `json:"reason"`
	FilePath string `json:"file_path"`
	// Timestamp is unix milliseconds.
	Timestamp int64 `json:"timestamp"`
}

StaleEvent is a notification about a stale memory.

Jump to

Keyboard shortcuts

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