# Wire protocol

> The request bodies and server-sent events the agent endpoint speaks.

Source: https://sideagent.dev/docs/protocol

The endpoint takes `POST` with a JSON body. A chat turn answers with server-sent events; history actions answer with JSON.

## Requests

```ts
{ "threadId"?: string, "message": string, "context"?: unknown }
{ "threadId": string, "approval": { "token": string, "decision": "approve" | "reject" } }
{ "action": "threads.list" }
{ "action": "threads.get", "threadId": string }
{ "action": "threads.delete", "threadId": string }
```

## Events in a turn

| Event | Meaning |
| --- | --- |
| `turn.start` | Carries the `threadId`. |
| `text.delta` | A piece of the assistant's text. |
| `tool.start` | The agent began calling an operation. |
| `approval.request` | The call needs approval. Carries the arguments, a token and an expiry. |
| `tool.complete` | The call finished: HTTP status, arguments, result, and tags to invalidate. |
| `tool.rejected` | The user rejected the call. |
| `error` | A `code` and a `message`. |
| `turn.end` | The turn is over. |
