import { ToolDefinition } from '../core/schema.js'; /** * HttpExecutor - Executes HTTP requests * Handles authentication, retries, and response validation */ export declare class HttpExecutor { /** * Execute a tool that makes an HTTP request. * * @param tool - Tool definition * @param params - Tool parameters (already env-injected by MatimoInstance) * @param credentials - Optional per-call credential overrides. Used for * `authentication.type: basic` (username_env / password_env keys) instead of * reading from `process.env`. Other auth schemes (bearer, api_key) are handled * upstream via parameter templating in MatimoInstance.injectAuthParameters(). * Values are never logged. */ execute(tool: ToolDefinition, params: Record, credentials?: Record): Promise; /** * Automatically inject `Authorization: Basic ` when * the tool declares `authentication.type: basic` with `username_env` and `password_env`. * * This is a zero-friction pattern: developers only set two natural env vars * (e.g. TWILIO_ACCOUNT_SID + TWILIO_AUTH_TOKEN) and Matimo handles encoding. * No pre-computed base64 credential string required. * * When `credentials` is provided the lookup order is: * 1. `credentials[envVarName]` (per-call override — multi-tenant use) * 2. `process.env[envVarName]` (singleton / single-tenant fallback) * * Credential values are never logged or included in error details. */ private applyBasicAuth; /** * Replace parameter placeholders in a string */ private templateString; /** * Check if a string is an unfilled placeholder * Only matches single placeholders like "{param}", not "{...}" or embedded placeholders */ private isUnfilledPlaceholder; /** * Validate that all URL parameters are provided */ private validateUrlParameters; /** * Build query string from query_params, only including provided values */ private buildQueryString; /** * Replace parameter placeholders in an object (headers, body, query params) * * CORE PRINCIPLE: "Define once in YAML, embed correctly at execution time" * * This method intelligently handles different parameter types: * - STRING placeholders like "{title}": Always templated as strings * - OBJECT placeholders like "{parent}": Embedded directly as JSON objects (not stringified) if paramDefinitions specifies type:object * - ARRAY placeholders like "{items}": Embedded directly as JSON arrays (not stringified) if paramDefinitions specifies type:array * * Key behaviors: * - Recursively processes nested objects * - Skips keys with unfilled placeholders (e.g., "{sort_by}" when sort_by not provided) * - Uses parameter schema type from YAML to determine how to embed values * - Preserves JSON structure for complex types (objects/arrays) sent to APIs * * @example * ``` * // YAML definition: * parameters: * parent: * type: object // <-- Tells executor to embed as-is, not stringify * items: * type: array // <-- Tells executor to embed as-is, not stringify * title: * type: string // <-- String templating applies * * body: * parent: "{parent}" // Object embedded as {"id": "123", ...} * items: "{items}" // Array embedded as [{"name": "a"}, ...] * title: "{title}" // String embedded as "My Title" * * // JavaScript call: * const result = await matimo.execute('notion_create_page', { * parent: { database_id: 'abc123' }, // JavaScript object * items: [{ type: 'text' }], // JavaScript array * title: 'Create This Page' // String * }); * * // HTTP body sent to API: * { * "parent": {"database_id": "abc123"}, // Proper JSON object * "items": [{"type": "text"}], // Proper JSON array * "title": "Create This Page" // String * } * ``` */ private templateObject; } export default HttpExecutor; //# sourceMappingURL=http-executor.d.ts.map