Documentation
¶
Overview ¶
Package api provides an HTTP API server for inspecting and managing the Merkle DAG.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ListenAddr is the address to listen on (e.g., ":8081")
ListenAddr string
// VectorDriver for semantic search (optional, enables MCP server)
VectorDriver vector.Driver
// Embedder for converting query text to vectors (optional, enables MCP server)
Embedder embeddings.Embedder
// Pricing is the model pricing table used by /v1/sessions/summary to
// compute per-session cost. When nil, sessions.DefaultPricing() is used.
Pricing sessions.PricingTable
}
Config is the API server configuration.
type Metrics ¶ added in v0.7.0
type Metrics struct {
// contains filtered or unexported fields
}
Metrics is the Prometheus surface for the Tapes API server. Each Server owns its own registry so tests can scrape in isolation; the production path mounts /metrics on the Fiber app via NewServer.
func NewMetrics ¶ added in v0.7.0
func NewMetrics() *Metrics
NewMetrics constructs the Tapes API server's RED metrics. Labels stay templated (`route`) rather than per-URL so :hash path params don't blow up cardinality.
func (*Metrics) Handler ¶ added in v0.7.0
Handler returns a Fiber handler that serves Prometheus text exposition from this Metrics instance's registry. Mount it at /metrics with no auth. The handler is built once at NewMetrics time and cached — see the scrapeHandler field comment for why.
func (*Metrics) Middleware ¶ added in v0.7.0
Middleware returns a Fiber handler that records request count + duration per (route template, method, status). Templates like /v1/sessions/:hash stay as the label value so the :hash path param never expands cardinality.
Register this OUTSIDE recover.New() (i.e. via app.Use before recover) — see resolveStatus for why.
func (*Metrics) Registry ¶ added in v0.7.0
func (m *Metrics) Registry() *prometheus.Registry
Registry exposes the *prometheus.Registry so tests can scrape against the same registry the middleware writes to.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the API server for managing and querying the Tapes system
func NewServer ¶
NewServer creates a new API server. The storer is injected to allow sharing with other components (e.g., the proxy when not run as a singleton).
func (*Server) RunWithListener ¶
RunWithListener starts the API server using the provided listener.
type SessionListItem ¶ added in v0.4.0
type SessionListItem struct {
Hash string `json:"hash"`
HeadRole string `json:"head_role,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitzero"`
Project string `json:"project,omitempty"`
AgentName string `json:"agent_name,omitempty"`
Model string `json:"model,omitempty"`
Provider string `json:"provider,omitempty"`
Preview string `json:"preview,omitempty"`
}
SessionListItem is the per-item shape returned by GET /v1/sessions.
It deliberately omits fields that would require an ancestry walk per item (e.g. started_at, depth, per-session aggregates). Callers that need those should fetch /v1/sessions/:hash for the specific session.
type SessionListResponse ¶ added in v0.4.0
type SessionListResponse struct {
Items []SessionListItem `json:"items"`
NextCursor string `json:"next_cursor,omitempty"`
}
SessionListResponse is the response envelope for GET /v1/sessions.
type SessionResponse ¶ added in v0.4.0
type SessionResponse struct {
// Hash is the head of the returned chain (== the requested hash).
Hash string `json:"hash"`
// Depth is the total number of turns in the full ancestry of Hash.
// When the client passes ?depth=N, the Turns array may contain fewer
// than Depth items.
Depth int `json:"depth"`
// Turns contains the chain in chronological order (root-first).
// When ?depth=N is supplied, only the last N turns (head + N-1 ancestors)
// are returned, still in chronological order.
Turns []Turn `json:"turns"`
// Truncated is true when the ancestry walk stopped at a parent_hash
// that could not be resolved in the current store. MissingParent
// names that hash. This is an expected edge case on stores that
// trim older data, merge foreign content, or offload history to
// another source — not an error.
Truncated bool `json:"truncated,omitempty"`
MissingParent string `json:"missing_parent,omitempty"`
}
SessionResponse is the response for GET /v1/sessions/:hash.
type SessionSummaryListResponse ¶ added in v0.4.0
type SessionSummaryListResponse struct {
Items []sessions.SessionSummary `json:"items"`
NextCursor string `json:"next_cursor,omitempty"`
}
SessionSummaryListResponse is the response envelope for GET /v1/sessions/summary. Items carry the rich per-session aggregates computed by pkg/sessions.BuildSummary.
type StatsResponse ¶ added in v0.4.0
type StatsResponse struct {
SessionCount int `json:"session_count"`
TurnCount int `json:"turn_count"`
RootCount int `json:"root_count"`
}
StatsResponse is the response for GET /v1/stats.
type Turn ¶ added in v0.4.0
type Turn struct {
Hash string `json:"hash"`
ParentHash *string `json:"parent_hash,omitempty"`
Role string `json:"role"`
Content []llm.ContentBlock `json:"content"`
Model string `json:"model,omitempty"`
Provider string `json:"provider,omitempty"`
AgentName string `json:"agent_name,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
Usage *llm.Usage `json:"usage,omitempty"`
CreatedAt time.Time `json:"created_at,omitzero"`
}
Turn is a single message in a session's chain.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mcp provides an MCP (Model Context Protocol) server for the Tapes system.
|
Package mcp provides an MCP (Model Context Protocol) server for the Tapes system. |
|
Package search provides shared search types and logic for semantic search over stored LLM sessions.
|
Package search provides shared search types and logic for semantic search over stored LLM sessions. |