Skip to content

@pgege/kaboo-react


Function: toolSchema()

toolSchema\<T>(jsonSchema, check): KabooJsonToolSchema\<T>

Defined in: src/requests/schema.ts:86

Build a KabooToolSchema from a JSON Schema and a check, for apps that describe a tool without a schema library.

Type Parameters

T

T

Parameters

jsonSchema

Record\<string, unknown>

What the agent sees.

check

(value) => string[]

The problems with a value, as messages; none when it is valid.

Returns

KabooJsonToolSchema\<T>

Example

import { toolSchema } from "@pgege/kaboo-react";

const pickColor = toolSchema<{ color: string }>(
  { type: "object", properties: { color: { type: "string" } }, required: ["color"] },
  (value) => (typeof (value as { color?: unknown })?.color === "string" ? [] : ["color must be a string"]),
);