registerTool static method

void registerTool(
  1. ToolDefinition definition,
  2. ToolExecutor executor
)

Register a tool with the SDK.

definition Tool definition including name, description, and parameters executor Async function to execute when the tool is called

Example:

RunAnywhereTools.registerTool(
  ToolDefinition(
    name: 'get_weather',
    description: 'Get current weather for a location',
    parameters: [
      ToolParameter(
        name: 'location',
        type: ToolParameterType.string,
        description: 'City name or coordinates',
      ),
    ],
  ),
  (args) async {
    final location = args['location']?.stringValue ?? 'Unknown';
    // Call weather API...
    return {'temperature': NumberToolValue(72), 'condition': StringToolValue('Sunny')};
  },
);

Implementation

static void registerTool(ToolDefinition definition, ToolExecutor executor) {
  _toolDefinitions[definition.name] = definition;
  _toolExecutors[definition.name] = executor;
  _logger.info('Registered tool: ${definition.name}');
}