Agent at work comes with Pro. Its preview shows once you unlock it.
Usage
import { ChatAgentRun } from './ChatAgentRun.jsx'
export function BookingRun({ runId }) {
return (
<ChatAgentRun
locale="en"
stage="idle"
// Another kind of task: your options and the plan's lines (the line with option takes the approved one).
options={rooms} // [{ name, detail, price, rating, tag?, image? }]
summary={[{ id: 'room', icon: 'home', label: 'Room', option: true }, { id: 'fee', icon: 'tag', label: 'Service', text: 'Booking fee', price: 4 }]}
currency="USD"
// Resolves when the step is done on the server; a rejection marks it failed with Try again.
onStep={(step) => fetch('/api/runs/' + runId + '/steps/' + step.id, { method: 'POST' })}
onApprove={(room) => fetch('/api/runs/' + runId + '/approve', { method: 'POST', body: JSON.stringify({ room: room.name }) })}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | Language of the built-in text, the sample run and the prices. |
task | string | sample | What the visitor asked for, shown above the steps. |
steps | { id, icon, title, running, result, approval?, tool?: { name, input, output } }[] | sample | The steps in order. `approval` makes a step wait for the visitor; `tool` opens to show the call’s input and output. |
options | { name, detail, price, rating, tag?, image?, art? }[] | sample | What the waiting step offers; Show another goes through them. `image` (a URL) or `art` (an element) replaces the drawn house. |
summary | { id, icon?, label, text?, price?, option? }[] | sample | The plan shown once every step is done, one line each. The line with `option: true` shows the option approved; the total adds every price. `icon` is a kit icon name or train. |
currency | string | by locale | ISO currency code of every price. |
stage | 'idle' | 'approval' | 'approval' | Where the run opens: before it starts (with Start), or at the step waiting for approval. |
onStep | (step, index) => Promise | — | Runs one step. The step shows as running until it resolves; a rejection marks it failed with Try again. |
onApprove | (option) => Promise | — | Called with the option the visitor approved; the rest of the run continues once it resolves. |
onStop | () => void | — | Called when the visitor stops the run. The running step is paused and can be resumed. |
loading | boolean | false | Shows the shape of the run while it starts. |
error | boolean | false | Opens with the second step failed and Try again on it. |
labels | object | — | Replaces any built-in text (see copy.js), such as status, approve, another or failText. |
className | string | — | Added to the root; other attributes go there too. |
Add it to your project
Pro includes the full source of this block. Copy its prompt to install it with your coding agent.
ChatAgentRun.jsxchat-agent-run.csscopy.jskit.jsxkit.cssui/base-button/ui/copy-button/ui/success-check/ui/agent-status/ui/skeleton-shimmer/tokens.cssREADME.md
The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.
