shiftlabs Start free
Menu Runners

Run commands in your network

A runner is a container you run in your own network. It takes commands from your workflows' step.exec steps, or runs the activities you list for step.activity, next to your clusters and servers, and sends back the exit code and output. It only makes outbound HTTPS requests, so it needs no inbound port.

What a runner runs

A runner runs whatever its allowed workflows send. Give it only the credentials those workflows need, and limit it to named workflows.

  • Outbound only

    The runner calls https://api.shiftlabs.org and waits there for work. Nothing connects to it, so it needs no inbound port, load balancer or public address.

  • Your credentials stay with you

    Commands use the credentials you give the runner, such as a kubeconfig or a cloud role, and the readable secrets a step passes in. shiftlabs never sees the runner's own credentials.

  • Limited to named workflows

    A runner token can name the workflows it serves. A runner then takes jobs from those workflows only. Anyone who can deploy one of them can run commands on it.

  • One workspace

    A token belongs to one workspace. Its runners take jobs from that workspace only.

  • Give each runner the least it needs: a read-only role for a runner that only reads, a separate runner with its own token for deploys.
  • Commands run as the user runner (uid 1000), each in a folder of its own that is removed after the command.
  • Commands on one runner share its user, home folder and network. Files one command leaves in the home folder, such as .gitconfig, .ssh/config or .aws/config, change what later commands' tools do. With SHIFTLABS_RUNNER_JOBS above 1, commands running at the same time can also read each other's folders and secret files.
  • Only separate runners, with separate tokens, keep workflows' secrets apart. Running one command at a time, the default, doesn't. Give workflows that use different secrets runners of their own, and limit each token to those workflows.
  • When no command is running, the runner kills every process earlier commands left behind, so none lives on into the next command. With SHIFTLABS_RUNNER_JOBS above 1, that happens only once all its commands have ended.
  • Commands can't read the runner token: the runner hides its own environment, and it refuses to start when another process shows the token. The token and the keys made from it are always replaced by [redacted] in output.
  • The two guarantees above hold only on Linux, as in the image. Built for another system, such as macOS, the runner still runs commands, but they could read its token, and processes they leave behind can live on. See Your own image.
  • A shell you open in the container with docker exec or kubectl exec gets the token from the container's environment, and a command could read it from that shell. Open one without it: docker exec -it shiftlabs-runner env -u SHIFTLABS_RUNNER_TOKEN bash, kubectl exec -it <pod> -- env -u SHIFTLABS_RUNNER_TOKEN bash, or use kubectl debug.
  • Developers who can deploy an allowed workflow decide what the runner runs. Use scoped API keys and approvals to control who deploys and when a run goes ahead.

Runner tokens

A runner signs in with a runner token. An admin creates one in Settings → Runners, or with POST /v1/runners/tokens.

shellcurl
curl -X POST https://api.shiftlabs.org/v1/runners/tokens \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" -H "content-type: application/json" \
  -d '{"name": "prod-cluster", "pool": "prod", "workflows": ["restart-app", "rotate-certs"]}'

# 201 {"id": "rtk_…", "token": "slr_…", "name": "prod-cluster", "pool": "prod",
#      "workflows": ["restart-app", "rotate-certs"], "prefix": "slr_…", "createdAt": …}
  • name

    1 to 64 characters, to tell tokens apart.

  • pool

    Optional. The pool the token's runners serve. Left out, each runner picks its pool.

  • workflows

    Optional. 1 to 50 workflow names. Left out, the runners take jobs from every workflow in the workspace.

  • The token is shown once. We keep only values derived from it, so it can't be shown again. Store it as a secret where the runner runs.
  • Revoke a token in Settings → Runners or with DELETE /v1/runners/tokens/:id. Its runners stop at once, and the commands they are running fail. A revoked runner exits with code 2. A revoke that answers an error may already have stopped the token for good; send it again until it answers {revoked}, which records it in the audit log.
  • GET /v1/runners lists the tokens, never their values, and up to 500 runners seen in the last 7 days, most recently seen first: their name, pool, version, when they were last seen, whether they are online, how many commands they are running, how many activities they list, and the profiles, imageVersion and tools their image manifest names, each null without one. It also lists the registered activities those runners advertise. Viewers can read it.
  • Creating and revoking tokens needs an admin. A workspace that has all its tokens gets 403 {"error": "quota exceeded", "limit": "runnerTokens", "max"}. See Limits.
Routes
RouteMethodMinimum role
/v1/runners {image, tokens, runners, activities}: tokens without their values, the runners seen in the last 7 days, and the activities they listGETviewer
/v1/runners/tokens {"name", "pool"?, "workflows"?}; 201 with the token, shown oncePOSTadmin
/v1/runners/tokens/:id {revoked}; its runners stop and their running commands failDELETEadmin

Run it with Docker

The image is shiftlabsorg/runner:1.2.0@sha256:e8a4112e5c9e2dcb41e23fb09e6572624396d6062970b3108034b50704e08906 on Docker Hub, for amd64 and arm64. Set the token and start it.

shelldocker
export SHIFTLABS_RUNNER_TOKEN=slr_…   # from Settings → Runners

# Check the token: prints the pool and the workflows it serves, then exits.
docker run --rm -e SHIFTLABS_RUNNER_TOKEN shiftlabsorg/runner:1.2.0@sha256:e8a4112e5c9e2dcb41e23fb09e6572624396d6062970b3108034b50704e08906 check

docker run -d --name shiftlabs-runner --restart unless-stopped \
  -e SHIFTLABS_RUNNER_TOKEN \
  -e SHIFTLABS_RUNNER_NAME=build-host-1 \
  -v "$PWD/runner-kubeconfig:/etc/shiftlabs/kubeconfig:ro" -e KUBECONFIG=/etc/shiftlabs/kubeconfig \
  shiftlabsorg/runner:1.2.0@sha256:e8a4112e5c9e2dcb41e23fb09e6572624396d6062970b3108034b50704e08906
  • -e SHIFTLABS_RUNNER_TOKEN without a value passes the variable from your shell, so the token stays out of the command line and docker inspect shows only the name. --env-file works too.
  • The commands Settings → Runners shows with a new token leave the token out too: read -rs SHIFTLABS_RUNNER_TOKEN && export SHIFTLABS_RUNNER_TOKEN asks for it without echoing it or keeping it in your shell history, then docker run and kubectl take it from the environment. Another user on the host can read a running command's arguments with ps, so never put the token in them.
  • runner-kubeconfig is a kubeconfig made for the runner, with only the rights its workflows need. Don't mount your own ~/.kube/config: it is usually an admin's, and every allowed workflow could use it.
  • A file you mount must be readable by uid 1000.
  • docker stop lets running commands finish their stop: see When a runner stops.

Run it on Kubernetes

A Deployment of runners, with a ServiceAccount that may only list pods in one namespace. Commands then run kubectl against the cluster the runner is in, with that ServiceAccount's rights.

yamlrunner.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: shiftlabs-runner   # optional: any namespace works
---
apiVersion: v1
kind: Secret
metadata:
  name: shiftlabs-runner
  namespace: shiftlabs-runner
type: Opaque
stringData:
  token: slr_…   # from Settings → Runners
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: shiftlabs-runner
  namespace: shiftlabs-runner
---
# An example: read-only access to pods in the namespace apps, enough for kubectl get pods -n apps.
# Never let this ServiceAccount read Secrets in shiftlabs-runner: the token Secret is there.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: shiftlabs-runner-read-pods
  namespace: apps
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: shiftlabs-runner-read-pods
  namespace: apps
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: shiftlabs-runner-read-pods
subjects:
  - kind: ServiceAccount
    name: shiftlabs-runner
    namespace: shiftlabs-runner
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: shiftlabs-runner
  namespace: shiftlabs-runner
spec:
  replicas: 2
  selector:
    matchLabels:
      app: shiftlabs-runner
  template:
    metadata:
      labels:
        app: shiftlabs-runner
    spec:
      serviceAccountName: shiftlabs-runner
      terminationGracePeriodSeconds: 30
      securityContext:
        runAsNonRoot: true
        runAsUser: 1000
        runAsGroup: 1000
        seccompProfile:
          type: RuntimeDefault
      volumes:
        - name: work
          emptyDir: {}
        - name: tmp
          emptyDir: {}
        - name: home
          emptyDir: {}
      containers:
        - name: runner
          image: shiftlabsorg/runner:1.2.0@sha256:e8a4112e5c9e2dcb41e23fb09e6572624396d6062970b3108034b50704e08906
          env:
            - name: SHIFTLABS_RUNNER_TOKEN
              valueFrom:
                secretKeyRef:
                  name: shiftlabs-runner
                  key: token
            - name: SHIFTLABS_RUNNER_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            # The runner makes this folder for itself: it refuses a work folder that others can write to.
            - name: SHIFTLABS_WORK_DIR
              value: /work/jobs
          volumeMounts:
            - name: work
              mountPath: /work
            - name: tmp
              mountPath: /tmp
            - name: home
              mountPath: /home/runner
          resources:
            requests:
              cpu: 100m
              memory: 256Mi
            limits:
              memory: 1Gi
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities:
              drop: ["ALL"]
  • kubectl apply -f runner.yaml starts two runners. Each pod is one runner, named after the pod. Raise replicas or SHIFTLABS_RUNNER_JOBS to run more commands at once.
  • terminationGracePeriodSeconds: 30 gives a stopping runner time to stop its commands, which get 10 seconds, and report them.
  • The image's files are read-only. Commands can write only to /work, /tmp and the home folder /home/runner, which start empty with each pod.
  • Give the Role only what your workflows need. For another cluster, mount a kubeconfig from a Secret and set KUBECONFIG instead.
  • To create the token Secret from your shell instead: printf '%s' "$SHIFTLABS_RUNNER_TOKEN" | kubectl create secret generic shiftlabs-runner -n shiftlabs-runner --from-file=token=/dev/stdin. --from-literal=token=… would put the token in kubectl's arguments.
  • The runner's ServiceAccount must not be able to read Secrets in the runner's own namespace, which holds the token. A command that could read that Secret would have the token.
  • A pod whose token was revoked exits with code 2 and restarts until you delete the Deployment.

Settings

The runner reads its settings from environment variables.

Runner settings
VariableWhat it sets
SHIFTLABS_RUNNER_TOKEN requiredThe runner token.
SHIFTLABS_RUNNER_NAMEThe runner's name in Settings → Runners and in results. Default: the host name.
SHIFTLABS_RUNNER_POOLThe pool it serves when its token names none. Default: default.
SHIFTLABS_RUNNER_JOBSHow many commands it runs at once, 1 to 16. Default: 1.
SHIFTLABS_ACTIVITIESThe path of an activities file. With it, the runner runs the activities the file lists and no commands.
SHIFTLABS_REDACTNames of the runner's own environment variables whose values are replaced by [redacted] in output, comma-separated. See Output.
SHIFTLABS_WORK_DIRWhere each command's folder is made. Default: /work in the image, else $HOME/.shiftlabs-runner/work. It must be owned by the runner's user and not writable by others, or the runner exits with code 2. Each runner needs a work folder of its own: a second runner on the same folder exits with code 2. Command folders left from an earlier start are deleted when the runner starts.
SHIFTLABS_API_URLDefault: https://api.shiftlabs.org.
HTTPS_PROXY · SSL_CERT_FILEA proxy and a certificate file. See Proxies.
  • shiftlabs-runner check signs in, prints the pool, the workflows the token serves, the profiles the image manifest names and the activities the activities file lists, and exits. shiftlabs-runner version prints the version.
  • The runner logs JSON lines on stderr: when it starts, and when each command starts and ends, with its run, workflow, step, exit code and duration. Logs never hold values, secrets or output.
  • Exit codes: 0 when stopped. 1 when the platform doesn't take registered activities yet. 2 when the token is wrong or revoked or names another pool, a setting, the activities file or the image manifest is wrong, the work folder is shared with others, or, on Linux, a parent process shows the token in its environment or the runner can't hide its own environment from commands. 3 when the runner is too old, with the tag to pull in its log.
  • The runner is the container's first process, with no init in front of it. It passes signals on, and it adopts the processes commands leave behind and kills them once no command is running. Don't start it with docker run --init or from a script that doesn't exec it: the process in front would keep the token readable, and the runner exits with code 2.

Credentials

A command gets credentials in two ways: from the runner itself, or from a readable secret that the step passes in.

  • The runner's own

    Commands get the runner's environment, without the SHIFTLABS_ variables. Mount a kubeconfig and set KUBECONFIG, use the pod's ServiceAccount in its cluster, set cloud variables such as AWS_PROFILE, or use workload identity: IRSA or EKS Pod Identity on AWS, Workload Identity on Google Cloud, workload identity on Azure. shiftlabs never sees these credentials. List any that commands might print in SHIFTLABS_REDACT.

  • Readable secrets, per command

    A value { secret: "NAME" } in env or files passes a secret marked readable to that one command. Only readable secrets can be passed. The value travels encrypted for the runner, each pass is audited, and the value is replaced by [redacted] in the output. A file holding a secret is readable only by the runner's user, and is removed after the command. Other commands running on the same runner at that time can read it: see What a runner runs.

  • Prefer the runner's own credentials for long-lived access to your systems, and secrets for values your workflows already keep in shiftlabs.
  • Each command also gets SHIFTLABS_RUN_ID, SHIFTLABS_WORKFLOW, SHIFTLABS_STEP, SHIFTLABS_ATTEMPT (the try, from 1), SHIFTLABS_JOB_ID and SHIFTLABS_IDEMPOTENCY_KEY. Your own env names can't start with SHIFTLABS_.
  • A name in a step's env replaces the runner's variable of that name for that command, for command and run alike, so a step can point KUBECONFIG or HOME at files it passes in files.
  • SHIFTLABS_IDEMPOTENCY_KEY is the step's idempotency key: the same on every try of the command, and for every call with the same step name in the run.

Run a command

step.exec(name, options) sends a command to a runner and waits for it to end. Give run, a bash script, or command, a program and its arguments with no shell.

restart-app
import { workflow } from "shiftlabs";

export default workflow<{ app: string }>(async ({ payload, step }) => {
  const pods = await step.exec("list pods", {
    command: ["kubectl", "get", "pods", "-n", "apps", "-o", "name"],
  });

  // Values go in env. A value pasted into the script would run as code.
  await step.exec("restart", {
    run: 'kubectl rollout restart "deployment/$APP" -n apps\nkubectl rollout status "deployment/$APP" -n apps --timeout=5m',
    env: { APP: payload.app },
    timeout: "10 minutes",
  });

  return { pods: pods.stdout.split("\n").filter(Boolean) };
});
deploy-web
import { ExecError, workflow } from "shiftlabs";

export default workflow<{ version: string }>(async ({ payload, step }) => {
  // kubectl exits with 1 when the deployment doesn't exist yet.
  const found = await step.exec("find web", {
    command: ["kubectl", "--kubeconfig", "kubeconfig", "get", "deployment", "web", "-n", "apps"],
    files: { kubeconfig: { secret: "STAGING_KUBECONFIG" } },
    okExitCodes: [0, 1],
  });

  try {
    await step.exec("deploy", {
      run: 'helm upgrade --install web oci://registry.example.com/charts/web --version "$VERSION" --kubeconfig kubeconfig --wait',
      env: { VERSION: payload.version },
      files: { kubeconfig: { secret: "STAGING_KUBECONFIG" } },
      runner: "staging",
      timeout: "20 minutes",
      retries: { limit: 2, delay: "1 minute" },
    });
  } catch (err) {
    if (err instanceof ExecError) return { deployed: false, exitCode: err.result.exitCode, stderr: err.result.stderr };
    throw err;
  }
  return { deployed: true, firstInstall: found.exitCode === 1 };
});
  • run

    A bash script, run with bash --noprofile --norc -eo pipefail, so it stops at the first failing command. Up to 64 KiB.

  • command

    The program and its arguments, run without a shell: 1 to 256 strings, up to 64 KiB in all. Give run or command, not both.

  • env

    Up to 100 environment variables. A value is text or { secret: "NAME" }, a readable secret.

  • files

    Up to 50 files written in the command's folder before it starts, by relative path such as config/app.yaml. Values as in env. Text up to 512 KiB in all.

  • stdin

    Text sent to the command's standard input, up to 256 KiB.

  • timeout

    How long the command may run. Default "10 minutes", and at most the plan's longest command.

  • runner

    The pool that runs it. Default "default".

  • profile

    The image profile the command needs, such as "k8s", or "network@2026.11.1" for that image version only. Only a runner whose image manifest lists it takes the command. Default: the project's runnerProfile, else any runner of the pool.

  • requires

    Tools the runner's image manifest must list, such as ["helm"], up to 64. Default: none.

  • okExitCodes

    The exit codes that count as success. Default [0]. "any" accepts every exit code. In Python, ok_exit_codes.

  • retries

    { limit, delay, backoff }: how many more times to try after a failure, 0 to 10, the wait between tries, and "constant", "linear" or "exponential" (the default). No retries by default.

  • Each command runs in a new folder, which is also its working directory. The folder and its files are removed when the command ends, so keep nothing there between steps.
  • Each attempt takes two steps: one sends the job and one reads its result. Waiting for a runner and for the command is not a step, but counts toward the run's lifetime.
  • A resumed run doesn't run the command again: it gets the stored result.
  • The run's page lists each try under commands: the runner that took it, or what it waits for, and its state and time. GET /v1/runs/:id lists them under commands, the newest 200.
  • Options are checked before any step, as the platform checks them. A mistake throws TypeError with a message that starts with step.exec:.
  • In tests, runWorkflow's execs answers each command by step name. See Test a workflow.
  • shiftlabs import crontab writes a workflow per crontab entry that runs its line as cron does: command: [shell, "-c", line], with the crontab's env and the text after % as stdin. See Import a crontab.

Results and errors

step.exec returns the result when the exit code is in okExitCodes. In Python it is a dict with the same keys in snake_case.

  • exitCode

    The command's exit code. 124 when it timed out, 128 plus the signal number when a signal killed it, 127 when the program wasn't found and 126 when it couldn't start.

  • stdout · stderr

    The last 256 KiB of each stream, with secrets redacted.

  • stdoutBytes · stderrBytes · truncated

    How many bytes each stream wrote in all, and whether stdout or stderr holds only the end.

  • timedOut · durationMs

    Whether the timeout stopped it, and how long it ran.

  • runner · attempt

    The name of the runner that ran it, and which try this was, from 1.

  • Any other exit code throws ExecError with the message exec <name>: exited with code N, or exec <name>: timed out after <timeout>. Its result holds the whole result. Catch it to read the output or go on.
  • A command that never ran, or whose runner stopped answering, throws a plain error that says why: no runner in the pool took it within 1 hour (no runner in pool default with k8s took the job within 1 hour when it asks for a profile or tools), the runner stopped responding, its token was revoked, or the run ended.
  • With retries, either kind of failure waits delay and runs the command again as a new job, maybe on another runner. Only the last try's result or error reaches your code.
  • Some failures come at once, with no retries: no token of the pool allows this workflow, the queue is full, or the timeout is over the plan's longest command.

Timeouts

When a command runs past its timeout, the runner sends SIGTERM to the command and every process it started, then SIGKILL 10 seconds later. The result has timedOut: true and exit code 124, so step.exec throws ExecError unless okExitCodes takes 124.

  • A timeout is at least 1 second, and at most the plan's longest command: 30 minutes on Free, 12 hours on Pro.
  • The timeout counts from when the command starts. Waiting for a runner doesn't count; a job waits up to 1 hour.
  • A process that starts its own session, with setsid or as a daemon, leaves the command's process group, so the timeout doesn't stop it. The runner kills it once no command is running on the runner.

Output

The run's logs show the command's output as it runs. The result keeps the last 256 KiB of each stream.

  • Up to 2 MiB of each command's output reaches the run's logs, as whole lines of up to 4,000 characters. After that the logs stop, and the result still holds the end of each stream.
  • Before output leaves the runner, the values of the secrets passed to the command, and of the runner's variables listed in SHIFTLABS_REDACT, are replaced by [redacted]. For a secret of several lines, each line of 8 characters or more is replaced too. Values shorter than 8 bytes are not.
  • The runner token, and the keys the runner makes from it, are always replaced by [redacted].
  • shiftlabs then replaces every readable secret of the workspace in the output before storing it, as it does in other logs.
  • Output that isn't valid UTF-8 is stored with replacement characters.
  • Set SHIFTLABS_REDACT to the names of any credentials in the runner's environment that a command might print, for example SHIFTLABS_REDACT=AWS_SECRET_ACCESS_KEY,GITHUB_TOKEN.

Registered activities

step.exec runs whatever command a workflow sends. For actions you'd rather fix in advance, list them in the runner's activities file: each activity is a program on the runner, with an input schema, a version, and whether it needs an approval. A workflow calls one by name with step.activity, sends it JSON and gets JSON back.

restart-service
import { workflow } from "shiftlabs";

export default workflow<{ service: string }>(async ({ payload, step }) => {
  const restarted = await step.activity<{ restarted: string }>("restart", {
    name: "restart-service",
    input: { service: payload.service },
    runner: "prod",
    heartbeat: "30 seconds",
  });

  return restarted;
});
  • name

    The activity's name in the activities file of the pool's runners.

  • input

    Any JSON value, up to 256 KiB. Default: {}. { secret: "NAME" } anywhere in it passes a readable secret. See Activity input.

  • runner

    The pool. Default: default.

  • profile · requires

    As step.exec's: the image profile and tools the runner's image must have. Default: no tools, and the project's runnerProfile if it names one, else any runner that lists the activity.

  • timeout

    How long the program may run, from 1 second to the plan's longest command. Default: 10 minutes.

  • heartbeat

    How long the program may go without a heartbeat, 1 second to 1 day. Default: none.

  • retries

    As step.exec's: { limit, delay, backoff }. No retries by default.

  • shiftlabs knows an activity from the runners of the pool that list it: those seen in the last 7 days, and a stopped one for an hour. A call to an activity none of them lists fails at once, with no retries: no runner of pool prod lists the activity restart-service: its runners list drain-node.
  • Only a runner that lists the activity takes its job. A runner with an activities file runs no step.exec commands, and runners without one take no activities, so a pool can hold both.
  • Each attempt takes two steps, as a command's do. A resumed run gets the stored output.
  • A cancelled run starts no more attempts. Once the run has ended, cancelled or not, a program still running is stopped at its runner's next lease renewal, within 15 seconds.
  • In tests, runWorkflow's activities answers each activity by step name. See Test a workflow.

The activities file

Set SHIFTLABS_ACTIVITIES to the path of the file. The runner reads it when it starts and tells shiftlabs what it lists each time it signs in.

yamlactivities.yaml
activities:
  restart-service:
    command: [/opt/ops/restart-service.sh]
    version: "1.2.0"
    description: Restarts a systemd unit and checks it came back
    input:
      type: object
      properties:
        service: { type: string, enum: [web, worker] }
      required: [service]
      additionalProperties: false
  drain-node:
    command: [/opt/ops/drain-node, --grace, "60"]
    version: "2.0.0"
    approval: true
    input:
      type: object
      properties:
        node: { type: string, pattern: "^web-[0-9]+$" }
      required: [node]
  • command

    The program and its arguments, run with no shell. A program without a / is looked up on the runner's PATH, and a relative path starts from the activities file's folder. A single string is a program with no arguments.

  • version

    Up to 32 letters, digits, ., _, + and -, shown in Settings → Runners and in each result. Quote it, as in "1.10", so it stays text.

  • description

    Up to 200 characters, shown in Settings → Runners.

  • approval

    true to need an approval before each call runs. Default: false.

  • input

    The JSON Schema the input must match before the program starts. Left out, any JSON goes.

  • Names are lowercase letters, digits and -, up to 63 characters. A file lists 1 to 50 activities. Each schema may be up to 16 KiB as JSON, and the whole list up to 64 KiB.
  • The file may be YAML or, when its first character is {, JSON. The YAML takes block maps and lists, plain and quoted text, [...] and {...} on one line, and | and > blocks for text over several lines. Anchors, aliases, tags, ? keys, several documents, .inf and .nan are refused, as is a tab in indentation.
  • The file may be up to 1 MiB, and must not be writable by the runner's group or others. A missing, unreadable or wrong file, or a program the runner can't find, stops it with exit code 2, and its log names the file, the line and the problem. The runner reads the file when it starts: restart it after a change.
  • Each program runs as a command does: in a folder of its own, with the runner's environment without the SHIFTLABS_ variables, and the same timeout, kill and output rules.
  • Settings → Runners shows each pool's registered activities, with their versions, descriptions, schemas and how many runners online list them.
  • A shiftlabs release that doesn't take registered activities yet would answer the runner as one of commands. The runner then signs out and exits with code 1, so it never runs commands it wasn't set up for.

Activity input and output

The program reads the input as JSON text on its standard input, and writes its output as JSON on its standard output.

shellrestart-service.sh
#!/usr/bin/env bash
set -euo pipefail
service=$(jq -r .service)        # the input, on stdin
echo "restarting $service" >&3   # a heartbeat with a message
systemctl restart "$service"
systemctl is-active --quiet "$service"
jq -n --arg service "$service" '{restarted: $service}'   # the output, on stdout
  • The program gets SHIFTLABS_ACTIVITY, its name, SHIFTLABS_ACTIVITY_VERSION, SHIFTLABS_HEARTBEAT_FD, which is 3, and SHIFTLABS_APPROVED_BY, who approved the call, when it needed an approval. It also gets the variables every command gets: see Credentials.
  • The output is the standard output with white space trimmed, as JSON, up to 256 KiB. No output is null. Standard error reaches the run's logs as a command's output does. Standard output doesn't, since it is the result.
  • { secret: "NAME" }, an object with secret as its only key, anywhere in the input passes a readable secret: the program gets the secret's value in its place. The input travels encrypted for the runner, each pass is audited, and the secret's value is replaced by [redacted] in output and heartbeat messages, as is any plain value in the input that equals a readable secret.
  • Input that doesn't match the schema fails the attempt before the program starts, with up to 10 problems: activity restart: the input doesn't match the activity restart-service's schema: /service: must be one of "web", "worker". The schema sees secret values in place of their references.
  • Schema keywords

    type (one of, or a list of, object, array, string, number, integer, boolean and null), enum, const, properties, required, additionalProperties (true, false or a schema), items (one schema for every element), minItems, maxItems, minLength, maxLength (in characters), pattern (RE2 syntax, matched anywhere in the text unless anchored with ^ and $), minimum, maximum, exclusiveMinimum, exclusiveMaximum (numbers), anyOf, and the schemas true and false.

  • Ignored

    title, description, default, examples, $comment, $schema, format, deprecated, readOnly and writeOnly.

  • Refused

    Any other keyword stops the runner when it starts: activity drain-node: input: unsupported keyword "oneOf".

Heartbeats

A long activity says it is still working, and how far it got, by writing lines to file descriptor 3.

shellbackup-db.sh
#!/usr/bin/env bash
set -euo pipefail
db=$(jq -r .database)
echo '{"progress": 0, "message": "dumping"}' >&3
pg_dump --format=custom --file="/backups/$db.dump" "$db"
echo '{"progress": 0.8, "message": "uploading"}' >&3
aws s3 cp "/backups/$db.dump" "s3://acme-backups/$db/$(date +%F).dump"
jq -n --arg db "$db" '{backedUp: $db}'
  • Each line is a heartbeat. A JSON object may give progress, a number from 0 to 1, and message; any other line is a heartbeat whose message is the line. An empty line is a heartbeat that changes nothing. Lines over 4 KiB are cut.
  • With heartbeat: "30 seconds", a program that writes no line for 30 seconds, counted from its start and then from its last line, is stopped as a timed-out command is: SIGTERM, then SIGKILL 10 seconds later. The attempt fails with activity <step>: no heartbeat for 30 seconds, and its result has heartbeatTimedOut: true and exit code 124. With retries, it runs again.
  • Without heartbeat, heartbeats are optional and only report progress.
  • The run's page, and GET /v1/runs/:id under activities, show each attempt with its runner, its heartbeats, and its latest progress and message. Messages are masked as output is, and cut to 200 characters.

Helpers for activity programs

The npm package shiftlabs has shiftlabs/activity for programs on Node 22 or later, and the PyPI package shiftlabs has shiftlabs.activity for Python 3.11 or later. Each reads the input, writes heartbeats and writes the output as the runner expects. Install the package on the runner's host next to the program, with npm install shiftlabs or pip install shiftlabs; the helpers need nothing else.

backup-db.mjs
import { execFileSync } from "node:child_process";
import { activity } from "shiftlabs/activity";

// stdio [_, 2, 2]: the commands' output goes to standard error, so it reaches the run's logs.
const run = (cmd, args) => execFileSync(cmd, args, { stdio: ["ignore", 2, 2] });

activity(async ({ database }, ctx) => {
  ctx.heartbeat(0, "dumping");
  run("pg_dump", ["--format=custom", `--file=/backups/${database}.dump`, database]);
  ctx.heartbeat(0.8, "uploading");
  run("aws", ["s3", "cp", `/backups/${database}.dump`, `s3://acme-backups/${database}/`]);
  return { backedUp: database, attempt: ctx.attempt };
});
  • List the program with its interpreter: command: [node, /opt/ops/backup-db.mjs] or command: [python3, /opt/ops/backup_db.py].
  • activity(handler) reads the input, calls the handler with it and a context, writes what the handler returns as the output, and exits: 0 when the handler returned, and 1 when it threw, with the error's message as the last line of standard error, which ActivityError's message ends with. In Python the handler may be an async def.
  • The context has activity, version, approvedBy (Python: approved_by, and snake case for the rest), runId, workflow, step, attempt, jobId and idempotencyKey, from the variables the program gets, and heartbeat. Outside a runner the names are empty and attempt is 0.
  • heartbeat(progress, message) writes one heartbeat line. Both are optional, and progress must be from 0 to 1. A message too long for the line's 4 KiB is cut. Without SHIFTLABS_HEARTBEAT_FD it warns once and does nothing, so the program also runs by hand: echo '{"database": "orders"}' | node backup-db.mjs.
  • Standard output is the output, so while the handler runs, what it prints goes to standard error and reaches the run's logs: in Node, console.log and process.stdout; in Python, print, sys.stdout and the output of the commands it starts. Start commands from Node with stdio: ["ignore", 2, 2], as above, or their output becomes part of the output.
  • readInput(), writeResult(output) and heartbeat also work without activity (Python: read_input(), write_result(output)).

Go has no module yet. A program in any language only needs the protocol: read standard input, write heartbeat lines to the file descriptor in SHIFTLABS_HEARTBEAT_FD, write the output to standard output, and exit non-zero with a message on standard error when it fails.

gomain.go
package main

import (
	"encoding/json"
	"fmt"
	"os"
	"os/exec"
	"strconv"
)

// Nil outside a runner, so the program also runs by hand.
var beats = func() *os.File {
	fd, err := strconv.Atoi(os.Getenv("SHIFTLABS_HEARTBEAT_FD"))
	if err != nil {
		return nil
	}
	return os.NewFile(uintptr(fd), "heartbeats")
}()

func heartbeat(progress float64, message string) {
	if beats != nil {
		line, _ := json.Marshal(map[string]any{"progress": progress, "message": message})
		beats.Write(append(line, '\n'))
	}
}

// ActivityError's message ends with the last line of standard error.
func fail(err error) {
	fmt.Fprintln(os.Stderr, err)
	os.Exit(1)
}

// The command's output goes to standard error: standard output is the result.
func run(name string, args ...string) {
	cmd := exec.Command(name, args...)
	cmd.Stdout, cmd.Stderr = os.Stderr, os.Stderr
	if err := cmd.Run(); err != nil {
		fail(fmt.Errorf("%s: %w", name, err))
	}
}

func main() {
	var input struct {
		Database string `json:"database"`
	}
	if err := json.NewDecoder(os.Stdin).Decode(&input); err != nil {
		fail(fmt.Errorf("the input isn't JSON: %w", err))
	}
	heartbeat(0, "dumping")
	run("pg_dump", "--format=custom", "--file=/backups/"+input.Database+".dump", input.Database)
	heartbeat(0.8, "uploading")
	run("aws", "s3", "cp", "/backups/"+input.Database+".dump", "s3://acme-backups/"+input.Database+"/")
	json.NewEncoder(os.Stdout).Encode(map[string]string{"backedUp": input.Database})
}

Approvals for activities

An activity with approval: true in a runner's file runs only once someone approves the call.

  • When a runner of the pool that lists the activity asks for an approval, the call first asks your workspace's approvers, as step.waitForApproval does: in the Approvals inbox, and in Slack and by email when those are set up. The run waits without a job until someone answers, for up to 72 hours and no longer than the run may live. Who may approve, and how many approvals it takes, follow the workspace's approval settings and its approval rules.
  • The request is named after the step, as in activity restart, and its message names the activity, the pool and the input: secrets passed by name show their name, and a plain value that is a readable secret shows [redacted].
  • Once approved, the job carries the approval, signed, and the program gets SHIFTLABS_APPROVED_BY. One approval covers every retry of the call.
  • A runner that asks for an approval refuses a job without one, before anything runs, so no workflow can skip it. A runner with an activities file runs no commands, so step.exec can't run the program around it either.
  • Denied, the call throws activity <step>: denied by <who>: <note>. Unanswered, it throws activity <step>: nobody approved it in time. Neither is retried.

Activity results and errors

step.activity returns the output. When the activity fails, it throws ActivityError, whose result says how the last attempt ran. In Python, result is a dict with the same keys in snake_case.

  • activity · version

    The activity's name, and its version in the activities file of the runner that ran it.

  • exitCode · timedOut · heartbeatTimedOut

    The program's exit code, and whether it was stopped for running past timeout or for a missing heartbeat. Either stop makes it 124.

  • stdout · stderr

    The output's text, up to 256 KiB, and the last 16 KiB of standard error, with secrets redacted.

  • stdoutBytes · stderrBytes · truncated · durationMs · runner · attempt

    As a command's. See Results and errors.

  • ActivityError's message is the first of these that applies: activity <step>: no heartbeat for <heartbeat>, timed out after <timeout>, exited with code N, followed by the last line of standard error, its output is over 262144 bytes, or its output is not JSON.
  • A job that never ran throws a plain error that says why: no runner of the pool took it within 1 hour, the runner stopped responding, or the runner refused it, as in the activity drain-node is not in this runner's activities file or the activity drain-node needs an approval on this runner, and the job has none.
  • With retries, either kind of failure waits delay and runs the activity again as a new job, maybe on another runner. Only the last try's result or error reaches your code. Retry now ends the wait early.

Pools

A pool is a group of runners that take the same commands. step.exec's runner option picks the pool, and any online runner in it takes the command. Without it, the pool is default.

  • Token's pool

    A token created with pool serves that pool only. A runner that sets another SHIFTLABS_RUNNER_POOL is refused and exits with code 2.

  • Runner's pool

    A token without a pool lets each runner pick one with SHIFTLABS_RUNNER_POOL, or default.

  • Names

    Lowercase letters, digits and -, up to 63 characters, starting with a letter or digit.

  • Use pools to keep places apart: prod runners in production with production credentials, staging runners with staging ones.
  • Commands wait for a runner of their pool. When none takes a command within 1 hour, it fails. A step's profile and requires narrow that to the runners whose image has them.

When a runner stops

A runner that takes a command holds it for 60 seconds at a time, and renews that every 15 seconds while the command runs.

  • Stopped

    On SIGTERM, such as docker stop or a pod being replaced, the runner takes no more commands, stops the ones running (SIGTERM, then SIGKILL after 10 seconds), and reports them as failed with the runner was stopped before the command finished. The step fails at once.

  • Gone

    A runner that dies or loses its network stops renewing. 60 seconds later the command fails with the runner stopped responding.

  • Retried

    With retries, the command runs again as a new job, on any runner of the pool.

A command that failed this way may have done part of its work. Write commands that can run twice, and pass SHIFTLABS_IDEMPOTENCY_KEY, which stays the same on every try, to APIs that take an idempotency key.

Limits

Runner limits per workspace
LimitFreePro
Runner tokens220
Longest command, the most a timeout may be30 minutes12 hours
Commands waiting for a runner20500
How long a command waits for a runner1 hour1 hour
Runners online with one token100100
Commands at once with one token, its online runners' SHIFTLABS_RUNNER_JOBS added up250250
Different activities files among the workspace's runners online100100
  • Commands run on your machines, so they use no CPU time or outbound requests of your plan. Their steps count as other steps do.
  • A command over the waiting limit fails at once.
  • A runner that would take a token past either limit gets 429, with the reason in its log, and tries again every minute. Lower SHIFTLABS_RUNNER_JOBS, stop a runner, or give it a token of its own.
  • Runner calls from one IP address are limited to 3,000 a minute, enough for several hundred runners behind one NAT.
  • While an operator restores a workspace's data, its runners get no jobs until the restore has finished.

Your own image

The image is Debian 13 slim with bash, coreutils, curl, jq, yq, git, an SSH client, unzip, Python 3 with pip and venv, kubectl, helm, kustomize, OpenTofu, the AWS CLI, gcloud, az and ansible-core. Its manifest gives each one's version. Add your own tools with FROM, or copy the runner into an image you already use.

dockerfileDockerfile
FROM shiftlabsorg/runner:1.2.0@sha256:e8a4112e5c9e2dcb41e23fb09e6572624396d6062970b3108034b50704e08906
USER root
RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client \
  && rm -rf /var/lib/apt/lists/*
USER 1000
dockerfileDockerfile
FROM your-registry.example.com/ops-tools:2026.10

COPY --from=shiftlabsorg/runner:1.2.0@sha256:e8a4112e5c9e2dcb41e23fb09e6572624396d6062970b3108034b50704e08906 /usr/local/bin/shiftlabs-runner /usr/local/bin/
USER 1000
ENTRYPOINT ["/usr/local/bin/shiftlabs-runner"]
CMD ["run"]
  • The runner is one static binary for Linux on amd64 and arm64. It needs bash for run scripts, and CA certificates.
  • Built from source for another system, such as macOS or FreeBSD, the runner runs commands without the Linux guards, and logs the warnings not_hidden and not_subreaper when it starts: commands could read its token, and processes they move out of their process group live on. On macOS it keeps its environment out of ps -E while System Integrity Protection is on, but a debugger allowed to attach to it, or a process that started it without exec, can still show the token. Give such a runner a token of its own, for workflows whose commands you trust with it.
  • Run it as a user other than root. In the image it runs as runner, uid 1000, as the container's first process, with no init in front of it.

The image manifest

An image can say what it holds in a manifest, the JSON file /etc/shiftlabs/profile.json. Runner 1.2.0 and later read it when they start and report its profiles, image version and tools each time they sign in. Settings → Runners shows them for each runner, and a step can ask for them.

jsonprofile.json
{
  "profiles": ["base", "k8s"],
  "image_version": "2026.11.1",
  "tools": {
    "helm": "4.3.1",
    "kubectl": "1.37.1",
    "kustomize": "5.8.3"
  },
  "licenses": {
    "helm": "Apache-2.0",
    "kubectl": "Apache-2.0",
    "kustomize": "Apache-2.0"
  }
}
  • profiles

    1 to 8 names of the profiles the image serves: lowercase letters, digits and -, up to 63 characters each.

  • image_version

    The image's version: 1 to 32 letters, digits, ., _, + and -, starting with a letter or digit.

  • tools

    Up to 64 tools, each its name and its version. A name is up to 64 lowercase letters, digits, ., _ and -. A version is up to 64 letters, digits, ., _, +, ~, : and -, such as 2.91.0-1~bookworm. Both start with a letter or digit. {} lists none.

  • licenses

    Optional. A tool's license, by its name in tools: an SPDX expression of up to 128 characters, such as Apache-2.0 or (MIT OR Apache-2.0). The runner checks it but doesn't send it.

  • Without the file, the runner signs in with no profile and no tools, as runners always have, and Settings → Runners shows No manifest.
  • A manifest that is wrong, unreadable or over 64 KiB stops the runner with exit code 2, and its log names the file and the problem. Field names are exact: "profile" or "Profiles" is refused.
  • The runner reads the file when it starts: restart it after a change.

The images we publish carry a manifest from 1.3.0. The base image serves the profiles base and k8s, and its manifest lists ansible-core, aws-cli, azure-cli, bash, coreutils, curl, git, gke-gcloud-auth-plugin, google-cloud-cli, helm, jq, kubectl, kustomize, openssh, opentofu, pip, python, unzip and yq, each at the version the tool itself reports, such as 1.37.1 for kubectl. For gke-gcloud-auth-plugin that is the Kubernetes version its --version prints, not the one gcloud version lists.

shelldocker
docker run --rm --entrypoint cat shiftlabsorg/runner:base-latest /etc/shiftlabs/profile.json
  • Before we publish an image, we run each tool its manifest lists, in the image, and check that it reports the version the manifest gives, that each of its Python libraries imports and that ansible --version runs, on amd64 and arm64.
  • Mount your own files into /etc/shiftlabs one at a time, as the Docker example does with a kubeconfig. A volume mounted on the folder hides the manifest, and the runner signs in without one.

Choose a runner by its image

A step can ask for a runner whose image manifest has what it needs: profile names a profile, and requires names tools. step.exec and step.activity take both.

upgrade-web
import { workflow } from "shiftlabs";

export default workflow<{ version: string }>(async ({ payload, step }) => {
  // Any runner whose image lists the k8s profile and helm.
  await step.exec("upgrade web", {
    run: 'helm upgrade --install web oci://registry.example.com/charts/web --version "$VERSION" -n apps --wait',
    env: { VERSION: payload.version },
    profile: "k8s",
    requires: ["helm"],
  });
  // Only a runner of the network image at version 2026.11.1.
  await step.exec("ansible version", { command: ["ansible", "--version"], profile: "network@2026.11.1" });
});
  • profile matches any profile the manifest lists: an image whose manifest lists base and k8s, as above, takes "k8s" steps. "name@version" matches only the manifest whose image_version is that version, so a workflow can stay on one image version while newer ones roll out.
  • requires matches a manifest that lists every tool, by its exact name. With both, the runner's image needs both.
  • A step with neither, in a project without a default (below), runs on any runner of its pool, as before, a runner without a manifest included. A runner without a manifest never takes a step that asks for a profile, "base" included, or a tool.
  • While no runner online in the pool has what a step asks for, the run's page shows waiting for a runner with network@2026.11.1 for its command, or waiting for a runner with k8s and helm. It waits up to 1 hour, as any command does, then fails.
  • The run's page lists each command and activity with the runner that took it and what that runner's manifest named then: the profile and the image version, or base (default; runner reported no manifest). GET /v1/runs/:id lists them under commands and activities, each with profile, profileSource, requires, profiles, imageVersion and waiting.

A project can give its steps a default: runnerProfile in shiftlabs.config.ts, a profile name or name@version as profile takes. A step.exec or step.activity call that names no profile asks for it, and one that names its own gets its own.

shiftlabs.config.ts
import { project } from "shiftlabs";

export default project({
  workflows: { "backup-configs": "./workflows/backup-configs.ts" },
  runnerProfile: "network@2026.11.1",
});
  • shiftlabs deploy keeps the default with each workflow version it deploys, and a run uses the one its version was deployed with. Deploying a new runnerProfile makes new versions and leaves the runs already going as they are, and a rollback to earlier versions brings their default back.
  • Without runnerProfile, the default is an implicit base that asks for nothing: steps run on any runner of their pool, a runner without a manifest included, as they always have, and shiftlabs deploy removes a default the project's workflows had. runnerProfile: "base" keeps them on runners whose manifest lists base.
  • A save in the dashboard's workflow editor sends the code and no profile, as do a deploy by the helper, shiftlabs deploy <file>... and PUT /v1/workflows/:workflow without ?profile. The version keeps the default of the workflow's current version, so where its steps run doesn't change, and ?profile= with nothing after it removes the default.
  • A runnerProfile that isn't a profile name or name@version stops deploy with exit code 3 before it uploads anything.
  • The run's page says where each profile came from, as in profile network (project default) or profile k8s (step), and profileSource says it as "project" or "step".

Proxies and certificates

  • Set HTTPS_PROXY to send the runner's requests through a proxy. Commands get the variable too.
  • For a proxy or network that uses your own certificate authority, mount its certificate bundle and set SSL_CERT_FILE to it. The runner always checks certificates; there is no setting to turn that off.
  • The runner needs to reach api.shiftlabs.org on port 443, nothing else.
  • Leave api.shiftlabs.org out of TLS inspection. A proxy that opens the runner's TLS sees each command and its output, and can take jobs in the runner's place. Those jobs then never run, so it can stop your commands from running.
  • Such a proxy can't read the values of secrets passed to commands, which are encrypted for the runner. It can't forge results, and it can't make your runner run anything your workflows didn't send. See The runner protocol.

The runner protocol

For security reviews: how a runner and shiftlabs talk. All of it is HTTPS from the runner to https://api.shiftlabs.org/runner/v1/.

  • The token never travels

    The runner derives three keys from its token with HMAC-SHA256: a bearer key it signs in with, a signing key and an encryption key. Only the bearer key is ever sent. shiftlabs keeps a hash of the bearer key, and the other two keys encrypted, not the token.

  • Long polling

    The runner registers, then asks for work. Each request waits up to 25 seconds for a job. A running command's output and lease renewal go up every 15 seconds, and the result when it ends.

  • Signed jobs

    Each job is signed with the signing key. The runner refuses a job with a bad signature, one meant for another runner, one that doesn't carry the random value of the request it answers, one issued too long ago, and any job it has seen before.

  • Signed results

    Output, lease renewals and results are signed with the signing key too, with a number that grows with each call. shiftlabs refuses any that don't match the runner and the job, and any replayed call.

  • Signed answers

    shiftlabs signs its answer to each lease renewal. A proxy can't keep a command running after shiftlabs failed it: without a signed answer, the runner stops the command when its lease runs out. A lease is never renewed past the command's timeout plus 2 minutes.

  • Encrypted secrets

    Readable secrets are added to a job when a runner takes it, never stored with the job, and each is audited as a reveal. Their values are encrypted with the encryption key, for that job only.

  • What TLS inspection exposes

    A proxy that opens TLS sees the bearer key, the commands and the output. With the bearer key it can take jobs, which then don't run. It can't decrypt secret values, sign results, or send your runner jobs of its own.

  • Audit and revocation

    Creating and revoking tokens, and each command a runner takes, are in the audit log. Revoking a token ends its runners' requests within seconds. Their running commands are stopped, and the steps fail.

Versions

The examples on this page, the token dialog in Settings → Runners and GET /v1/runners give shiftlabsorg/runner:1.2.0@sha256:e8a4112e5c9e2dcb41e23fb09e6572624396d6062970b3108034b50704e08906: a version and the digest of its image. Docker and Kubernetes pull the image with that digest, so you get exactly the image we published, for amd64 or arm64. shiftlabsorg/runner:1 moves to each new 1.x release, so a runner that pulls it again gets fixes without a change on your side. A new major version is a new tag, announced in the changelog. From 1.3.0, each release is also tagged with the names of the profiles its image serves.

Runner image tags
TagWhat it names
<version>, such as 1.3.0The base image of that release.
base-<version> · k8s-<version>The same image, by the profiles it serves.
<major>, such as 1The newest base image of that major version.
base-latest · k8s-latestThe newest base image.
  • A tag with a version never changes: we never push a published version again. The others move to each new release.
  • Every week we rebuild the image and compare its Debian packages with the newest release's. When any changed, such as for a security fix, the rebuild is released as the next patch version, such as 1.3.1, and its changelog entry lists each changed package with its old and new version.
  • Pin the version and digest to decide when the runner changes, and move to the next release when it is announced.
  • A runner too old for the platform exits with code 3 and logs the tag to pull.