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
- Variables
- func Auth(token string, next http.Handler) http.Handler
- func CORS(enabled bool, next http.Handler) http.Handler
- type API
- func (a *API) AppNotify(w http.ResponseWriter, r *http.Request)
- func (a *API) AuthorizeDesktopViewer(sessionID string) error
- func (a *API) Busy(chatID string) bool
- func (a *API) BusyPath(path string) bool
- func (a *API) Close()
- func (a *API) ConnectionOperation(next http.HandlerFunc) http.HandlerFunc
- func (a *API) EnableLocalDesktop(controlToken string) error
- func (a *API) InitError() error
- func (a *API) IntegrationWebhook(w http.ResponseWriter, r *http.Request)
- func (a *API) Register(mux *http.ServeMux)
- func (a *API) Routes() []Route
- func (a *API) ServeDesktopViewer(ctx context.Context, sessionID string, stream io.ReadWriteCloser) error
- func (a *API) SetAppsAddress(address string) error
- func (a *API) SetConnectionActivity(activity func() int)
- func (a *API) SetConnectionUpdateForce(force func() bool)
- func (a *API) StartScheduledJobs() error
- type Route
Constants ¶
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 ¶
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 ¶
Auth wraps a handler with a static bearer-token check (constant-time). Empty token (dev) passes through.
func CORS ¶
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 (*API) ConnectionOperation ¶
func (a *API) ConnectionOperation(next http.HandlerFunc) http.HandlerFunc
func (*API) EnableLocalDesktop ¶
func (*API) IntegrationWebhook ¶
func (a *API) IntegrationWebhook(w http.ResponseWriter, r *http.Request)
func (*API) Routes ¶
Routes is the full authenticated API surface. Every agent-specific route accepts ?agent=<type>.
func (*API) ServeDesktopViewer ¶
func (*API) SetAppsAddress ¶
func (*API) SetConnectionActivity ¶
Computer connections are optional and share the same service-update admission.
func (*API) SetConnectionUpdateForce ¶
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 ¶
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.
Source Files
¶
- api.go
- app_automation.go
- apps.go
- attachments.go
- bots.go
- commands.go
- conversations.go
- cors.go
- desktop_catalog.go
- git.go
- git_author.go
- git_operations.go
- history_page.go
- history_revision.go
- integrations.go
- native_sessions.go
- project_icon.go
- project_library.go
- project_sync.go
- projects.go
- service_update.go
- surfaces.go
- turn_requests.go
- voice.go
- workspace.go
- workspace_execution.go