/**
 * Extracts the top-level description from an AI SDK tool.
 */
export function extractToolDescription(tool) {
    if ('description' in tool && typeof tool.description === 'string') {
        return tool.description;
    }
    return undefined;
}
/**
 * Extracts the input JSON Schema from an AI SDK tool, unwrapping the
 * `jsonSchema()` wrapper and falling back to the older `parameters` shape.
 */
export function extractToolSchema(tool) {
    // AI SDK v6 tools use inputSchema (from jsonSchema())
    if ('inputSchema' in tool && tool.inputSchema) {
        const schema = tool.inputSchema;
        // jsonSchema() wraps the schema, so we need to unwrap it
        if (schema.jsonSchema) {
            return schema.jsonSchema;
        }
        return schema;
    }
    // Fallback: check for parameters (older format)
    if ('parameters' in tool && tool.parameters) {
        const params = tool.parameters;
        if (params.jsonSchema) {
            return params.jsonSchema;
        }
        return params;
    }
    return undefined;
}
/**
 * Picks up to two example parameter names for a tool-call example — preferring
 * required params, falling back to whatever properties exist.
 */
export function selectExampleParamNames(properties, required) {
    return required.length > 0
        ? required.slice(0, 2)
        : Object.keys(properties).slice(0, 2);
}
//# sourceMappingURL=tool-schema-extract.js.map