Documentation
¶
Overview ¶
Package server exposes the memory over MCP (streamable HTTP, loopback) with nine tools.
Index ¶
- Constants
- func VectorLine(ctx context.Context, db *index.DB, emb index.Embedder) string
- func VectorsHeader(reason error) string
- type FactIn
- type FeedbackIn
- type LearnIn
- type ListIn
- type RecallIn
- type RetireIn
- type Server
- func (s *Server) CatchUp(ctx context.Context, interval time.Duration)
- func (s *Server) ContextBlock(ctx context.Context, query, project string, budget int) (block string, warn error)
- func (s *Server) Handler() http.Handler
- func (s *Server) Recall(ctx context.Context, in RecallIn) string
- func (s *Server) Reload() error
- func (s *Server) Rights(req *mcp.CallToolRequest) (*access.Rights, error)
- func (s *Server) Stats(ctx context.Context, in StatsIn) string
- type StatsIn
- type VerifyIn
- type WikiReadIn
Constants ¶
const ( QuotaWiki = 2 QuotaMemory = 1 QuotaGlobal = 1 HitChars = 600 Version = "0.1.0" // MaxQuery is the longest recall query, in characters; a longer one is cut. MaxQuery = 2000 )
Quotas per layer for an unrestricted recall, and the cap on one hit's text.
Variables ¶
This section is empty.
Functions ¶
func VectorLine ¶
VectorLine is the vector state for stats: on with the model and the number of embedded chunks, off, or unavailable with the reason. It asks the embedder (at most 10 s); with no embedder it makes no call.
func VectorsHeader ¶
VectorsHeader is the one line that goes first in an answer that had to use keywords only.
Types ¶
type FactIn ¶
type FactIn struct {
Text string `json:"text" jsonschema:"one durable fact"`
Project string `json:"project,omitempty" jsonschema:"project name; empty means global"`
Category string `json:"category,omitempty" jsonschema:"for example user_pref, project, tool, general"`
Trust float64 `json:"trust,omitempty" jsonschema:"0 to 1, default 0.5"`
}
type FeedbackIn ¶
type FeedbackIn struct {
ID string `json:"id" jsonschema:"short id recall printed"`
Rating string `json:"rating" jsonschema:"helpful or unhelpful"`
Session string `json:"session" jsonschema:"required: a stable name for this conversation or run; only a session's last rating counts"`
Project string `json:"project,omitempty" jsonschema:"restrict the lookup to this project"`
}
type LearnIn ¶
type LearnIn struct {
Text string `json:"text" jsonschema:"one learning, a sentence or two (cut at 500 characters)"`
Project string `json:"project,omitempty" jsonschema:"project name; empty means global"`
Kind string `` /* 182-byte string literal not displayed */
Supersedes string `json:"supersedes,omitempty" jsonschema:"short id (or unique prefix) of the note this one replaces"`
}
type ListIn ¶
type ListIn struct {
Project string `json:"project,omitempty" jsonschema:"the project whose notes to list; required without tokens"`
Status string `json:"status,omitempty" jsonschema:"empty for all, unverified or active"`
Limit int `json:"limit,omitempty" jsonschema:"notes per page, default 50, at most 200"`
Offset int `json:"offset,omitempty" jsonschema:"notes to skip, default 0"`
}
type RecallIn ¶
type RecallIn struct {
Query string `json:"query" jsonschema:"what to look for, in plain words"`
Project string `json:"project,omitempty" jsonschema:"project name; empty searches every project"`
Layer string `json:"layer,omitempty" jsonschema:"auto (default), wiki, memory or fact"`
Budget int `json:"budget,omitempty" jsonschema:"maximum characters in the answer (0 means no limit)"`
// contains filtered or unexported fields
}
type RetireIn ¶
type RetireIn struct {
ID string `json:"id" jsonschema:"short id recall prints, or a unique prefix of it (at least 4 characters)"`
Reason string `json:"reason,omitempty" jsonschema:"why the note is withdrawn"`
Project string `json:"project,omitempty" jsonschema:"restrict the lookup to this project"`
}
type Server ¶
type Server struct {
St *store.Store
DB *index.DB
Emb index.Embedder
// TokensDir, if set, turns token mode on: /mcp needs a bearer token listed in a file there (see package access).
TokensDir string
// contains filtered or unexported fields
}
Server holds what the tools need. The vector matrix is loaded once and reloaded after a write.
func NewReader ¶
NewReader makes a server that can only answer recall: no store, no writes. The command-line context format uses it.
func (*Server) CatchUp ¶
CatchUp embeds the chunks that have no vector, once now and then every interval, until ctx ends. It runs beside the service and never holds the write lock: a write or a recall does not wait for it. A failing embedder is not an error here; the next round tries again. After a round that embedded something the vector matrix is reloaded.
func (*Server) ContextBlock ¶
func (s *Server) ContextBlock(ctx context.Context, query, project string, budget int) (block string, warn error)
ContextBlock is the text a harness hook adds in front of a prompt: only real hits, no empty-state lines (a prompt that finds nothing adds nothing). It is empty when there is nothing to add. warn is why vectors were not used, for the caller to put on standard error; it is never part of the block.
func (*Server) Handler ¶
Handler builds the MCP HTTP handler. Each connection gets its own MCP server object over the shared state.
func (*Server) Recall ¶
Recall answers a query. It never returns an error to the caller: an empty index, no result and a failing part are three different lines (`not built`, `no results`, `unavailable: <reason>`).
type StatsIn ¶
type StatsIn struct {
Project string `json:"project,omitempty" jsonschema:"project name; empty counts everything"`
}
type WikiReadIn ¶
type WikiReadIn struct {
Path string `json:"path" jsonschema:"path under wiki/ (project/Page Title.md) or a page title (Page Title, or project/Page Title)"`
}