Skip to content
AgentsShell toolMenu

Shell tool

A shell command: a monochrome terminal that streams output and stays pinned to the bottom, the exit code, and Stop while it runs.

Output streams into a monochrome terminal. Stop ends it.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/tool-bash.json

Usage

tsx
import { ToolBash } from "@/components/ui/chatcn/tool-bash"

<ToolBash state="input-available" command="pnpm test" output={stdout} onStop={stop} />
<ToolBash state="output-available" command="pnpm test" output={stdout} exitCode={0} />
tsx
import { ToolBashPart, toolBashRenderers } from "@/components/ui/chatcn/tool-bash"

// One part straight from AI SDK or the chatcn contract
<ToolBashPart part={part} onApprove={approve} onDeny={deny} />

// Or map tool names to renderers for a whole message
renderToolPart(part, { ...toolBashRenderers })

A part with preliminary: true output keeps streaming as a running call. ANSI escape codes are stripped: the terminal is monochrome by design.

Examples

Failed command

A non-zero exit code with standard error.

Props

PropTypeNotes
commandstring
output, stderrstringStandard error renders in full ink
exitCodenumberNon-zero shows in red text in the header and footer
cwdstringShown quietly before the command
onStop() => voidShows Stop while running
stateToolDisplayStateThe ToolCall lifecycle: streaming, running, approval, output, error, denied, cancelled
approval, decisionApproval request and the user's answer, as on ToolCall
onApprove, onDeny, onRetrySame callbacks as ToolCall
errorTextReactNodeShown on output-error
durationMs, startedAtnumberOptional. Measured automatically when omitted
variant"card" | "inline"Inline sits on a trace rail
open, defaultOpen, onOpenChangeControlled or uncontrolled details

Keyboard

KeyAction
Enter, SpaceExpand or collapse the details
TabMove through the header, links, copy buttons and approval actions

Motion

  • Output appends without effects. The square caret marks the live end of the stream.
  • Open by default while running. If you close it, it stays closed.