Docs

Overview

Daemons run resident processes on machines or nodes. Use Daemon for endpoint agents, host bootstrap loaders, node supervisors, local connectors, telemetry collectors, command handlers, and cluster-side services that should come up with the environment and stay running.

Daemons can run anywhere Alien has a daemon controller. They are private by default and can optionally expose named HTTP public endpoints. Their image command starts the app directly; source builds are converted to runnable images before deployment, without a Worker runtime wrapper.

Platform Mapping

PlatformBacking RuntimeStatus
LocalLocal process from a container imageSupported
Kubernetes / On-PremKubernetes DaemonSetSupported
AWSOne instance on every machine in an Alien Machines clusterSupported
GCPOne instance on every machine in an Alien Machines clusterSupported
AzureOne instance on every machine in an Alien Machines clusterSupported

When to Use

Use Daemon when the work is machine-oriented: a connector that maintains a long-lived session, a host loader that prepares the machine, a background command executor, a local/on-prem control loop, or a helper service that should restart if it exits.

Use Worker for request-response handlers. Use Container for cloud services with ports, stateful storage, GPUs, or scaling.

Quick Start

alien.ts
import * as alien from "@alienplatform/core"

const connector = new alien.Daemon("connector")
  .code({ type: "image", image: "ghcr.io/acme/connector:2026-05-17" })
  .commandsEnabled(true)
  .environment({
    LOG_LEVEL: "info",
  })
  .permissions("execution")
  .build()

export default new alien.Stack("edge")
  .add(connector, "live")
  .platforms(["local", "kubernetes"])
  .build()

Public Endpoints

Daemons are private unless they declare a named HTTP endpoint:

const gateway = new alien.Daemon("gateway")
  .code({ type: "image", image: "ghcr.io/acme/gateway:v1" })
  .publicEndpoint("api", 8080, "http")
  .healthCheck({
    path: "/health",
    method: "GET",
    timeoutSeconds: 1,
    failureThreshold: 3,
  })
  .permissions("execution")
  .build()

Host Runtime

Trusted daemon infrastructure can request host-level runtime options. Use this for loaders or node agents that intentionally need to inspect, prepare, or supervise the host:

const loader = new alien.Daemon("host-loader")
  .code({ type: "image", image: "ghcr.io/acme/host-loader:v1" })
  .cluster("runtime")
  .runtime({
    privileged: true,
    pidNamespace: "host",
    networkMode: "host",
    mounts: [{ source: "/", target: "/host" }],
    user: "0",
  })
  .permissions("execution")
  .build()

Commands

Daemons can participate in the Commands protocol. Setting .commandsEnabled(true) tells Alien to inject the command-receiver environment (ALIEN_COMMANDS_*) into the process. The daemon runs your process directly, so it runs an explicit pull receiver — createCommandReceiver() from @alienplatform/commands — that leases commands addressed to it and dispatches them to registered handlers over outbound HTTPS. There is no runtime wrapper; the receiver is a library your app runs. See Remote Commands.

src/index.ts
import { createCommandReceiver } from "@alienplatform/commands"

const receiver = createCommandReceiver()
receiver.command("status", async () => ({ ready: true }))

async function main() {
  await receiver.run()
}

void main()
const executor = new alien.Daemon("executor")
  .code({ type: "image", image: "ghcr.io/acme/executor:v1" })
  .commandsEnabled(true)
  .permissions("execution")
  .build()

Configuration

MethodRequiredDescription
.code(code)YesContainer image or source build configuration. Source builds become runnable images before deployment.
.environment(vars)NoEnvironment variables injected into the daemon process.
.link(resource)NoGives the daemon binding access to another resource.
.publicEndpoint(name, port, "http")NoAdds a named HTTP public endpoint.
.healthCheck(config)NoConfigures HTTP health checks for public daemon endpoints.
.cluster(clusterId)AWS/GCP/AzureSelects the ComputeCluster that should run the daemon.
.cpu(value)NoCPU requested for each daemon instance.
.memory(size)NoMemory requested for each daemon instance.
.runtime(config)NoHost runtime settings for trusted daemon infrastructure.
.permissions(profile)YesPermission profile used for linked resources and cloud access.
.commandsEnabled(boolean)NoInjects the command-receiver environment so the daemon's own command receiver can lease its commands. Default: false.

Daemons do not have triggers, direct invocation, request timeouts, replica settings, or autoscaling.

See API Reference for every builder method and Behavior & Limits for supported platforms and lifecycle behavior.

On this page