Function adaptTools

  • Converts supported tool inputs into an array of ITool instances suitable for use with the AgentOS provider layer.

    • Existing ITool instances (identified by inputSchema + id properties) are passed through unchanged.
    • Plain ToolDefinition objects are wrapped in a minimal ITool implementation. Zod schemas are converted to JSON Schema when zod-to-json-schema is available.
    • ExternalToolRegistry inputs are adapted into executable ITool instances, preserving any prompt metadata they expose.
    • ToolDefinitionForLLM[] arrays are treated as prompt-only schemas and produce tools that fail explicitly when invoked without an executor.

    Parameters

    • tools: undefined | AdaptableToolInput

      Optional map of tool names to definitions. Returns [] when falsy.

    Returns ITool[]

    Flat array of normalised ITool instances ready for provider dispatch.

    Example

    const tools = adaptTools({
    getWeather: {
    description: 'Returns current weather for a city.',
    parameters: { type: 'object', properties: { city: { type: 'string' } }, required: ['city'] },
    execute: async ({ city }) => fetchWeather(city),
    },
    });