API Reference
Constructor
new alien.Daemon(id: string)| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Daemon 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" })| Field | Type | Required | Description |
|---|---|---|---|
type | "image" | "source" | Yes | Use an existing image or build from source. |
image | string | For image | Container image reference. |
src | string | For source | Source directory. |
toolchain | ToolchainConfig | For source | Build 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",
})| Parameter | Type | Required | Description |
|---|---|---|---|
vars | Record<string, string> | Yes | Environment variable map. |
Calling .environment() replaces the current daemon environment map.
link
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")| Parameter | Type | Required | Description |
|---|---|---|---|
profile | string | Yes | Permission 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,
})| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Endpoint name. Lowercase DNS label. |
port | number | Yes | Port the daemon listens on. |
options | string | object | No | Protocol 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,
})| Field | Type | Required | Description |
|---|---|---|---|
path | string | No | HTTP endpoint path to check (e.g., "/health"). |
method | string | No | HTTP method to use. |
port | number | No | Port to check. Defaults to the endpoint port. |
timeoutSeconds | number | No | Request timeout in seconds (1–5). |
failureThreshold | number | No | Consecutive failures before marking the replica unhealthy. |
commandsEnabled
Enables or disables the Commands protocol.
.commandsEnabled(true)| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | When 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.
| Field | Type | Description |
|---|---|---|
daemonName | string | Runtime daemon name. |
publicEndpoints | Record<string, PublicEndpointOutput> | undefined | Public endpoints keyed by endpoint name, when configured. |
running | boolean | Whether 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