import type { PayOptions } from "./facilitators/base.js"; import type { AgentWallet } from "./agentWallet.js"; /** The AI clients the AiFinPay backend records for AIFP-Agent-Framework. */ export declare const AGENT_FRAMEWORKS: readonly ["chatgpt", "claude", "perplexity", "gemini", "cursor", "openai-agents", "windsurf", "codex", "custom"]; export type AgentFramework = (typeof AGENT_FRAMEWORKS)[number]; /** `undefined` stays unset; any value outside AGENT_FRAMEWORKS throws. Never guessed. */ export declare function agentFramework(value: unknown): AgentFramework | undefined; /** Optional observation capability, scoped to fixed first-party quote endpoints. * Invalid input loses attribution, never payment/access. No state is retained. */ export declare function reportingHeaders(reportingToken: unknown, endpoint: string): Record; export interface Invoice { amountUsd: number; treasuryVault: string; programId: string; nonce: string; raw: Record; } export interface AgentOptions { baseUrl?: string; timeoutMs?: number; fetchImpl?: typeof fetch; /** Import an existing EVM wallet for standard x402; keep this key alongside * the Solana secret when backing up an agent with an override. */ evmPrivateKey?: `0x${string}`; /** * Inject an external EVM wallet (any viem LocalAccount — see AgentWallet). * Takes priority over `evmPrivateKey` and seed derivation: the SDK calls the * wallet's sign methods instead of holding the key itself. */ evmWallet?: AgentWallet; /** * The AI client this agent runs in, sent as AIFP-Agent-Framework so the * merchant sees who paid. One of AGENT_FRAMEWORKS; anything else throws. * Unset sends no header. */ framework?: AgentFramework; } export interface PayInit extends Omit { method?: string; options?: PayOptions; maxRetries?: number; } export declare class Agent { readonly publicKey: Uint8Array; readonly secretKey: Uint8Array; readonly baseUrl: string; readonly timeoutMs: number; /** Internal — facilitators reach for this when they need to refetch from the backend. */ readonly fetchImpl: typeof fetch; readonly framework?: AgentFramework; private constructor(); static new(opts?: AgentOptions): Agent; /** Load from base58 secret (Solana style: 64 bytes = secret + public). */ static fromSecretB58(secretB58: string, opts?: AgentOptions): Agent; /** Load from a Solana CLI ``solana-keygen`` JSON file path (Node only). */ static fromKeypairFile(path: string, opts?: AgentOptions): Promise; /** Solana base58 public key. */ get address(): string; /** 64-byte base58 secret. Save this safely — server never sees it. */ get secretB58(): string; private _evm?; /** * The agent's EVM account, derived from the same 32-byte seed as the * Solana key via domain-separated SHA-256 ("aifinpay:evm:v1\0" || seed) — * byte-for-byte identical to AiFinPayAgent's EVM address. Used by the * standard x402 (EIP-3009) facilitator. Priority: an injected `evmWallet` * first, then an explicitly imported `evmPrivateKey` (cached during * construction), then seed derivation. * Default derivation is Node-only (sync SHA-256). */ evmAccount(): Promise; /** The agent's EVM (Polygon / Base / …) address. */ evmAddress(): Promise; manifesto(): Promise>; wellKnown(): Promise>; fetchNonce(): Promise<{ nonce: string; expires_at: string; }>; /** Build a fresh AiFinPay-native x402 header set. */ authHeaders(): Promise>; hasSeat(): Promise; waitForFunding({ minUsdCents, pollMs, timeoutMs, }?: { minUsdCents?: number; pollMs?: number; timeoutMs?: number; }): Promise; /** * @deprecated since 0.3.0 — use `AiFinPayAgent.deposit(usd, { asset })` * instead. The unified surface picks the chain and asset for you. * Kept for back-compat; will not be removed before 1.0.0. */ reserveSeatInvoice({ amountUsd, asset, }: { amountUsd: number; asset?: "SOL" | "USDC" | "USDT"; }): Promise; /** * Pure-view fee-on-top breakdown — no payment, no auth. * * Returns merchant amount, treasury fee, IP creator fee, and total — * so the agent can decide whether to pay BEFORE building the tx. * * @deprecated since 0.3.0 — pricing is exposed through the provider * registry consumed by `AiFinPayAgent.call()`. Direct on-chain quote * is rarely needed anymore. Kept for back-compat through 1.0.0. */ quoteSplit(args: { /** @deprecated "botchain" is deprecated. Use "robinhood" instead. */ chain: "solana" | "polygon" | "base" | "optimism" | "unichain" | "botchain" | "xrplevm"; merchantAmount: bigint | number | string; /** Explicit, memory-only reporting.v2 observation; never payment authorization. */ reportingToken?: string; }): Promise>; /** * @deprecated since 0.3.0 — use `AiFinPayAgent.call({ provider })`, * which selects the chain, builds the tx, and submits it for you. * Kept for back-compat through 1.0.0. * * Get the on-chain instructions for a fee-on-top split payment. * * The merchant receives `merchantAmount` units (lamports for Solana, * wei for Polygon). Treasury fee + IP-creator fee are added ON TOP. * * The SDK does **not** submit the transaction — it's non-custodial. * Caller uses the returned `args` + `accounts` (Solana) or * `args` + `msg_value_wei` (Polygon) with a chain SDK of choice * (`@solana/web3.js`, `viem`, `ethers`, …). * * Throws `FacilitatorNotImplementedError` if the corresponding splitter * is not yet deployed on the requested chain (backend returns 503 with * onboarding message). */ payWithSplitInvoice(args: { /** @deprecated "botchain" is deprecated. Use "robinhood" instead. */ chain: "solana" | "polygon" | "base" | "optimism" | "unichain" | "botchain" | "xrplevm"; merchantWallet: string; merchantAmount: bigint | number | string; orderId: string; feeRecipient?: string; }): Promise>; /** * HTTP request that auto-handles x402 across multiple facilitators. * * First sends the request unauthenticated. On 402, detects which * facilitator the server speaks (AiFinPay native, Coinbase x402, …), * builds the appropriate auth payload, and retries. */ pay(url: string, init?: PayInit): Promise; request(method: string, url: string, init?: RequestInit): Promise; get(url: string, init?: PayInit): Promise; post(url: string, init?: PayInit): Promise; /** `headers` plus the SDK's own, which replace a caller's copy in any letter case. */ private sdkHeaders; private json; } //# sourceMappingURL=agent.d.ts.map