# Payload

A block of code or query text from the agent: a query it ran, code it wrote, a config file. Rendered as text in a sunken well, with its language and a copy control that only says "Copied" once the clipboard took it. `bare` drops the frame and the caption, for a card or panel that already has its own.

Code is split into tokens (keywords, strings, comments…) rendered as spans of text, never as HTML. They're coloured when `highlight` is set, or anywhere under `data-syntax="highlight"` (set it on `<html>` for the whole app).

- Registry name: `payload` (`@candor/payload`)
- Tier: Free (MIT). No licence key needed.
- Docs: https://candor.themethodic.com/docs/payload

## Install

```bash
npx candor-ui add payload
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/payload`.
It brings in: chat, highlight, locale, use-copy, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import { Payload } from "@/components/payload"

const query = "SELECT status, COUNT(*)\nFROM orders\nWHERE created_at > now() - interval '7 days'\nGROUP BY status"

const fix = 'export async function refund(orderId: string) {\n  // Only settled orders can be refunded\n  const order = await db.orders.find(orderId)\n  if (order.status !== "settled") return { ok: false, reason: "not settled" }\n  return payments.refund(order.chargeId, 4200)\n}'

export default function Example() {
  return (
    <div className="flex max-w-lg flex-col gap-4">
      <Payload language="sql" title="The query I ran" text={query} />
      {/* highlight: coloured by syntax, as text spans. data-syntax="highlight" on <html> turns it on everywhere. */}
      <Payload highlight language="ts" title="The fix" text={fix} />
      {/* bare: inside a card that already has a title and its own actions. */}
      <section aria-labelledby="payload-card" className="rounded-lg border p-3">
        <h4 id="payload-card" className="mb-2 text-sm font-medium">
          Orders by status, last 7 days
        </h4>
        <Payload bare language="sql" text={query} />
      </section>
    </div>
  )
}
```

## <Payload>

Props:

- `language: PayloadLanguage`: Shown as the label, e.g. json, sql, python. Never executed or highlighted as HTML.
- `text: string`: The code or query, shown as text.
- `title?: string | undefined`: What it is, e.g. "The query I ran". Not shown when `bare`.
- `bare?: boolean | undefined` (default `false`): Just the code: no border, language label or copy button, for inside something that has them.
- `highlight?: boolean | undefined`: Colour the code by its syntax. Left out, it follows the nearest `data-syntax` attribute (off by default).
- `className?: string | undefined`

## Strings (`payload`)

The fixed words, English by default. Override any of them under `payload` in `<LocaleProvider strings={{ payload: { … } }}>`; the table is exported as `payloadStrings`.

- `copy`: Copy
- `copied`: Copied
- `copyFailed`: Couldn’t copy
- `shell`: Shell
- `text`: Text

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
