Docs

API Reference

Constructor

new alien.Daemon(id: string)
ParameterTypeRequiredDescription
idstringYesDaemon resource ID. Must contain only letters, numbers, hyphens, and underscores, up to 64 characters.

code

Sets what the daemon runs.

.code({ type: "image", image: "ghcr.io/acme/connector:v1" })
FieldTypeRequiredDescription
type"image" | "source"YesUse an existing image or build from source.
imagestringFor imageContainer image reference.
srcstringFor sourceSource directory.
toolchainToolchainConfigFor sourceBuild toolchain.

For source code, alien build runs the selected toolchain and rewrites the resource to the resulting image before a controller sees it. The image command starts the app directly; there is no Worker runtime wrapper in front of a Daemon.

environment

Sets environment variables.

.environment({
  LOG_LEVEL: "info",
  ENDPOINT: "https://example.com",
})
ParameterTypeRequiredDescription
varsRecord<string, string>YesEnvironment variable map.

Calling .environment() replaces the current daemon environment map.

Links another resource to the daemon.

const vault = new alien.Vault("credentials").build()

const daemon = new alien.Daemon("connector")
  .code({ type: "image", image: "ghcr.io/acme/connector:v1" })
  .link(vault)
  .permissions("execution")
  .build()

Linked resources are passed to the daemon through the same environment variables used by Workers and Containers.

permissions

Assigns the daemon permission profile.

.permissions("execution")
ParameterTypeRequiredDescription
profilestringYesPermission profile name from the stack permissions configuration.

publicEndpoint

Adds a named HTTP public endpoint. Daemons are private unless they declare one.

.publicEndpoint("api", 8080, "http")

.publicEndpoint("webhooks", 8080, {
  protocol: "http",
  hostLabel: "webhooks",
  wildcardSubdomains: true,
})
ParameterTypeRequiredDescription
namestringYesEndpoint name. Lowercase DNS label.
portnumberYesPort the daemon listens on.
optionsstring | objectNoProtocol string, or an object with protocol, hostLabel, and wildcardSubdomains.

hostLabel overrides the host label on the deployment domain ("@" serves the endpoint at the apex). wildcardSubdomains also routes *.<hostLabel>.<deployment-domain> to the endpoint; it cannot be combined with the apex host label. See External URLs.

healthCheck

Configures HTTP health checks for public daemon endpoints.

.healthCheck({
  path: "/health",
  method: "GET",
  timeoutSeconds: 1,
  failureThreshold: 3,
})
FieldTypeRequiredDescription
pathstringNoHTTP endpoint path to check (e.g., "/health").
methodstringNoHTTP method to use.
portnumberNoPort to check. Defaults to the endpoint port.
timeoutSecondsnumberNoRequest timeout in seconds (1–5).
failureThresholdnumberNoConsecutive failures before marking the replica unhealthy.

commandsEnabled

Enables or disables the Commands protocol.

.commandsEnabled(true)
ParameterTypeDefaultDescription
enabledbooleanfalseWhen enabled, Alien injects the command-receiver environment so the daemon's own pull receiver (createCommandReceiver from @alienplatform/commands) can lease and dispatch commands over outbound HTTPS. It does not start a runtime or sidecar. See Remote Commands.

cluster

Selects the ComputeCluster that runs the daemon on AWS, GCP, and Azure. Local and Kubernetes ignore this field.

.cluster("runtime")

cpu and memory

Sets the resources requested by each daemon instance. Numeric CPU values set both the minimum and desired allocation; pass a ResourceSpec when they differ. Memory uses Kubernetes-style size strings.

.cpu(0.5)
.memory("512Mi")

// Or set different minimum and desired CPU allocations.
.cpu({ min: "0.25", desired: "1" })

pool

Selects the capacity group or machine pool used for placement.

.pool("general")

command

Overrides the image's default command.

.command(["/app/agent", "--foreground"])

stopGracePeriod

Sets the time allowed for a daemon to stop during an update, drain, or delete. Valid values are 1 through 86,400 seconds. When omitted, the runtime backend chooses its default.

.stopGracePeriod(30)

runtime

Configures host-level options for trusted infrastructure daemons. Supported fields are privileged, networkMode ("host" or "appnet"), pidNamespace ("host" or "private"), user, and host mounts.

.runtime({
  privileged: true,
  networkMode: "host",
  pidNamespace: "host",
  user: "0",
  mounts: [{ source: "/", target: "/host" }],
})

Use host access only for workloads such as node agents or bootstrap loaders that intentionally need it.

readinessProbe

Shorthand for the public-endpoint health check that uses the default timeout and failure threshold.

.readinessProbe({ method: "GET", path: "/health" })

build

const daemon = new alien.Daemon("connector")
  .code({ type: "image", image: "ghcr.io/acme/connector:v1" })
  .permissions("execution")
  .build()

build() validates the daemon configuration and returns a Resource with type "daemon".

Outputs

Daemon outputs are available in stack state after provisioning.

FieldTypeDescription
daemonNamestringRuntime daemon name.
publicEndpointsRecord<string, PublicEndpointOutput> | undefinedPublic endpoints keyed by endpoint name, when configured.
runningbooleanWhether the daemon is running according to the controller.

Unsupported Surface

Daemons do not expose builder methods for:

  • triggers
  • direct invocation
  • request timeout
  • replica count or autoscaling
  • persistent storage

On this page