Documentation
¶
Overview ¶
Package web serves `mesh ui`: a sovereign, single-binary localhost graph viewer (no CDN, no third-party JS, self-hosted fonts). It exposes the same in-memory graph the agent reads over MCP, as one /graph.json the SPA renders in two views (an Obsidian-style force graph and a galaxy orbiting the index note).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Serve ¶
func Serve(vaultRoot, addr, token, basePath string, verify func(string) (int64, string, bool), scopesFor func(int64) map[string]bool, roleFor func(int64) (string, bool)) error
Serve builds the server and listens on addr (e.g. 127.0.0.1:7474), printing the URL. A loopback bind needs no auth; binding beyond loopback is fail-closed and requires a token (see newAuthConfig). Serve builds the server and listens. When verify != nil the app runs in per-member mode (each request authenticates as a hub client and is scoped to them); member auth is then the fail-closed gate, so the single-token requirement is skipped. Otherwise it is the standalone single-token viewer (loopback needs no token).
Types ¶
type Export ¶
type Export struct {
Meta ExportMeta `json:"meta"`
Nodes []ExportNode `json:"nodes"`
Edges []ExportEdge `json:"edges"`
Communities []ExportComm `json:"communities"`
}
Export is the full graph payload the SPA consumes. Only note nodes and the note-to-note links are included (tags/headings are intra-structure); community, degree, size, and galaxy orbit are precomputed so the client only renders.
func BuildExport ¶
BuildExport projects the in-memory graph into the SPA payload. allowed (nil = unrestricted) filters notes to the caller's readable scopes; an excluded note drops out of nodes, so its edges and orbit fall away with it.
type ExportComm ¶
type ExportEdge ¶
type ExportMeta ¶
type ExportMeta struct {
Vault string `json:"vault"` // absolute vault root, for the editor:// bridge
IndexID string `json:"index_id"` // galaxy center: the highest-degree note
NodeCount int `json:"node_count"`
EdgeCount int `json:"edge_count"`
MaxOrbit int `json:"max_orbit"` // largest graph-distance from the index note
}
type ExportNode ¶
type ExportNode struct {
ID string `json:"id"` // frontmatter id
Label string `json:"label"` // title
Path string `json:"path"` // vault-relative
Line int `json:"line"` // source line for the editor bridge (1 = top)
Type string `json:"type"` // frontmatter type (decision/gotcha/entity/...)
Community int `json:"community"`
Degree int `json:"degree"`
Size float64 `json:"size"` // sqrt(degree), the client scales to a radius
Orbit int `json:"orbit"` // graph-distance from the index note (0 = center)
Tags []string `json:"tags,omitempty"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves the localhost graph viewer + app shell for one vault.
func (*Server) Handler ¶
Handler wires the routes: the SPA shell, the graph payload, embedded assets, and the /api surface, all behind the auth guard (a no-op on a loopback bind).
func (*Server) SetMemberAuth ¶
func (s *Server) SetMemberAuth(verify func(token string) (int64, string, bool), scopesFor func(int64) map[string]bool, roleFor func(int64) (string, bool))
SetMemberAuth puts the web app in per-member mode: requests authenticate as a hub client and the graph/search/note surfaces are scoped to that member. verify checks a client token; scopesFor returns a member's readable scopes (nil = unrestricted); roleFor returns the member's role and whether the client still exists.
func (*Server) SetScopeResolver ¶
SetScopeResolver installs the per-request scope resolver (used by the hub to serve the app under per-member identity).