/** * Type definitions for MCP paywall functionality */ import type { Address, StartAgentRequest } from '../../common/types.js'; /** * Context provided to dynamic credits functions */ /** * Context provided to dynamic credits functions. */ export interface CreditsContext { args: unknown; result: any; request: { authHeader: string; logicalUrl: string; toolName: string; }; } /** * Credits calculation option - can be fixed amount or dynamic function */ /** * Credits option: fixed bigint or a function receiving {@link CreditsContext}. */ export type CreditsOption = bigint | ((ctx: CreditsContext) => bigint); /** * Configuration options for paywall protection */ /** * Unified paywall options for tools, resources and prompts. */ export interface BasePaywallOptions { name: string; credits?: CreditsOption; onRedeemError?: 'ignore' | 'propagate'; /** * Optional override for the Nevermined plan to charge against. * If omitted, the plan is inferred from the X402 access token. */ planId?: string; /** * Maximum amount of credits to verify during authentication. * Defaults to 1n if not specified. */ maxAmount?: bigint; } export interface ToolOptions extends BasePaywallOptions { kind: 'tool'; } export interface ResourceOptions extends BasePaywallOptions { kind: 'resource'; } export interface PromptOptions extends BasePaywallOptions { kind: 'prompt'; } export type PaywallOptions = ToolOptions | ResourceOptions | PromptOptions; /** * Options for decorating tools with paywall protection */ /** * Authentication result from paywall validation */ export interface AuthResult { token: string; agentId?: string; logicalUrl: string; httpUrl?: string; planId: string; subscriberAddress: Address; agentRequest?: StartAgentRequest; } /** * Context provided to paywall-protected handlers */ export interface PaywallContext { authResult: AuthResult; credits?: bigint; planId: string; subscriberAddress: Address; agentRequest?: StartAgentRequest; } /** * MCP integration configuration */ export interface McpConfig { /** Plan ID the server charges against (required). The facilitator is * plan-centric: verify/settle resolve everything from the plan + token. */ planId: string; /** Agent ID — optional, informational/observability only. */ agentId?: string; serverName?: string; } //# sourceMappingURL=paywall.types.d.ts.map