# AgentLink

<!-- https://uncage.vercel.app/docs/api/agent/interfaces/agentlink/ -->

Defined in: agent/src/transport/types.ts:67

One connection to a hub over one transport, from dial to end.

## Properties

| Property | Modifier | Type | Defined in |
| ------ | ------ | ------ | ------ |
| <a id="property-ended"></a> `ended` | `readonly` | `Promise`\<[`LinkEnd`](https://uncage.vercel.app/docs/api/agent/type-aliases/linkend.md)\> | agent/src/transport/types.ts:75 |
| <a id="property-kind"></a> `kind` | `readonly` | `"ws"` \| `"http"` | agent/src/transport/types.ts:68 |

## Methods

### close()

```ts
close(): void;
```

Defined in: agent/src/transport/types.ts:77

Ends the link (HTTP: also tells the hub, so the machine goes offline at once).

#### Returns

`void`

***

### send()

```ts
send(f): Promise<void>;
```

Defined in: agent/src/transport/types.ts:74

Resolves once the frame is handed over. ws: written to the socket; http: listed in `processed`
by the hub (retried with the same `up_` id until then). Rejects with `machine_offline` when the
link is not welcomed or ends first, `FrameTooLargeError` for an oversized frame.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `f` | \| \{ `agentVersion`: `string`; `machine`: \{ `name`: `string`; `os`: `string`; `runtimes`: `object`[]; \}; `protocol`: `number`; `t`: `"hello"`; `transport`: `"ws"` \| `"http"`; \} \| \{ `data`: `unknown`; `id`: `string`; `ok`: `true`; `t`: `"result"`; \} \| \{ `error`: \{ `code`: \| `"auth_required"` \| `"runtime_unavailable"` \| `"unsupported_capability"` \| `"invalid_workspace"` \| `"session_busy"` \| `"session_read_only"` \| `"not_found"` \| `"unauthorized"` \| `"forbidden_origin"` \| `"invalid_request"` \| `"approval_expired"` \| `"approval_already_resolved"` \| `"event_replay_unavailable"` \| `"runtime_disconnected"` \| `"policy_denied"` \| `"store_locked"` \| `"attachment_too_large"` \| `"attachment_type_unsupported"` \| `"machine_offline"` \| `"machine_not_found"` \| `"upgrade_required"` \| `"tool_failed"` \| `"device_code_expired"` \| `"rate_limited"` \| `"internal_error"`; `details?`: `Record`\<`string`, `unknown`\>; `hint?`: `string`; `message`: `string`; `requestId?`: `string`; `retryable`: `boolean`; \}; `id`: `string`; `ok`: `false`; `t`: `"result"`; \} \| \{ `events`: `UncageEvent`[]; `sessionId`: `string`; `t`: `"events"`; \} \| \{ `args`: `unknown`; `id`: `string`; `runId`: `string`; `sessionId`: `string`; `t`: `"tool_call"`; `tool`: `string`; \} \| \{ `data`: `string`; `id`: `string`; `last`: `boolean`; `path`: `string`; `seq`: `number`; `t`: `"file_chunk"`; \} \| \{ `files`: `object`[]; `id`: `string`; `skipped?`: `object`[]; `t`: `"file_done"`; \} \| \{ `at`: `number`; `t`: `"pong"`; \} |

#### Returns

`Promise`\<`void`\>
