Documentation
¶
Overview ¶
Package client wraps the MemSpace server HTTP API for client-side use.
Index ¶
- func IsStatus(err error, status int) bool
- func PrivateHost(host string) bool
- func Retryable(err error) bool
- type Client
- func (c *Client) BatchEvents(ctx context.Context, projectID string, events []model.Event) (*model.BatchEventsResponse, error)
- func (c *Client) ClaimDevice(ctx context.Context, claimToken string) (*model.DeviceRequestStatus, error)
- func (c *Client) Do(ctx context.Context, method, path string, reqBody, respBody any) error
- func (c *Client) EmbeddingStatus(ctx context.Context) (*EmbeddingStatus, error)
- func (c *Client) EnsureProject(ctx context.Context, name, gitIdentity string) (string, error)
- func (c *Client) EnsureSession(ctx context.Context, req model.EnsureSessionRequest) (*model.EnsureSessionResponse, error)
- func (c *Client) Health(ctx context.Context) (string, error)
- func (c *Client) Register(ctx context.Context, name, platform, invite string) (deviceID, token string, err error)
- func (c *Client) ReportSync(ctx context.Context, rep model.SyncReport) error
- func (c *Client) RequestDevice(ctx context.Context, name, platform, version string) (*model.DeviceRequestCreated, error)
- func (c *Client) RotateMCPToken(ctx context.Context) (string, error)
- func (c *Client) Search(ctx context.Context, req model.SearchRequest) (*model.SearchResponse, error)
- func (c *Client) ServerVersion(ctx context.Context) (string, error)
- func (c *Client) SyncStatus(ctx context.Context) (*model.SyncStatusResponse, error)
- type EmbeddingStatus
- type HTTPError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrivateHost ¶
PrivateHost reports whether host is a loopback, private, link-local or CGNAT address, or a single-label / .local / .lan / .internal / .home.arpa name.
Types ¶
type Client ¶
Client is an HTTP client for the MemSpace server.
func (*Client) BatchEvents ¶
func (c *Client) BatchEvents(ctx context.Context, projectID string, events []model.Event) (*model.BatchEventsResponse, error)
BatchEvents uploads a batch of events for one project.
func (*Client) ClaimDevice ¶
func (c *Client) ClaimDevice(ctx context.Context, claimToken string) (*model.DeviceRequestStatus, error)
ClaimDevice polls a device request. Status is "pending", "approved" (with the device token), "denied", "expired" (also when already claimed) or "unknown".
func (*Client) EmbeddingStatus ¶
func (c *Client) EmbeddingStatus(ctx context.Context) (*EmbeddingStatus, error)
EmbeddingStatus returns the state of semantic search on the server.
func (*Client) EnsureProject ¶
EnsureProject idempotently resolves a project by Git identity or name.
func (*Client) EnsureSession ¶
func (c *Client) EnsureSession(ctx context.Context, req model.EnsureSessionRequest) (*model.EnsureSessionResponse, error)
EnsureSession idempotently resolves a session.
func (*Client) Register ¶
func (c *Client) Register(ctx context.Context, name, platform, invite string) (deviceID, token string, err error)
Register calls POST /api/v1/devices with a one-time invite and returns the device id and token.
func (*Client) ReportSync ¶
ReportSync sends the local spool state (POST /api/v1/sync/report).
func (*Client) RequestDevice ¶
func (c *Client) RequestDevice(ctx context.Context, name, platform, version string) (*model.DeviceRequestCreated, error)
RequestDevice asks to join without an invite; an administrator approves the request (POST /api/v1/device-requests).
func (*Client) RotateMCPToken ¶
RotateMCPToken issues a new read-only MCP token for this device.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, req model.SearchRequest) (*model.SearchResponse, error)
Search runs a full-text search.
func (*Client) ServerVersion ¶
Health calls GET /api/v1/health (no auth required). ServerVersion returns the version the server reports ("" for servers that predate reporting it).
func (*Client) SyncStatus ¶
SyncStatus returns the server's view of this device.
type EmbeddingStatus ¶
type EmbeddingStatus struct {
Enabled bool `json:"enabled"`
Active *struct {
Model string `json:"model"`
Docs int `json:"docs_embedded"`
Pending int `json:"docs_pending"`
} `json:"active_space"`
Building *struct {
Model string `json:"model"`
Docs int `json:"docs_embedded"`
Pending int `json:"docs_pending"`
} `json:"building_space"`
LastError string `json:"last_error"`
}
EmbeddingStatus describes the server's semantic index.