# createAgent

<!-- https://uncage.vercel.app/docs/api/agent/functions/createagent/ -->

```ts
function createAgent(o): Promise<Agent>;
```

Defined in: agent/src/agent.ts:92

The Connected Mode daemon: one link per configured (non-revoked) site — WebSocket, or HTTP
streaming when the site only offers that or WebSocket keeps failing — each with its own core
instance, workspace root and activity log. Revocation (4401 / HTTP 401) marks the site in
`agent.yaml` and stops dialing it; replacement (4409) stops that connection without fighting;
`upgrade_required` runs `npm i -g @uncage/cli@latest` and, if that worked, exits non-zero so
launchd restarts (a failed upgrade keeps only that site offline, retried at most hourly). A site
that fails to start is logged and skipped; only if every site fails does this throw.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `o` | [`CreateAgentOptions`](https://uncage.vercel.app/docs/api/agent/interfaces/createagentoptions.md) |

## Returns

`Promise`\<[`Agent`](https://uncage.vercel.app/docs/api/agent/interfaces/agent.md)\>
