Skip to content
function 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 Parameter
I
Parameter Type
t SiteTool<I>

SiteTool<I>

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 }),
});