<Tool>

<Tool>

What the model can call. A tool that is not rendered is not in the request (State and conditional tools).

import { Tool } from "curb";

function Tool(props: ToolProps): ReactNode;

Props

Every tool takes these:

PropTypeWhat it does
namestringThe name the model calls
descriptionstringWhen to call it, for the model
iconstringA lucide icon name for the preview. Never reaches the model

Then one of three ways to take input:

FormPropsUse it for
Schemaschema, onSubmit, tryWithMost tools: a Zod object, and typed input in onSubmit
Fields<Field> children, onSubmit, tryWithA few flat fields
No inputonCallA tool that takes nothing

onSubmit and onCall return a ToolResult, { ok, message?, data? }, or a promise of one. With schema or fields, more props apply, and confirm holds the tool until the caller agrees:

PropTypeWhat it does
successstringThe line after a successful run. Without it, the result’s message
errorstringThe line when a failed result has no message
tryWithobjectWhat the preview’s Try form opens with. Never reaches the model
confirm(input) => stringThe question that holds the tool until the caller says yes. Only with onSubmit (Confirmations)

A handler can refuse its input with ToolInputError.

Example

import { Tool, z } from "curb";

<Tool
  name="open_claim"
  description="Open a claim once the caller has described what happened."
  schema={z.object({ policy: z.string(), what: z.string() })}
  onSubmit={async ({ policy, what }) => {
    const id = await claims.open(policy, what);
    return { ok: true, message: `Claim ${id} is open.` };
  }}
/>

Version history

VersionChanges
v1.5.0tryWith added
v1.4.33confirm added
v1.0.0icon added
v0.1.2<Tool> introduced