defineTool
View as Markdownfunction defineTool<I>(t): SiteTool<I>;Defined in: hub/src/tools.ts:71
Declares a site tool, keeping the handler’s args typed from input. Its input is turned
into JSON Schema (z.toJSONSchema) for the machine.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
I |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
t |
SiteTool<I> |
Returns
Section titled “Returns”SiteTool<I>
Example
Section titled “Example”const lookupOrder = defineTool({ name: 'lookup_order', description: 'Look up one of the signed-in user\'s orders', input: z.object({ id: z.string() }), handler: async ({ id }, ctx) => db.orders.find({ id, userId: ctx.user.id }),});