@coinbase/agentkit
Version:
Coinbase AgentKit core primitives
70 lines (69 loc) • 3.24 kB
TypeScript
import { z } from "zod";
import { ActionProvider } from "../actionProvider";
import { Network } from "../../network";
import { HttpRequestSchema, RetryWithX402Schema, DirectX402RequestSchema, ListX402ServicesSchema } from "./schemas";
import { WalletProvider } from "../../wallet-providers";
/**
* X402ActionProvider provides actions for making HTTP requests, with optional x402 payment handling.
*/
export declare class X402ActionProvider extends ActionProvider<WalletProvider> {
/**
* Creates a new instance of X402ActionProvider.
* Initializes the provider with x402 capabilities.
*/
constructor();
/**
* Discovers available x402 services with optional filtering.
*
* @param walletProvider - The wallet provider to use for network filtering
* @param args - Optional filters: discoveryUrl, maxUsdcPrice
* @returns JSON string with the list of services (filtered by network and description)
*/
discoverX402Services(walletProvider: WalletProvider, args: z.infer<typeof ListX402ServicesSchema>): Promise<string>;
/**
* 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: WalletProvider, 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: WalletProvider, 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: WalletProvider, 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;
/**
* Creates an x402 client configured for the given wallet provider.
*
* @param walletProvider - The wallet provider to configure the client for
* @returns Configured x402Client
*/
private createX402Client;
/**
* Parses response data based on content type.
*
* @param response - The fetch Response object
* @returns Parsed response data
*/
private parseResponseData;
}
export declare const x402ActionProvider: () => X402ActionProvider;