Tool ApprovalPRO
A human-in-the-loop card where an agent asks permission before running an action.
Code
1 file · 240 lines of TypeScriptPRO
Tool Approval is part of Pro
Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.
Motion notes
- On a decision, the buttons collapse while the status row expands on the same spring, so the card's height moves smoothly between the two instead of jumping. Both sides blur as they cross.
- The status icon pops in just after the row lands and its check or cross draws itself, so the outcome reads as one beat, not two.
- While waiting, a small dot on the icon breathes slowly: enough to signal that the agent is blocked on you, without nagging. The arguments dim once resolved, since they are now history.
- The pressed button unmounts, so focus moves to the status row and a persistent live region announces the result. With reduced motion, the rows swap with a short fade and the dot holds still.
Usage
Example
<ApprovalCard
title="Run a shell command"
tool="bash"
args="rm -rf build/ && npm run build"
risk="high"
onDecision={(decision) => respond(toolCallId, decision)}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | ReactNode | — | What the agent wants to do, in plain words. |
| tool | string | — | Tool or function name, e.g. bash. |
| args | ReactNode | — | Short preview of the arguments, shown in a mono well and clamped to 3 lines. |
| description | ReactNode | — | Why the agent wants to do it. |
| risk | "low" | "medium" | "high" | "low" | Sets the risk chip. Medium and high use the warning and danger tones. |
| decision | "deny" | "once" | "always" | null | — | Controlled decision. null means still waiting. |
| defaultDecision | "deny" | "once" | "always" | null | null | Initial decision when uncontrolled. |
| onDecision | (decision: "deny" | "once" | "always") => void | — | Called when a button is pressed. |
| allowAlways | boolean | true | Show “Always allow”. Without it, the primary button reads “Approve”. |
| icon | ReactNode | — | Replaces the default shield icon. |
| className | string | — | Classes for the card. |