validation library

Opt-in validation of tool arguments against the tool's JSON Schema.

Appduct.instance.registerTool(
  'add',
  description: 'Adds two numbers.',
  inputSchema: schema,
  handler: validated(schema, (args, context) => (args['a'] as num) + (args['b'] as num)),
);

Functions

validated(Map<String, Object?> inputSchema, AppductToolHandler handler) → AppductToolHandler
Wraps handler so arguments that do not match inputSchema answer tool_input_validation_error without reaching it.