<!-- Generated by scripts/gen-docs.mts from the JSDoc in registry/. Do not edit; run `pnpm run docs`. -->

# ToolCall

One call an agent made to a tool, as a row in its conversation: a status icon, what it did, a summary of the arguments and how long it took. A call with `output` is a Collapsible whose title is the row, and it opens to show the output in a CodeBlock. A failed call says "Failed" and a waiting one "Waiting for you" in words, not only by colour, and a screen reader hears the status after the row.

## Install

Once per app, with Tailwind CSS v4 and an `@/*` path alias (skip `init` in an existing shadcn app), then the component:

```sh
npx shadcn@latest init --base base --preset nova --yes --no-monorepo
npx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.3.823
npx shadcn@latest add ourostack/ouro-ui/tool-call#v1.3.823
```

More: [Installing](https://ui.ouroboros.bot/docs/installing.md).

```tsx
import { ToolCall } from "@/components/ouro/tool-call/tool-call";
```

## Example

```tsx
<ToolCall name="Ran command" detail="npm test" status="done" duration={4.2} output={log} outputLanguage="ansi" />
```

## Use instead when

- Use `ToolCallGroup` instead for several calls in a row, under one "Ran 3 tools" line.
- Use `ThinkingBlock` instead for the agent's reasoning, and `CodeBlock` alone for code that isn't a tool's output.

## Props

Type: `ToolCallProps`.

| Prop | Type | Description |
| --- | --- | --- |
| `className` | `string` | Layout only: margins, width (`mt-1`). Appearance classes warn in development. |
| `defaultOpen` | `boolean` | Shows the output first, when the component keeps its own state. |
| `detail` | `ReactNode` | A short summary of its arguments, in the code font, cut short on one line: `recipes/roast.md`, `npm test`. |
| `duration` | `number` | How long it took, in seconds, shown short at the row's end: "1.2s", "2m 5s". |
| `name` (required) | `ReactNode` | What the agent did, as the person reads it: "Read file", "Ran command", "Searched the web". |
| `onOpenChange` | `((open: boolean) => void)` | Called with the new state when the person shows or hides the output. |
| `open` | `boolean` | Whether the output shows, when you control it. Pair it with `onOpenChange`. |
| `output` | `string` | What the tool gave back, as plain text. With it the row opens to show it in a CodeBlock. |
| `outputLanguage` | `string` | The output's language, for CodeBlock: `"ansi"` reads terminal escape codes as colours. |
| `ref` | `Ref<HTMLDivElement>` | Reaches the rendered element. |
| `status` (required) | `"failed" \| "running" \| "done" \| "waiting"` | Where the call stands. `running` shows a spinner; `done` a tick; `failed` a cross and "Failed"; `waiting` (for the person, such as for their permission) a clock and "Waiting for you". |

## Don't use

These are not props. Passing one fails the type check with the fix in the error, and in development a console message names the fix.

- `args`: Not a prop. A summary of the arguments is `detail`: `<ToolCall detail="recipes/roast.md">`.
- `input`: Not a prop. A summary of the arguments is `detail`: `<ToolCall detail="recipes/roast.md">`.
- `result`: Not a prop. What the tool gave back is `output`, a string: `<ToolCall output={text}>`.
- `state`: Not a prop. Where the call stands is `status`: `<ToolCall status="running">`.
- `toolName`: Not a prop. The tool's name is `name`: `<ToolCall name="Read file">`.

## `className` is for layout only

Pass margins, width and grid placement (`mt-4`, `w-full`, `col-span-2`).

Appearance comes from props, not classes. In development, a class that sets appearance logs one warning per component instance, naming the prop to use instead. A class sets appearance when, after its variants (`hover:`, `sm:`) and any `!` are removed, it starts with `bg-`, `text-`, `border-`, `rounded-`, `shadow-`, `font-`, `ring-`, `from-`, `via-`, `to-`, `fill-` or `stroke-`, or is `border`, `rounded`, `shadow` or `ring`, or has a `dark:` variant. Text wrapping, overflow and table layout classes (`text-wrap`, `text-ellipsis`, `border-collapse`) are layout and do not warn.

Alignment classes (`text-center`) warn too: set alignment on a parent element.
