import { AIQueryApi } from './api/query-api.js'; import { PaymentOptions } from './common/types.js'; import { BasePaymentsAPI } from './api/base-payments.js'; import { PlansAPI } from './api/plans-api.js'; import { ContractsAPI } from './api/contracts-api.js'; import { AgentsAPI } from './api/agents-api.js'; import { AgentRequestsAPI } from './api/requests-api.js'; import { ObservabilityAPI } from './api/observability-api/observability-api.js'; import type { PaymentsA2AServerOptions, PaymentsA2AServerResult } from './a2a/server.js'; import { buildPaymentAgentCard } from './a2a/agent-card.js'; import * as mcpModule from './mcp/index.js'; import { OrganizationsAPI } from './api/organizations-api/organizations-api.js'; import { FacilitatorAPI } from './x402/facilitator-api.js'; import { X402TokenAPI } from './x402/token.js'; import { DelegationAPI } from './x402/delegation-api.js'; /** * Main class that interacts with the Nevermined payments API. * Use `Payments.getInstance` for server-side usage or `Payments.getBrowserInstance` for browser usage. * @remarks This API requires a Nevermined API Key, which can be obtained by logging in to the Nevermined App. * * The library provides methods to manage AI Agents, Plans & process AI Agent Requests. * * Each of these functionalities is encapsulated in its own API class: * - `plans`: Manages AI Plans, including registration and ordering and retrieving plan details. * - `agents`: Handles AI Agents, including registration of AI Agents and access token generation. * - `requests`: Manages requests received by AI Agents, including validation and tracking. * - `observability`: Provides observability and logging utilities for AI Agents with Helicone integration */ export declare class Payments extends BasePaymentsAPI { query: AIQueryApi; plans: PlansAPI; agents: AgentsAPI; requests: AgentRequestsAPI; observability: ObservabilityAPI; organizations: OrganizationsAPI; contracts: ContractsAPI; facilitator: FacilitatorAPI; x402: X402TokenAPI; private _a2aRegistry?; private _delegation?; /** * Cached MCP integration to preserve configuration (e.g., agentId, serverName) * across multiple getter accesses. This ensures callers do not need to retain * a reference to a previously configured instance. */ private _mcpIntegration?; /** * Exposes A2A server and client registry methods. * The client registry is initialized only if getClient is called. */ get a2a(): { /** * Starts the A2A server with payment integration. * @param options - Server options. */ start: (options: Omit) => PaymentsA2AServerResult; /** * Gets (or creates) a RegisteredPaymentsClient for the given alias. * The registry is initialized only on first use. * @param options - ClientRegistryOptions. */ getClient: (options: any) => Promise; }; /** * Returns the MCP integration API. The instance is memoized so that configuration * set via `configure({ agentId, serverName })` persists across calls. */ get mcp(): { configure: (options: mcpModule.ExtendedMcpConfig) => void; withPaywall: { (handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext) => Promise | any, options: import("./mcp/types/paywall.types.js").ToolOptions | import("./mcp/types/paywall.types.js").PromptOptions): (args: TArgs, extra?: any) => Promise; (handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext) => Promise | any): (args: TArgs, extra?: any) => Promise; (handler: (uri: URL, variables: Record, extra?: any, context?: mcpModule.PaywallContext) => Promise | any, options: import("./mcp/types/paywall.types.js").ResourceOptions): (uri: URL, variables: Record, extra?: any) => Promise; }; attach: (server: { registerTool: (name: string, config: any, handler: any) => void; registerResource: (name: string, template: any, config: any, handler: any) => void; registerPrompt: (name: string, config: any, handler: any) => void; }) => { registerTool(name: string, config: any, handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext) => Promise | any, options?: Omit): void; registerResource(name: string, template: any, config: any, handler: (uri: URL, variables: Record, extra?: any, context?: mcpModule.PaywallContext) => Promise | any, options?: Omit): void; registerPrompt(name: string, config: any, handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext) => Promise | any, options?: Omit): void; }; authenticateMeta: (extra: any, options: { planId?: string; } | undefined, method: string) => Promise; createRouter: (options: mcpModule.CreateRouterOptions) => import("express").Router; createApp: (options: Omit & { agentId?: string; }) => import("express").Application; startServer: (options: mcpModule.StartServerOptions) => Promise; getConfig: () => mcpModule.ExtendedMcpConfig; registerTool: (name: string, config: mcpModule.McpToolConfig, handler: mcpModule.ToolHandler, options?: mcpModule.McpRegistrationOptions) => void; registerResource: (name: string, uriOrTemplate: string, config: mcpModule.McpResourceConfig, handler: mcpModule.ResourceHandler, options?: mcpModule.McpRegistrationOptions) => void; registerPrompt: (name: string, config: mcpModule.McpPromptConfig, handler: mcpModule.PromptHandler, options?: mcpModule.McpRegistrationOptions) => void; start: (config: mcpModule.McpServerConfig) => Promise; stop: () => Promise; }; /** * Returns the Delegation API for listing enrolled payment methods. * The instance is lazily initialized on first access — the current * organization pin (set via `setOrganizationId` or the constructor * option) and the backend API version pin (`options.version`) are * forwarded so the first call carries the right `X-Current-Org-Id` * and `Nevermined-Version` headers. */ get delegation(): DelegationAPI; /** * Static A2A helpers and utilities. * Example: Payments.a2a.buildPaymentAgentCard(...) */ static a2a: { buildPaymentAgentCard: typeof buildPaymentAgentCard; }; /** * Get an instance of the Payments class for server-side usage. * * @param options - The options to initialize the payments class. * @example * ``` * const payments = Payments.getInstance({ * nvmApiKey: 'your-nvm-api-key', * environment: 'sandbox' * }) * ``` * @returns An instance of {@link Payments} * @throws PaymentsError if nvmApiKey is missing. */ static getInstance(options: PaymentOptions): Payments; /** * Get an instance of the Payments class for browser usage. * * @remarks * This is a browser-only function. * * @param options - The options to initialize the payments class. * @example * ``` * const payments = Payments.getBrowserInstance({ * returnUrl: 'https://mysite.example', * environment: 'sandbox', * appId: 'my-app-id', * version: '1.1' * }) * ``` * @returns An instance of {@link Payments} * @throws PaymentsError if returnUrl is missing. */ static getBrowserInstance(options: PaymentOptions): Payments; /** * Initializes the Payments class. * * @param options - The options to initialize the payments class. * @param isBrowserInstance - Whether this instance is for browser usage. */ private constructor(); /** * Initializes the AI Query Protocol API. */ private initializeApi; /** * Initiates the connect flow. The user's browser will be redirected to * the Nevermined App login page. * * @remarks * This is a browser-only function. * @example * ``` * payments.connect() * ``` */ connect(): void; /** * Logs out the user by removing the NVM API key. * * @remarks * This is a browser-only function. * @example * ``` * payments.logout() * ``` */ logout(): void; /** * Pins (or clears) the active organization workspace used by every * subsequent authenticated request. The SDK forwards the choice as the * `X-Current-Org-Id` header so the backend scopes publications and * other org-aware queries to the requested organization. * * Pass `null` to clear the pin and let the backend fall back to the * API key's org tag or the caller's most-recent active membership. * * For one-off targeting (e.g. publish a single agent into Org B without * leaving Org B as the active workspace) prefer the per-call * `{ organizationId }` option on `agents.registerAgent` / * `plans.registerPlan` / similar. * * @param organizationId - Org ID to pin (e.g. `org-…`) or `null` to clear. * @example * ```ts * payments.setOrganizationId('org-abc123') * await payments.agents.registerAgent(metadata, api, [planId]) // lands in org-abc123 * ``` */ setOrganizationId(organizationId: string | null): void; /** * Checks if a user is logged in. * @example * ``` * payments.isLoggedIn * ``` * @returns True if the user is logged in. */ get isLoggedIn(): boolean; } //# sourceMappingURL=payments.d.ts.map