Documentation
¶
Overview ¶
Package httpclient provides a memstore.Store implementation that talks to a memstored daemon over HTTP. It is the daemon-mode client for memstore-mcp and the CLI.
Index ¶
- type BackfillFeedbackResult
- type Client
- func (c *Client) ActiveCount(ctx context.Context) (int64, error)
- func (c *Client) BackfillFeedback(ctx context.Context) (*BackfillFeedbackResult, error)
- func (c *Client) Breakdown(ctx context.Context) (memstore.FactBreakdown, error)
- func (c *Client) BySubject(ctx context.Context, subject string, onlyActive bool) ([]memstore.Fact, error)
- func (c *Client) Close() error
- func (c *Client) Confirm(ctx context.Context, id int64) error
- func (c *Client) Delete(ctx context.Context, id int64) error
- func (c *Client) DeleteLink(ctx context.Context, linkID int64) error
- func (c *Client) EmbedFacts(_ context.Context, _ int) (int, error)
- func (c *Client) Exists(ctx context.Context, content, subject string) (bool, error)
- func (c *Client) FactChunks(_ context.Context, _ int64) ([]memstore.FactChunk, error)
- func (c *Client) Get(ctx context.Context, id int64) (*memstore.Fact, error)
- func (c *Client) GetLink(ctx context.Context, linkID int64) (*memstore.Link, error)
- func (c *Client) GetLinks(ctx context.Context, factID int64, direction memstore.LinkDirection, ...) ([]memstore.Link, error)
- func (c *Client) GetPendingHints(ctx context.Context, sessionID, cwd string) ([]memstore.ContextHint, error)
- func (c *Client) History(ctx context.Context, id int64, subject string) ([]memstore.HistoryEntry, error)
- func (c *Client) Insert(ctx context.Context, f memstore.Fact) (int64, error)
- func (c *Client) InsertBatch(ctx context.Context, facts []memstore.Fact) error
- func (c *Client) LinkFacts(ctx context.Context, sourceID, targetID int64, linkType string, ...) (int64, error)
- func (c *Client) List(ctx context.Context, opts memstore.QueryOpts) ([]memstore.Fact, error)
- func (c *Client) ListSubsystems(ctx context.Context, subject string) ([]string, error)
- func (c *Client) MarkEmbedFailed(_ context.Context, _ int64, _ string) error
- func (c *Client) MarkHintConsumed(ctx context.Context, hintID int64) error
- func (c *Client) NeedingEmbedding(_ context.Context, _ int) ([]memstore.Fact, error)
- func (c *Client) PostHint(ctx context.Context, hint memstore.ContextHint) error
- func (c *Client) PostSessionHook(ctx context.Context, rawPayload json.RawMessage) error
- func (c *Client) PostSessionTranscript(ctx context.Context, sessionID, cwd, persona, content string) error
- func (c *Client) RecordFeedback(ctx context.Context, fb memstore.ContextFeedback) error
- func (c *Client) RecordInjection(ctx context.Context, sessionID, refID, refType string, rank int) error
- func (c *Client) Search(ctx context.Context, query string, opts memstore.SearchOpts) ([]memstore.SearchResult, error)
- func (c *Client) SearchBatch(ctx context.Context, queries []string, opts memstore.SearchOpts) ([][]memstore.SearchResult, error)
- func (c *Client) SearchFTS(ctx context.Context, query string, opts memstore.SearchOpts) ([]memstore.SearchResult, error)
- func (c *Client) SetEmbedding(_ context.Context, _ int64, _ []float32) error
- func (c *Client) SetFactVectors(_ context.Context, _ int64, _ memstore.FactVectors) error
- func (c *Client) Supersede(ctx context.Context, oldID, newID int64) error
- func (c *Client) SyncDocuments(ctx context.Context, repoURL string, entries []DocSyncEntry) (*DocSyncResult, error)
- func (c *Client) Touch(ctx context.Context, ids []int64) error
- func (c *Client) UpdateLink(ctx context.Context, linkID int64, label string, metadata map[string]any) error
- func (c *Client) UpdateMetadata(ctx context.Context, id int64, patch map[string]any) error
- func (c *Client) UploadDocument(ctx context.Context, up DocUpload) (*DocUploadResult, error)
- func (c *Client) WhoAmI(ctx context.Context) (memstore.WhoAmIResponse, error)
- type ClientOptions
- type DocSkip
- type DocSyncEntry
- type DocSyncResult
- type DocUpload
- type DocUploadResult
- type HTTPError
- type HTTPGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackfillFeedbackResult ¶
type BackfillFeedbackResult struct {
Sessions int `json:"sessions"`
Rated int `json:"rated"`
Errors int `json:"errors"`
}
BackfillFeedbackResult mirrors httpapi.BackfillResult.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements memstore.Store by calling the memstored HTTP API.
func New ¶
New creates a client pointing at the given memstored base URL. If apiKey is non-empty, it is sent as Bearer token on every request.
func NewWithOptions ¶
func NewWithOptions(baseURL, apiKey string, opts ClientOptions) (*Client, error)
NewWithOptions is New with TLS configuration applied. Returns an error if the TLS config in opts cannot be loaded (bad cert path, malformed PEM).
func (*Client) BackfillFeedback ¶
func (c *Client) BackfillFeedback(ctx context.Context) (*BackfillFeedbackResult, error)
BackfillFeedback triggers a full backfill of fact feedback scores on the daemon.
func (*Client) Close ¶
Close is a no-op for the HTTP client — there is no local resource to release.
func (*Client) FactChunks ¶
func (*Client) GetPendingHints ¶
func (c *Client) GetPendingHints(ctx context.Context, sessionID, cwd string) ([]memstore.ContextHint, error)
GetPendingHints returns unconsumed context hints matching sessionID or cwd (OR semantics). Either may be empty; pass both for maximum coverage.
func (*Client) InsertBatch ¶
func (*Client) ListSubsystems ¶
func (*Client) MarkEmbedFailed ¶
func (*Client) MarkHintConsumed ¶
MarkHintConsumed marks a context hint as consumed so it is not re-injected.
func (*Client) NeedingEmbedding ¶
func (*Client) PostHint ¶
PostHint stores a context hint on the daemon. Used by the Stop hook to emit a "store your decisions" nudge after a session crosses a turn threshold without storing anything.
func (*Client) PostSessionHook ¶
PostSessionHook forwards a raw Claude Code Stop hook payload to the daemon.
func (*Client) PostSessionTranscript ¶
func (c *Client) PostSessionTranscript(ctx context.Context, sessionID, cwd, persona, content string) error
PostSessionTranscript forwards a JSONL session transcript to the daemon. persona is the OS-level user who ran the session; the daemon uses it as the subject for user/preference-scoped session summaries. Pass an empty string to let the daemon fall back to its routing default.
func (*Client) RecordFeedback ¶
RecordFeedback posts context feedback to the daemon. Implements the minimal subset of memstore.SessionStore needed by memstore-mcp for memory_rate_context.
func (*Client) RecordInjection ¶
func (c *Client) RecordInjection(ctx context.Context, sessionID, refID, refType string, rank int) error
RecordInjection records that a ref was injected into a session (dedup log). rank is the 0-based position of the item in the candidate list; -1 if unknown.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query string, opts memstore.SearchOpts) ([]memstore.SearchResult, error)
func (*Client) SearchBatch ¶
func (c *Client) SearchBatch(ctx context.Context, queries []string, opts memstore.SearchOpts) ([][]memstore.SearchResult, error)
func (*Client) SearchFTS ¶
func (c *Client) SearchFTS(ctx context.Context, query string, opts memstore.SearchOpts) ([]memstore.SearchResult, error)
func (*Client) SetEmbedding ¶
func (*Client) SetFactVectors ¶
func (*Client) SyncDocuments ¶
func (c *Client) SyncDocuments(ctx context.Context, repoURL string, entries []DocSyncEntry) (*DocSyncResult, error)
SyncDocuments posts the manifest for one repo identity (repoURL "" = loose files) and returns the delta. Orphaned documents are deleted server-side.
func (*Client) UpdateLink ¶
func (*Client) UpdateMetadata ¶
func (*Client) UploadDocument ¶
UploadDocument ships one file. The daemon hashes, verifies, chunks, and stores; a hash mismatch or unroutable file comes back as an error.
func (*Client) WhoAmI ¶
WhoAmI reports what the client's credential may do, as computed by the daemon. Callers should read the Allows field rather than Scopes: the implication rules live server-side precisely so a client does not reimplement them.
A daemon predating the endpoint returns 404, which surfaces as an error. Callers that use this to shape optional behaviour should treat any error as "unknown" and fall back to their configured default, not as "no permissions" -- a network blip must not silently strip capability.
type ClientOptions ¶
ClientOptions configures TLS behavior for outbound requests to memstored.
TLSCAFile is added to the system trust store (not a replacement). Use it to trust a self-signed memstored cert without modifying the OS root store.
TLSClientCertFile / TLSClientKeyFile are presented during the TLS handshake when memstored is configured with --tls-client-ca-file (mTLS). Both must be set together or neither.
func ClientOptionsFromConfig ¶
func ClientOptionsFromConfig(cfg memstore.AppConfig) ClientOptions
ClientOptionsFromConfig pulls client-side TLS knobs out of an AppConfig.
func (ClientOptions) HasTLSConfig ¶
func (o ClientOptions) HasTLSConfig() bool
HasTLSConfig reports whether any TLS-related field is set.
type DocSyncEntry ¶
type DocSyncEntry struct {
Path string `json:"path"`
SHA256 string `json:"sha256"` // hex
Size int64 `json:"size"`
}
DocSyncEntry is one manifest line: a file the client can see.
type DocSyncResult ¶
type DocSyncResult struct {
Need []string `json:"need"`
Skip []DocSkip `json:"skip"`
Orphaned []string `json:"orphaned"`
Unchanged int `json:"unchanged"`
}
DocSyncResult is the daemon's manifest delta.
type DocUpload ¶
type DocUpload struct {
RepoURL string
Commit string
Path string
Content []byte
SHA256 string // hex of Content
Mtime *time.Time
Dirty bool
}
DocUpload is one file's bytes plus the client-asserted provenance.
type DocUploadResult ¶
type DocUploadResult struct {
ID int64 `json:"id"`
Chunks int `json:"chunks"`
Strategy string `json:"strategy"`
}
DocUploadResult reports what the daemon stored.
type HTTPError ¶
HTTPError represents an error response from the daemon.
func (*HTTPError) Unwrap ¶
Unwrap maps a 404 onto memstore.ErrNotFound so errors.Is works the same against the daemon as it does in-process. The MCP server runs over this client in the deployed configuration, and it routes a miss and a store failure to different channels (#165); without this the daemon collapses that distinction at the network boundary.
type HTTPGenerator ¶
type HTTPGenerator struct {
// contains filtered or unexported fields
}
HTTPGenerator implements memstore.Generator and memstore.JSONGenerator by calling the memstored /v1/generate endpoints. This keeps Ollama access server-side so clients don't need direct Ollama connectivity.
func NewHTTPGenerator ¶
func NewHTTPGenerator(baseURL, apiKey string) *HTTPGenerator
NewHTTPGenerator creates a generator that talks to memstored.
func NewHTTPGeneratorWithOptions ¶
func NewHTTPGeneratorWithOptions(baseURL, apiKey string, opts ClientOptions) (*HTTPGenerator, error)
NewHTTPGeneratorWithOptions is NewHTTPGenerator with TLS configuration.
func (*HTTPGenerator) GenerateJSON ¶
func (*HTTPGenerator) Model ¶
func (g *HTTPGenerator) Model() string
Model returns "remote" since the actual model is determined server-side.