> ## Documentation Index
> Fetch the complete documentation index at: https://iii.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Workers

> Add and operate project workers with iii Compose.

Workers are processes that connect to iii over WebSocket, register functions, and create observers.
When a worker disconnects, its functions stop being callable and its observers are suspended until
it reconnects.

## Worker identity and namespaces

A worker's identity is `(namespace, name)`. Two namespaces may use the same name; within one
namespace the name is exclusive. A duplicate live owner is rejected with
`WORKER_NAMESPACE_CONFLICT`.

The `namespace:` field in `worker-compose.yaml` selects the namespace for its containers. The
Compose daemon's `--namespace` separately addresses that daemon's `compose::*` functions.

## Declare workers with Compose

Project workers live under `containers:` in `worker-compose.yaml`:

```yaml theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
# namespace: default
engine:
  workers:
    configuration: {}
containers:
  state:
    worker: package://api.workers.iii.dev/state
    version: "0.22.2"
    config_name: state
  api:
    worker: path://./workers/api
    start_after: [state]
    scripts:
      run: pnpm start
```

Registry packages require an explicit version. `path://` workers use `scripts.run` from the Compose
file or `scripts.start` from their `iii.worker.yaml` manifest.

Start a project and keep its daemon in the foreground:

```bash theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
iii compose build --file worker-compose.yaml
iii compose --namespace dev --up --file worker-compose.yaml
```

`build` downloads all declared `package://` workers before startup. `--up` then reuses the shared
package cache. The command skips local `path://` workers.

The presence of `engine:` makes the daemon own and stop the engine. Without it, pass `--engine` or
set `III_URL` to connect to an engine managed elsewhere.

## Add a registry worker

`compose::add` resolves the package graph, writes exact versions into the Compose file, and restarts
the project:

```bash theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
iii call -n dev compose::add worker=state
iii call -n dev compose::add worker=queue@0.21.5
```

Pass `file=/absolute/path/worker-compose.yaml` when the daemon's working directory is not the
project directory. A registry root whose kind is `engine` is rejected because the engine already
supplies it.

Find published workers at [workers.iii.dev](https://workers.iii.dev/) and inspect a package's page
before adding it.

## Operate workers

```bash theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
iii call -n dev compose::status file=worker-compose.yaml
iii compose logs state --follow --namespace dev
iii call -n dev compose::restart file=worker-compose.yaml worker=state
iii call -n dev compose::update file=worker-compose.yaml worker=state@latest
iii call -n dev compose::down file=worker-compose.yaml
```

`compose::restart worker=` restarts one container. `compose::update worker=<name>@<selector>` edits
the package pin and restarts the project. `compose::down` stops containers in reverse dependency
order.

Use `engine::workers::list` and `engine::workers::info` for the engine's live connection view. Use
`compose::status` for process ownership, PID, and the last supervisor error. Use
`iii compose logs <worker> --follow --namespace <daemon>` for live raw stdout and stderr.

## Configuration

Packages ship defaults. A container can name its configuration-worker entry with `config_name` and
override values with `config_override`. Precedence is package default, stored configuration value,
then `config_override`.

```yaml theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
containers:
  http:
    worker: package://api.workers.iii.dev/http
    version: "0.21.3"
    config_name: http
    config_override:
      host: 0.0.0.0
      port: 3111
```

Compose injects the merged execution value into configuration service memory under
`III_CONFIG_NAME`, without persisting it. Workers read it through `configuration::get`. Explicit
saves persist the submitted value. See [Configuration](https://iii.dev/docs/0-26-0/using-iii/configuration.md).

## Engine-managed exceptions

`configuration`, `iii-worker-manager`, `iii-http-functions`, and `iii-stream` (deprecated) remain
engine-owned. Put them under `engine.workers` for managed Compose, or in `config.yaml` only when an
external supervisor owns the engine. Internal `iii-engine-functions`, `iii-telemetry`,
`iii-observability`, and the `iii-sandbox` router are injected automatically. They must not be
added as Compose package roots. The router forwards `sandbox::*` calls to the `sandbox-libkrun`
worker, which Compose installs; an engine no Compose file manages sets a top-level `sandbox:`
section in its `config.yaml`, or those calls fail with S303 (see
[Sandboxes](https://iii.dev/docs/0-26-0/creating-workers/sandboxes.md)).

> [!WARNING]
>
> `iii-stream` is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is
> unchanged for now. See [Migrate from iii-stream and pubsub](https://iii.dev/docs/0-26-0/upgrading/migrate-from-streams.md).

To admit untrusted workers, browsers, or agents, keep the engine port internal and add the
[rbac-proxy worker](https://workers.iii.dev/workers/rbac-proxy) with
`iii call compose::add worker=rbac-proxy`. It opens its own public port and applies the engine's
RBAC rules (authentication, function gating, registration hooks, filtered discovery) in front of the
existing engine port.

## Workers outside Compose

Compose is optional for a process managed by Kubernetes, systemd, another host, or an SDK-driven
development command. Give it the engine URL and a worker name; once connected it participates in the
same function and observer registry. Compose only owns processes declared in its file.

## Migrating an existing project

Follow the [manual migration guide](https://iii.dev/docs/0-26-0/upgrading/workers-to-compose.md) before starting a project
from iii 0.22 or earlier.

## Authoring workers

For SDK connection code, manifests, functions, observable functions, and publishing, see
[Creating Workers / Workers](https://iii.dev/docs/0-26-0/creating-workers/workers.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.