Skip to content

tool

tool<F, A>(definition): ToolDefinition<F, A>

Declares a tool with its inputs and outputs typed end to end: values in run is inferred from fields (values.name is a string for a text field) and action from actions. Identity at runtime.

lookup: tool({
title: "npm",
icon: "shippingbox",
fields: [{ id: "name", type: "text", placeholder: "Package name" }],
actions: [{ id: "lookup", title: "Look Up", role: "primary" }],
async run(action, values, ctx) {
return [status(values.name), table({ License: "MIT" })];
},
})
Type Parameter Default type
F extends readonly ToolField[] []
A extends readonly ToolAction[] []
Parameter Type
definition ToolDefinition<F, A>

ToolDefinition<F, A>