runloop

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 33 Imported by: 0

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

View Source
const DevboxesPath = devboxesPath

DevboxesPath is the root every routed call lives under.

View Source
const PathPrefix = "/runloop"

Variables

This section is empty.

Functions

func AuditRoute added in v0.6.8

func AuditRoute(r *http.Request) (route, sandboxID, target string, deletesSandbox bool)

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

func RegisterRoutes(mux apihttp.Mux, d Deps)

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
	// ListGate bounds the cluster-wide lists this node runs at once
	// (clusterlist.Admit); nil admits every list. One gate is shared by v1
	// and every facade: they cost the same fan-out.
	ListGate *apihttp.Gate
}

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.

type ToolboxCall added in v0.6.12

type ToolboxCall struct {
	Method string
	Path   string
}

ToolboxCall is one toolboxd request this facade makes, with sample ids in place of real session and command ids.

func ToolboxCalls added in v0.6.12

func ToolboxCalls() []ToolboxCall

ToolboxCalls lists every toolboxd request the Runloop facade makes. The toolboxd route inventory test (plan X2) checks toolboxd answers each one, and TestToolboxCallsCoverEveryCallSite keeps this list in step with the call sites in this package.

Jump to

Keyboard shortcuts

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