import { EnvironmentName } from '../environments.js'; /** * The payment scheme to use. * - 'nvm' (default): Nevermined-issued x402 access tokens covering both * credit-based ERC-4337 payments and fiat card delegations (Stripe, * Braintree, Visa). */ export type PaymentScheme = 'nvm'; export interface PaymentOptions { /** * The Nevermined environment to connect to. * * @deprecated The environment is now derived from the NVM API key prefix * (`:`), so this option is no longer required. It is still * accepted for backward compatibility and as a fallback when the key prefix * is unrecognized (e.g. local/custom development), but when the prefix maps * to a known environment the key wins and this option is ignored (a one-time * deprecation warning is emitted). It will be removed in a future release. */ environment?: EnvironmentName; /** * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API. * You can get your API key by logging in to the Nevermined App. * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys */ nvmApiKey: string; /** * The payment scheme to use. Defaults to 'nvm'. */ scheme?: PaymentScheme; /** * The URL to return to the app after a successful login. */ returnUrl?: string; /** * The app id. This attribute is optional and helps to associate assets registered into Nevermined with a common identifier. */ appId?: string; /** * Pins the Nevermined backend API version (MAJOR.MINOR) sent with every * request via the `Nevermined-Version` header. Defaults to * {@link LOCKED_API_VERSION} — the backend contract this SDK release is * built and tested against. Override only to deliberately target a * different backend contract. * * @see https://docs.nevermined.app/api-reference/versioning */ version?: string; /** * Optional organization ID to use as the active workspace for every * authenticated backend request. When set, the SDK sends an * `X-Current-Org-Id` header so the backend scopes published agents, * plans, and other resources to this organization. * * If omitted the backend falls back to the API key's org tag or to the * caller's most-recent active membership (see `CurrentOrgContextGuard` * in nvm-monorepo). * * Override per-call via the `organizationId` option on create methods. * * @see Payments.setOrganizationId */ organizationId?: string; } export interface Endpoint { [verb: string]: string; } export interface ApiResponse { success: boolean; data?: T; error?: string; } export type Address = `0x${string}`; /** * Definition of the price configuration for a Payment Plan */ export interface PlanPriceConfig { /** * The address of the token (ERC20 or Native if zero address) for paying the plan */ tokenAddress?: Address; /** * The amounts to be paid for the plan */ amounts: bigint[]; /** * The receivers of the payments of the plan */ receivers: string[]; /** * The address of the smart contract that calculates the price */ contractAddress?: Address; /** * The address of the fee controller contract, if any * @remarks if not given, the fee controller is the default one */ feeController?: Address; /** * The address of the external price contract, if any */ externalPriceAddress?: Address; /** * The address of the template contract, if any */ templateAddress?: Address; /** * Whether this is a crypto payment (true) or fiat payment (false) */ isCrypto: boolean; /** * Optional currency for the plan (e.g., 'USD', 'EUR', 'USDC', 'EURC'). * When omitted, the backend determines the default based on the payment type. */ currency?: Currency | string; } /** * Definition of the credits configuration for a payment plan */ export interface PlanCreditsConfig { /** * Whether the redemption amount is fixed (true) or dynamic (false) */ isRedemptionAmountFixed: boolean; /** * How the credits can be redeemed */ redemptionType: PlanRedemptionType; /** * Whether burns of these credits are mirrored on-chain. When `false` * (default) the credits ledger lives in the API's Postgres and burns * are recorded off-chain only. When `true` an `OnchainMirrorWorker` * replays each off-chain burn to `NFT1155Credits` for audit. */ onchainMirror: boolean; /** * The duration of the credits in seconds * @remarks 0 means non-expirable */ durationSecs: bigint; /** * The amount of credits that are granted when purchasing the plan (as string for API) */ amount: bigint; /** * The minimum number of credits redeemed when using the plan */ minAmount: bigint; /** * The maximum number of credits redeemed when using the plan */ maxAmount: bigint; /** * The address of the NFT contract that represents the plan's credits */ nftAddress?: Address; } /** * Different types of prices that can be configured for a plan * @remarks 0 - FIXED_PRICE, 1 - FIXED_FIAT_PRICE, 2 - SMART_CONTRACT_PRICE * If FIXED_PRICE it means the plan can be paid in crypto by a fixed amount of a ERC20 or Native token * If FIXED_FIAT_PRICE it means the plan can be paid in fiat by a fixed amount (typically USD) * If SMART_CONTRACT_PRICE it means the plan can be paid in crypto and the amount to be paid is calculated by a smart contract */ export declare enum PlanPriceType { FIXED_PRICE = 0, FIXED_FIAT_PRICE = 1, SMART_CONTRACT_PRICE = 2 } /** * Supported currencies for payment plans. * - Fiat: USD, EUR (processed via Stripe) * - Crypto: USDC, EURC (ERC20 stablecoins on Base) */ export declare enum Currency { USD = "USD", EUR = "EUR", USDC = "USDC", EURC = "EURC" } /** EURC token address on Base Mainnet (chain 8453) */ export declare const EURC_TOKEN_ADDRESS: Address; /** EURC token address on Base Sepolia testnet (chain 84532) */ export declare const EURC_TOKEN_ADDRESS_TESTNET: Address; /** * Different types of credits that can be obtained when purchasing a plan * @remarks 0 - EXPIRABLE, 1 - FIXED, 2 - DYNAMIC * If EXPIRABLE it means the credits can be used for a fixed amount of time (calculated in seconds) * If FIXED it means the credits can be used for a fixed amount of times * If DYNAMIC it means the credits can be used but the redemption amount is dynamic */ export declare enum PlanCreditsType { EXPIRABLE = 0, FIXED = 1, DYNAMIC = 2 } /** * Different types of redemptions criterias that can be used when redeeming credits * @remarks 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER * If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE` * If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan * If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan * If ONLY_SUBSCRIBER means only the subscriber (the one who holds the credits NFT) can redeem */ export declare enum PlanRedemptionType { ONLY_GLOBAL_ROLE = 0,// NVM Proxy can burn ONLY_OWNER = 1,// Agent can burn ONLY_PLAN_ROLE = 2, ONLY_SUBSCRIBER = 4 } export interface PlanBalance { planId: string; planName: string; planType: string; holderAddress: Address; balance: bigint; creditsContract: Address; isSubscriber: boolean; pricePerCredit: number; } export interface StartAgentRequest { agentRequestId: string; agentName: string; agentId: string; balance: PlanBalance; urlMatching: string; verbMatching: string; batch: boolean; } export interface ValidationAgentRequest { balance: PlanBalance; urlMatching: string; verbMatching: string; } export interface AgentAccessCredentials { accessToken: string; proxies?: string[]; } export interface SubscriberRequestStatus { planId: string; agentId: string; isValid: boolean; code: number; message?: string; } export interface NvmAPIResult { success: boolean; message?: string; txHash?: string; httpStatus?: number; data?: APIOutputData; when?: Date; } export interface APIOutputData { [key: string]: any; } export interface StripeCheckoutResult { stripeCheckoutSessionId: string; checkoutLink: string; clientReferenceId: string; paymentStatus?: string; linkCreatedAt: number; linkExpiresAt: number; } /** * Metadata attributes describing the AI Agent. */ export interface AgentMetadata { /** * Name of the Agent */ name: string; /** * Description of the Agent */ description?: string; /** * The author of the Agent (organization or person) that own the Agent. */ author?: string; /** * The author of the Agent (organization or person) that own the Agent. */ license?: string; /** * Tags describing the AI Agent */ tags?: string[]; /** * Some description or instructions about how to integrate the Agent. */ integration?: string; /** * A link to some same usage of the Agent. */ sampleLink?: string; /** * Text describing the API of the Agent. */ apiDescription?: string; /** * The date when the Agent was created. */ dateCreated?: Date; } /** * Metadata attributes describing the Payment Plan. */ export interface PlanMetadata extends AgentMetadata { /** * Indicates if a payment plan is a Trial plan. * A Trial plan is a plan that allows users to test the AI Agents associated with it typically without any cost. * @remarks A Trial plan only can be purchased once by a user. */ isTrialPlan?: boolean; /** * Indicates if a payment plan is limited by credits. * If 'time', the plan will be limited by time. * If 'credits', the plan will be limited by credits. */ accessLimit?: 'credits' | 'time'; } /** * It describes the API exposed by an AI Agent. * This information is necessary to query the AI Agent and to know which endpoints are available. */ export interface AgentAPIAttributes { /** * Optional allowlist of upstream endpoints that require a valid Payment Plan * subscription. When provided, the Nevermined platform enforces this list as * **Additional Security** (defense-in-depth) on top of any per-route gating * the Payments library middleware applies in your agent. When omitted, no * route-level allowlist is enforced — your library middleware remains the * sole gate. */ endpoints?: Endpoint[]; /** * The list of endpoints of the upstream service that publicly available. The access to these endpoints don't require subscription to the Payment Plan. They are useful to expose documentation, etc. */ openEndpoints?: string[]; /** * Optional URL to a discoverable agent definition (OpenAPI spec, MCP * Manifest, or A2A agent card). Stored as metadata for documentation / * discovery — not consumed at runtime by the Nevermined platform. */ agentDefinitionUrl?: string; /** * The upstream agent/service authentication type ('none', 'basic', 'bearer' or 'oauth'). */ authType?: 'none' | 'basic' | 'oauth' | 'bearer'; /** * The upstream agent/service username for authentication. Only if `authType` is 'basic'. */ username?: string; /** * The upstream agent/service password for authentication. Only if `authType` is 'basic'. */ password?: string; /** * The upstream agent/service bearer token for authentication. Only if `authType` is 'bearer' or 'oauth'. */ token?: string; } /** * Options for pagination in API requests to the Nevermined API. */ export declare class PaginationOptions { /** * The field to sort the results by. * If not provided, the default sorting defined by the API will be applied. */ sortBy?: string; /** * The order in which to sort the results. * Default is 'desc' (descending). */ sortOrder: 'asc' | 'desc'; /** * The page number to retrieve. * Default is 1. */ page: number; /** * The number of items per page. * Default is 10. */ offset: number; /** * Constructs a new PaginationOptions instance. * @param options - Optional initial values for the pagination options. */ constructor(options?: Partial); /** * It returns a string representation of the pagination options * @returns A string representation of the pagination options as URL query parameters. * This can be used to append to API requests for pagination. */ asQueryParams(): string; } /** * Status of an agent task */ export declare enum AgentTaskStatus { SUCCESS = "SUCCESS", FAILED = "FAILED", PENDING = "PENDING" } /** * Data transfer object for tracking agent sub tasks */ export interface TrackAgentSubTaskDto { /** * The unique identifier of the agent task */ agentRequestId: string; /** * The number of credits burned in this agent sub task (optional) * @defaultValue 0 */ creditsToRedeem?: number; /** * A tag to categorize this agent sub task (optional) */ tag?: string; /** * A description of this agent sub task (optional) */ description?: string; /** * The status of the agent sub task (optional) */ status?: AgentTaskStatus; } export type SimulationRequestOptions = { agentName?: string; planName?: string; batch?: boolean; pricePerCredit?: number; }; /** * x402 payment scheme type. * - 'nvm:erc4337': Crypto payments via ERC-4337 smart accounts * - 'nvm:card-delegation': Fiat/Stripe card delegation payments */ export type X402SchemeType = 'nvm:erc4337' | 'nvm:card-delegation'; /** * Default network for each x402 scheme (backward-compat: defaults to Base Sepolia). */ export declare const X402_SCHEME_NETWORKS: Record; /** * Return the default network for a scheme, accounting for the environment. * * For `nvm:erc4337`, the network depends on the environment: * - sandbox / staging_sandbox → `eip155:84532` (Base Sepolia) * - live / staging_live → `eip155:8453` (Base Mainnet) * * Falls back to `X402_SCHEME_NETWORKS` when no environment is given. */ export declare function getDefaultNetwork(scheme: X402SchemeType, environment?: EnvironmentName): string; /** * Type guard to check if a value is a valid x402 scheme type. */ export declare function isValidScheme(s: unknown): s is X402SchemeType; /** * Currency codes accepted for a delegation. Lowercase, mirroring the * backend's `@IsIn(['usd','eur','usdc','eurc'])` constraint on * `POST /api/v1/delegation/create` and the Python SDK's `DelegationCurrency`. * Card providers use `'usd'`/`'eur'`; erc4337 uses `'usdc'`/`'eurc'`. */ export type DelegationCurrency = 'usd' | 'eur' | 'usdc' | 'eurc'; /** * Configuration for delegation-based payments (both crypto and card schemes). * * The supported flow is **create-first**: create a delegation with * {@link DelegationAPI.createDelegation}, then request the access token with * `delegationConfig: { delegationId }`. * * @remarks * The inline create-on-the-fly fields (`providerPaymentMethodId`, * `spendingLimitCents`, `durationSecs`, `currency`, `merchantAccountId`, * `maxTransactions`, `cardId`) are individually deprecated. Calling * {@link X402TokenAPI.getX402AccessToken} with a `delegationConfig` that lacks * `delegationId` but carries one of those fields emits a runtime deprecation * warning; create the delegation first and pass only `delegationId` (optionally * `apiKeyId`) here. The interface itself is NOT deprecated — the * `{ delegationId }` reuse path is the supported way to configure a token request. */ export interface DelegationConfig { /** * PaymentMethod entity UUID — references an enrolled card. * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`. */ cardId?: string; /** Existing delegation UUID to reuse instead of creating a new one. The supported (non-deprecated) path. */ delegationId?: string; /** * Stripe payment method ID (e.g., 'pm_...'). Required only for new delegations. * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`. */ providerPaymentMethodId?: string; /** * Maximum spending limit in cents. Required only for new delegations. * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`. */ spendingLimitCents?: number; /** * Duration of the delegation in seconds. Required only for new delegations. * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`. */ durationSecs?: number; /** * Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337). * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`. */ currency?: DelegationCurrency; /** * Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId). * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`. */ merchantAccountId?: string; /** * Maximum number of transactions allowed. * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`. */ maxTransactions?: number; /** * Plan ID to scope a newly-created delegation to. Optional and additive: * delegations are plan-agnostic by default; supplying `planId` opts into a * plan-bound delegation. (Visa delegations are always plan-specific and * require it server-side.) * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`. */ planId?: string; /** NVM API Key ID to scope the delegation to. Active (non-deprecated). */ apiKeyId?: string; } /** * Payload for creating a new delegation via POST /api/v1/delegation/create. */ export interface CreateDelegationPayload { /** Delegation provider: 'stripe' | 'braintree' | 'visa' for card, 'erc4337' for crypto */ provider: 'stripe' | 'braintree' | 'visa' | 'erc4337'; /** Payment method ID from the provider (Stripe 'pm_...', Braintree vault token, or Visa Agentic token id). Required for card providers. */ providerPaymentMethodId?: string; /** Maximum spending limit in cents */ spendingLimitCents: number; /** Duration of the delegation in seconds */ durationSecs: number; /** Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337). Required by the backend — no silent default. */ currency: DelegationCurrency; /** * Plan ID to scope the delegation to. Optional and additive: delegations are * plan-agnostic by default; supplying `planId` opts into a plan-bound * delegation. (Visa delegations are always plan-specific and require it.) */ planId?: string; /** Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId) */ merchantAccountId?: string; /** Maximum number of transactions allowed */ maxTransactions?: number; /** NVM API Key ID to scope the delegation to */ apiKeyId?: string; } /** * Response from creating a delegation. */ export interface CreateDelegationResponse { /** Delegation token (for card delegations) */ delegationToken?: string; /** Delegation UUID */ delegationId: string; } /** * Options for x402 token generation that control scheme and delegation behavior. */ export interface X402TokenOptions { /** The x402 scheme to use (defaults to 'nvm:erc4337') */ scheme?: X402SchemeType; /** Network identifier (auto-derived from scheme if omitted) */ network?: string; /** Delegation configuration for both erc4337 and card-delegation schemes */ delegationConfig?: DelegationConfig; } //# sourceMappingURL=types.d.ts.map