Skip to content

Worker Agent

The worker agent is a lightweight Go binary that runs on each machine and bridges the orchestrator to local Podman (or Docker) containers. It requires no runtime dependencies — just download and run.

Orchestrator (cloud)
│ WebSocket (outbound from worker)
Worker Agent (your machine)
│ child_process / Podman API
Podman Containers
  1. Connects to the orchestrator via WebSocket (outbound, authenticated with worker token)
  2. Registers itself with system info (see below)
  3. Sends heartbeats every 10 seconds (see below)
  4. Receives commands from the orchestrator
  5. Executes container operations locally via Podman or Docker

On connect, the agent sends a worker.register message with:

FieldTypeDescription
namestringWorker name (env, config, or hostname)
hostnamestringSystem hostname
platformstringOS — linux, darwin, or windows
cpuCountintNumber of CPU cores
memoryTotaluint64Total RAM in bytes
containerEnginesstring[]Detected engines (podman, docker)
agentVersionstringAgent version, e.g. 2.0.0
modestringbyom (bring-your-own-machine) or fleet

Every 10 seconds the agent sends a worker.heartbeat with:

FieldTypeDescription
cpuUsagefloat64CPU usage 0–100%
memoryFreeuint64Free RAM in bytes
diskTotaluint64?Total disk in bytes
diskFreeuint64?Free disk in bytes
containersRunningintNumber of running containers
gatewayStatusstring?Gateway connectivity status
gatewayStatusDetailstring?Additional gateway info
CommandAction
container.createCreate a new container from image
container.setupRun initial setup (clone repo, generate CLAUDE.md)
container.startStart a stopped container
container.stopStop a running container
container.removeRemove a container
container.listList containers for a tenant
container.list-allList all containers across tenants
container.execExecute a command inside a container
container.exec.backgroundRun a background command in a container
container.exec.background.killKill a background command
container.exec.background.captureCapture background command output
images.listList available container images
image.checkCheck if an image exists
image.deleteDelete a container image
image.buildBuild a container image from Dockerfile
terminal.openStart an interactive shell session
terminal.inputForward keystrokes to a terminal
terminal.resizeResize terminal dimensions
terminal.closeClose a terminal session
display.openOpen a VNC display session
display.closeClose a VNC display session

Terminal output from containers is streamed back through the worker agent to the orchestrator, which relays it to the browser via WebSocket. This gives you a live web terminal with full xterm.js rendering.

If the WebSocket connection drops, the agent reconnects automatically with exponential backoff:

1s → 2s → 4s → 8s → 16s → 30s (max)

Containers continue running during disconnection — they’re not affected by the agent’s connection state.

The worker agent reads configuration from environment variables, YAML config files, or CLI flags.

BYOM mode (bring-your-own-machine — default):

PathContents
~/.cropscode/credentials.jsonAuth token from cropscode login
~/.cropscode/worker.jsonWorker registration state
~/.cropscode/config.jsonUser preferences (WORKER_NAME)

Fleet mode (managed deployments):

PathContents
/etc/cropscode/agent.yamlFull agent config (URL, token, mode, security)
AGENT_CONFIG env varOverride the YAML path

Key environment variables: ORCHESTRATOR_WS_URL, WORKER_NAME, AGENT_MODE, PODMAN_PATH, DATA_DIR, SECURITY_FLOOR. See Environment Variables for the full list.

The worker agent runs as a foreground process. To run it as a background service:

Linux (systemd):

Terminal window
cropscode worker

macOS (launchd):

Terminal window
cropscode worker

The agent is designed to be restarted safely — it picks up existing containers on reconnection.

Getting Started Concepts Guides CLI Self-Hosting Reference Links