Documentation
¶
Overview ¶
Package lodgeapp serves notesd as lodge's notes app (docs/specs/lodge-app.md, ADR-0026) over lodge/kit, which owns the app socket, its peer check and the Lodge-* headers: /health, /api as caller session, /content/blobs/ for lodge-content, /mcp for agents with lodge's tokens, and the hub's device routes under /device/.
Index ¶
- Constants
- func Agent(ctx context.Context, cfg Config, token string, scope api.Scope) (*api.Client, error)
- func Device(h http.Handler) http.Handler
- func Identity(c kit.Caller, contentKey []byte) api.Identity
- func LoadContentKey(dir string) ([]byte, error)
- func MCP(cfg Config) *mcpsession.Sessions
- func Serve(ctx context.Context, cfg Config) error
- func Server(cfg Config) *kit.Server
- type Config
Constants ¶
const ( MaxRange = 8 << 20 MaxWhole = 64 << 20 )
Limits of a blob answer (docs/specs/lodge-app.md#limits).
const ID = "notes"
ID is notes' app id: its manifest's, its socket's name and its URLs' segment.
Variables ¶
This section is empty.
Functions ¶
func Agent ¶
Agent opens an in-process connection to notesd as caller agent, bound to the token's name and scope, and completes rpc.hello. It lives until the client is closed.
func Device ¶
Device serves the hub's endpoints (sync-protocol.md's paths) under /device/, as lodge forwards /device/notes/…: the device token still authenticates each request, and lodge's peer headers only name the node beside a pending pairing.
func Identity ¶
Identity is the connection identity of an /api session: caller session, named by lodge's headers, whose writes are "<node> (web)", and which learns the content key from rpc.hello.
func LoadContentKey ¶
LoadContentKey returns the content key kept in dir, making it (32 bytes from crypto/rand, mode 0600) on first use, so content URLs stay the same across restarts and browsers can cache files.
func MCP ¶
func MCP(cfg Config) *mcpsession.Sessions
MCP serves /mcp (docs/specs/mcp.md#through-lodge): the kit binds each MCP session to its token's name and scope, keeps 8 per token and ends idle ones, and each session's tools reach notesd over an in-process connection of caller agent bound to that scope, which the engine enforces.
Types ¶
type Config ¶
type Config struct {
RPC *rpcserver.Server
Router *api.Router
Blobs *blobs.Store
// Hub serves the device routes; nil answers them 404.
Hub *hub.Hub
// Version is notesd's, for /health.
Version string
// ContentKey names files in content URLs (blobhttp.ContentMAC); a
// session learns it from rpc.hello. LoadContentKey keeps it.
ContentKey []byte
Log *slog.Logger
// Sessions bounds /mcp's sessions: the kit's Max, Idle and Every, its
// defaults where zero. lodgeapp sets CheckScope and Logger.
Sessions mcpsession.Options
// Opened, when set, hears of each notesd connection an MCP session
// opens, for tests.
Opened func(*api.Client)
}
Config is what the app socket serves.