See the complete route index at https://docs.crusible.dev/llms.txt before following links.

# Agent media publishing

How an agent publishes screenshots, images and video to an unlisted public link with crusible media publish, and the limits that apply.

<!-- https://docs.crusible.dev/reference/agent-media-publishing/ · doctype: reference · role: both · reviewed: pending human review -->


An agent running in a Crusible terminal can publish images and video to an
unlisted public link. Pull request bodies then link to the media instead of a
file kept in the repository. Publishing is on for sandbox workspaces
unless an administrator turns it off. The switch is described in [control public image links](../../admin/control-public-image-links/).

Publishing needs the media host of the workspace's class to be live. Public links work only once
it is. `crusible media publish` does not check the host. Only
`ui:shots:link` checks it, and it then applies the fallback described below.

## Commands

| Command                             | Does                                                                        |
| ----------------------------------- | --------------------------------------------------------------------------- |
| `crusible media publish FILE...`    | Publishes each file and prints one JSON line per file.                      |
| `crusible media revoke LINK_ID...`  | Revokes links this agent published.                                         |
| `mise run media:publish -- FILE...` | Runs `crusible media publish` from a repository checkout.                   |
| `mise run ui:shots:link -- PR`      | Publishes the captured screenshots and links them in the pull request body. |

Each JSON line holds `path`, `url`, `contentType`, `bytes`, `blake3`,
`reused` and `linkId`. Keep the `linkId`: it is the argument to
`crusible media revoke`. Publishing the same bytes again returns the first
link with `reused` set.

## Limits

| Limit           | Value                                               |
| --------------- | --------------------------------------------------- |
| Image types     | PNG, JPEG, GIF, WebP                                |
| Largest image   | 5 MiB                                               |
| Video types     | WebM, MP4                                           |
| Largest video   | 25 MiB                                              |
| Links per agent | 2,000 in a rolling 24 hours, revoked links included |

An agent revokes only its own links. A link that is absent or belongs to
another agent returns `not_found`, which is final, and `crusible media revoke`
exits 3 with that reason.

## Exit codes

| Code | Meaning                                                              |
| ---- | -------------------------------------------------------------------- |
| 0    | Every file published or revoked.                                     |
| 2    | Usage error.                                                         |
| 3    | A file was refused. The reason is printed.                           |
| 69   | Not in a Crusible terminal. A fleet pod has none.                    |
| 75   | The outcome is uncertain. State is kept. Run the same command again. |
| 1    | Another runtime failure.                                             |

## When publishing is refused

`ui:shots:link` publishes per shot. When one shot is refused it prints a
fallback line and links that shot from the `ui-shots` branch instead:

```text
ui:shots:link: <path> refused (<reason>); linked from the ui-shots branch
```

`ui:shots:link` takes “--backend auto|img|branch”. Without the flag the mode is `auto`.

| Mode     | Behaviour                                                                                                                                                 |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `auto`   | Publishes through the media host. A refusal falls back per shot. An unavailable host, exit 69 or 75, or a failed HEAD check falls back for the whole run. |
| `img`    | Publishes through the media host only. It never falls back, and fails when any shot is not published.                                                     |
| `branch` | Skips the media host and links every shot from the `ui-shots` branch.                                                                                     |

When the media host is unavailable, `ui:shots:link` in `auto` mode
prints a line that begins “ui:shots:link: img backend unavailable”, names the
reason in parentheses and ends with `used branch`, then links every shot from the branch. `img` mode never falls back and fails instead.

