UNPKG

@coinbase/agentkit

Version:

Coinbase AgentKit core primitives

56 lines (55 loc) 2.65 kB
import { z } from "zod"; import { ActionProvider } from "../actionProvider"; import { Network } from "../../network"; import { HttpRequestSchema, RetryWithX402Schema, DirectX402RequestSchema } from "./schemas"; import { EvmWalletProvider } from "../../wallet-providers"; /** * X402ActionProvider provides actions for making HTTP requests, with optional x402 payment handling. */ export declare class X402ActionProvider extends ActionProvider<EvmWalletProvider> { /** * Creates a new instance of X402ActionProvider. * Initializes the provider with x402 capabilities. */ constructor(); /** * Makes a basic HTTP request to an API endpoint. * * @param walletProvider - The wallet provider to use for potential payments * @param args - The request parameters including URL, method, headers, and body * @returns A JSON string containing the response or error details */ makeHttpRequest(walletProvider: EvmWalletProvider, args: z.infer<typeof HttpRequestSchema>): Promise<string>; /** * Retries a request with x402 payment after receiving a 402 response. * * @param walletProvider - The wallet provider to use for making the payment * @param args - The request parameters including URL, method, headers, body, and payment option * @returns A JSON string containing the response with payment details or error information */ retryWithX402(walletProvider: EvmWalletProvider, args: z.infer<typeof RetryWithX402Schema>): Promise<string>; /** * Makes an HTTP request with automatic x402 payment handling. * * @param walletProvider - The wallet provider to use for automatic payments * @param args - The request parameters including URL, method, headers, and body * @returns A JSON string containing the response with optional payment details or error information */ makeHttpRequestWithX402(walletProvider: EvmWalletProvider, args: z.infer<typeof DirectX402RequestSchema>): Promise<string>; /** * Checks if the action provider supports the given network. * * @param network - The network to check support for * @returns True if the network is supported, false otherwise */ supportsNetwork: (network: Network) => boolean; /** * Helper method to handle HTTP errors consistently. * * @param error - The axios error to handle * @param url - The URL that was being accessed when the error occurred * @returns A JSON string containing formatted error details */ private handleHttpError; } export declare const x402ActionProvider: () => X402ActionProvider;