lodgeapp

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	MaxRange = 8 << 20
	MaxWhole = 64 << 20
)

Limits of a blob answer (docs/specs/lodge-app.md#limits).

View Source
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

func Agent(ctx context.Context, cfg Config, token string, scope api.Scope) (*api.Client, error)

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

func Device(h http.Handler) http.Handler

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

func Identity(c kit.Caller, contentKey []byte) api.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

func LoadContentKey(dir string) ([]byte, error)

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.

func Serve

func Serve(ctx context.Context, cfg Config) error

Serve listens on notes' app socket (LODGE_ROOT and LODGE_UID for development, else /run/lodge/apps/notes.sock, or the socket systemd passed) and serves it until ctx ends.

func Server

func Server(cfg Config) *kit.Server

Server returns the kit's server for notes' routes. Without a content key it makes one for this process: content URLs are never unkeyed.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL