Documentation
¶
Overview ¶
Package runloop is a compatibility facade for the official Runloop SDKs (@runloop/api-client, runloop_api_client). Pointing RUNLOOP_BASE_URL at https://<host>/runloop makes the SDK's /v1/devboxes/... calls land here, where they are translated onto internal/service the same way the /e2b and /daytona facades are. Devboxes are native sandboxes; executions and file calls go through the sandbox toolbox.
Index ¶
- Constants
- func AuditRoute(r *http.Request) (route, sandboxID, target string, deletesSandbox bool)
- func RegisterRoutes(mux apihttp.Mux, d Deps)
- func WriteError(w http.ResponseWriter, status int, message string)
- func WriteErrorReason(w http.ResponseWriter, status int, message, reason string)
- type Deps
Constants ¶
const DevboxesPath = devboxesPath
DevboxesPath is the root every routed call lives under.
const PathPrefix = "/runloop"
Variables ¶
This section is empty.
Functions ¶
func AuditRoute ¶ added in v0.6.8
AuditRoute describes r for its api record: the route pattern, the devbox it acts on (the sandbox id), the object it acts on otherwise (a disk snapshot or an execution id), and whether it ends the devbox's life.
func RegisterRoutes ¶
RegisterRoutes mounts the facade. Routing below /v1/devboxes is done by hand rather than with ServeMux patterns: Runloop puts literal segments (create_and_await_running, disk_snapshots, evictions) where devbox ids go, and ServeMux panics at registration on pairs such as "POST .../disk_snapshots/{sid}" vs "POST .../{id}/shutdown", which match the same path with neither more specific.
func WriteError ¶
func WriteError(w http.ResponseWriter, status int, message string)
WriteError writes the Runloop error body. Both SDKs retry 408, 409, 429 and every 5xx up to five times with backoff, POSTs included, so a status in that set that retrying cannot fix carries x-should-retry: false. Without it a 501 or a permanent conflict costs the caller ~30s of pointless retries before the error surfaces.
func WriteErrorReason ¶ added in v0.6.8
func WriteErrorReason(w http.ResponseWriter, status int, message, reason string)
WriteErrorReason is WriteError with the D17 refusal reason in the body (omitted when empty). The API edge sets the matching WWW-Authenticate header before calling it.
Types ¶
type Deps ¶
type Deps struct {
Service *service.Service
Logger *slog.Logger
// Auth authenticates a request (pkg/api). The facade never calls it
// directly: RouteBy composes it with the permission check.
Auth func(http.Handler) http.Handler
// Audit is the seam task T5 fills with kind "api" records
// (apihttp.AuditHook). nil records nothing.
Audit apihttp.AuditHook
// BlueprintMapJSON maps blueprint names/ids → images
// (SB_RUNLOOP_BLUEPRINT_MAP_JSON), read once in config; the facade parses
// it and applies its own defaults.
BlueprintMapJSON string
}
Deps are the shared dependencies the Runloop facade needs from the top-level API package.
func (Deps) RouteBy ¶ added in v0.6.8
func (d Deps) RouteBy(tag string, classify func(*http.Request) controlplane.Permission, h http.Handler) http.Handler
RouteBy returns h behind authenticate → authorize → audit seam (plans/identity-and-access.md §5.3), with the permission chosen per request: the facade dispatches every verb below one mux pattern.