api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package api serves the HTTP API described in api/openapi.yaml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(o Options) http.Handler

NewHandler returns the daemon's HTTP routes.

Types

type ModelSource

type ModelSource interface {
	Live(ctx context.Context) (router *models.Router, minConfidence float64)
	RouterFor(ctx context.Context, spec string) *models.Router
	Composer(ctx context.Context) (models.Generator, error)
}

ModelSource is how this package reaches the models (settings.Settings implements it): the decision router in force, the router of a rule's own model, and the generative model the composer writes with.

type Options

type Options struct {
	Store         *store.Store
	SecureCookies bool             // set when the UI is not served from localhost
	Now           func() time.Time // nil means time.Now

	Hub      *events.Hub        // the SSE stream's source; nil = a private hub nothing publishes to
	Exec     *actions.Exec      // undo and corrections: the only way this package changes a mailbox
	Settings *settings.Settings // the settings the user changes at runtime
	Models   ModelSource        // the models the composer and tester use; nil = Settings
	Master   []byte             // seals account passwords
	Metrics  *telemetry.Metrics // nil = a private registry
	Version  string             // shown in GET /api/settings

	// StartCheck starts a cleanup check of an account in the background and returns it,
	// running (worker.Manager.StartCheck). Checks holds the account checks in memory, and
	// Sort applies a finished check's kept rows as one undoable batch (worker.Manager.Sort).
	StartCheck func(c worker.Cleanup, fingerprint string, run worker.CheckFunc) (*worker.Check, error)
	Checks     *worker.CheckStore
	Sort       func(ctx context.Context, sr worker.SortRun) (store.Batch, error)
	// Connect logs in to a mail server with credentials that are not stored yet, trying
	// the usernames the preset allows, and returns the connection with the username that worked.
	Connect func(ctx context.Context, acct store.Account, password string) (mail.Mailbox, string, error)
	// StartAccount (re)starts watching an account; StopAccount stops it and waits until
	// mail already queued is finished.
	StartAccount func(acct store.Account)
	StopAccount  func(accountID int64)
	// Modules are the features compiled in from outside this repository. Their routes are
	// served like the built-in ones, and each one's name is on in GET /api/settings
	// features. A route of the contract that only a module provides is refused with 404
	// not_available while no module serves it.
	Modules []ext.Module
	// Summary is the summary email; nil = one built from Settings.Env that cannot send.
	Summary *summary.Service
}

Options configures the HTTP handler.

Jump to

Keyboard shortcuts

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