LaufwerkLaufwerk
API reference

Execution providers

All local, Docker and legacy Microsandbox options, resource units and image preparation helpers.

An execution provider controls where commands and agent processes run. Constructors define configuration; allocation happens when a session uses it.

Local and Docker return values

Import constructors from @laufwerk/execution (also available through /local and /docker). Both return an object with:

PropertyType / meaning
kind"local" | "docker"
sandboxHarnessV1SandboxProvider
agent(settings)Constructs a workspace-compatible Harness agent; all settings

The public ExecutionTarget type from @laufwerk/sdk contains only kind and sandbox. Keep the constructor's inferred type if you need .agent(); annotating it as ExecutionTarget hides the factory method from TypeScript.

createLocalExecution(options = {})

PropertyTypeDefault / meaning
storageDirectoryOptional string~/.laufwerk/execution; session records are stored below local/
credentialsOptional "codex-subscription" | "claude-subscription"Agent bootstrap defaults to Codex subscription credentials
cwdOptional stringFallback workspace for an unbound native session; explicit workspace binding takes precedence
shellOptional string/bin/bash on Unix; discovered Git for Windows Bash on Windows

Local execution uses the host user's permissions. It rejects read-only workspace access and injected skills; it is not a security sandbox. Agent bootstrap requires Node.js 22+ on PATH and suitable subscription credentials. Local resume checks the recorded host/platform and requires retained session state.

createDockerExecution(options = {})

PropertyTypeDefault / meaning
codexBootstrapOptional "prepared" | "install"Standard Codex with no explicit image defaults to a managed prepared image; "install" opts into session bootstrap
imageCacheDirectoryOptional string~/.laufwerk/images/codex; shared prepared-image cache, separate from session storage
resourcesOptional DockerResourcesNo explicit limits added when omitted
imageOptional stringCustom image; otherwise uses the standard base and, for Codex, its managed prepared image
storageDirectoryOptional string~/.laufwerk/execution; records below docker/
credentialsOptional "codex-subscription" | "claude-subscription"Agent bootstrap defaults to Codex subscription credentials

Requires a local Docker engine/Desktop in Linux-container mode. Remote Docker contexts are rejected. Custom images must contain Node, pnpm, Git, Bash and setsid. Docker supports copy workspaces and enforced read-only mounts; it does not support direct workspaces. Each session has its own container even when several sessions mount the same workspace.

Standard Codex agents require a prepared image in alpha.13. init --execution docker prepares it; for existing consumers run laufwerk prepare docker before starting workflows and again after recipe-changing upgrades. Session startup reports a missing/stale image rather than preparing it. Explicit image keeps its own bootstrap behavior unless codexBootstrap: "prepared" is selected. Claude uses its normal bootstrap path.

DockerResources

PropertyTypeUnits and validation
cpusOptional numberCPU quota; finite, from 0.001 through 1000000
memoryBytesOptional numberPositive safe integer bytes, at least 6 MiB
swapBytesOptional numberAdditional swap beyond RAM; nonnegative safe integer, requires memoryBytes; sum must be a safe integer
pidsOptional numberPositive safe integer process limit

swapBytes: 0 requests no additional swap. Omitted limits leave Docker/host defaults; they do not mean zero resource consumption. Invalid values throw synchronously during provider construction.

execution-example.ts
import { createDockerExecution, createLocalExecution } from "@laufwerk/execution";

export const docker = createDockerExecution({
  credentials: "codex-subscription",
  resources: {
    cpus: 2,
    memoryBytes: 4 * 1024 ** 3,
    swapBytes: 0,
    pids: 512,
  },
});

export const local = createLocalExecution({ credentials: "codex-subscription" });

These limits are example configuration, not a guarantee every task fits within them. See Execution choices for operational setup.

Prepared Codex images

prepareDockerCodex(options) is exported from @laufwerk/execution/docker (not the package root). It manages the standard Codex image cache and returns Promise<{ image: string; manifestPath: string; reused: boolean }>.

PropertyRequiredMeaning
resources: DockerResourcesYesExplicit memoryBytes required
image: stringNoExisting base image; defaults to the standard toolchain image
cacheDirectory: stringNoDefaults to ~/.laufwerk/images/codex; match execution's imageCacheDirectory
signal: AbortSignalNoCancellation signal

Preparation uses a cache lock and validates the pinned bootstrap recipe and image identity before reusing a receipt. The CLI's prepare docker is the setup path for most consumers. The following lower-level helpers manage explicit receipts.

prepareCodexImage(options): Promise<string> prepares a reusable Docker image using the pinned adapter bootstrap. Run it during setup, outside a workflow.

PropertyTypeRequiredMeaning
imagestringYesExisting compatible base Docker image
manifestPathstringYesWhere to store the prepared-image receipt
resourcesDockerResourcesYesMust include explicit memoryBytes; other validation above applies
signalAbortSignalNoCancellation signal

loadPreparedCodexImage(manifestPath: string, expectedBaseId?: string, signal?: AbortSignal): Promise<string> validates the manifest against the adapter recipe, user/group and Docker image identities, then returns the usable image identity. Stale/mismatched manifests fail; prepare again when the recipe changes. Neither helper attaches customer workspaces or runtime credentials to the reusable image.

prepared-image-example.ts
import { createDockerExecution, loadPreparedCodexImage, prepareCodexImage } from "@laufwerk/execution";

export async function prepare(baseImage: string, manifestPath: string) {
  await prepareCodexImage({
    image: baseImage, manifestPath,
    resources: { memoryBytes: 4 * 1024 ** 3, cpus: 2 },
  });
  return createDockerExecution({
    image: await loadPreparedCodexImage(manifestPath),
    credentials: "codex-subscription",
  });
}

Legacy createMicrosandbox(options)

Import from @laufwerk/sandbox. Returns HarnessV1SandboxProvider, not the local/Docker object with .agent(). Construct a HarnessAgent directly and omit execution in Workspace.open for this legacy path.

PropertyTypeRequiredDefault / meaning
credentials"codex-subscription" | "claude-subscription"YesSubscription credentials to load
imagestringNoPinned Node 22 Bookworm slim image
cpusnumberNo2
memoryMiBnumberNo3072 MiB; unlike Docker this is not bytes
workdirstringNo/root for an unbound environment
bridgePortnumberNo43121 inside the environment
bootstrapCommandsreadonly string[]NoInstall certificates/Git and pnpm 10.28.1

This integration also exports low-level workspace-volume, credential and provider helpers plus Microsandbox's upstream exports. They are infrastructure APIs; workflow authors should use Workspace for managed files and Session for lifecycle. Do not mix a Microsandbox agent with a local/Docker workspace.

On this page