api

package
v0.1.58 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 46 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 api is the daemon's unified HTTP surface — the one protocol the app speaks regardless of which agent runs. It is thin glue over the orchestrator.Supervisor: it decodes/authorizes/streams, and delegates agent resolution and turn supervision. Every agent-specific route accepts ?agent=<type> (default otherwise); turns/runs/chats are shared (keyed by chatId), while auth/config/creds are isolated per agent type.

Index

Constants

View Source
const HistoryPageVersion = 1

HistoryPageVersion adds an opt-in envelope and byte budget to the existing messages endpoint. Legacy callers continue to receive their unchanged array.

Variables

View Source
var PublicRoutes = []Route{
	{Method: "POST", Pattern: "/integrations/{id}/webhook"},
	{Method: "GET", Pattern: "/healthz"},
	{Method: "POST", Pattern: "/apps/{id}/notify"},
}

PublicRoutes are served OUTSIDE the auth middleware (registered directly in cmd/daemon, not here). Listed as data so the OpenAPI parity test can cover them.

Functions

func Auth

func Auth(token string, next http.Handler) http.Handler

Auth wraps a handler with a static bearer-token check (constant-time). Empty token (dev) passes through.

func CORS

func CORS(enabled bool, next http.Handler) http.Handler

CORS optionally wraps the whole handler with permissive cross-origin headers for local development (a web console on another origin). OFF unless enabled — production sandboxes keep the daemon same-origin only. Must wrap OUTSIDE Auth so OPTIONS preflight (which carries no token) is answered before the auth check.

Types

type API

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

func New

func New(store *session.Store, hub *stream.Hub, sup *orchestrator.Supervisor, registries ...*registry.Store) *API

New builds the HTTP API over the supervisor (which hosts all agents) and the shared store.

func (*API) AppNotify

func (a *API) AppNotify(w http.ResponseWriter, r *http.Request)

AppNotify authenticates ONLY the app-scoped credential. It is loopback-only, cannot choose a recipient or another app, and never accepts the owner token.

func (*API) AuthorizeDesktopViewer

func (a *API) AuthorizeDesktopViewer(sessionID string) error

func (*API) Busy

func (a *API) Busy(chatID string) bool

func (*API) BusyPath

func (a *API) BusyPath(path string) bool

func (*API) Close

func (a *API) Close()

func (*API) ConnectionOperation

func (a *API) ConnectionOperation(next http.HandlerFunc) http.HandlerFunc

func (*API) EnableLocalDesktop

func (a *API) EnableLocalDesktop(controlToken string) error

func (*API) InitError

func (a *API) InitError() error

func (*API) IntegrationWebhook

func (a *API) IntegrationWebhook(w http.ResponseWriter, r *http.Request)

func (*API) Register

func (a *API) Register(mux *http.ServeMux)

func (*API) Routes

func (a *API) Routes() []Route

Routes is the full authenticated API surface. Every agent-specific route accepts ?agent=<type>.

func (*API) ServeDesktopViewer

func (a *API) ServeDesktopViewer(ctx context.Context, sessionID string, stream io.ReadWriteCloser) error

func (*API) SetAppsAddress

func (a *API) SetAppsAddress(address string) error

func (*API) SetConnectionActivity

func (a *API) SetConnectionActivity(activity func() int)

Computer connections are optional and share the same service-update admission.

func (*API) SetConnectionUpdateForce

func (a *API) SetConnectionUpdateForce(force func() bool)

The daemon owns the durable manual-update policy, so an older computer CLI can keep using its existing lease/download/restart loop without losing owner intent.

func (*API) StartScheduledJobs

func (a *API) StartScheduledJobs() error

StartScheduledJobs is called explicitly by the long-lived daemon host.

type Route

type Route struct {
	Method  string
	Pattern string
	Handler http.HandlerFunc
}

Route is one HTTP route as data (method + Go 1.22 mux pattern + handler). Keeping the surface as a table lets Register register it in a loop AND lets the OpenAPI parity test enumerate the live routes and assert they match packages/daemon/openapi.json — so the spec can't silently drift.

Jump to

Keyboard shortcuts

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