API Reference
Complete API documentation for the Runners SDK
Core Types
Runner
A runner function that accepts context and optional input, returns a result.
Type Parameters:
TInput: Input type (usually inferred from Zod schema) - validated at runtimeTOutput: Output details type (usually inferred from Zod schema) - provides TypeScript typing fordetailsfield
Example with both schemas:
RunnerContext
Context provided to all runners.
Properties:
region?: string- Region identifier (e.g., "us-east-1")runId?: string- Unique run identifierlog(message, meta?)- Logging function
RunnerResult
Result returned by runners.
Properties:
name: string- Unique runner identifierstatus: "pass" | "fail" | "error"- Execution statusdetails?: TDetails- Optional custom dataerrorMessage?: string- Error message if status is "error"durationMs?: number- Execution duration in milliseconds
RunStatus
Possible runner execution statuses.
Runner API
runRunners
Execute one or more runners programmatically.
Parameters:
runners: Runner[]- Array of runner functions to executeregion?: string- Optional region identifierrunId?: string- Optional run identifiertimeout?: number- Optional timeout in milliseconds
Returns:
Example:
HTTP API
createHttpRunner
Create an HTTP handler for exposing runners as an API.
Parameters:
runners: Record<string, Runner>- Object mapping runner names to functionsregion?: string- Optional region identifier
Returns: HTTP request handler (framework-agnostic)
Example:
Endpoints
POST /api/runner/execute
Execute one or more runners.
Request:
Response:
GET /api/runner/info
Get information about available runners.
Response:
GET /api/runner/docs
Interactive API documentation (Scalar UI).
GET /api/runner/spec.json
OpenAPI specification in JSON format.
Orchestrator API
createOrchestratorHandler
Create an HTTP handler for the orchestrator service.
Returns: HTTP request handler
Configuration:
Set PLAYWRIGHT_RUNNERS environment variable:
Endpoints
POST /api/orchestrator
Submit a new run request.
Request:
Response:
GET /api/orchestrator/{runId}/status
Get run status.
Response:
GET /api/orchestrator/{runId}
Get run results.
Response:
Orchestrator Types
RunRequest
RunnerConfig
RunStatus
RunSummary
CLI API
Commands
run
Execute runners locally.
Options:
--url <url>- URL to pass to runners--config <path>- Path to config file--region <region>- Region identifier--timeout <ms>- Timeout in milliseconds--help- Show help
Examples:
Config File
Playwright API
withPlaywright
Get Playwright context for browser automation.
Parameters:
ctx: RunnerContext- Runner contexturl: string- URL to navigate to
Returns:
Example:
Framework Integrations
Nitro Module
Automatically:
- Discovers runners from
src/**/*.tsandrunners/**/*.ts - Exposes
/api/runner/executeendpoint - Serves OpenAPI docs at
/api/runner/docs
Nitro Orchestrator Module
Exposes orchestrator endpoints at /api/orchestrator/*.
Error Types
RunnerNotFoundError
Thrown when a requested runner is not found.
InputValidationError
Thrown when runner input validation fails.
ExecutionError
Thrown when runner execution fails.
Type Exports
All types are exported from the main package: