Skip to content

Latest commit

 

History

History
232 lines (172 loc) · 6.78 KB

File metadata and controls

232 lines (172 loc) · 6.78 KB

Examples

This file is auto-generated from metadata in examples/*.ts. Do not edit this file manually. Run yarn generate:examples-md instead.

Runnable examples live in examples/.

Table of Contents

Blueprint with Build Context

Use case: Create a blueprint using the object store to provide docker build context files, then verify files are copied into the image.

Tags: blueprint, object-store, build-context, devbox, cleanup

Workflow

  • Create a temporary directory with sample application files
  • Upload the directory to object storage as build context
  • Create a blueprint with a Dockerfile that copies the context files
  • Create a devbox from the blueprint
  • Verify the files were copied into the image
  • Shutdown devbox and delete blueprint and storage object

Prerequisites

  • RUNLOOP_API_KEY

Run

yarn tsn -T examples/blueprint-with-build-context.ts

Test

yarn test:examples

Source: examples/blueprint-with-build-context.ts

Devbox From Blueprint (Run Command, Shutdown)

Use case: Create a devbox from a blueprint, run a command, fetch logs, validate output, and cleanly tear everything down.

Tags: devbox, blueprint, commands, logs, cleanup

Workflow

  • Create a blueprint
  • Fetch blueprint build logs
  • Create a devbox from the blueprint
  • Execute a command in the devbox
  • Fetch devbox logs
  • Validate exit code, stdout, and logs
  • Shutdown devbox and delete blueprint

Prerequisites

  • RUNLOOP_API_KEY

Run

yarn tsn -T examples/devbox-from-blueprint-lifecycle.ts

Test

yarn test:examples

Source: examples/devbox-from-blueprint-lifecycle.ts

Devbox Mounts (Agent, Code, Object)

Use case: Launch a devbox that combines an agent mount for Claude Code, a code mount for the Runloop CLI repo, and an object mount for startup files.

Tags: devbox, mounts, agent, code, object, claude-code, agent-gateway, ttl

Workflow

  • Create or reuse an agent by name
  • Create a secret for an agent and route it through agent gateway
  • Upload a temporary directory as a storage object with a TTL
  • Launch a devbox with agent, code, and object mounts together
  • Run Claude Code on Opus 4.5 through the Anthropic agent gateway
  • Verify the rl-cli repo and extracted object files are present on the devbox
  • Shutdown the devbox and delete the temporary secret and object

Prerequisites

  • RUNLOOP_API_KEY
  • ANTHROPIC_API_KEY

Run

ANTHROPIC_API_KEY=sk-ant-xxx yarn tsn -T examples/devbox-mounts.ts

Test

yarn test:examples

Source: examples/devbox-mounts.ts

Devbox Snapshots (Suspend, Resume, Restore, Delete)

Use case: Upload a file to a devbox, preserve it across suspend and resume, create a disk snapshot, restore multiple devboxes from that snapshot, mutate each copy independently, and delete the snapshot when finished.

Tags: devbox, snapshot, suspend, resume, files, cleanup

Workflow

  • Create a source devbox
  • Upload a file and mutate it into a shared baseline
  • Suspend and resume the source devbox
  • Create a disk snapshot from the resumed devbox
  • Restore two additional devboxes from the same snapshot baseline
  • Mutate the same file differently in each devbox to prove isolation
  • Shutdown the devboxes and delete the snapshot

Prerequisites

  • RUNLOOP_API_KEY

Run

yarn tsn -T examples/devbox-snapshots.ts

Test

yarn test:examples

Source: examples/devbox-snapshots.ts

Devbox Tunnel (HTTP Server Access)

Use case: Create a devbox with a tunnel, start an HTTP server, and access the server from the local machine through the tunnel.

Tags: devbox, tunnel, networking, http

Workflow

  • Create a devbox with a tunnel
  • Start an HTTP server inside the devbox
  • Read the tunnel details from the devbox
  • Make an HTTP request from the local machine through the tunnel
  • Validate the response
  • Shutdown the devbox

Prerequisites

  • RUNLOOP_API_KEY

Run

yarn tsn -T examples/devbox-tunnel.ts

Test

yarn test:examples

Source: examples/devbox-tunnel.ts

MCP Hub + Claude Code + GitHub

Use case: Connect Claude Code running in a devbox to GitHub tools through MCP Hub without exposing raw GitHub credentials to the devbox.

Tags: mcp, devbox, github, commands, cleanup

Workflow

  • Create an MCP config for GitHub
  • Store GitHub token as a Runloop secret
  • Launch a devbox with MCP Hub wiring
  • Install Claude Code and register MCP endpoint
  • Run a Claude prompt through MCP tools
  • Shutdown devbox and clean up cloud resources

Prerequisites

  • RUNLOOP_API_KEY
  • GITHUB_TOKEN (GitHub PAT with repo scope)
  • ANTHROPIC_API_KEY

Run

GITHUB_TOKEN=ghp_xxx ANTHROPIC_API_KEY=sk-ant-xxx yarn tsn -T examples/mcp-github-tools.ts

Test

yarn test:examples

Source: examples/mcp-github-tools.ts

Secrets with Devbox and Agent Gateway

Use case: Use a normal secret for sensitive app data in the devbox and agent gateway for upstream API credentials that should never be exposed to the agent.

Tags: secrets, devbox, agent-gateway, credentials, environment-variables, cleanup

Workflow

  • Create a secret for application data that should be available inside the devbox
  • Create a separate secret for an upstream API credential
  • Create an agent gateway config for an upstream API
  • Launch a devbox with one secret injected directly and the credential wired through agent gateway
  • Verify the devbox can read MAGIC_NUMBER while the upstream API credential is replaced with gateway values
  • Shutdown the devbox and delete the gateway config and both secrets

Prerequisites

  • RUNLOOP_API_KEY

Run

yarn tsn -T examples/secrets-with-devbox.ts

Test

yarn test:examples

Source: examples/secrets-with-devbox.ts