UNPKG

run402-mcp

Version:

MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.

75 lines • 3 kB
type FetchFn = typeof globalThis.fetch; export interface X402LnbtcRequirements { scheme: string; network: string; amount: string; asset: string; payTo: string; maxTimeoutSeconds: number; extra: Record<string, unknown>; } export interface X402LnbtcOffer { paymentRequired: { x402Version: number; resource?: { url?: string; description?: string; mimeType?: string; }; accepts: X402LnbtcRequirements[]; }; requirements: X402LnbtcRequirements; } /** The thrown error type, shared with the MPP Lightning buyer. */ export interface X402LnbtcErrorFactory { (code: string, message: string, details?: Record<string, unknown>): Error; } export interface X402LnbtcWallet { payInvoice(bolt11: string): Promise<{ preimage: string; }>; lookupInvoice(paymentHash: string): Promise<{ state: string | null; preimage: string | null; } | null>; } /** A POST to a Run402 surface that offers x402 on Lightning. */ export declare function isX402LightningCandidate(input: RequestInfo | URL, init: RequestInit | undefined): boolean; /** The x402 v2 challenge's `exact` entry on an `lnbtc:` network with an invoice, or null. */ /** The x402 network ids of every payable `lnbtc` entry in a 402 (empty when there is none). */ export declare function x402LightningNetworks(response: Response): string[]; /** * The payable `lnbtc` entry of a 402: on `network` when one is named (the * wallet's), else the first one. Null when the 402 carries none. */ export declare function readX402LightningOffer(response: Response, network?: string): X402LnbtcOffer | null; /** * The request headers made explicit: a string body without a content type is * sent by fetch as `text/plain;charset=UTF-8`, and the request hash must bind * the value actually sent, so it is set here rather than left to fetch. */ export declare function explicitRequestHeaders(init: RequestInit | undefined): Headers; /** What `onPaid` learns about a payment: the entry it paid, never the preimage. */ export interface X402LnbtcPaid { network: string; amountMsat: number; payTo: string; resourceUrl: string; } export interface PayX402LightningOptions { input: RequestInfo | URL; init: RequestInit | undefined; offer: X402LnbtcOffer; wallet: X402LnbtcWallet; baseFetch: FetchFn; fail: X402LnbtcErrorFactory; /** Checks the all-in cost (sats) against the rail's ceiling and the wallet's budget; throws to refuse. */ checkCaps: (amountSats: number) => Promise<void>; onPaid?: (paymentHash: string, paid: X402LnbtcPaid) => void; /** Unix seconds; the invoice checks' clock. Tests pin it; production uses the system clock. */ clock?: () => number; } /** Pay the offer and send the paid retry. */ export declare function payX402Lightning(options: PayX402LightningOptions): Promise<Response>; export {}; //# sourceMappingURL=lightning-x402-lnbtc.d.ts.map