> For the complete documentation index, see [llms.txt](/llms.txt).
> A full single-fetch corpus is available at [llms-full.txt](/llms-full.txt).
---
last_verified: 2026-10-09
title: Worker
description: Start a TypeScript worker, register components and agents, and connect them to AGNT5
category: TypeScript SDK
hideRightSidebar: true
---

A worker is the process that runs your components. It registers them with AGNT5, receives runs, and executes them. `agnt5 dev` starts it locally and `agnt5 deploy` runs it in an environment, both using the command in `agnt5.yaml`.

## `new Worker(serviceName, options?)`

```typescript
import { Worker } from '@agnt5/sdk';

import './src/functions.js';
import './src/workflows.js';
import { supportAgent } from './src/agents.js';

const worker = new Worker('support', { serviceVersion: '1.0.0' });
worker.registerAgents([supportAgent]);
await worker.run();
```

| Option | Description |
|---|---|
| `serviceVersion` | A version string for this worker, shown with its components. |
| `coordinatorEndpoint` | The AGNT5 coordinator to connect to. `agnt5 dev` and deployments set `AGNT5_COORDINATOR_ENDPOINT`, which the worker reads, so you only set this to connect somewhere else. |

## Registering components

| Component | How it registers |
|---|---|
| Functions (`fn`) | When the module that defines it is imported. |
| Workflows (`workflow`) | When the module that defines it is imported. |
| Tools (`tool`) | When the module that defines it is imported. |
| Agents (`new Agent`) | `worker.registerAgents([agent, ...])`. Only registered agents can be run as agents with `agnt5 run --type agent` or the API. |

Import every module that defines components from the worker's entry point, before `worker.run()`. To check what registered, run `agnt5 components --dev` while `agnt5 dev` is running.

## `worker.run()`

Connects to AGNT5, registers the components, and serves runs until the process stops. It prints a startup banner with the registered components.

## `agnt5.yaml`

```yaml
name: support
language: typescript
worker:
  command: "npx tsx app.ts"
```

The CLI runs `worker.command` from the project root, for `agnt5 dev` and in deployments.

## Next steps

* [Getting started](/sdk/typescript/getting-started.md): a complete project with a worker.
* [Local development](/docs/build/local-development.md): run the worker with `agnt5 dev`.
* [Deploying](/docs/run/deploying.md): run it in an environment.
