// ─── Agent config ───────────────────────────────────────────────────────────── export interface FluidAgentConfig { /** Fluid agent key — starts with fwag_ (value of FLUID_AGENT_KEY env var) */ agentKey: string; baseUrl?: string; /** Enable FADP auto-pay — agent.fetch() will automatically pay 402 FADP walls */ fadp?: boolean; /** Max USD amount to auto-pay per FADP request (default: 10) */ fadpMaxUsd?: number; /** * Check USDC balance before every FADP payment. * If balance is insufficient, logs the funding address and throws instead of * attempting a payment that will fail. * Default: false (balance check skipped for speed; server rejects if insufficient) */ checkBalanceBeforePayment?: boolean; } // ─── Payment params ─────────────────────────────────────────────────────────── export interface SendPaymentParams { to: string; amount: string; chain?: string; token?: string; } export interface BatchRecipient { to: string; // wallet address or Fluid ID amount: string; // USDC amount label?: string; // optional label (e.g. player name, rank) } export interface BatchSendParams { recipients: BatchRecipient[]; chain?: string; token?: string; } export interface BatchSendResult { sent: BatchRecipient[]; failed: { recipient: BatchRecipient; error: string }[]; total: string; chain: string; token: string; } export interface SwapParams { fromToken: string; toToken: string; amount: string; slippage?: string; chain?: string; /** TOTP code from the wallet owner's authenticator app — required when the account has TOTP enabled */ otpCode?: string; } export interface AgentPayParams { toEmail: string; amount: string; token?: string; memo?: string; } export interface QuoteParams { fromToken: string; toToken: string; amount: string; chain?: string; } export interface ApprovalStatusParams { approvalToken: string; } // ─── Payment results ────────────────────────────────────────────────────────── // ─── UOI — Universal Onchain ID ────────────────────────────────────────────── // Format: {emailLocal}-{base64url8}.fluidbase.eth (agents) // {emailLocal}.fluidbase.eth (users) export interface UOIIdentity { type: "agent" | "fluid_user" | "external"; address: string; uoi: string | null; email?: string | null; agentKey?: string; // keyPrefix only, e.g. "fwag_a3f9…" agentName?: string | null; } export interface FADPReceipt { id: string; // e.g. "receipt_fwag_a3f9_1714400000000" protocol: "FADP/1.0"; status: "confirmed"; timestamp: string; // ISO 8601 network: string; // "Base Mainnet" chainId: number; // 8453 txHash: string; explorerUrl: string; // https://basescan.org/tx/{txHash} from: UOIIdentity & { email: string }; to: UOIIdentity; payment: { amount: string; token: string; tokenAddress: string; // e.g. USDC: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 }; memo?: string; } export interface PaymentResult { status: string; // "confirmed" | "pending_approval" | "failed" txHash?: string; explorerUrl?: string; receipt?: FADPReceipt; approvalToken?: string; // present when status === "pending_approval" pollUrl?: string; // present when status === "pending_approval" // legacy flat fields (still present for backwards compatibility) from?: string; to?: string; amount?: string; chain?: string; token?: string; message?: string; } export interface ApprovalStatusResult { status: string; // "pending" | "approved" | "rejected" | "expired" approvalToken: string; txHash?: string; explorerUrl?: string; decidedAt?: string; } // ─── Identity / UAI ─────────────────────────────────────────────────────────── export interface IdentityResult { email: string; walletAddress: string | null; } export interface UAIResolveResult { username: string; address: string | null; displayName?: string | null; avatarUrl?: string | null; networkId?: string; } export interface UAIReverseResult { address: string; username: string | null; fluidId?: string | null; } export interface UAIRegisterResult { success: boolean; username: string; address: string; message?: string; } // ─── Price ──────────────────────────────────────────────────────────────────── export interface PriceResult { token: string; usd: number; source?: string; } // ─── Pauli Keys (scoped agent keys) ────────────────────────────────────────── /** * Scopes a Pauli key can carry (subset of parent key's scopes). * Scope format: "read", "pay", "swap", "spawn", "read:pay" (combined) */ export type PauliScope = "read" | "pay" | "swap" | "spawn" | string; export interface CreateKeyParams { label: string; // human-readable name (e.g. "Worker-A") scopes: PauliScope[]; // must be ⊆ parent key scopes spendLimit?: string; // max USD per tx (e.g. "100") dailyLimit?: string; // max USD per day expiresIn?: number; // seconds until key expires (0 = no expiry) } export interface PauliKey { keyId: string; // e.g. "fwag_read_pay_" label: string; scopes: PauliScope[]; spendLimit?: string; dailyLimit?: string; createdAt: string; expiresAt?: string | null; active: boolean; usageCount: number; lastUsedAt?: string | null; } export interface RevokeKeyResult { success: boolean; keyId: string; message?: string; } // ─── Agent identity ─────────────────────────────────────────────────────────── export interface AgentMeResult { email: string; keyPrefix: string; name: string; scopes: string[]; }