# Manifest, grants and the bot card

> What a bot asks for in zaun-bot.toml, how grants are decided, and what every member can see.

## The manifest

`zbot pack` turns `zaun-bot.toml` into the manifest inside the package. Unknown keys are refused,
so a typo can't silently drop a request. The manifest is the same whether the bot is written in
TypeScript or Rust.

```toml title="zaun-bot.toml"
app_id = "org.example.weather"     # lowercase reverse-DNS; one install per community
version = "1.2.0"                  # updates must increase it
name = "Weather"                   # the bot member's display name, 1-32
description = "Forecasts on demand."
permissions = ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"]
events = ["messages"]              # event groups or types to receive (default: only interactions)
update_url = "https://example.org/weather/"   # optional

[capabilities]
message_content = false            # read every message (privileged; shown to all members)
members = false                    # list members
presence = false                   # receive other members' status and activity
dms = false                        # direct messages with members
voice = false                      # join voice channels and play audio
timers = true
attachments = false                # upload files
storage_bytes = 1048576            # private storage (≤ 1 GiB)
network = ["api.open-meteo.com"]   # HTTPS hosts; "*.example.org" allowed as a leading label

[limits]                           # requests; the host may lower them
memory_bytes = 33554432
cpu_ms = 200
```

Answering an interaction doesn't need `SEND_MESSAGES`; posting on its own does.
Ask for the least you need: owners see the request in plain words, and a request for
`ADMINISTRATOR` or `message_content` is a good reason to refuse a bot.

## How grants are decided

What a bot may do is the **intersection** of what its manifest asks for, what the installer chose to
grant, and the operator's ceiling (`[bots]` in the host's configuration). Permission bits are
granted through a **managed role** that only the bot holds; its bits change only by a new grant.

| Capability | Meaning |
|---|---|
| `message_content` | receive the text of messages that don't mention it (privileged) |
| `members` | list and fetch members beyond those it sees in events |
| `presence` | receive other members' status and activity (`presenceUpdate`); setting the bot's [own presence](/docs/guide/bots/status-and-presence/) needs nothing |
| `dms` | open [direct messages](/docs/guide/bots/direct-messages/) with members (the operator may forbid it host-wide: `[bots] allow_dms`) |
| `voice` | join voice channels and [play audio](/docs/guide/bots/voice-and-music/) (`[bots] allow_voice`); `CONNECT` and `SPEAK` still apply per channel |
| `timers` | schedule timers |
| `attachments` | upload files for its messages |
| `storage_bytes` | the size of its private key-value store |
| `network` | the internet hosts it may contact over HTTPS |

Without `message_content`, the host blanks the content, embeds and attachments of messages delivered
to the bot, except messages that mention it, reply to it, that it wrote, or that are in a direct
message with it. Interactions always arrive whole.

`events` takes the groups `messages`, `reactions`, `members` (needs `members`), `channels`,
`roles`, `typing`, `presence` (needs `presence`), `community`, `commands` and `dms` (needs `dms`),
exact event types, or `*`. Unknown names are refused at install. See [Events](/docs/guide/bots/events/).

## The bot card

Every member can open any bot's **card**: name, publisher, version, signed or not, state, its
permissions, whether it can read message content, the hosts it may contact, its storage and its
events. Every install, update, grant change, disable and removal is announced to every member and
written to the audit log.

## Lifecycle

| State | Meaning |
|---|---|
| `enabled` | running |
| `disabled` | stopped by the owner; its commands are hidden |
| `pending_approval` | an update asks for more than the current grants; the old version keeps running |
| `crashed` | crashed 5 times in 10 minutes; off until the owner enables it again |
