api

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 41 Imported by: 0

Documentation

Overview

Package api will implement the looperd HTTP surface and adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRootHandler added in v0.11.0

func NewRootHandler(api http.Handler, dash http.Handler) http.Handler

NewRootHandler mounts the dashboard static handler under /dashboard and forwards all other traffic to the API handler.

Types

type ConfigFieldMetadata added in v0.11.0

type ConfigFieldMetadata struct {
	Source    string `json:"source"`
	Editable  bool   `json:"editable"`
	ApplyMode string `json:"applyMode"`
}

ConfigFieldMetadata describes where an effective field came from and whether the dashboard may change it without restarting looperd.

type ConfigMetadata added in v0.11.0

type ConfigMetadata struct {
	ConfigPath    string                         `json:"configPath"`
	Format        string                         `json:"format"`
	FilePresent   bool                           `json:"filePresent"`
	Revision      string                         `json:"revision"`
	LastAttemptAt *time.Time                     `json:"lastAttemptAt,omitempty"`
	LastAppliedAt *time.Time                     `json:"lastAppliedAt,omitempty"`
	LastError     *string                        `json:"lastError,omitempty"`
	RejectedPaths []string                       `json:"rejectedPaths"`
	Fields        map[string]ConfigFieldMetadata `json:"fields"`
}

ConfigMetadata describes the effective configuration source and the most recent file reload attempt. Fields is keyed by canonical dotted config path.

type ConfigPatchIssue added in v0.11.0

type ConfigPatchIssue struct {
	Path    string `json:"path,omitempty"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

ConfigPatchIssue identifies one rejected field-level mutation.

type ConfigPatchRequest added in v0.11.0

type ConfigPatchRequest struct {
	Revision string                     `json:"revision"`
	Set      map[string]json.RawMessage `json:"set"`
	Unset    []string                   `json:"unset"`
}

ConfigPatchRequest is the dashboard's field-level mutation contract. Set values stay as raw JSON so the configuration authority performs all typing and validation; Unset removes values from the file layer.

type ConfigRequestError added in v0.11.0

type ConfigRequestError struct {
	Kind    ConfigRequestErrorKind
	Message string
	Issues  []ConfigPatchIssue
}

ConfigRequestError lets the configuration authority report stable field issues while the HTTP layer owns status codes and envelope formatting.

func (ConfigRequestError) Error added in v0.11.0

func (e ConfigRequestError) Error() string

type ConfigRequestErrorKind added in v0.11.0

type ConfigRequestErrorKind string
const (
	ConfigRequestErrorKindValidation  ConfigRequestErrorKind = "validation"
	ConfigRequestErrorKindConflict    ConfigRequestErrorKind = "conflict"
	ConfigRequestErrorKindUnsupported ConfigRequestErrorKind = "unsupported"
	ConfigRequestErrorKindTooLarge    ConfigRequestErrorKind = "too_large"
)

type Context

type Context struct {
	Config             config.Config
	ConfigMetadata     func() ConfigMetadata
	ConfigSnapshot     func() (config.Config, ConfigMetadata)
	PatchConfig        func(context.Context, ConfigPatchRequest) error
	Runtime            RuntimeState
	WebhookForwarder   webhookforward.Forwarder
	ProjectsService    projectService
	Now                func() time.Time
	RecoverySummary    func() any
	ReconcileStaleRuns func(context.Context) (looperdruntime.StaleRunReconcileSummary, error)
	StopLoop           func(context.Context, string, string) (any, error)
	CloseLoop          func(context.Context, string, string) (any, error)
	StopAll            func(context.Context, string) (any, error)
	// TakeoverLoop parks a loop for interactive human takeover: stops the daemon's
	// in-flight run (session id preserved on disk) and transitions the loop to
	// human_takeover, returning what a human needs to resume the exact session.
	TakeoverLoop         func(context.Context, string, string) (TakeoverResult, error)
	RepairReviewer       func(context.Context, reviewer.RepairInput) (reviewer.RepairResult, error)
	TriggerSchedulerTick func()
}

type Handler

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

func NewHandler

func NewHandler(context Context) *Handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RuntimeState

type RuntimeState interface {
	Services() looperdruntime.Services
	StartedAt() (time.Time, bool)
}

type Server

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

func NewServer

func NewServer(cfg config.Config, handler http.Handler) *Server

func (*Server) Addr

func (s *Server) Addr() net.Addr

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

type TakeoverResult added in v0.10.0

type TakeoverResult struct {
	LoopID       string
	Vendor       string
	SessionID    string
	WorktreePath string
}

TakeoverResult is what a takeover yields: the native session id + worktree + vendor of the loop's last run, so the caller can hand a human the exact resume command.

Jump to

Keyboard shortcuts

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