server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

The admin console's read-only JSON API at /api, ported from 8f2af2e:src/keepsake/server/api.py.

The HTTP entry point, which verifies the database first. Ported from 8f2af2e:src/keepsake/server/app.py.

The admin session, ported from 8f2af2e:src/keepsake/server/auth.py: one password, one signed cookie.

The MCP wiring, ported from 2de90d2:src/keepsake/server/tools.py's register and 8f2af2e:src/keepsake/server/app.py's streamable HTTP app.

The seven advertised tools, ported from 2de90d2:src/keepsake/server/tools.py's _TOOLS in wire key order.

The seven tool bodies, ported from 2de90d2:src/keepsake/server/tools.py. The tenant is bound at startup, so no tool takes one, and no tool returns a body the agent could not read.

Index

Constants

View Source
const MaxLimit = 200

MaxLimit caps and advertises a call's results, so one call cannot return the whole corpus.

View Source
const MaxVersion = 2147483647

MaxVersion is int4's maximum, so expected_version never overflows into a database error.

Variables

This section is empty.

Functions

func AdminPassword

func AdminPassword() (string, error)

AdminPassword reads KEEPSAKE_ADMIN_PASSWORD, refusing when the console is on without one.

func BuildApp

func BuildApp(ctx context.Context, cfg Config) (http.Handler, func(), error)

BuildApp serves /mcp and /readyz and returns a closer, or fails when the database does not isolate tenants.

func NewAPI

func NewAPI(cs *store.ConceptStore, a *Auth) http.Handler

NewAPI serves the admin API. Mount it at /api with the prefix stripped.

func NewMCPHandler

func NewMCPHandler(t *Tools) http.Handler

NewMCPHandler serves the seven okf tools over stateless streamable HTTP with JSON responses.

func UIEnabled

func UIEnabled() bool

UIEnabled reports whether the admin console is on. It defaults to on.

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

Auth is the one admin account. The password is the whole credential.

func NewAuth

func NewAuth(password string) *Auth

NewAuth derives the cookie key from the password with scrypt, so a password change revokes every cookie.

func (*Auth) CheckPassword

func (a *Auth) CheckPassword(supplied string) bool

func (*Auth) Issue

func (a *Auth) Issue(ttl time.Duration) string

Issue returns a cookie of the form "<expiry>.<hexdigest>".

func (*Auth) Valid

func (a *Auth) Valid(cookie string) bool

type Config

type Config struct {
	DSN      string
	TenantID uuid.UUID
	Schema   string
}

type MisconfiguredAdmin

type MisconfiguredAdmin struct{ Msg string }

MisconfiguredAdmin is returned at startup. An enabled console with no password is worse than none.

func (*MisconfiguredAdmin) Error

func (e *MisconfiguredAdmin) Error() string

type ToolError

type ToolError struct{ Msg string }

ToolError is surfaced to the agent. It MUST NOT contain a concept body.

func (*ToolError) Error

func (e *ToolError) Error() string

type Tools

type Tools struct {
	// contains filtered or unexported fields
}

func NewTools

func NewTools(cs *store.ConceptStore, tenant uuid.UUID, actor string) *Tools

func (*Tools) Create

func (t *Tools) Create(ctx context.Context, path string, kw map[string]any) (writeResult, error)

func (*Tools) Grep

func (t *Tools) Grep(ctx context.Context, pattern string, limit int) ([]grepHit, error)

func (*Tools) List

func (t *Tools) List(ctx context.Context, prefix string) (listing, error)

func (*Tools) Read

func (t *Tools) Read(ctx context.Context, path string) (*concept, error)

Read returns nil when nothing is stored at path.

func (*Tools) Relate

func (t *Tools) Relate(ctx context.Context, fromPath, toPath string) (any, error)

Relate appends the edge, retrying past concurrent writers, since appending a link commutes.

func (*Tools) Search

func (t *Tools) Search(ctx context.Context, query string, limit int, prefix *string) ([]searchHit, error)

func (*Tools) Update

func (t *Tools) Update(ctx context.Context, path string, expectedVersion *int, kw map[string]any) (any, error)

Update returns a writeResult, or a conflictResult when expectedVersion is stale.

Jump to

Keyboard shortcuts

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