/**
 * API Executor Service - Handles API execution with enhanced error handling.
 *
 * This service provides a wrapper around aiExecuteV2Api with proto validation
 * and comprehensive error reporting for the AI model.
 */
import type { Api } from "@superblocksteam/library-shared/types";
import type { IntegrationStore } from "../../../integrations/store.js";
import type { EditorClient } from "../../../types.js";
export interface ApiExecutionResult {
    success: boolean;
    outputs?: Record<string, any>;
    stepOutputs?: Record<string, {
        error?: any;
        output?: any;
    }>;
    errors?: ApiExecutionError[];
    systemError?: string;
    executionTime?: number;
}
export type ApiExecutionError = {
    type: "validation" | "execution" | "proto" | "auth" | "rate_limit" | "binding" | "unknown";
    handled?: boolean;
    message: string;
    displayMessage?: string;
    bodyDetails?: string;
    suggestion?: string;
    originalError?: unknown;
};
export type ApiExecutionInputs = Record<string, any>;
export interface ApiExecutionOptions {
    includeStepOutputs?: boolean;
    timeout?: number;
}
export declare class ApiExecutor {
    private editorClient;
    private integrationStore;
    constructor(editorClient: EditorClient, integrationStore: IntegrationStore);
    /**
     * Execute an API with comprehensive error handling.
     *
     * @param api - The API definition to execute
     * @param inputs - Input variables for the API
     * @param options - Execution options
     * @returns Execution result with outputs or detailed error information
     */
    execute(api: {
        type: "fetch";
        apiName: string;
    } | {
        type: "inline";
        definition: Api;
    }, inputs?: ApiExecutionInputs, options?: ApiExecutionOptions): Promise<ApiExecutionResult>;
    /**
     * Validate that the API can roundtrip through protobuf.
     * Throws an error if validation fails.
     */
    private validateProtoCompatibility;
    /**
     * Parse error messages to extract the message and body (JSON) separately.
     *
     * @param errorMessage - The raw error message that may contain JSON with escaped newlines
     * @returns Object with message and body if body exists, undefined otherwise
     */
    private parseErrorMessage;
    /**
     * Parse execution errors to provide helpful details.
     */
    private parseExecutionError;
    /**
     * Determine whether an error message indicates an authentication or authorization failure.
     */
    private isAuthError;
    /**
     * Determine whether an error message indicates a rate limit condition.
     */
    private isRateLimitError;
    /**
     * Determine whether an error message indicates missing or incorrect bindings.
     */
    private isBindingError;
    /**
     * Get suggestion for proto errors.
     */
    private getProtoErrorSuggestion;
    /**
     * Get suggestion for validation errors.
     */
    private getValidationErrorSuggestion;
}
//# sourceMappingURL=api-executor.d.ts.map