@nevermined-io/payments 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -467,6 +467,45 @@ const result = await client.callTool({
467
467
  - `credits` can be a `bigint` or `(ctx) => bigint` with `{ args, result }`. Use `args` for input-based pricing and `result` for output-based pricing.
468
468
  - `name` builds the logical URL `mcp://{serverName}/{kind}/{name}`.
469
469
 
470
+ ## Documentation
471
+
472
+ Comprehensive markdown documentation is available in the `markdown/` directory:
473
+
474
+ - **Installation** - Setup and prerequisites
475
+ - **Initialization** - Getting started with the SDK
476
+ - **Payment Plans** - Creating and managing payment plans
477
+ - **Agents** - Registering and managing AI agents
478
+ - **Static Resources** - Publishing static content
479
+ - **Payments & Balance** - Ordering plans and checking balances
480
+ - **Querying Agents** - Using X402 access tokens
481
+ - **Request Validation** - Verifying and settling permissions
482
+ - **MCP Integration** - Model Context Protocol setup
483
+ - **A2A Integration** - Agent-to-Agent protocol setup
484
+ - **X402 Protocol** - Complete payment protocol specification
485
+
486
+ ### Automated Documentation
487
+
488
+ The documentation is automatically maintained and published:
489
+
490
+ - **On Push**: Documentation metadata is updated when source code changes
491
+ - **On Tag**: Documentation is published to [nevermined-io/docs_mintlify](https://github.com/nevermined-io/docs_mintlify) repository
492
+
493
+ For more details, see [DOCUMENTATION.md](./DOCUMENTATION.md).
494
+
495
+ ### Quick Commands
496
+
497
+ ```bash
498
+ # Validate documentation
499
+ ./scripts/generate-docs.sh
500
+
501
+ # Publish documentation (manual)
502
+ ./scripts/publish-docs.sh
503
+
504
+ # View workflows
505
+ gh run list --workflow=update-docs.yml
506
+ gh run list --workflow=publish-docs.yml
507
+ ```
508
+
470
509
  ## License
471
510
 
472
511
  ```text
@@ -33,6 +33,12 @@ export declare class PaymentsClient extends A2AClient {
33
33
  * Clears the cached access token for this client instance.
34
34
  */
35
35
  clearToken(): void;
36
+ /**
37
+ * Type guard to check if a JSON-RPC response is an error response.
38
+ * @param response - The JSON-RPC response to check
39
+ * @returns true if the response contains an error, false otherwise
40
+ */
41
+ private isErrorResponse;
36
42
  /**
37
43
  * Sends a message to the agent, managing authentication automatically.
38
44
  * @param params - The parameters for sending the message.
@@ -1 +1 @@
1
- {"version":3,"file":"paymentsClient.d.ts","sourceRoot":"","sources":["../../src/a2a/paymentsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,qCAAqC,EACrC,YAAY,EACZ,qCAAqC,EACtC,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAI9C;;;GAGG;AACH,qBAAa,cAAe,SAAQ,SAAS;IACpC,QAAQ,EAAE,QAAQ,CAAA;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,WAAW,CAAe;IAElC;;;;;;;OAOG;IACH,OAAO;IAQP;;;OAGG;WACiB,MAAM,CACxB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,SAA2B,GACvC,OAAO,CAAC,cAAc,CAAC;IAO1B;;;OAGG;YACW,mBAAmB;IASjC;;OAEG;IACI,UAAU;IAIjB;;;;OAIG;IACU,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUpF;;;;;;;;OAQG;IACW,oBAAoB,CAChC,MAAM,EAAE,iBAAiB,GACxB,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC;IAsDvC;;;;;;;;OAQG;YACY,eAAe;IAoD9B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAuDz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EAC1B,qCAAqC,EACrC,YAAY,EACZ,qCAAqC,GACtC,MAAM,aAAa,CAAA"}
@@ -49,6 +49,14 @@ export class PaymentsClient extends A2AClient {
49
49
  clearToken() {
50
50
  this.accessToken = null;
51
51
  }
52
+ /**
53
+ * Type guard to check if a JSON-RPC response is an error response.
54
+ * @param response - The JSON-RPC response to check
55
+ * @returns true if the response contains an error, false otherwise
56
+ */
57
+ isErrorResponse(response) {
58
+ return response && typeof response === 'object' && 'error' in response;
59
+ }
52
60
  /**
53
61
  * Sends a message to the agent, managing authentication automatically.
54
62
  * @param params - The parameters for sending the message.
@@ -1 +1 @@
1
- {"version":3,"file":"paymentsClient.js","sourceRoot":"","sources":["../../src/a2a/paymentsClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAW3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAGnC;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,SAAS;IAM3C;;;;;;;OAOG;IACH,YAAoB,SAAoB,EAAE,QAAkB,EAAE,OAAe,EAAE,MAAc;QAC3F,KAAK,CAAC,SAAS,CAAC,CAAA;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACxB,YAAoB,EACpB,QAAkB,EAClB,OAAe,EACf,MAAc,EACd,aAAa,GAAG,wBAAwB;QAExC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAA;QACpE,MAAM,GAAG,GAAG,MAAM,SAAS,CAA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EAAE,iDAAiD,EACtJ,gBAAgB,CACjB,CAAA;QACH,CAAC;QACD,OAAO,WAAwB,CAAA;IACjC,CAAC;CACF","sourcesContent":["import { Payments } from '../index.js'\nimport { PaymentsError } from '../common/payments.error.js'\nimport {\n MessageSendParams,\n SendMessageResponse,\n TaskQueryParams,\n GetTaskResponse,\n TaskPushNotificationConfig,\n SetTaskPushNotificationConfigResponse,\n TaskIdParams,\n GetTaskPushNotificationConfigResponse,\n} from '@a2a-js/sdk'\nimport { A2AClient } from '@a2a-js/sdk/client'\nimport { v4 as uuidv4 } from 'uuid'\nimport type { AgentCard } from './types.js'\n\n/**\n * PaymentsClient is a high-level client for A2A agents with payments integration.\n * Each instance is bound to a specific agentId and planId.\n */\nexport class PaymentsClient extends A2AClient {\n public payments: Payments\n private readonly agentId: string\n private readonly planId: string\n private accessToken: string | null\n\n /**\n * Creates a new PaymentsClient instance.\n * @param agentBaseUrl - The base URL of the agent (e.g. http://localhost:3005/a2a/).\n * @param payments - The Payments object.\n * @param agentId - The ID of the agent.\n * @param planId - The ID of the plan.\n * @param agentCardPath - Optional path to the agent card relative to base URL (defaults to '.well-known/agent.json').\n */\n private constructor(agentCard: AgentCard, payments: Payments, agentId: string, planId: string) {\n super(agentCard)\n this.payments = payments\n this.agentId = agentId\n this.planId = planId\n this.accessToken = null\n }\n\n /**\n * Creates a PaymentsClient by fetching the AgentCard first and then\n * constructing the underlying A2AClient with the AgentCard object.\n */\n public static async create(\n agentBaseUrl: string,\n payments: Payments,\n agentId: string,\n planId: string,\n agentCardPath = '.well-known/agent.json',\n ): Promise<PaymentsClient> {\n const agentCardUrl = new URL(agentCardPath, agentBaseUrl).toString()\n const a2a = await A2AClient.fromCardUrl(agentCardUrl)\n const agentCard = await (a2a as any).getAgentCard()\n return new PaymentsClient(agentCard as AgentCard, payments, agentId, planId)\n }\n\n /**\n * Gets and caches the access token for this client instance.\n * @returns The access token string.\n */\n private async _getX402AccessToken(): Promise<string> {\n if (this.accessToken) {\n return this.accessToken\n }\n const accessParams = await this.payments.x402.getX402AccessToken(this.planId, this.agentId)\n this.accessToken = accessParams.accessToken\n return this.accessToken\n }\n\n /**\n * Clears the cached access token for this client instance.\n */\n public clearToken() {\n this.accessToken = null\n }\n\n /**\n * Sends a message to the agent, managing authentication automatically.\n * @param params - The parameters for sending the message.\n * @returns The response from the agent.\n */\n public async sendA2AMessage(params: MessageSendParams): Promise<SendMessageResponse> {\n const accessToken = await this._getX402AccessToken()\n const headers = { Authorization: `Bearer ${accessToken}` }\n return this._postRpcRequestWithHeaders<MessageSendParams, SendMessageResponse>(\n 'message/send',\n params,\n headers,\n )\n }\n\n /**\n * Sends a message to the agent and streams back responses using Server-Sent Events (SSE).\n * Push notification configuration can be specified in `params.configuration`.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params - The parameters for sending the message.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n * The generator throws an error if streaming is not supported or if an HTTP/SSE error occurs.\n */\n public async *sendA2AMessageStream(\n params: MessageSendParams,\n ): AsyncGenerator<any, void, undefined> {\n const agentCard = await (this as any).agentCardPromise\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\n 'Agent does not support streaming (AgentCard.capabilities.streaming is not true).',\n )\n }\n const endpoint = await (this as any)._getServiceEndpoint()\n const clientRequestId = uuidv4()\n const rpcRequest = {\n jsonrpc: '2.0',\n method: 'message/stream',\n params: params as { [key: string]: any },\n id: clientRequestId,\n }\n const accessToken = await this._getX402AccessToken()\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/event-stream',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify(rpcRequest),\n })\n if (!response.ok) {\n let errorBody = ''\n try {\n errorBody = await response.text()\n const errorJson = JSON.parse(errorBody)\n if (errorJson.error) {\n throw new Error(\n `HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`,\n )\n }\n } catch (e: any) {\n if (e.message.startsWith('HTTP error establishing stream')) throw e\n throw new Error(\n `HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. Response: ${errorBody || '(empty)'}`,\n )\n }\n throw new Error(\n `HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}`,\n )\n }\n if (!response.headers.get('Content-Type')?.startsWith('text/event-stream')) {\n throw new Error(\"Invalid response Content-Type for SSE stream. Expected 'text/event-stream'.\")\n }\n // Parse and yield SSE events\n for await (const event of this._parseA2AStream(response, clientRequestId)) {\n yield event\n }\n }\n\n /**\n * Parses an HTTP response body as an A2A Server-Sent Event stream.\n * Each 'data' field of an SSE event is expected to be a JSON-RPC 2.0 Response object,\n * specifically a SendStreamingMessageResponse (or similar structure for resubscribe).\n * @param response -The HTTP Response object whose body is the SSE stream.\n * @param originalRequestId - The ID of the client's JSON-RPC request that initiated this stream.\n * Used to validate the `id` in the streamed JSON-RPC responses.\n * @returns An AsyncGenerator yielding the `result` field of each valid JSON-RPC success response from the stream.\n */\n private async *_parseA2AStream<TStreamItem>(\n response: Response,\n originalRequestId: number | string | null,\n ): AsyncGenerator<TStreamItem, void, undefined> {\n if (!response.body) {\n throw new Error('SSE response body is undefined. Cannot read stream.')\n }\n const reader = response.body.pipeThrough(new TextDecoderStream()).getReader()\n let buffer = '' // Holds incomplete lines from the stream\n let eventDataBuffer = '' // Holds accumulated 'data:' lines for the current event\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done) {\n // Process any final buffered event data if the stream ends abruptly after a 'data:' line\n if (eventDataBuffer.trim()) {\n const result = this._processEventData<TStreamItem>(eventDataBuffer, originalRequestId)\n yield result\n }\n break // Stream finished\n }\n\n buffer += value // Append new chunk to buffer\n let lineEndIndex\n // Process all complete lines in the buffer\n while ((lineEndIndex = buffer.indexOf('\\n')) >= 0) {\n const line = buffer.substring(0, lineEndIndex).trim() // Get and trim the line\n buffer = buffer.substring(lineEndIndex + 1) // Remove processed line from buffer\n\n if (line === '') {\n // Empty line: signifies the end of an event\n if (eventDataBuffer) {\n // If we have accumulated data for an event\n const result = this._processEventData<TStreamItem>(eventDataBuffer, originalRequestId)\n yield result\n eventDataBuffer = '' // Reset buffer for the next event\n }\n } else if (line.startsWith('data:')) {\n eventDataBuffer += line.substring(5).trimStart() + '\\n' // Append data (multi-line data is possible)\n } else if (line.startsWith(':')) {\n // This is a comment line in SSE, ignore it.\n }\n }\n }\n } catch (error: any) {\n throw new PaymentsError(error.message, 'payments_error')\n } finally {\n reader.releaseLock() // Ensure the reader lock is released\n }\n }\n\n /**\n * Processes a single SSE event's data string, expecting it to be a JSON-RPC response.\n * @param jsonData - The string content from one or more 'data:' lines of an SSE event.\n * @param originalRequestId - The ID of the client's request that initiated the stream.\n * @returns The `result` field of the parsed JSON-RPC success response.\n * @throws Error if data is not valid JSON, not a valid JSON-RPC response, an error response, or ID mismatch.\n */\n private _processEventData<TStreamItem>(\n jsonData: string,\n originalRequestId: number | string | null,\n ): TStreamItem {\n if (!jsonData.trim()) {\n throw new Error('Attempted to process empty SSE event data.')\n }\n try {\n // SSE data can be multi-line, ensure it's treated as a single JSON string.\n const sseJsonRpcResponse = JSON.parse(jsonData.replace(/\\n$/, ''))\n\n // Type assertion to SendStreamingMessageResponse, as this is the expected structure for A2A streams.\n const a2aStreamResponse: any = sseJsonRpcResponse\n\n if (a2aStreamResponse.id !== originalRequestId) {\n // According to JSON-RPC spec, notifications (which SSE events can be seen as) might not have an ID,\n // or if they do, it should match. A2A spec implies streamed events are tied to the initial request.\n throw new PaymentsError(\n `SSE Event's JSON-RPC response ID mismatch. Client request ID: ${originalRequestId}, event response ID: ${a2aStreamResponse.id}.`,\n 'payments_error',\n )\n }\n\n if (this.isErrorResponse && this.isErrorResponse(a2aStreamResponse)) {\n const err = a2aStreamResponse.error\n throw new PaymentsError(\n `SSE event contained an error: ${err.message} (Code: ${err.code}) Data: ${JSON.stringify(err.data)}`,\n )\n }\n\n // Check if 'result' exists, as it's mandatory for successful JSON-RPC responses\n if (!('result' in a2aStreamResponse) || typeof a2aStreamResponse.result === 'undefined') {\n throw new PaymentsError(\n `SSE event JSON-RPC response is missing 'result' field. Data: ${jsonData}`,\n 'payments_error',\n )\n }\n\n return a2aStreamResponse as TStreamItem\n } catch (e: any) {\n // Catch errors from JSON.parse or if it's an error response that was thrown by this function\n if (\n e.message.startsWith('SSE event contained an error') ||\n e.message.startsWith(\"SSE event JSON-RPC response is missing 'result' field\")\n ) {\n throw new PaymentsError(e.message, 'payments_error')\n }\n\n throw new PaymentsError(\n `Failed to parse SSE event data: \"${jsonData.substring(0, 100)}...\". Original error: ${e.message}`,\n 'payments_error',\n )\n }\n }\n\n /**\n * Resubscribes to a task's event stream using Server-Sent Events (SSE).\n * This is used if a previous SSE connection for an active task was broken.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params - Parameters containing the taskId.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n */\n public async *resubscribeA2ATask(params: TaskIdParams): AsyncGenerator<any, void, undefined> {\n const agentCard = await (this as any).agentCardPromise\n if (!agentCard.capabilities?.streaming) {\n throw new Error('Agent does not support streaming (required for tasks/resubscribe).')\n }\n const endpoint = await (this as any)._getServiceEndpoint()\n const clientRequestId = uuidv4()\n const rpcRequest = {\n jsonrpc: '2.0',\n method: 'tasks/resubscribe',\n params: params as { [key: string]: any },\n id: clientRequestId,\n }\n const accessToken = await this._getX402AccessToken()\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/event-stream',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify(rpcRequest),\n })\n if (!response.ok) {\n let errorBody = ''\n try {\n errorBody = await response.text()\n const errorJson = JSON.parse(errorBody)\n if (errorJson.error) {\n throw new Error(\n `HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`,\n )\n }\n } catch (e: any) {\n if (e.message.startsWith('HTTP error establishing stream')) throw e\n throw new Error(\n `HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. Response: ${errorBody || '(empty)'}`,\n )\n }\n throw new Error(\n `HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}`,\n )\n }\n if (!response.headers.get('Content-Type')?.startsWith('text/event-stream')) {\n throw new Error(\n \"Invalid response Content-Type for SSE stream on resubscribe. Expected 'text/event-stream'.\",\n )\n }\n // Parse and yield SSE events\n for await (const event of this._parseA2AStream(response, clientRequestId)) {\n yield event\n }\n }\n\n /**\n * Retrieves a task by its ID, managing authentication automatically.\n * @param params - The parameters for the task query.\n * @returns The task response.\n */\n public async getA2ATask(params: TaskQueryParams): Promise<GetTaskResponse> {\n const accessToken = await this._getX402AccessToken()\n const headers = { Authorization: `Bearer ${accessToken}` }\n return this._postRpcRequestWithHeaders<TaskQueryParams, GetTaskResponse>(\n 'tasks/get',\n params,\n headers,\n )\n }\n\n /**\n * Sets or updates the push notification configuration for a given task, managing authentication automatically.\n * @param params - The parameters for the task push notification configuration.\n * @returns The response from the agent.\n */\n public async setA2ATaskPushNotificationConfig(\n params: TaskPushNotificationConfig,\n ): Promise<SetTaskPushNotificationConfigResponse> {\n const accessToken = await this._getX402AccessToken()\n const headers = { Authorization: `Bearer ${accessToken}` }\n return this._postRpcRequestWithHeaders<\n TaskPushNotificationConfig,\n SetTaskPushNotificationConfigResponse\n >('tasks/pushNotificationConfig/set', params, headers)\n }\n\n /**\n * Gets the push notification configuration for a given task, managing authentication automatically.\n * @param params - The parameters for the task push notification configuration.\n * @returns The response from the agent.\n */\n public async getA2ATaskPushNotificationConfig(\n params: TaskIdParams,\n ): Promise<GetTaskPushNotificationConfigResponse> {\n const accessToken = await this._getX402AccessToken()\n const headers = { Authorization: `Bearer ${accessToken}` }\n return this._postRpcRequestWithHeaders<TaskIdParams, GetTaskPushNotificationConfigResponse>(\n 'tasks/pushNotificationConfig/get',\n params,\n headers,\n )\n }\n\n /**\n * Internal helper to make a JSON-RPC POST request with custom headers.\n * @param method - The RPC method name.\n * @param params - The parameters for the RPC method.\n * @param headers - Optional custom headers.\n * @returns The response from the agent.\n */\n protected async _postRpcRequestWithHeaders<TParams, TResponse>(\n method: string,\n params: TParams,\n headers?: Record<string, string>,\n ): Promise<TResponse> {\n const endpoint = await (this as any)._getServiceEndpoint()\n const requestId = uuidv4()\n const rpcRequest = { jsonrpc: '2.0', method, params, id: requestId }\n const httpResponse = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n ...(headers || {}),\n },\n body: JSON.stringify(rpcRequest),\n })\n if (!httpResponse.ok) {\n let errorBodyText = '(empty or non-JSON response)'\n try {\n errorBodyText = await httpResponse.text()\n const errorJson = JSON.parse(errorBodyText)\n if (!errorJson.jsonrpc && errorJson.error) {\n throw new Error(\n `RPC error for ${method}: ${errorJson.error.message} (Code: ${errorJson.error.code}, HTTP Status: ${httpResponse.status}) Data: ${JSON.stringify(errorJson.error.data)}`,\n )\n } else if (!errorJson.jsonrpc) {\n throw new Error(\n `HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`,\n )\n }\n } catch (e: any) {\n if (e.message.startsWith('RPC error for') || e.message.startsWith('HTTP error for')) throw e\n throw new Error(\n `HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`,\n )\n }\n }\n const rpcResponse = await httpResponse.json()\n if (rpcResponse.id !== requestId) {\n throw new PaymentsError(\n `CRITICAL: RPC response ID mismatch for method ${method}. Expected ${requestId}, got ${rpcResponse.id}. This may lead to incorrect response handling.`,\n 'payments_error',\n )\n }\n return rpcResponse as TResponse\n }\n}\n\nexport type {\n MessageSendParams,\n SendMessageResponse,\n TaskQueryParams,\n GetTaskResponse,\n TaskPushNotificationConfig,\n SetTaskPushNotificationConfigResponse,\n TaskIdParams,\n GetTaskPushNotificationConfigResponse,\n} from '@a2a-js/sdk'\n"]}
1
+ {"version":3,"file":"paymentsClient.js","sourceRoot":"","sources":["../../src/a2a/paymentsClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAW3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAGnC;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,SAAS;IAM3C;;;;;;;OAOG;IACH,YAAoB,SAAoB,EAAE,QAAkB,EAAE,OAAe,EAAE,MAAc;QAC3F,KAAK,CAAC,SAAS,CAAC,CAAA;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACxB,YAAoB,EACpB,QAAkB,EAClB,OAAe,EACf,MAAc,EACd,aAAa,GAAG,wBAAwB;QAExC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAA;QACpE,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;QACrD,MAAM,SAAS,GAAG,MAAO,GAAW,CAAC,YAAY,EAAE,CAAA;QACnD,OAAO,IAAI,cAAc,CAAC,SAAsB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAC9E,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,mBAAmB;QAC/B,IAAI,IAAI,CAAC,WAAW,EAA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from '../common/payments.error.js'\nimport {\n MessageSendParams,\n SendMessageResponse,\n TaskQueryParams,\n GetTaskResponse,\n TaskPushNotificationConfig,\n SetTaskPushNotificationConfigResponse,\n TaskIdParams,\n GetTaskPushNotificationConfigResponse,\n} from '@a2a-js/sdk'\nimport { A2AClient } from '@a2a-js/sdk/client'\nimport { v4 as uuidv4 } from 'uuid'\nimport type { AgentCard } from './types.js'\n\n/**\n * PaymentsClient is a high-level client for A2A agents with payments integration.\n * Each instance is bound to a specific agentId and planId.\n */\nexport class PaymentsClient extends A2AClient {\n public payments: Payments\n private readonly agentId: string\n private readonly planId: string\n private accessToken: string | null\n\n /**\n * Creates a new PaymentsClient instance.\n * @param agentBaseUrl - The base URL of the agent (e.g. http://localhost:3005/a2a/).\n * @param payments - The Payments object.\n * @param agentId - The ID of the agent.\n * @param planId - The ID of the plan.\n * @param agentCardPath - Optional path to the agent card relative to base URL (defaults to '.well-known/agent.json').\n */\n private constructor(agentCard: AgentCard, payments: Payments, agentId: string, planId: string) {\n super(agentCard)\n this.payments = payments\n this.agentId = agentId\n this.planId = planId\n this.accessToken = null\n }\n\n /**\n * Creates a PaymentsClient by fetching the AgentCard first and then\n * constructing the underlying A2AClient with the AgentCard object.\n */\n public static async create(\n agentBaseUrl: string,\n payments: Payments,\n agentId: string,\n planId: string,\n agentCardPath = '.well-known/agent.json',\n ): Promise<PaymentsClient> {\n const agentCardUrl = new URL(agentCardPath, agentBaseUrl).toString()\n const a2a = await A2AClient.fromCardUrl(agentCardUrl)\n const agentCard = await (a2a as any).getAgentCard()\n return new PaymentsClient(agentCard as AgentCard, payments, agentId, planId)\n }\n\n /**\n * Gets and caches the access token for this client instance.\n * @returns The access token string.\n */\n private async _getX402AccessToken(): Promise<string> {\n if (this.accessToken) {\n return this.accessToken\n }\n const accessParams = await this.payments.x402.getX402AccessToken(this.planId, this.agentId)\n this.accessToken = accessParams.accessToken\n return this.accessToken\n }\n\n /**\n * Clears the cached access token for this client instance.\n */\n public clearToken() {\n this.accessToken = null\n }\n\n /**\n * Type guard to check if a JSON-RPC response is an error response.\n * @param response - The JSON-RPC response to check\n * @returns true if the response contains an error, false otherwise\n */\n private isErrorResponse(response: any): boolean {\n return response && typeof response === 'object' && 'error' in response\n }\n\n /**\n * Sends a message to the agent, managing authentication automatically.\n * @param params - The parameters for sending the message.\n * @returns The response from the agent.\n */\n public async sendA2AMessage(params: MessageSendParams): Promise<SendMessageResponse> {\n const accessToken = await this._getX402AccessToken()\n const headers = { Authorization: `Bearer ${accessToken}` }\n return this._postRpcRequestWithHeaders<MessageSendParams, SendMessageResponse>(\n 'message/send',\n params,\n headers,\n )\n }\n\n /**\n * Sends a message to the agent and streams back responses using Server-Sent Events (SSE).\n * Push notification configuration can be specified in `params.configuration`.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params - The parameters for sending the message.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n * The generator throws an error if streaming is not supported or if an HTTP/SSE error occurs.\n */\n public async *sendA2AMessageStream(\n params: MessageSendParams,\n ): AsyncGenerator<any, void, undefined> {\n const agentCard = await (this as any).agentCardPromise\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\n 'Agent does not support streaming (AgentCard.capabilities.streaming is not true).',\n )\n }\n const endpoint = await (this as any)._getServiceEndpoint()\n const clientRequestId = uuidv4()\n const rpcRequest = {\n jsonrpc: '2.0',\n method: 'message/stream',\n params: params as { [key: string]: any },\n id: clientRequestId,\n }\n const accessToken = await this._getX402AccessToken()\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/event-stream',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify(rpcRequest),\n })\n if (!response.ok) {\n let errorBody = ''\n try {\n errorBody = await response.text()\n const errorJson = JSON.parse(errorBody)\n if (errorJson.error) {\n throw new Error(\n `HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`,\n )\n }\n } catch (e: any) {\n if (e.message.startsWith('HTTP error establishing stream')) throw e\n throw new Error(\n `HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. Response: ${errorBody || '(empty)'}`,\n )\n }\n throw new Error(\n `HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}`,\n )\n }\n if (!response.headers.get('Content-Type')?.startsWith('text/event-stream')) {\n throw new Error(\"Invalid response Content-Type for SSE stream. Expected 'text/event-stream'.\")\n }\n // Parse and yield SSE events\n for await (const event of this._parseA2AStream(response, clientRequestId)) {\n yield event\n }\n }\n\n /**\n * Parses an HTTP response body as an A2A Server-Sent Event stream.\n * Each 'data' field of an SSE event is expected to be a JSON-RPC 2.0 Response object,\n * specifically a SendStreamingMessageResponse (or similar structure for resubscribe).\n * @param response -The HTTP Response object whose body is the SSE stream.\n * @param originalRequestId - The ID of the client's JSON-RPC request that initiated this stream.\n * Used to validate the `id` in the streamed JSON-RPC responses.\n * @returns An AsyncGenerator yielding the `result` field of each valid JSON-RPC success response from the stream.\n */\n private async *_parseA2AStream<TStreamItem>(\n response: Response,\n originalRequestId: number | string | null,\n ): AsyncGenerator<TStreamItem, void, undefined> {\n if (!response.body) {\n throw new Error('SSE response body is undefined. Cannot read stream.')\n }\n const reader = response.body.pipeThrough(new TextDecoderStream()).getReader()\n let buffer = '' // Holds incomplete lines from the stream\n let eventDataBuffer = '' // Holds accumulated 'data:' lines for the current event\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done) {\n // Process any final buffered event data if the stream ends abruptly after a 'data:' line\n if (eventDataBuffer.trim()) {\n const result = this._processEventData<TStreamItem>(eventDataBuffer, originalRequestId)\n yield result\n }\n break // Stream finished\n }\n\n buffer += value // Append new chunk to buffer\n let lineEndIndex\n // Process all complete lines in the buffer\n while ((lineEndIndex = buffer.indexOf('\\n')) >= 0) {\n const line = buffer.substring(0, lineEndIndex).trim() // Get and trim the line\n buffer = buffer.substring(lineEndIndex + 1) // Remove processed line from buffer\n\n if (line === '') {\n // Empty line: signifies the end of an event\n if (eventDataBuffer) {\n // If we have accumulated data for an event\n const result = this._processEventData<TStreamItem>(eventDataBuffer, originalRequestId)\n yield result\n eventDataBuffer = '' // Reset buffer for the next event\n }\n } else if (line.startsWith('data:')) {\n eventDataBuffer += line.substring(5).trimStart() + '\\n' // Append data (multi-line data is possible)\n } else if (line.startsWith(':')) {\n // This is a comment line in SSE, ignore it.\n }\n }\n }\n } catch (error: any) {\n throw new PaymentsError(error.message, 'payments_error')\n } finally {\n reader.releaseLock() // Ensure the reader lock is released\n }\n }\n\n /**\n * Processes a single SSE event's data string, expecting it to be a JSON-RPC response.\n * @param jsonData - The string content from one or more 'data:' lines of an SSE event.\n * @param originalRequestId - The ID of the client's request that initiated the stream.\n * @returns The `result` field of the parsed JSON-RPC success response.\n * @throws Error if data is not valid JSON, not a valid JSON-RPC response, an error response, or ID mismatch.\n */\n private _processEventData<TStreamItem>(\n jsonData: string,\n originalRequestId: number | string | null,\n ): TStreamItem {\n if (!jsonData.trim()) {\n throw new Error('Attempted to process empty SSE event data.')\n }\n try {\n // SSE data can be multi-line, ensure it's treated as a single JSON string.\n const sseJsonRpcResponse = JSON.parse(jsonData.replace(/\\n$/, ''))\n\n // Type assertion to SendStreamingMessageResponse, as this is the expected structure for A2A streams.\n const a2aStreamResponse: any = sseJsonRpcResponse\n\n if (a2aStreamResponse.id !== originalRequestId) {\n // According to JSON-RPC spec, notifications (which SSE events can be seen as) might not have an ID,\n // or if they do, it should match. A2A spec implies streamed events are tied to the initial request.\n throw new PaymentsError(\n `SSE Event's JSON-RPC response ID mismatch. Client request ID: ${originalRequestId}, event response ID: ${a2aStreamResponse.id}.`,\n 'payments_error',\n )\n }\n\n if (this.isErrorResponse && this.isErrorResponse(a2aStreamResponse)) {\n const err = a2aStreamResponse.error\n throw new PaymentsError(\n `SSE event contained an error: ${err.message} (Code: ${err.code}) Data: ${JSON.stringify(err.data)}`,\n )\n }\n\n // Check if 'result' exists, as it's mandatory for successful JSON-RPC responses\n if (!('result' in a2aStreamResponse) || typeof a2aStreamResponse.result === 'undefined') {\n throw new PaymentsError(\n `SSE event JSON-RPC response is missing 'result' field. Data: ${jsonData}`,\n 'payments_error',\n )\n }\n\n return a2aStreamResponse as TStreamItem\n } catch (e: any) {\n // Catch errors from JSON.parse or if it's an error response that was thrown by this function\n if (\n e.message.startsWith('SSE event contained an error') ||\n e.message.startsWith(\"SSE event JSON-RPC response is missing 'result' field\")\n ) {\n throw new PaymentsError(e.message, 'payments_error')\n }\n\n throw new PaymentsError(\n `Failed to parse SSE event data: \"${jsonData.substring(0, 100)}...\". Original error: ${e.message}`,\n 'payments_error',\n )\n }\n }\n\n /**\n * Resubscribes to a task's event stream using Server-Sent Events (SSE).\n * This is used if a previous SSE connection for an active task was broken.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params - Parameters containing the taskId.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n */\n public async *resubscribeA2ATask(params: TaskIdParams): AsyncGenerator<any, void, undefined> {\n const agentCard = await (this as any).agentCardPromise\n if (!agentCard.capabilities?.streaming) {\n throw new Error('Agent does not support streaming (required for tasks/resubscribe).')\n }\n const endpoint = await (this as any)._getServiceEndpoint()\n const clientRequestId = uuidv4()\n const rpcRequest = {\n jsonrpc: '2.0',\n method: 'tasks/resubscribe',\n params: params as { [key: string]: any },\n id: clientRequestId,\n }\n const accessToken = await this._getX402AccessToken()\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/event-stream',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify(rpcRequest),\n })\n if (!response.ok) {\n let errorBody = ''\n try {\n errorBody = await response.text()\n const errorJson = JSON.parse(errorBody)\n if (errorJson.error) {\n throw new Error(\n `HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`,\n )\n }\n } catch (e: any) {\n if (e.message.startsWith('HTTP error establishing stream')) throw e\n throw new Error(\n `HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. Response: ${errorBody || '(empty)'}`,\n )\n }\n throw new Error(\n `HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}`,\n )\n }\n if (!response.headers.get('Content-Type')?.startsWith('text/event-stream')) {\n throw new Error(\n \"Invalid response Content-Type for SSE stream on resubscribe. Expected 'text/event-stream'.\",\n )\n }\n // Parse and yield SSE events\n for await (const event of this._parseA2AStream(response, clientRequestId)) {\n yield event\n }\n }\n\n /**\n * Retrieves a task by its ID, managing authentication automatically.\n * @param params - The parameters for the task query.\n * @returns The task response.\n */\n public async getA2ATask(params: TaskQueryParams): Promise<GetTaskResponse> {\n const accessToken = await this._getX402AccessToken()\n const headers = { Authorization: `Bearer ${accessToken}` }\n return this._postRpcRequestWithHeaders<TaskQueryParams, GetTaskResponse>(\n 'tasks/get',\n params,\n headers,\n )\n }\n\n /**\n * Sets or updates the push notification configuration for a given task, managing authentication automatically.\n * @param params - The parameters for the task push notification configuration.\n * @returns The response from the agent.\n */\n public async setA2ATaskPushNotificationConfig(\n params: TaskPushNotificationConfig,\n ): Promise<SetTaskPushNotificationConfigResponse> {\n const accessToken = await this._getX402AccessToken()\n const headers = { Authorization: `Bearer ${accessToken}` }\n return this._postRpcRequestWithHeaders<\n TaskPushNotificationConfig,\n SetTaskPushNotificationConfigResponse\n >('tasks/pushNotificationConfig/set', params, headers)\n }\n\n /**\n * Gets the push notification configuration for a given task, managing authentication automatically.\n * @param params - The parameters for the task push notification configuration.\n * @returns The response from the agent.\n */\n public async getA2ATaskPushNotificationConfig(\n params: TaskIdParams,\n ): Promise<GetTaskPushNotificationConfigResponse> {\n const accessToken = await this._getX402AccessToken()\n const headers = { Authorization: `Bearer ${accessToken}` }\n return this._postRpcRequestWithHeaders<TaskIdParams, GetTaskPushNotificationConfigResponse>(\n 'tasks/pushNotificationConfig/get',\n params,\n headers,\n )\n }\n\n /**\n * Internal helper to make a JSON-RPC POST request with custom headers.\n * @param method - The RPC method name.\n * @param params - The parameters for the RPC method.\n * @param headers - Optional custom headers.\n * @returns The response from the agent.\n */\n protected async _postRpcRequestWithHeaders<TParams, TResponse>(\n method: string,\n params: TParams,\n headers?: Record<string, string>,\n ): Promise<TResponse> {\n const endpoint = await (this as any)._getServiceEndpoint()\n const requestId = uuidv4()\n const rpcRequest = { jsonrpc: '2.0', method, params, id: requestId }\n const httpResponse = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n ...(headers || {}),\n },\n body: JSON.stringify(rpcRequest),\n })\n if (!httpResponse.ok) {\n let errorBodyText = '(empty or non-JSON response)'\n try {\n errorBodyText = await httpResponse.text()\n const errorJson = JSON.parse(errorBodyText)\n if (!errorJson.jsonrpc && errorJson.error) {\n throw new Error(\n `RPC error for ${method}: ${errorJson.error.message} (Code: ${errorJson.error.code}, HTTP Status: ${httpResponse.status}) Data: ${JSON.stringify(errorJson.error.data)}`,\n )\n } else if (!errorJson.jsonrpc) {\n throw new Error(\n `HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`,\n )\n }\n } catch (e: any) {\n if (e.message.startsWith('RPC error for') || e.message.startsWith('HTTP error for')) throw e\n throw new Error(\n `HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`,\n )\n }\n }\n const rpcResponse = await httpResponse.json()\n if (rpcResponse.id !== requestId) {\n throw new PaymentsError(\n `CRITICAL: RPC response ID mismatch for method ${method}. Expected ${requestId}, got ${rpcResponse.id}. This may lead to incorrect response handling.`,\n 'payments_error',\n )\n }\n return rpcResponse as TResponse\n }\n}\n\nexport type {\n MessageSendParams,\n SendMessageResponse,\n TaskQueryParams,\n GetTaskResponse,\n TaskPushNotificationConfig,\n SetTaskPushNotificationConfigResponse,\n TaskIdParams,\n GetTaskPushNotificationConfigResponse,\n} from '@a2a-js/sdk'\n"]}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  /**
3
2
  * PaymentsA2AServer sets up and starts the A2A server for payments agents.
4
3
  * Handles A2A protocol endpoints and allows optional custom endpoints.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/a2a/server.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;AACH,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA8C,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AA4BpE;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,oEAAoE;IACpE,SAAS,EAAE,SAAS,CAAA;IACpB,uDAAuD;IACvD,QAAQ,EAAE,aAAa,CAAA;IACvB,kEAAkE;IAClE,eAAe,EAAE,GAAG,CAAA;IACpB,wCAAwC;IACxC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAA;IACZ,uEAAuE;IACvE,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iEAAiE;IACjE,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC,OAAO,CAAA;IAC5B,kEAAkE;IAClE,oBAAoB,CAAC,EAAE,GAAG,CAAA;IAC1B,kEAAkE;IAClE,cAAc,CAAC,EAAE;QACf,cAAc,CAAC,EAAE,OAAO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GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;QACnF,2CAA2C;QAC3C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAChF,CAAA;CACF;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,yCAAyC;IACzC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAA;IACpB,+BAA+B;IAC/B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;IACnB,+DAA+D;IAC/D,OAAO,EAAE,sBAAsB,CAAA;IAC/B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B;AAiHD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,wBAAwB,GAAG,uBAAuB;CAmKzE"}
@@ -21,7 +21,7 @@ export declare class AgentsAPI extends BasePaymentsAPI {
21
21
  * @remarks This method is oriented to AI Builders
22
22
  * @remarks To call this method, the NVM API Key must have publication permissions
23
23
  *
24
- * @see https://docs.nevermined.app/docs/tutorials/builders/register-agent
24
+ * @see https://nevermined.ai/docs/tutorials/builders/register-agent
25
25
  *
26
26
  * @param agentMetadata - @see {@link AgentMetadata}
27
27
  * @param agentApi - @see {@link AgentAPIAttributes}
@@ -50,7 +50,7 @@ export declare class AgentsAPI extends BasePaymentsAPI {
50
50
  * @remarks This method is oriented to AI Builders
51
51
  * @remarks To call this method, the NVM API Key must have publication permissions
52
52
  *
53
- * @see https://docs.nevermined.app/docs/tutorials/builders/register-agent
53
+ * @see https://nevermined.ai/docs/tutorials/builders/register-agent
54
54
  *
55
55
  * @param agentMetadata - @see {@link AgentMetadata}
56
56
  * @param agentApi - @see {@link AgentAPIAttributes}
@@ -25,7 +25,7 @@ export class AgentsAPI extends BasePaymentsAPI {
25
25
  * @remarks This method is oriented to AI Builders
26
26
  * @remarks To call this method, the NVM API Key must have publication permissions
27
27
  *
28
- * @see https://docs.nevermined.app/docs/tutorials/builders/register-agent
28
+ * @see https://nevermined.ai/docs/tutorials/builders/register-agent
29
29
  *
30
30
  * @param agentMetadata - @see {@link AgentMetadata}
31
31
  * @param agentApi - @see {@link AgentAPIAttributes}
@@ -66,7 +66,7 @@ export class AgentsAPI extends BasePaymentsAPI {
66
66
  * @remarks This method is oriented to AI Builders
67
67
  * @remarks To call this method, the NVM API Key must have publication permissions
68
68
  *
69
- * @see https://docs.nevermined.app/docs/tutorials/builders/register-agent
69
+ * @see https://nevermined.ai/docs/tutorials/builders/register-agent
70
70
  *
71
71
  * @param agentMetadata - @see {@link AgentMetadata}
72
72
  * @param agentApi - @see {@link AgentAPIAttributes}
@@ -1 +1 @@
1
- {"version":3,"file":"agents-api.js","sourceRoot":"","sources":["../../src/api/agents-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAIL,iBAAiB,GAKlB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,cAAc,CAAA;AAErB;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,eAAe;IAC5C;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,OAAuB;QACxC,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,aAAa,CAAC,WAAW,CAAC,kCAAkC,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5F,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;CACF","sourcesContent":["import { PaymentsError } from '../common/payments.error.js'\nimport {\n AgentAPIAttributes,\n AgentMetadata,\n NvmAPIResult,\n PaginationOptions,\n PaymentOptions,\n PlanCreditsConfig,\n PlanMetadata,\n PlanPriceConfig,\n} from '../common/types.js'\nimport { BasePaymentsAPI } from './base-payments.js'\nimport {\n API_URL_ADD_PLAN_AGENT,\n API_URL_GET_AGENT,\n API_URL_GET_AGENT_PLANS,\n API_URL_REGISTER_AGENT,\n API_URL_REGISTER_AGENTS_AND_PLAN,\n API_URL_REMOVE_PLAN_AGENT,\n API_URL_UPDATE_AGENT,\n} from './nvm-api.js'\n\n/**\n * The AgentsAPI class provides methods to register and interact with AI Agents on Nevermined.\n */\nexport class AgentsAPI extends BasePaymentsAPI {\n /**\n * This method is used to create a singleton instance of the AgentsAPI class.\n *\n * @param options - The options to initialize the payments class.\n * @returns The instance of the AgentsAPI class.\n */\n static getInstance(options: PaymentOptions): AgentsAPI {\n return new AgentsAPI(options)\n }\n\n /**\n *\n * It registers a new AI Agent on Nevermined.\n * The agent must be associated to one or multiple Payment Plans. Users that are subscribers of a payment plan can query the agent.\n * Depending on the Payment Plan and the configuration of the agent, the usage of the agent/service will consume credits.\n * When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue using the agent.\n *\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://docs.nevermined.app/docs/tutorials/builders/register-agent\n *\n * @param agentMetadata - @see {@link AgentMetadata}\n * @param agentApi - @see {@link AgentAPIAttributes}\n * @param paymentPlans - the list of payment plans giving access to the agent.\n *\n * @example\n * ```\n * const agentMetadata = { name: 'My AI Payments Agent', tags: ['test'] }\n * const agentApi = { endpoints: [{ 'POST': 'https://example.com/api/v1/agents/:agentId/tasks' }] }\n * const paymentPlans = [planId]\n *\n * const { agentId } = await payments.agents.registerAgent(agentMetadata, agentApi, paymentPlans)\n * ```\n *\n * @returns The unique identifier of the newly created agent (Agent Id).\n */\n public async registerAgent(\n agentMetadata: AgentMetadata,\n agentApi: AgentAPIAttributes,\n paymentPlans: string[],\n ): Promise<{ agentId: string }> {\n const body = {\n metadataAttributes: agentMetadata,\n agentApiAttributes: agentApi,\n plans: paymentPlans,\n }\n\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_REGISTER_AGENT, this.environment.backend)\n\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to register agent', await response.json())\n }\n const agentData = await response.json()\n return { agentId: agentData.data.agentId }\n }\n\n /**\n *\n * It registers a new AI Agent and a Payment Plan associated to this new agent.\n * Depending on the Payment Plan and the configuration of the agent, the usage of the agent/service will consume credits.\n * When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue using the agent.\n *\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://docs.nevermined.app/docs/tutorials/builders/register-agent\n *\n * @param agentMetadata - @see {@link AgentMetadata}\n * @param agentApi - @see {@link AgentAPIAttributes}\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const agentMetadata = { name: 'My AI Payments Agent', tags: ['test'] }\n * const agentApi { endpoints: [{ 'POST': 'https://example.com/api/v1/agents/:agentId/tasks' }] }\n * const cryptoPriceConfig = getNativeTokenPriceConfig(100n, builderAddress)\n * const 1dayDurationPlan = getExpirableDurationConfig(ONE_DAY_DURATION)\n * const { agentId, planId } = await payments.agents.registerAgentAndPlan(\n * agentMetadata,\n * agentApi,\n * cryptoPriceConfig,\n * 1dayDurationPlan\n * )\n * ```\n *\n * @returns The unique identifier of the newly created agent (agentId).\n * @returns The unique identifier of the newly created plan (planId).\n */\n public async registerAgentAndPlan(\n agentMetadata: AgentMetadata,\n agentApi: AgentAPIAttributes,\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n accessLimit?: 'credits' | 'time',\n ): Promise<{\n agentId: string\n planId: string\n txHash: string\n }> {\n if (accessLimit && !['credits', 'time'].includes(accessLimit)) {\n throw new PaymentsError(\n 'Invalid access limit',\n 'accessLimit must be either \"credits\" or \"time\"',\n )\n }\n if (!accessLimit) {\n accessLimit = creditsConfig.durationSecs > 0n ? 'time' : 'credits'\n }\n const body = {\n plan: {\n metadataAttributes: planMetadata,\n priceConfig: priceConfig,\n creditsConfig: creditsConfig,\n accessLimit,\n },\n agent: {\n metadataAttributes: agentMetadata,\n agentApiAttributes: agentApi,\n },\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_REGISTER_AGENTS_AND_PLAN, this.environment.backend)\n\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to register agent & plan', await response.json())\n }\n const result = await response.json()\n return {\n agentId: result.data.agentId,\n planId: result.data.planId,\n txHash: result.txHash,\n }\n }\n\n /**\n * Gets the metadata for a given Agent identifier.\n *\n * @param agentId - The unique identifier of the agent.\n * @returns A promise that resolves to the agent's metadata.\n * @throws PaymentsError if the agent is not found.\n *\n * @example\n * ```\n * const plan = payments.agents.getAgent(agentId)\n * ```\n */\n public async getAgent(agentId: string) {\n const url = new URL(API_URL_GET_AGENT.replace(':agentId', agentId), this.environment.backend)\n const response = await fetch(url)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Agent not found', await response.json())\n }\n return response.json()\n }\n\n /**\n * Updates the metadata and API attributes of an existing AI Agent.\n *\n * @param agentId - The unique identifier of the agent.\n * @param agentMetadata - The new metadata attributes for the agent.\n * @param agentApi - The new API attributes for the agent.\n * @returns @see {@link NvmAPIResult} A promise that resolves indicating if the operation was successful.\n * @throws PaymentsError if the agent is not found or if the update fails.\n *\n * @example\n * ```\n * const agentMetadata = { name: 'My Updated Agent', tags: ['test'] }\n * const agentApi = { endpoints: [{ 'POST': 'https://nevermined.app/api/v1/agents/:agentId/tasks' }] }\n *\n * await payments.agents.updateAgentMetadata(agentId, agentMetadata, agentApi)\n * ```\n */\n public async updateAgentMetadata(\n agentId: string,\n agentMetadata: AgentMetadata,\n agentApi: AgentAPIAttributes,\n ): Promise<NvmAPIResult> {\n const body = {\n metadataAttributes: agentMetadata,\n agentApiAttributes: agentApi,\n }\n const url = new URL(API_URL_UPDATE_AGENT.replace(':agentId', agentId), this.environment.backend)\n const options = this.getBackendHTTPOptions('PUT', body)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Error updating agent', await response.json())\n }\n return response.json()\n }\n\n /**\n * Gets the list of plans that can be ordered to get access to an agent.\n *\n * @param agentId - The unique identifier of the agent.\n * @param pagination - Optional pagination options to control the number of results returned.p\n * @returns A promise that resolves to the list of all different plans giving access to the agent.\n * @throws PaymentsError if the agent is not found.\n *\n * @example\n * ```\n * const result = payments.agents.getAgentPlans(planId)\n * // {\n * // total: 10,\n * // page: 1,\n * // offset: 5,\n * // plans: [ ..]\n * // }\n * ```\n */\n public async getAgentPlans(agentId: string, pagination = new PaginationOptions()) {\n const query =\n API_URL_GET_AGENT_PLANS.replace(':agentId', agentId) + '?' + pagination.asQueryParams()\n const url = new URL(query, this.environment.backend)\n const response = await fetch(url)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Agent not found', await response.json())\n }\n return response.json()\n }\n\n /**\n * Adds an existing Payment Plan to an AI Agent.\n * After this operation, users with access to the Payment Plan will be able to access the AI Agent.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param planId - The unique identifier of the Payment Plan.\n * @param agentId - The unique identifier of the AI Agent.\n * @returns @see {@link NvmAPIResult} A promise that resolves indicating if the operation was successful.\n * @throws PaymentsError if unable to add the plan to the agent.\n *\n * @example\n * ```\n * const result = await payments.agents.addPlanToAgent(planId, agentId)\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async addPlanToAgent(planId: string, agentId: string): Promise<NvmAPIResult> {\n const options = this.getBackendHTTPOptions('POST')\n const endpoint = API_URL_ADD_PLAN_AGENT.replace(':planId', planId).replace(':agentId', agentId)\n const url = new URL(endpoint, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to add plan to agent', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Removes a Payment Plan from an AI Agent.\n * After this operation, users with access to the Payment Plan will no longer be able to access the AI Agent.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param planId - The unique identifier of the Payment Plan.\n * @param agentId - The unique identifier of the AI Agent.\n * @returns @see {@link NvmAPIResult} A promise that resolves indicating if the operation was successful.\n * @throws PaymentsError if unable to remove the plan from the agent.\n *\n * @example\n * ```\n * const result = await payments.agents.removePlanFromAgent(planId, agentId)\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async removePlanFromAgent(planId: string, agentId: string): Promise<NvmAPIResult> {\n const options = this.getBackendHTTPOptions('DELETE')\n const endpoint = API_URL_REMOVE_PLAN_AGENT.replace(':planId', planId).replace(\n ':agentId',\n agentId,\n )\n const url = new URL(endpoint, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to remove plan from agent', await response.json())\n }\n\n return response.json()\n }\n}\n"]}
1
+ {"version":3,"file":"agents-api.js","sourceRoot":"","sources":["../../src/api/agents-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAA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,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,KAAK,CAAC,mBAAmB,CAAC,MAAc,EAAE,OAAe;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAA;QACpD,MAAM,QAAQ,GAAG,yBAAyB,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,OAAO,CAC3E,UAAU,EACV,OAAO,CACR,CAAA;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACvD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,aAAa,CAAC,WAAW,CAAC,kCAAkC,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5F,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;CACF","sourcesContent":["import { PaymentsError } from '../common/payments.error.js'\nimport {\n AgentAPIAttributes,\n AgentMetadata,\n NvmAPIResult,\n PaginationOptions,\n PaymentOptions,\n PlanCreditsConfig,\n PlanMetadata,\n PlanPriceConfig,\n} from '../common/types.js'\nimport { BasePaymentsAPI } from './base-payments.js'\nimport {\n API_URL_ADD_PLAN_AGENT,\n API_URL_GET_AGENT,\n API_URL_GET_AGENT_PLANS,\n API_URL_REGISTER_AGENT,\n API_URL_REGISTER_AGENTS_AND_PLAN,\n API_URL_REMOVE_PLAN_AGENT,\n API_URL_UPDATE_AGENT,\n} from './nvm-api.js'\n\n/**\n * The AgentsAPI class provides methods to register and interact with AI Agents on Nevermined.\n */\nexport class AgentsAPI extends BasePaymentsAPI {\n /**\n * This method is used to create a singleton instance of the AgentsAPI class.\n *\n * @param options - The options to initialize the payments class.\n * @returns The instance of the AgentsAPI class.\n */\n static getInstance(options: PaymentOptions): AgentsAPI {\n return new AgentsAPI(options)\n }\n\n /**\n *\n * It registers a new AI Agent on Nevermined.\n * The agent must be associated to one or multiple Payment Plans. Users that are subscribers of a payment plan can query the agent.\n * Depending on the Payment Plan and the configuration of the agent, the usage of the agent/service will consume credits.\n * When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue using the agent.\n *\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://nevermined.ai/docs/tutorials/builders/register-agent\n *\n * @param agentMetadata - @see {@link AgentMetadata}\n * @param agentApi - @see {@link AgentAPIAttributes}\n * @param paymentPlans - the list of payment plans giving access to the agent.\n *\n * @example\n * ```\n * const agentMetadata = { name: 'My AI Payments Agent', tags: ['test'] }\n * const agentApi = { endpoints: [{ 'POST': 'https://example.com/api/v1/agents/:agentId/tasks' }] }\n * const paymentPlans = [planId]\n *\n * const { agentId } = await payments.agents.registerAgent(agentMetadata, agentApi, paymentPlans)\n * ```\n *\n * @returns The unique identifier of the newly created agent (Agent Id).\n */\n public async registerAgent(\n agentMetadata: AgentMetadata,\n agentApi: AgentAPIAttributes,\n paymentPlans: string[],\n ): Promise<{ agentId: string }> {\n const body = {\n metadataAttributes: agentMetadata,\n agentApiAttributes: agentApi,\n plans: paymentPlans,\n }\n\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_REGISTER_AGENT, this.environment.backend)\n\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to register agent', await response.json())\n }\n const agentData = await response.json()\n return { agentId: agentData.data.agentId }\n }\n\n /**\n *\n * It registers a new AI Agent and a Payment Plan associated to this new agent.\n * Depending on the Payment Plan and the configuration of the agent, the usage of the agent/service will consume credits.\n * When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue using the agent.\n *\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://nevermined.ai/docs/tutorials/builders/register-agent\n *\n * @param agentMetadata - @see {@link AgentMetadata}\n * @param agentApi - @see {@link AgentAPIAttributes}\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const agentMetadata = { name: 'My AI Payments Agent', tags: ['test'] }\n * const agentApi { endpoints: [{ 'POST': 'https://example.com/api/v1/agents/:agentId/tasks' }] }\n * const cryptoPriceConfig = getNativeTokenPriceConfig(100n, builderAddress)\n * const 1dayDurationPlan = getExpirableDurationConfig(ONE_DAY_DURATION)\n * const { agentId, planId } = await payments.agents.registerAgentAndPlan(\n * agentMetadata,\n * agentApi,\n * cryptoPriceConfig,\n * 1dayDurationPlan\n * )\n * ```\n *\n * @returns The unique identifier of the newly created agent (agentId).\n * @returns The unique identifier of the newly created plan (planId).\n */\n public async registerAgentAndPlan(\n agentMetadata: AgentMetadata,\n agentApi: AgentAPIAttributes,\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n accessLimit?: 'credits' | 'time',\n ): Promise<{\n agentId: string\n planId: string\n txHash: string\n }> {\n if (accessLimit && !['credits', 'time'].includes(accessLimit)) {\n throw new PaymentsError(\n 'Invalid access limit',\n 'accessLimit must be either \"credits\" or \"time\"',\n )\n }\n if (!accessLimit) {\n accessLimit = creditsConfig.durationSecs > 0n ? 'time' : 'credits'\n }\n const body = {\n plan: {\n metadataAttributes: planMetadata,\n priceConfig: priceConfig,\n creditsConfig: creditsConfig,\n accessLimit,\n },\n agent: {\n metadataAttributes: agentMetadata,\n agentApiAttributes: agentApi,\n },\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_REGISTER_AGENTS_AND_PLAN, this.environment.backend)\n\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to register agent & plan', await response.json())\n }\n const result = await response.json()\n return {\n agentId: result.data.agentId,\n planId: result.data.planId,\n txHash: result.txHash,\n }\n }\n\n /**\n * Gets the metadata for a given Agent identifier.\n *\n * @param agentId - The unique identifier of the agent.\n * @returns A promise that resolves to the agent's metadata.\n * @throws PaymentsError if the agent is not found.\n *\n * @example\n * ```\n * const plan = payments.agents.getAgent(agentId)\n * ```\n */\n public async getAgent(agentId: string) {\n const url = new URL(API_URL_GET_AGENT.replace(':agentId', agentId), this.environment.backend)\n const response = await fetch(url)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Agent not found', await response.json())\n }\n return response.json()\n }\n\n /**\n * Updates the metadata and API attributes of an existing AI Agent.\n *\n * @param agentId - The unique identifier of the agent.\n * @param agentMetadata - The new metadata attributes for the agent.\n * @param agentApi - The new API attributes for the agent.\n * @returns @see {@link NvmAPIResult} A promise that resolves indicating if the operation was successful.\n * @throws PaymentsError if the agent is not found or if the update fails.\n *\n * @example\n * ```\n * const agentMetadata = { name: 'My Updated Agent', tags: ['test'] }\n * const agentApi = { endpoints: [{ 'POST': 'https://nevermined.app/api/v1/agents/:agentId/tasks' }] }\n *\n * await payments.agents.updateAgentMetadata(agentId, agentMetadata, agentApi)\n * ```\n */\n public async updateAgentMetadata(\n agentId: string,\n agentMetadata: AgentMetadata,\n agentApi: AgentAPIAttributes,\n ): Promise<NvmAPIResult> {\n const body = {\n metadataAttributes: agentMetadata,\n agentApiAttributes: agentApi,\n }\n const url = new URL(API_URL_UPDATE_AGENT.replace(':agentId', agentId), this.environment.backend)\n const options = this.getBackendHTTPOptions('PUT', body)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Error updating agent', await response.json())\n }\n return response.json()\n }\n\n /**\n * Gets the list of plans that can be ordered to get access to an agent.\n *\n * @param agentId - The unique identifier of the agent.\n * @param pagination - Optional pagination options to control the number of results returned.p\n * @returns A promise that resolves to the list of all different plans giving access to the agent.\n * @throws PaymentsError if the agent is not found.\n *\n * @example\n * ```\n * const result = payments.agents.getAgentPlans(planId)\n * // {\n * // total: 10,\n * // page: 1,\n * // offset: 5,\n * // plans: [ ..]\n * // }\n * ```\n */\n public async getAgentPlans(agentId: string, pagination = new PaginationOptions()) {\n const query =\n API_URL_GET_AGENT_PLANS.replace(':agentId', agentId) + '?' + pagination.asQueryParams()\n const url = new URL(query, this.environment.backend)\n const response = await fetch(url)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Agent not found', await response.json())\n }\n return response.json()\n }\n\n /**\n * Adds an existing Payment Plan to an AI Agent.\n * After this operation, users with access to the Payment Plan will be able to access the AI Agent.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param planId - The unique identifier of the Payment Plan.\n * @param agentId - The unique identifier of the AI Agent.\n * @returns @see {@link NvmAPIResult} A promise that resolves indicating if the operation was successful.\n * @throws PaymentsError if unable to add the plan to the agent.\n *\n * @example\n * ```\n * const result = await payments.agents.addPlanToAgent(planId, agentId)\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async addPlanToAgent(planId: string, agentId: string): Promise<NvmAPIResult> {\n const options = this.getBackendHTTPOptions('POST')\n const endpoint = API_URL_ADD_PLAN_AGENT.replace(':planId', planId).replace(':agentId', agentId)\n const url = new URL(endpoint, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to add plan to agent', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Removes a Payment Plan from an AI Agent.\n * After this operation, users with access to the Payment Plan will no longer be able to access the AI Agent.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param planId - The unique identifier of the Payment Plan.\n * @param agentId - The unique identifier of the AI Agent.\n * @returns @see {@link NvmAPIResult} A promise that resolves indicating if the operation was successful.\n * @throws PaymentsError if unable to remove the plan from the agent.\n *\n * @example\n * ```\n * const result = await payments.agents.removePlanFromAgent(planId, agentId)\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async removePlanFromAgent(planId: string, agentId: string): Promise<NvmAPIResult> {\n const options = this.getBackendHTTPOptions('DELETE')\n const endpoint = API_URL_REMOVE_PLAN_AGENT.replace(':planId', planId).replace(\n ':agentId',\n agentId,\n )\n const url = new URL(endpoint, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to remove plan from agent', await response.json())\n }\n\n return response.json()\n }\n}\n"]}
@@ -49,9 +49,9 @@ export declare abstract class BasePaymentsAPI {
49
49
  method: string;
50
50
  headers: {
51
51
  Accept: string;
52
- 'Content-Type': string;
52
+ "Content-Type": string;
53
53
  };
54
- body?: string | undefined;
54
+ body?: string;
55
55
  };
56
56
  }
57
57
  //# sourceMappingURL=base-payments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-payments.d.ts","sourceRoot":"","sources":["../../src/api/base-payments.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAgB,MAAM,oBAAoB,CAAA;AAEnF;;;GAGG;AACH,8BAAsB,eAAe;IACnC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAA;IAC3B,SAAS,CAAC,WAAW,EAAE,eAAe,CAAA;IACtC,SAAS,CAAC,eAAe,EAAE,eAAe,CAAA;IAC1C,SAAS,CAAC,SAAS,EAAE,MAAM,CAAA;IAC3B,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IAC1B,SAAS,CAAC,cAAc,EAAE,MAAM,CAAA;IAChC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAA;IACzB,iBAAiB,UAAO;gBAEnB,OAAO,EAAE,cAAc;IAYnC;;;OAGG;IACH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I9C;;;;;;OAMG;IACH,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAY1D;;;;;;;;OAQG;IACH,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;gBAE7C,MAAM;iBACL;YACP,MAAM,EAAE,MAAM,CAAA;YACd,cAAc,EAAE,MAAM,CAAA;SACvB;eACM,MAAM;;CAelB"}
@@ -34,7 +34,7 @@ export interface BackendApiOptions {
34
34
  /**
35
35
  * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.
36
36
  * You can get your API key by logging in to the Nevermined App.
37
- * @see https://docs.nevermined.app/docs/tutorials/integration/nvm-api-keys
37
+ * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys
38
38
  */
39
39
  apiKey?: string;
40
40
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"nvm-api.js","sourceRoot":"","sources":["../../src/api/nvm-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAA;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AAC/D,MAAM,CAAC,MAAM,gCAAgC,GAAG,+BAA+B,CAAA;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,kCAAkC,CAAA;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kCAAkC,CAAA;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wCAAwC,CAAA;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,gCAAgC,CAAA;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,uCAAuC,CAAA;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAA;AACxE,MAAM,CAAC,MAAM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,CAAC,CAAA;IACtD,CAAC;CACF","sourcesContent":["import axios from 'axios'\n\nexport const API_URL_REGISTER_PLAN = '/api/v1/protocol/plans'\nexport const API_URL_REGISTER_AGENT = '/api/v1/protocol/agents'\nexport const API_URL_REGISTER_AGENTS_AND_PLAN = '/api/v1/protocol/agents/plans'\nexport const API_URL_GET_AGENT = '/api/v1/protocol/agents/:agentId'\nexport const API_URL_UPDATE_AGENT = '/api/v1/protocol/agents/:agentId'\nexport const API_URL_GET_AGENT_PLANS = '/api/v1/protocol/agents/:agentId/plans'\nexport const API_URL_GET_PLAN = '/api/v1/protocol/plans/:planId'\nexport const API_URL_GET_PLANS = '/api/v1/protocol/plans'\nexport const API_URL_GET_PLAN_AGENTS = '/api/v1/protocol/plans/:planId/agents'\nexport const API_URL_ORDER_PLAN = '/api/v1/protocol/plans/:planId/order'\nexport const API_URL_MINT_PLAN = '/api/v1/protocol/plans/mint'\nexport const API_URL_MINT_EXPIRABLE_PLAN = '/api/v1/protocol/plans/mintExpirable'\nexport const API_URL_ADD_PLAN_AGENT = '/api/v1/protocol/agents/:agentId/plan/:planId'\nexport const API_URL_REMOVE_PLAN_AGENT = '/api/v1/protocol/agents/:agentId/plan/:planId'\nexport const API_URL_REDEEM_PLAN = '/api/v1/protocol/plans/redeem'\nexport const API_URL_PLAN_BALANCE = '/api/v1/protocol/plans/:planId/balance/:holderAddress'\nexport const API_URL_INITIALIZE_AGENT = '/api/v1/protocol/agents/initialize/:agentId'\nexport const API_URL_SIMULATE_AGENT_REQUEST = '/api/v1/protocol/agents/simulate/start'\nexport const API_URL_SIMULATE_REDEEM_AGENT_REQUEST = '/api/v1/protocol/agents/simulate/finish'\nexport const API_URL_TRACK_AGENT_SUB_TASK = '/api/v1/protocol/agent-sub-tasks'\nexport const API_URL_VALIDATE_AGENT_ACCESS_TOKEN = '/api/v1/protocol/token/validate/:agentId'\nexport const API_URL_CREATE_PERMISSION = '/api/v1/x402/permissions'\nexport const API_URL_VERIFY_PERMISSIONS = '/api/v1/x402/verify'\nexport const API_URL_SETTLE_PERMISSIONS = '/api/v1/x402/settle'\nexport const API_URL_STRIPE_CHECKOUT = '/api/v1/stripe/checkout'\nexport const API_URL_CREATE_USER = '/api/v1/organizations/account'\nexport const API_URL_GET_MEMBERS = '/api/v1/organizations/members'\nexport const API_URL_CONNECT_STRIPE_ACCOUNT = '/api/v1/stripe/account'\n\nexport interface BackendApiOptions {\n /**\n * The host of the backend server\n */\n backendHost: string\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://docs.nevermined.app/docs/tutorials/integration/nvm-api-keys\n */\n apiKey?: string\n\n /**\n * The host of the Nevermined Proxy\n */\n proxyHost?: string\n\n /**\n * Additional headers to send with the requests\n */\n headers?: { [key: string]: string }\n}\n\nexport class HTTPRequestOptions {\n accessToken?: string\n sendThroughProxy = true\n proxyHost?: string = undefined\n headers?: { [key: string]: string } = {}\n}\n\nexport abstract class AbstractHTTPClient {\n // protected opts: BackendApiOptions\n // private hasKey = false\n // private agentId = ''\n\n // constructor(opts: BackendApiOptions) {\n // const defaultHeaders = {\n // Accept: 'application/json',\n // ...opts.headers,\n // ...(opts.apiKey && { Authorization: `Bearer ${opts.apiKey}` }),\n // }\n\n // this.opts = {\n // ...opts,\n // headers: defaultHeaders,\n // }\n\n // try {\n // if (this.opts.apiKey && this.opts.apiKey.length > 0) {\n // const jwt = decodeJwt(this.opts.apiKey)\n // if (isEthereumAddress(jwt.sub)) {\n // this.hasKey = true\n // }\n // }\n // } catch {\n // this.hasKey = false\n // }\n\n // let backendUrl\n // try {\n // backendUrl = new URL(this.opts.backendHost)\n // this.opts.backendHost = backendUrl.origin\n // } catch (error) {\n // throw new Error(`Invalid URL: ${this.opts.backendHost} - ${(error as Error).message}`)\n // }\n // }\n\n constructor() {\n // Empty constructor - required for abstract class implementation\n }\n\n parseUrl(urlRequested: string, reqOptions: HTTPRequestOptions) {\n let _host: URL\n if (reqOptions.sendThroughProxy) {\n if (!reqOptions.proxyHost)\n throw new Error('Proxy host is required when sendThroughProxy is true')\n return `${new URL(reqOptions.proxyHost).origin}${new URL(urlRequested).href}`\n } else {\n return urlRequested\n }\n }\n\n parseHeaders(requestHeaders: { [key: string]: string }, accessToken?: string) {\n return {\n ...(accessToken && { Authorization: `Bearer ${accessToken}` }),\n ...requestHeaders,\n }\n }\n\n // setBearerToken(token: string) {\n // this.opts.headers = {\n // ...this.opts.headers,\n // Authorization: `Bearer ${token}`,\n // }\n // }\n\n async request(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',\n url: string,\n data?: any,\n reqOptions: HTTPRequestOptions = {\n sendThroughProxy: false,\n },\n ) {\n try {\n const response = await axios({\n method,\n url: this.parseUrl(url, reqOptions),\n headers: this.parseHeaders(reqOptions.headers || {}, reqOptions.accessToken),\n ...(data && { data }), // Only include `data` for methods that support it\n })\n\n return response\n } catch (err) {\n if (axios.isAxiosError(err) && err.response) {\n throw new Error(\n `HTTP ${err.response.status}: ${err.response.data?.message || 'Request failed'}`,\n )\n }\n throw new Error('Network error or request failed without a response.')\n }\n }\n\n async get(url: string, reqOptions: HTTPRequestOptions = { sendThroughProxy: true }) {\n return this.request('GET', url, undefined, reqOptions)\n }\n\n async post(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('POST', url, data, reqOptions)\n }\n\n async put(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('PUT', url, data, reqOptions)\n }\n\n async delete(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('DELETE', url, data, reqOptions)\n }\n}\n"]}
1
+ {"version":3,"file":"nvm-api.js","sourceRoot":"","sources":["../../src/api/nvm-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAA;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AAC/D,MA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AAC,GAAW,EAAE,IAAS,EAAE,UAA8B;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;IACpD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,IAAS,EAAE,UAA8B;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;IACnD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,IAAS,EAAE,UAA8B;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;IACtD,CAAC;CACF","sourcesContent":["import axios from 'axios'\n\nexport const API_URL_REGISTER_PLAN = '/api/v1/protocol/plans'\nexport const API_URL_REGISTER_AGENT = '/api/v1/protocol/agents'\nexport const API_URL_REGISTER_AGENTS_AND_PLAN = '/api/v1/protocol/agents/plans'\nexport const API_URL_GET_AGENT = '/api/v1/protocol/agents/:agentId'\nexport const API_URL_UPDATE_AGENT = '/api/v1/protocol/agents/:agentId'\nexport const API_URL_GET_AGENT_PLANS = '/api/v1/protocol/agents/:agentId/plans'\nexport const API_URL_GET_PLAN = '/api/v1/protocol/plans/:planId'\nexport const API_URL_GET_PLANS = '/api/v1/protocol/plans'\nexport const API_URL_GET_PLAN_AGENTS = '/api/v1/protocol/plans/:planId/agents'\nexport const API_URL_ORDER_PLAN = '/api/v1/protocol/plans/:planId/order'\nexport const API_URL_MINT_PLAN = '/api/v1/protocol/plans/mint'\nexport const API_URL_MINT_EXPIRABLE_PLAN = '/api/v1/protocol/plans/mintExpirable'\nexport const API_URL_ADD_PLAN_AGENT = '/api/v1/protocol/agents/:agentId/plan/:planId'\nexport const API_URL_REMOVE_PLAN_AGENT = '/api/v1/protocol/agents/:agentId/plan/:planId'\nexport const API_URL_REDEEM_PLAN = '/api/v1/protocol/plans/redeem'\nexport const API_URL_PLAN_BALANCE = '/api/v1/protocol/plans/:planId/balance/:holderAddress'\nexport const API_URL_INITIALIZE_AGENT = '/api/v1/protocol/agents/initialize/:agentId'\nexport const API_URL_SIMULATE_AGENT_REQUEST = '/api/v1/protocol/agents/simulate/start'\nexport const API_URL_SIMULATE_REDEEM_AGENT_REQUEST = '/api/v1/protocol/agents/simulate/finish'\nexport const API_URL_TRACK_AGENT_SUB_TASK = '/api/v1/protocol/agent-sub-tasks'\nexport const API_URL_VALIDATE_AGENT_ACCESS_TOKEN = '/api/v1/protocol/token/validate/:agentId'\nexport const API_URL_CREATE_PERMISSION = '/api/v1/x402/permissions'\nexport const API_URL_VERIFY_PERMISSIONS = '/api/v1/x402/verify'\nexport const API_URL_SETTLE_PERMISSIONS = '/api/v1/x402/settle'\nexport const API_URL_STRIPE_CHECKOUT = '/api/v1/stripe/checkout'\nexport const API_URL_CREATE_USER = '/api/v1/organizations/account'\nexport const API_URL_GET_MEMBERS = '/api/v1/organizations/members'\nexport const API_URL_CONNECT_STRIPE_ACCOUNT = '/api/v1/stripe/account'\n\nexport interface BackendApiOptions {\n /**\n * The host of the backend server\n */\n backendHost: string\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys\n */\n apiKey?: string\n\n /**\n * The host of the Nevermined Proxy\n */\n proxyHost?: string\n\n /**\n * Additional headers to send with the requests\n */\n headers?: { [key: string]: string }\n}\n\nexport class HTTPRequestOptions {\n accessToken?: string\n sendThroughProxy = true\n proxyHost?: string = undefined\n headers?: { [key: string]: string } = {}\n}\n\nexport abstract class AbstractHTTPClient {\n // protected opts: BackendApiOptions\n // private hasKey = false\n // private agentId = ''\n\n // constructor(opts: BackendApiOptions) {\n // const defaultHeaders = {\n // Accept: 'application/json',\n // ...opts.headers,\n // ...(opts.apiKey && { Authorization: `Bearer ${opts.apiKey}` }),\n // }\n\n // this.opts = {\n // ...opts,\n // headers: defaultHeaders,\n // }\n\n // try {\n // if (this.opts.apiKey && this.opts.apiKey.length > 0) {\n // const jwt = decodeJwt(this.opts.apiKey)\n // if (isEthereumAddress(jwt.sub)) {\n // this.hasKey = true\n // }\n // }\n // } catch {\n // this.hasKey = false\n // }\n\n // let backendUrl\n // try {\n // backendUrl = new URL(this.opts.backendHost)\n // this.opts.backendHost = backendUrl.origin\n // } catch (error) {\n // throw new Error(`Invalid URL: ${this.opts.backendHost} - ${(error as Error).message}`)\n // }\n // }\n\n constructor() {\n // Empty constructor - required for abstract class implementation\n }\n\n parseUrl(urlRequested: string, reqOptions: HTTPRequestOptions) {\n let _host: URL\n if (reqOptions.sendThroughProxy) {\n if (!reqOptions.proxyHost)\n throw new Error('Proxy host is required when sendThroughProxy is true')\n return `${new URL(reqOptions.proxyHost).origin}${new URL(urlRequested).href}`\n } else {\n return urlRequested\n }\n }\n\n parseHeaders(requestHeaders: { [key: string]: string }, accessToken?: string) {\n return {\n ...(accessToken && { Authorization: `Bearer ${accessToken}` }),\n ...requestHeaders,\n }\n }\n\n // setBearerToken(token: string) {\n // this.opts.headers = {\n // ...this.opts.headers,\n // Authorization: `Bearer ${token}`,\n // }\n // }\n\n async request(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',\n url: string,\n data?: any,\n reqOptions: HTTPRequestOptions = {\n sendThroughProxy: false,\n },\n ) {\n try {\n const response = await axios({\n method,\n url: this.parseUrl(url, reqOptions),\n headers: this.parseHeaders(reqOptions.headers || {}, reqOptions.accessToken),\n ...(data && { data }), // Only include `data` for methods that support it\n })\n\n return response\n } catch (err) {\n if (axios.isAxiosError(err) && err.response) {\n throw new Error(\n `HTTP ${err.response.status}: ${err.response.data?.message || 'Request failed'}`,\n )\n }\n throw new Error('Network error or request failed without a response.')\n }\n }\n\n async get(url: string, reqOptions: HTTPRequestOptions = { sendThroughProxy: true }) {\n return this.request('GET', url, undefined, reqOptions)\n }\n\n async post(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('POST', url, data, reqOptions)\n }\n\n async put(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('PUT', url, data, reqOptions)\n }\n\n async delete(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('DELETE', url, data, reqOptions)\n }\n}\n"]}
@@ -123,7 +123,7 @@ export declare class PlansAPI extends BasePaymentsAPI {
123
123
  * This method is oriented to AI Builders.
124
124
  * The NVM API Key must have publication permissions.
125
125
  *
126
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
126
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
127
127
  *
128
128
  * @param planMetadata - @see {@link PlanMetadata}
129
129
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -152,7 +152,7 @@ export declare class PlansAPI extends BasePaymentsAPI {
152
152
  * @remarks This method is oriented to AI Builders
153
153
  * @remarks To call this method, the NVM API Key must have publication permissions
154
154
  *
155
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
155
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
156
156
  *
157
157
  * @param planMetadata - @see {@link PlanMetadata}
158
158
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -185,7 +185,7 @@ export declare class PlansAPI extends BasePaymentsAPI {
185
185
  * @remarks This method is oriented to AI Builders
186
186
  * @remarks To call this method, the NVM API Key must have publication permissions
187
187
  *
188
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
188
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
189
189
  *
190
190
  * @param planMetadata - @see {@link PlanMetadata}
191
191
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -216,7 +216,7 @@ export declare class PlansAPI extends BasePaymentsAPI {
216
216
  * @remarks This method is oriented to AI Builders
217
217
  * @remarks To call this method, the NVM API Key must have publication permissions
218
218
  *
219
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
219
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
220
220
  *
221
221
  * @param planMetadata - @see {@link PlanMetadata}
222
222
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -247,7 +247,7 @@ export declare class PlansAPI extends BasePaymentsAPI {
247
247
  * @remarks This method is oriented to AI Builders
248
248
  * @remarks To call this method, the NVM API Key must have publication permissions
249
249
  *
250
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
250
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
251
251
  *
252
252
  * @param planMetadata - @see {@link PlanMetadata}
253
253
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -160,7 +160,7 @@ export class PlansAPI extends BasePaymentsAPI {
160
160
  * This method is oriented to AI Builders.
161
161
  * The NVM API Key must have publication permissions.
162
162
  *
163
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
163
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
164
164
  *
165
165
  * @param planMetadata - @see {@link PlanMetadata}
166
166
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -209,7 +209,7 @@ export class PlansAPI extends BasePaymentsAPI {
209
209
  * @remarks This method is oriented to AI Builders
210
210
  * @remarks To call this method, the NVM API Key must have publication permissions
211
211
  *
212
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
212
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
213
213
  *
214
214
  * @param planMetadata - @see {@link PlanMetadata}
215
215
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -247,7 +247,7 @@ export class PlansAPI extends BasePaymentsAPI {
247
247
  * @remarks This method is oriented to AI Builders
248
248
  * @remarks To call this method, the NVM API Key must have publication permissions
249
249
  *
250
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
250
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
251
251
  *
252
252
  * @param planMetadata - @see {@link PlanMetadata}
253
253
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -283,7 +283,7 @@ export class PlansAPI extends BasePaymentsAPI {
283
283
  * @remarks This method is oriented to AI Builders
284
284
  * @remarks To call this method, the NVM API Key must have publication permissions
285
285
  *
286
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
286
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
287
287
  *
288
288
  * @param planMetadata - @see {@link PlanMetadata}
289
289
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -315,7 +315,7 @@ export class PlansAPI extends BasePaymentsAPI {
315
315
  * @remarks This method is oriented to AI Builders
316
316
  * @remarks To call this method, the NVM API Key must have publication permissions
317
317
  *
318
- * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
318
+ * @see https://nevermined.ai/docs/tutorials/builders/create-plan
319
319
  *
320
320
  * @param planMetadata - @see {@link PlanMetadata}
321
321
  * @param priceConfig - @see {@link PlanPriceConfig}
@@ -1 +1 @@
1
- {"version":3,"file":"plans-api.js","sourceRoot":"","sources":["../../src/api/plans-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAGL,iBAAiB,GAQlB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAErB;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,eAAe;IAG3C,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,CAAC,CAA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C1C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,aAAa,CAAC,WAAW,CAAC,kCAAkC,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5F,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACI,KAAK,CAAC,aAAa,CACxB,cAAsB,EACtB,MAAc,EACd,UAAmB,EACnB,qBAA6B;QAE7B,MAAM,IAAI,GAAG;YACX,cAAc;YACd,MAAM;YACN,UAAU;YACV,MAAM,EAAE,qBAAqB;SAC9B,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAClE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,aAAa,CAAC,WAAW,CAAC,0BAA0B,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;QACpF,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;CACF","sourcesContent":["import { PaymentsError } from '../common/payments.error.js'\nimport {\n Address,\n NvmAPIResult,\n PaginationOptions,\n PaymentOptions,\n PlanBalance,\n PlanCreditsConfig,\n PlanRedemptionType,\n PlanMetadata,\n PlanPriceConfig,\n StripeCheckoutResult,\n} from '../common/types.js'\nimport { ZeroAddress } from '../environments.js'\nimport { getRandomBigInt, isEthereumAddress } from '../utils.js'\nimport { BasePaymentsAPI } from './base-payments.js'\nimport * as Plans from '../plans.js'\nimport { ContractsAPI } from './contracts-api.js'\nimport {\n API_URL_REDEEM_PLAN,\n API_URL_GET_PLAN,\n API_URL_GET_PLAN_AGENTS,\n API_URL_MINT_EXPIRABLE_PLAN,\n API_URL_MINT_PLAN,\n API_URL_ORDER_PLAN,\n API_URL_PLAN_BALANCE,\n API_URL_REGISTER_PLAN,\n API_URL_STRIPE_CHECKOUT,\n API_URL_GET_PLANS,\n} from './nvm-api.js'\n\n/**\n * The PlansAPI class provides methods to register and interact with payment plans on Nevermined.\n */\nexport class PlansAPI extends BasePaymentsAPI {\n private contractsApi: ContractsAPI\n\n constructor(options: PaymentOptions) {\n super(options)\n this.contractsApi = new ContractsAPI(options)\n }\n /** Price helpers */\n /**\n * Builds a Fiat price configuration for a plan.\n *\n * @param amount - Amount to charge in minor units (e.g., cents) as bigint.\n * @param receiver - Wallet address that will receive the payment.\n * @returns The PlanPriceConfig representing a fiat price.\n */\n public getFiatPriceConfig(amount: bigint, receiver: Address): PlanPriceConfig {\n return Plans.getFiatPriceConfig(amount, receiver)\n }\n\n /**\n * Builds a Pay-As-You-Go price configuration using the template address from the API.\n */\n public async getPayAsYouGoPriceConfig(\n amount: bigint,\n receiver: Address,\n tokenAddress: Address = ZeroAddress,\n ): Promise<PlanPriceConfig> {\n const templateAddress = await this.contractsApi.getPayAsYouGoTemplateAddress()\n return Plans.getPayAsYouGoPriceConfig(amount, receiver, tokenAddress, templateAddress)\n }\n\n /**\n * Builds a Pay-As-You-Go credits configuration.\n */\n public getPayAsYouGoCreditsConfig(): PlanCreditsConfig {\n return Plans.getPayAsYouGoCreditsConfig()\n }\n\n /**\n * Builds a crypto price configuration for a plan.\n *\n * @param amount - Amount to charge in token minor units as bigint.\n * @param receiver - Wallet address that will receive the payment.\n * @param tokenAddress - Optional ERC20 token address. If omitted, native token is assumed.\n * @returns The PlanPriceConfig representing a crypto price.\n */\n public getCryptoPriceConfig(\n amount: bigint,\n receiver: Address,\n tokenAddress?: Address,\n ): PlanPriceConfig {\n return Plans.getCryptoPriceConfig(amount, receiver, tokenAddress)\n }\n\n /**\n * Builds an ERC20 price configuration for a plan.\n *\n * @param amount - Amount to charge in token minor units as bigint.\n * @param tokenAddress - ERC20 token contract address.\n * @param receiver - Wallet address that will receive the payment.\n * @returns The PlanPriceConfig representing an ERC20 price.\n */\n public getERC20PriceConfig(\n amount: bigint,\n tokenAddress: Address,\n receiver: Address,\n ): PlanPriceConfig {\n return Plans.getERC20PriceConfig(amount, tokenAddress, receiver)\n }\n\n /**\n * Builds a FREE price configuration (no payment required).\n * @returns The PlanPriceConfig representing a free plan.\n */\n public getFreePriceConfig(): PlanPriceConfig {\n return Plans.getFreePriceConfig()\n }\n\n /**\n * Builds a native token price configuration for a plan.\n *\n * @param amount - Amount to charge in native token minor units as bigint.\n * @param receiver - Wallet address that will receive the payment.\n * @returns The PlanPriceConfig representing a native token price.\n */\n public getNativeTokenPriceConfig(amount: bigint, receiver: Address): PlanPriceConfig {\n return Plans.getNativeTokenPriceConfig(amount, receiver)\n }\n\n /** Credits helpers */\n /**\n * Builds an EXPIRABLE credits configuration (time-based access).\n *\n * @param durationOfPlan - Duration in seconds.\n * @returns The PlanCreditsConfig representing expirable credits.\n */\n public getExpirableDurationConfig(durationOfPlan: bigint): PlanCreditsConfig {\n return Plans.getExpirableDurationConfig(durationOfPlan)\n }\n\n /**\n * Builds a NON-EXPIRABLE credits configuration (no expiration).\n * @returns The PlanCreditsConfig representing non-expirable credits.\n */\n public getNonExpirableDurationConfig(): PlanCreditsConfig {\n return Plans.getNonExpirableDurationConfig()\n }\n\n /**\n * Builds a FIXED credits configuration.\n *\n * @param creditsGranted - Total credits granted by the plan.\n * @param creditsPerRequest - Credits spent per request (default 1n).\n * @returns The PlanCreditsConfig representing fixed credits.\n */\n public getFixedCreditsConfig(creditsGranted: bigint, creditsPerRequest = 1n): PlanCreditsConfig {\n return Plans.getFixedCreditsConfig(creditsGranted, creditsPerRequest)\n }\n\n /**\n * Builds a DYNAMIC credits configuration (range-limited per request).\n *\n * @param creditsGranted - Total credits granted by the plan.\n * @param minCreditsPerRequest - Minimum credits per request.\n * @param maxCreditsPerRequest - Maximum credits per request.\n * @returns The PlanCreditsConfig representing dynamic credits.\n */\n public getDynamicCreditsConfig(\n creditsGranted: bigint,\n minCreditsPerRequest = 1n,\n maxCreditsPerRequest = 1n,\n ): PlanCreditsConfig {\n return Plans.getDynamicCreditsConfig(creditsGranted, minCreditsPerRequest, maxCreditsPerRequest)\n }\n\n /**\n * Sets the redemption type in a credits configuration.\n *\n * @param creditsConfig - Credits configuration to modify.\n * @param redemptionType - Redemption type to set.\n * @returns The updated PlanCreditsConfig.\n */\n public setRedemptionType(\n creditsConfig: PlanCreditsConfig,\n redemptionType: PlanRedemptionType,\n ): PlanCreditsConfig {\n return Plans.setRedemptionType(creditsConfig, redemptionType)\n }\n\n /**\n * Marks whether proof is required in a credits configuration.\n *\n * @param creditsConfig - Credits configuration to modify.\n * @param proofRequired - Whether proof is required (default true).\n * @returns The updated PlanCreditsConfig.\n */\n public setProofRequired(\n creditsConfig: PlanCreditsConfig,\n proofRequired = true,\n ): PlanCreditsConfig {\n return Plans.setProofRequired(creditsConfig, proofRequired)\n }\n /**\n * This method is used to create a singleton instance of the PlansAPI class.\n *\n * @param options - The options to initialize the payments class.\n * @returns The instance of the PlansAPI class.\n */\n static getInstance(options: PaymentOptions): PlansAPI {\n return new PlansAPI(options)\n }\n\n /**\n *\n * It allows to an AI Builder to register a Payment Plan on Nevermined in a flexible manner.\n * A Payment Plan defines 2 main aspects:\n * 1. What a subscriber needs to pay to get the plan (i.e. 100 USDC, 5 USD, etc).\n * 2. What the subscriber gets in return to access the AI agents associated to the plan (i.e. 100 credits, 1 week of usage, etc).\n *\n * With Payment Plans, AI Builders control the usage to their AI Agents.\n *\n * Every time a user accesses an AI Agent to the Payment Plan, the usage consumes from a capped amount of credits (or when the plan duration expires).\n * When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.\n *\n * @remarks\n * This method is oriented to AI Builders.\n * The NVM API Key must have publication permissions.\n *\n * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n * @param nonce - Optional nonce to prevent replay attacks. Default is a random BigInt.\n * @example\n * ```\n * const cryptoPriceConfig = getNativeTokenPriceConfig(100n, builderAddress)\n * const creditsConfig = getFixedCreditsConfig(100n)\n * const { planId } = await payments.plans.registerPlan({ name: 'AI Assistants Plan'}, cryptoPriceConfig, creditsConfig)\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerPlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n nonce = getRandomBigInt(),\n accessLimit?: 'credits' | 'time',\n ): Promise<{ planId: string }> {\n if (accessLimit && !['credits', 'time'].includes(accessLimit)) {\n throw new PaymentsError(\n 'Invalid access limit',\n 'accessLimit must be either \"credits\" or \"time\"',\n )\n }\n if (!accessLimit) {\n accessLimit = creditsConfig.durationSecs > 0n ? 'time' : 'credits'\n }\n const body = {\n metadataAttributes: planMetadata,\n priceConfig,\n creditsConfig,\n nonce,\n isTrialPlan: planMetadata.isTrialPlan || false,\n accessLimit,\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_REGISTER_PLAN, this.environment.backend)\n\n const response = await fetch(url, options)\n if (!response.ok) {\n throw Error(`${response.statusText} - ${await response.text()}`)\n }\n\n return response.json()\n }\n\n /**\n *\n * It allows to an AI Builder to create a Payment Plan on Nevermined based on Credits.\n * A Nevermined Credits Plan limits the access by the access/usage of the Plan.\n * With them, AI Builders control the number of requests that can be made to an agent or service.\n * Every time a user accesses any resouce associated to the Payment Plan, the usage consumes from a capped amount of credits.\n * When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.\n *\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const cryptoPriceConfig = getNativeTokenPriceConfig(100n, builderAddress)\n * const creditsConfig = getFixedCreditsConfig(100n)\n * const { planId } = await payments.plans.registerCreditsPlan(\n * { name: 'AI Credits Plan'},\n * cryptoPriceConfig,\n * creditsConfig\n * )\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerCreditsPlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n ): Promise<{ planId: string }> {\n // Credits plans must have durationSecs = 0 (non-expirable) and either fixed or dynamic redemption\n if (creditsConfig.durationSecs !== 0n)\n throw new PaymentsError(\n 'The creditsConfig.durationSecs must be 0 for credits plans (non-expirable)',\n )\n\n if (creditsConfig.minAmount > creditsConfig.maxAmount)\n throw new PaymentsError(\n 'The creditsConfig.minAmount can not be more than creditsConfig.maxAmount',\n )\n\n return this.registerPlan(planMetadata, priceConfig, creditsConfig, undefined, 'credits')\n }\n\n /**\n *\n * It allows to an AI Builder to create a Payment Plan on Nevermined limited by duration.\n * A Nevermined Credits Plan limits the access by the access/usage of the Plan.\n * With them, AI Builders control the number of requests that can be made to an agent or service.\n * Every time a user accesses any resouce associated to the Payment Plan, the usage consumes from a capped amount of credits.\n * When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.\n *\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const cryptoPriceConfig = getNativeTokenPriceConfig(100n, builderAddress)\n * const 1dayDurationPlan = getExpirableDurationConfig(ONE_DAY_DURATION)\n * const { planId } = await payments.plans.registerTimePlan(\n * { name: 'Just for today plan'},\n * cryptoPriceConfig,\n * 1dayDurationPlan\n * )\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerTimePlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n ): Promise<{ planId: string }> {\n // Time plans must have durationSecs > 0 (expirable) and isRedemptionAmountFixed = false\n if (creditsConfig.durationSecs === 0n)\n throw new PaymentsError(\n 'The creditsConfig.durationSecs must be greater than 0 for time plans (expirable)',\n )\n\n if (creditsConfig.isRedemptionAmountFixed)\n throw new PaymentsError(\n 'The creditsConfig.isRedemptionAmountFixed must be false for time plans',\n )\n\n return this.registerPlan(planMetadata, priceConfig, creditsConfig, undefined, 'time')\n }\n\n /**\n *\n * It allows to an AI Builder to create a Trial Payment Plan on Nevermined limited by duration.\n * A Nevermined Trial Plan allow subscribers of that plan to test the Agents associated to it.\n * A Trial plan is a plan that only can be purchased once by a user.\n * Trial plans, as regular plans, can be limited by duration (i.e 1 week of usage) or by credits (i.e 100 credits to use the agent).\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const freePriceConfig = getFreePriceConfig()\n * const 1dayDurationPlan = getExpirableDurationConfig(ONE_DAY_DURATION)\n * const { planId } = await payments.plans.registerCreditsTrialPlan(\n * {name: 'Trial plan'},\n * freePriceConfig,\n * 1dayDurationPlan\n * )\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerCreditsTrialPlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n ): Promise<{ planId: string }> {\n planMetadata.isTrialPlan = true\n return this.registerCreditsPlan(planMetadata, priceConfig, creditsConfig)\n }\n\n /**\n *\n * It allows to an AI Builder to create a Trial Payment Plan on Nevermined limited by duration.\n * A Nevermined Trial Plan allow subscribers of that plan to test the Agents associated to it.\n * A Trial plan is a plan that only can be purchased once by a user.\n * Trial plans, as regular plans, can be limited by duration (i.e 1 week of usage) or by credits (i.e 100 credits to use the agent).\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://docs.nevermined.app/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const freePriceConfig = getFreePriceConfig()\n * const 1dayDurationPlan = getExpirableDurationConfig(ONE_DAY_DURATION)\n * const { planId } = await payments.plans.registerTimeTrialPlan(\n * {name: '1 day Trial plan'},\n * freePriceConfig,\n * 1dayDurationPlan\n * )\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerTimeTrialPlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n ): Promise<{ planId: string }> {\n planMetadata.isTrialPlan = true\n return this.registerTimePlan(planMetadata, priceConfig, creditsConfig)\n }\n\n /**\n * Gets the information about a Payment Plan by its identifier.\n *\n * @param planId - The unique identifier of the plan.\n * @returns A promise that resolves to the plan's description.\n * @throws PaymentsError if the plan is not found.\n * @example\n * ```\n * const plan = payments.plans.getPlan(planId)\n * ```\n */\n public async getPlan(planId: string) {\n const query = API_URL_GET_PLAN.replace(':planId', planId)\n const url = new URL(query, this.environment.backend)\n const response = await fetch(url)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Plan not found', await response.json())\n }\n return response.json()\n }\n\n /**\n *\n * @param page - The page number to retrieve.\n * @param offset - The number of items per page.\n * @param sortBy - The field to sort the results by.\n * @param sortOrder - The order in which to sort the results.\n * @returns A promise that resolves to the list of all different plans.\n */\n public async getPlans(page = 1, offset = 100, sortBy = 'created', sortOrder = 'desc') {\n const url = new URL(API_URL_GET_PLANS, this.environment.backend)\n url.searchParams.set('page', page.toString())\n url.searchParams.set('offset', offset.toString())\n url.searchParams.set('sortBy', sortBy)\n url.searchParams.set('sortOrder', sortOrder)\n const options = this.getBackendHTTPOptions('GET')\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to get plans', await response.json())\n }\n\n const data = await response.json()\n return data\n }\n\n /**\n * Gets the list of Agents that have associated a specific Payment Plan.\n * All the agents returned can be accessed by the users that are subscribed to the Payment Plan.\n *\n * @param planId - The unique identifier of the plan.\n * @param pagination - Optional pagination options to control the number of results returned.\n * @returns A promise that resolves to the list of agents associated with the plan.\n * @throws PaymentsError if the plan is not found.\n *\n * @example\n * ```\n * const result = payments.plans.getAgentsAssociatedToAPlan(planId)\n * // {\n * // total: 10,\n * // page: 1,\n * // offset: 5,\n * // agents: [ ..]\n * // }\n * ```\n */\n public async getAgentsAssociatedToAPlan(planId: string, pagination = new PaginationOptions()) {\n const query =\n API_URL_GET_PLAN_AGENTS.replace(':planId', planId) + '?' + pagination.asQueryParams()\n const url = new URL(query, this.environment.backend)\n const response = await fetch(url)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Plan not found', await response.json())\n }\n return response.json()\n }\n\n /**\n * Gets the balance of an account for a Payment Plan.\n *\n * @param planId - The identifier of the Payment Plan.\n * @param accountAddress - The address of the account to get the balance for.\n * @returns @see {@link PlanBalance} A promise that resolves to the balance result.\n * @throws PaymentsError if unable to get the balance.\n *\n * ```\n * const balance = payments.plans.getPlanBalance(planId)\n * // {\n * // planId: '105906633592154016712415751065660953070604027297000423385655551747721326921578',\n * // planType: 'credits',\n * // holderAddress: '0x505384192Ba6a4D4b50EAB846ee67db3b9A93359',\n * // creditsContract: '0xdd0240858fE744C3BF245DD377abBC04d1FDA443',\n * // balance: '100',\n * // isSubscriber: true\n * // }\n * ```\n *\n */\n public async getPlanBalance(planId: string, accountAddress?: Address): Promise<PlanBalance> {\n const holderAddress = isEthereumAddress(accountAddress)\n ? accountAddress\n : this.getAccountAddress()\n\n if (!holderAddress) {\n throw new PaymentsError('Holder address is required')\n }\n\n const balanceUrl = API_URL_PLAN_BALANCE.replace(':planId', planId).replace(\n ':holderAddress',\n holderAddress,\n )\n\n const options = {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n }\n const url = new URL(balanceUrl, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to get balance', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Orders a Payment Plan requiring the payment in crypto. The user must have enough balance in the selected token.\n *\n * @remarks\n * The payment is done using crypto in the token (ERC20 or native) defined in the plan.\n *\n * @param planId - The unique identifier of the plan.\n * @returns @see {@link NvmAPIResult} A promise that resolves indicating if the operation was successful.\n * @throws PaymentsError if unable to order the plan.\n *\n * @example\n * ```\n * const result = await payments.plans.orderPlan(planId)\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async orderPlan(planId: string): Promise<NvmAPIResult> {\n const options = this.getBackendHTTPOptions('POST')\n const url = new URL(API_URL_ORDER_PLAN.replace(':planId', planId), this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to order plan', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Initiates the purchase of a Plan requiring the payment in Fiat. This method will return a URL where the user can complete the payment.\n *\n * @remarks\n * The payment is completed using a credit card in a external website (Stripe).\n * @remarks\n * This method is only valid for plans with price in Fiat.\n *\n * @param planId - The unique identifier of the plan.\n * @returns A promise that resolves indicating the URL to complete the payment.\n * @throws PaymentsError if unable to order the plan.\n *\n * @example\n * ```\n * const result = await payments.plans.orderFiatPlan(planId)\n * ```\n */\n public async orderFiatPlan(planId: string): Promise<{ result: StripeCheckoutResult }> {\n const body = {\n sessionType: 'embedded',\n planId,\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_STRIPE_CHECKOUT, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to order fiat plan', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Mints credits for a given Payment Plan and transfers them to a receiver.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param planId - The unique identifier of the Payment Plan.\n * @param creditsAmount - The number of credits to mint.\n * @param creditsReceiver - The address of the receiver.\n * @returns @see {@link NvmAPIResult} A promise that resolves to the result of the operation.\n * @throws PaymentsError if unable to mint credits.\n *\n * @example\n * ```\n * const result = await payments.plans.mintPlanCredits(planId, 5n, '0x505384192Ba6a4D4b50EAB846ee67db3b9A93359')\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async mintPlanCredits(\n planId: string,\n creditsAmount: bigint,\n creditsReceiver: Address,\n ): Promise<NvmAPIResult> {\n const body = { planId, amount: creditsAmount, creditsReceiver }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_MINT_PLAN, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to mint plan credits', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Mints expirable credits for a given Payment Plan and transfers them to a receiver.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param planId - The unique identifier of the Payment Plan.\n * @param creditsAmount - The number of credits to mint.\n * @param creditsReceiver - The address of the receiver.\n * @param creditsDuration - The duration of the credits in seconds. Default is 0 (no expiration).\n * @returns @see {@link NvmAPIResult} A promise that resolves to the result of the operation.\n * @throws PaymentsError if unable to mint expirable credits.\n *\n * @example\n * ```\n * const result = await payments.plans.mintPlanExpirable(\n * planId,\n * 1n,\n * '0x505384192Ba6a4D4b50EAB846ee67db3b9A93359',\n * 86_400n // 1 day in seconds\n * )\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async mintPlanExpirable(\n planId: string,\n creditsAmount: bigint,\n creditsReceiver: Address,\n creditsDuration = 0n,\n ): Promise<NvmAPIResult> {\n const body = { planId, creditsAmount, creditsReceiver, creditsDuration }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_MINT_EXPIRABLE_PLAN, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to mint expirable credits', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Burns/redeem credits for a given Payment Plan.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param agentRequestId - The unique identifier of the agent request to track the operation. This ID is generated via the `requests.startProcessingRequest` method\n * @param planId - The unique identifier of the Payment Plan.\n * @param redeemFrom - The address of the account to redeem from.\n * @param creditsAmountToRedeem - The amount of credits to redeem.\n * @returns @see {@link NvmAPIResult} A promise that resolves to the result of the operation.\n * @throws PaymentsError if unable to burn credits.\n *\n * ```\n * const result = await payments.plans.redeemCredits(\n * 'request-id-12345', // The request ID to track the operation\n * planId,\n * '0x505384192Ba6a4D4b50EAB846ee67db3b9A93359', // The address of the account to redeem from\n * 5n\n * )\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async redeemCredits(\n agentRequestId: string,\n planId: string,\n redeemFrom: Address,\n creditsAmountToRedeem: string,\n ): Promise<NvmAPIResult> {\n const body = {\n agentRequestId,\n planId,\n redeemFrom,\n amount: creditsAmountToRedeem,\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_REDEEM_PLAN, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to redeem credits', await response.json())\n }\n\n return response.json()\n }\n}\n"]}
1
+ {"version":3,"file":"plans-api.js","sourceRoot":"","sources":["../../src/api/plans-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAGL,iBAAiB,GAQlB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAErB;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,eAAe;IAG3C,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;IACD,oBAAoB;IACpB;;;;;;OAMG;IACI,kBAAkB,CAAC,MAAc,EAAE,QAAiB;QACzD,OAAO,KAAK,CAAC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACnD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,wBAAwB,CACnC,MAAc,EACd,QAAiB,EACjB,eAAwB,WAAW;QAEnC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,4BAA4B,EAAE,CAAA;QAC9E,OAAO,KAAK,CAAC,wBAAwB,CAAC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AAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAClE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,aAAa,CAAC,WAAW,CAAC,0BAA0B,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;QACpF,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;CACF","sourcesContent":["import { PaymentsError } from '../common/payments.error.js'\nimport {\n Address,\n NvmAPIResult,\n PaginationOptions,\n PaymentOptions,\n PlanBalance,\n PlanCreditsConfig,\n PlanRedemptionType,\n PlanMetadata,\n PlanPriceConfig,\n StripeCheckoutResult,\n} from '../common/types.js'\nimport { ZeroAddress } from '../environments.js'\nimport { getRandomBigInt, isEthereumAddress } from '../utils.js'\nimport { BasePaymentsAPI } from './base-payments.js'\nimport * as Plans from '../plans.js'\nimport { ContractsAPI } from './contracts-api.js'\nimport {\n API_URL_REDEEM_PLAN,\n API_URL_GET_PLAN,\n API_URL_GET_PLAN_AGENTS,\n API_URL_MINT_EXPIRABLE_PLAN,\n API_URL_MINT_PLAN,\n API_URL_ORDER_PLAN,\n API_URL_PLAN_BALANCE,\n API_URL_REGISTER_PLAN,\n API_URL_STRIPE_CHECKOUT,\n API_URL_GET_PLANS,\n} from './nvm-api.js'\n\n/**\n * The PlansAPI class provides methods to register and interact with payment plans on Nevermined.\n */\nexport class PlansAPI extends BasePaymentsAPI {\n private contractsApi: ContractsAPI\n\n constructor(options: PaymentOptions) {\n super(options)\n this.contractsApi = new ContractsAPI(options)\n }\n /** Price helpers */\n /**\n * Builds a Fiat price configuration for a plan.\n *\n * @param amount - Amount to charge in minor units (e.g., cents) as bigint.\n * @param receiver - Wallet address that will receive the payment.\n * @returns The PlanPriceConfig representing a fiat price.\n */\n public getFiatPriceConfig(amount: bigint, receiver: Address): PlanPriceConfig {\n return Plans.getFiatPriceConfig(amount, receiver)\n }\n\n /**\n * Builds a Pay-As-You-Go price configuration using the template address from the API.\n */\n public async getPayAsYouGoPriceConfig(\n amount: bigint,\n receiver: Address,\n tokenAddress: Address = ZeroAddress,\n ): Promise<PlanPriceConfig> {\n const templateAddress = await this.contractsApi.getPayAsYouGoTemplateAddress()\n return Plans.getPayAsYouGoPriceConfig(amount, receiver, tokenAddress, templateAddress)\n }\n\n /**\n * Builds a Pay-As-You-Go credits configuration.\n */\n public getPayAsYouGoCreditsConfig(): PlanCreditsConfig {\n return Plans.getPayAsYouGoCreditsConfig()\n }\n\n /**\n * Builds a crypto price configuration for a plan.\n *\n * @param amount - Amount to charge in token minor units as bigint.\n * @param receiver - Wallet address that will receive the payment.\n * @param tokenAddress - Optional ERC20 token address. If omitted, native token is assumed.\n * @returns The PlanPriceConfig representing a crypto price.\n */\n public getCryptoPriceConfig(\n amount: bigint,\n receiver: Address,\n tokenAddress?: Address,\n ): PlanPriceConfig {\n return Plans.getCryptoPriceConfig(amount, receiver, tokenAddress)\n }\n\n /**\n * Builds an ERC20 price configuration for a plan.\n *\n * @param amount - Amount to charge in token minor units as bigint.\n * @param tokenAddress - ERC20 token contract address.\n * @param receiver - Wallet address that will receive the payment.\n * @returns The PlanPriceConfig representing an ERC20 price.\n */\n public getERC20PriceConfig(\n amount: bigint,\n tokenAddress: Address,\n receiver: Address,\n ): PlanPriceConfig {\n return Plans.getERC20PriceConfig(amount, tokenAddress, receiver)\n }\n\n /**\n * Builds a FREE price configuration (no payment required).\n * @returns The PlanPriceConfig representing a free plan.\n */\n public getFreePriceConfig(): PlanPriceConfig {\n return Plans.getFreePriceConfig()\n }\n\n /**\n * Builds a native token price configuration for a plan.\n *\n * @param amount - Amount to charge in native token minor units as bigint.\n * @param receiver - Wallet address that will receive the payment.\n * @returns The PlanPriceConfig representing a native token price.\n */\n public getNativeTokenPriceConfig(amount: bigint, receiver: Address): PlanPriceConfig {\n return Plans.getNativeTokenPriceConfig(amount, receiver)\n }\n\n /** Credits helpers */\n /**\n * Builds an EXPIRABLE credits configuration (time-based access).\n *\n * @param durationOfPlan - Duration in seconds.\n * @returns The PlanCreditsConfig representing expirable credits.\n */\n public getExpirableDurationConfig(durationOfPlan: bigint): PlanCreditsConfig {\n return Plans.getExpirableDurationConfig(durationOfPlan)\n }\n\n /**\n * Builds a NON-EXPIRABLE credits configuration (no expiration).\n * @returns The PlanCreditsConfig representing non-expirable credits.\n */\n public getNonExpirableDurationConfig(): PlanCreditsConfig {\n return Plans.getNonExpirableDurationConfig()\n }\n\n /**\n * Builds a FIXED credits configuration.\n *\n * @param creditsGranted - Total credits granted by the plan.\n * @param creditsPerRequest - Credits spent per request (default 1n).\n * @returns The PlanCreditsConfig representing fixed credits.\n */\n public getFixedCreditsConfig(creditsGranted: bigint, creditsPerRequest = 1n): PlanCreditsConfig {\n return Plans.getFixedCreditsConfig(creditsGranted, creditsPerRequest)\n }\n\n /**\n * Builds a DYNAMIC credits configuration (range-limited per request).\n *\n * @param creditsGranted - Total credits granted by the plan.\n * @param minCreditsPerRequest - Minimum credits per request.\n * @param maxCreditsPerRequest - Maximum credits per request.\n * @returns The PlanCreditsConfig representing dynamic credits.\n */\n public getDynamicCreditsConfig(\n creditsGranted: bigint,\n minCreditsPerRequest = 1n,\n maxCreditsPerRequest = 1n,\n ): PlanCreditsConfig {\n return Plans.getDynamicCreditsConfig(creditsGranted, minCreditsPerRequest, maxCreditsPerRequest)\n }\n\n /**\n * Sets the redemption type in a credits configuration.\n *\n * @param creditsConfig - Credits configuration to modify.\n * @param redemptionType - Redemption type to set.\n * @returns The updated PlanCreditsConfig.\n */\n public setRedemptionType(\n creditsConfig: PlanCreditsConfig,\n redemptionType: PlanRedemptionType,\n ): PlanCreditsConfig {\n return Plans.setRedemptionType(creditsConfig, redemptionType)\n }\n\n /**\n * Marks whether proof is required in a credits configuration.\n *\n * @param creditsConfig - Credits configuration to modify.\n * @param proofRequired - Whether proof is required (default true).\n * @returns The updated PlanCreditsConfig.\n */\n public setProofRequired(\n creditsConfig: PlanCreditsConfig,\n proofRequired = true,\n ): PlanCreditsConfig {\n return Plans.setProofRequired(creditsConfig, proofRequired)\n }\n /**\n * This method is used to create a singleton instance of the PlansAPI class.\n *\n * @param options - The options to initialize the payments class.\n * @returns The instance of the PlansAPI class.\n */\n static getInstance(options: PaymentOptions): PlansAPI {\n return new PlansAPI(options)\n }\n\n /**\n *\n * It allows to an AI Builder to register a Payment Plan on Nevermined in a flexible manner.\n * A Payment Plan defines 2 main aspects:\n * 1. What a subscriber needs to pay to get the plan (i.e. 100 USDC, 5 USD, etc).\n * 2. What the subscriber gets in return to access the AI agents associated to the plan (i.e. 100 credits, 1 week of usage, etc).\n *\n * With Payment Plans, AI Builders control the usage to their AI Agents.\n *\n * Every time a user accesses an AI Agent to the Payment Plan, the usage consumes from a capped amount of credits (or when the plan duration expires).\n * When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.\n *\n * @remarks\n * This method is oriented to AI Builders.\n * The NVM API Key must have publication permissions.\n *\n * @see https://nevermined.ai/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n * @param nonce - Optional nonce to prevent replay attacks. Default is a random BigInt.\n * @example\n * ```\n * const cryptoPriceConfig = getNativeTokenPriceConfig(100n, builderAddress)\n * const creditsConfig = getFixedCreditsConfig(100n)\n * const { planId } = await payments.plans.registerPlan({ name: 'AI Assistants Plan'}, cryptoPriceConfig, creditsConfig)\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerPlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n nonce = getRandomBigInt(),\n accessLimit?: 'credits' | 'time',\n ): Promise<{ planId: string }> {\n if (accessLimit && !['credits', 'time'].includes(accessLimit)) {\n throw new PaymentsError(\n 'Invalid access limit',\n 'accessLimit must be either \"credits\" or \"time\"',\n )\n }\n if (!accessLimit) {\n accessLimit = creditsConfig.durationSecs > 0n ? 'time' : 'credits'\n }\n const body = {\n metadataAttributes: planMetadata,\n priceConfig,\n creditsConfig,\n nonce,\n isTrialPlan: planMetadata.isTrialPlan || false,\n accessLimit,\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_REGISTER_PLAN, this.environment.backend)\n\n const response = await fetch(url, options)\n if (!response.ok) {\n throw Error(`${response.statusText} - ${await response.text()}`)\n }\n\n return response.json()\n }\n\n /**\n *\n * It allows to an AI Builder to create a Payment Plan on Nevermined based on Credits.\n * A Nevermined Credits Plan limits the access by the access/usage of the Plan.\n * With them, AI Builders control the number of requests that can be made to an agent or service.\n * Every time a user accesses any resouce associated to the Payment Plan, the usage consumes from a capped amount of credits.\n * When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.\n *\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://nevermined.ai/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const cryptoPriceConfig = getNativeTokenPriceConfig(100n, builderAddress)\n * const creditsConfig = getFixedCreditsConfig(100n)\n * const { planId } = await payments.plans.registerCreditsPlan(\n * { name: 'AI Credits Plan'},\n * cryptoPriceConfig,\n * creditsConfig\n * )\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerCreditsPlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n ): Promise<{ planId: string }> {\n // Credits plans must have durationSecs = 0 (non-expirable) and either fixed or dynamic redemption\n if (creditsConfig.durationSecs !== 0n)\n throw new PaymentsError(\n 'The creditsConfig.durationSecs must be 0 for credits plans (non-expirable)',\n )\n\n if (creditsConfig.minAmount > creditsConfig.maxAmount)\n throw new PaymentsError(\n 'The creditsConfig.minAmount can not be more than creditsConfig.maxAmount',\n )\n\n return this.registerPlan(planMetadata, priceConfig, creditsConfig, undefined, 'credits')\n }\n\n /**\n *\n * It allows to an AI Builder to create a Payment Plan on Nevermined limited by duration.\n * A Nevermined Credits Plan limits the access by the access/usage of the Plan.\n * With them, AI Builders control the number of requests that can be made to an agent or service.\n * Every time a user accesses any resouce associated to the Payment Plan, the usage consumes from a capped amount of credits.\n * When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.\n *\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://nevermined.ai/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const cryptoPriceConfig = getNativeTokenPriceConfig(100n, builderAddress)\n * const 1dayDurationPlan = getExpirableDurationConfig(ONE_DAY_DURATION)\n * const { planId } = await payments.plans.registerTimePlan(\n * { name: 'Just for today plan'},\n * cryptoPriceConfig,\n * 1dayDurationPlan\n * )\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerTimePlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n ): Promise<{ planId: string }> {\n // Time plans must have durationSecs > 0 (expirable) and isRedemptionAmountFixed = false\n if (creditsConfig.durationSecs === 0n)\n throw new PaymentsError(\n 'The creditsConfig.durationSecs must be greater than 0 for time plans (expirable)',\n )\n\n if (creditsConfig.isRedemptionAmountFixed)\n throw new PaymentsError(\n 'The creditsConfig.isRedemptionAmountFixed must be false for time plans',\n )\n\n return this.registerPlan(planMetadata, priceConfig, creditsConfig, undefined, 'time')\n }\n\n /**\n *\n * It allows to an AI Builder to create a Trial Payment Plan on Nevermined limited by duration.\n * A Nevermined Trial Plan allow subscribers of that plan to test the Agents associated to it.\n * A Trial plan is a plan that only can be purchased once by a user.\n * Trial plans, as regular plans, can be limited by duration (i.e 1 week of usage) or by credits (i.e 100 credits to use the agent).\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://nevermined.ai/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const freePriceConfig = getFreePriceConfig()\n * const 1dayDurationPlan = getExpirableDurationConfig(ONE_DAY_DURATION)\n * const { planId } = await payments.plans.registerCreditsTrialPlan(\n * {name: 'Trial plan'},\n * freePriceConfig,\n * 1dayDurationPlan\n * )\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerCreditsTrialPlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n ): Promise<{ planId: string }> {\n planMetadata.isTrialPlan = true\n return this.registerCreditsPlan(planMetadata, priceConfig, creditsConfig)\n }\n\n /**\n *\n * It allows to an AI Builder to create a Trial Payment Plan on Nevermined limited by duration.\n * A Nevermined Trial Plan allow subscribers of that plan to test the Agents associated to it.\n * A Trial plan is a plan that only can be purchased once by a user.\n * Trial plans, as regular plans, can be limited by duration (i.e 1 week of usage) or by credits (i.e 100 credits to use the agent).\n * @remarks This method is oriented to AI Builders\n * @remarks To call this method, the NVM API Key must have publication permissions\n *\n * @see https://nevermined.ai/docs/tutorials/builders/create-plan\n *\n * @param planMetadata - @see {@link PlanMetadata}\n * @param priceConfig - @see {@link PlanPriceConfig}\n * @param creditsConfig - @see {@link PlanCreditsConfig}\n *\n * @example\n * ```\n * const freePriceConfig = getFreePriceConfig()\n * const 1dayDurationPlan = getExpirableDurationConfig(ONE_DAY_DURATION)\n * const { planId } = await payments.plans.registerTimeTrialPlan(\n * {name: '1 day Trial plan'},\n * freePriceConfig,\n * 1dayDurationPlan\n * )\n * ```\n *\n * @returns The unique identifier of the plan (Plan ID) of the newly created plan.\n */\n public async registerTimeTrialPlan(\n planMetadata: PlanMetadata,\n priceConfig: PlanPriceConfig,\n creditsConfig: PlanCreditsConfig,\n ): Promise<{ planId: string }> {\n planMetadata.isTrialPlan = true\n return this.registerTimePlan(planMetadata, priceConfig, creditsConfig)\n }\n\n /**\n * Gets the information about a Payment Plan by its identifier.\n *\n * @param planId - The unique identifier of the plan.\n * @returns A promise that resolves to the plan's description.\n * @throws PaymentsError if the plan is not found.\n * @example\n * ```\n * const plan = payments.plans.getPlan(planId)\n * ```\n */\n public async getPlan(planId: string) {\n const query = API_URL_GET_PLAN.replace(':planId', planId)\n const url = new URL(query, this.environment.backend)\n const response = await fetch(url)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Plan not found', await response.json())\n }\n return response.json()\n }\n\n /**\n *\n * @param page - The page number to retrieve.\n * @param offset - The number of items per page.\n * @param sortBy - The field to sort the results by.\n * @param sortOrder - The order in which to sort the results.\n * @returns A promise that resolves to the list of all different plans.\n */\n public async getPlans(page = 1, offset = 100, sortBy = 'created', sortOrder = 'desc') {\n const url = new URL(API_URL_GET_PLANS, this.environment.backend)\n url.searchParams.set('page', page.toString())\n url.searchParams.set('offset', offset.toString())\n url.searchParams.set('sortBy', sortBy)\n url.searchParams.set('sortOrder', sortOrder)\n const options = this.getBackendHTTPOptions('GET')\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to get plans', await response.json())\n }\n\n const data = await response.json()\n return data\n }\n\n /**\n * Gets the list of Agents that have associated a specific Payment Plan.\n * All the agents returned can be accessed by the users that are subscribed to the Payment Plan.\n *\n * @param planId - The unique identifier of the plan.\n * @param pagination - Optional pagination options to control the number of results returned.\n * @returns A promise that resolves to the list of agents associated with the plan.\n * @throws PaymentsError if the plan is not found.\n *\n * @example\n * ```\n * const result = payments.plans.getAgentsAssociatedToAPlan(planId)\n * // {\n * // total: 10,\n * // page: 1,\n * // offset: 5,\n * // agents: [ ..]\n * // }\n * ```\n */\n public async getAgentsAssociatedToAPlan(planId: string, pagination = new PaginationOptions()) {\n const query =\n API_URL_GET_PLAN_AGENTS.replace(':planId', planId) + '?' + pagination.asQueryParams()\n const url = new URL(query, this.environment.backend)\n const response = await fetch(url)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Plan not found', await response.json())\n }\n return response.json()\n }\n\n /**\n * Gets the balance of an account for a Payment Plan.\n *\n * @param planId - The identifier of the Payment Plan.\n * @param accountAddress - The address of the account to get the balance for.\n * @returns @see {@link PlanBalance} A promise that resolves to the balance result.\n * @throws PaymentsError if unable to get the balance.\n *\n * ```\n * const balance = payments.plans.getPlanBalance(planId)\n * // {\n * // planId: '105906633592154016712415751065660953070604027297000423385655551747721326921578',\n * // planType: 'credits',\n * // holderAddress: '0x505384192Ba6a4D4b50EAB846ee67db3b9A93359',\n * // creditsContract: '0xdd0240858fE744C3BF245DD377abBC04d1FDA443',\n * // balance: '100',\n * // isSubscriber: true\n * // }\n * ```\n *\n */\n public async getPlanBalance(planId: string, accountAddress?: Address): Promise<PlanBalance> {\n const holderAddress = isEthereumAddress(accountAddress)\n ? accountAddress\n : this.getAccountAddress()\n\n if (!holderAddress) {\n throw new PaymentsError('Holder address is required')\n }\n\n const balanceUrl = API_URL_PLAN_BALANCE.replace(':planId', planId).replace(\n ':holderAddress',\n holderAddress,\n )\n\n const options = {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n }\n const url = new URL(balanceUrl, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to get balance', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Orders a Payment Plan requiring the payment in crypto. The user must have enough balance in the selected token.\n *\n * @remarks\n * The payment is done using crypto in the token (ERC20 or native) defined in the plan.\n *\n * @param planId - The unique identifier of the plan.\n * @returns @see {@link NvmAPIResult} A promise that resolves indicating if the operation was successful.\n * @throws PaymentsError if unable to order the plan.\n *\n * @example\n * ```\n * const result = await payments.plans.orderPlan(planId)\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async orderPlan(planId: string): Promise<NvmAPIResult> {\n const options = this.getBackendHTTPOptions('POST')\n const url = new URL(API_URL_ORDER_PLAN.replace(':planId', planId), this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to order plan', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Initiates the purchase of a Plan requiring the payment in Fiat. This method will return a URL where the user can complete the payment.\n *\n * @remarks\n * The payment is completed using a credit card in a external website (Stripe).\n * @remarks\n * This method is only valid for plans with price in Fiat.\n *\n * @param planId - The unique identifier of the plan.\n * @returns A promise that resolves indicating the URL to complete the payment.\n * @throws PaymentsError if unable to order the plan.\n *\n * @example\n * ```\n * const result = await payments.plans.orderFiatPlan(planId)\n * ```\n */\n public async orderFiatPlan(planId: string): Promise<{ result: StripeCheckoutResult }> {\n const body = {\n sessionType: 'embedded',\n planId,\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_STRIPE_CHECKOUT, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to order fiat plan', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Mints credits for a given Payment Plan and transfers them to a receiver.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param planId - The unique identifier of the Payment Plan.\n * @param creditsAmount - The number of credits to mint.\n * @param creditsReceiver - The address of the receiver.\n * @returns @see {@link NvmAPIResult} A promise that resolves to the result of the operation.\n * @throws PaymentsError if unable to mint credits.\n *\n * @example\n * ```\n * const result = await payments.plans.mintPlanCredits(planId, 5n, '0x505384192Ba6a4D4b50EAB846ee67db3b9A93359')\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async mintPlanCredits(\n planId: string,\n creditsAmount: bigint,\n creditsReceiver: Address,\n ): Promise<NvmAPIResult> {\n const body = { planId, amount: creditsAmount, creditsReceiver }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_MINT_PLAN, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to mint plan credits', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Mints expirable credits for a given Payment Plan and transfers them to a receiver.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param planId - The unique identifier of the Payment Plan.\n * @param creditsAmount - The number of credits to mint.\n * @param creditsReceiver - The address of the receiver.\n * @param creditsDuration - The duration of the credits in seconds. Default is 0 (no expiration).\n * @returns @see {@link NvmAPIResult} A promise that resolves to the result of the operation.\n * @throws PaymentsError if unable to mint expirable credits.\n *\n * @example\n * ```\n * const result = await payments.plans.mintPlanExpirable(\n * planId,\n * 1n,\n * '0x505384192Ba6a4D4b50EAB846ee67db3b9A93359',\n * 86_400n // 1 day in seconds\n * )\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async mintPlanExpirable(\n planId: string,\n creditsAmount: bigint,\n creditsReceiver: Address,\n creditsDuration = 0n,\n ): Promise<NvmAPIResult> {\n const body = { planId, creditsAmount, creditsReceiver, creditsDuration }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_MINT_EXPIRABLE_PLAN, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to mint expirable credits', await response.json())\n }\n\n return response.json()\n }\n\n /**\n * Burns/redeem credits for a given Payment Plan.\n *\n * @remarks\n * Only the owner of the Payment Plan can call this method.\n *\n * @param agentRequestId - The unique identifier of the agent request to track the operation. This ID is generated via the `requests.startProcessingRequest` method\n * @param planId - The unique identifier of the Payment Plan.\n * @param redeemFrom - The address of the account to redeem from.\n * @param creditsAmountToRedeem - The amount of credits to redeem.\n * @returns @see {@link NvmAPIResult} A promise that resolves to the result of the operation.\n * @throws PaymentsError if unable to burn credits.\n *\n * ```\n * const result = await payments.plans.redeemCredits(\n * 'request-id-12345', // The request ID to track the operation\n * planId,\n * '0x505384192Ba6a4D4b50EAB846ee67db3b9A93359', // The address of the account to redeem from\n * 5n\n * )\n * // {\n * // txHash: '0x8d29d5769e832a35e53f80cd4e8890d941c50a09c33dbd975533debc894f2535',\n * // success: true\n * // }\n * ```\n */\n public async redeemCredits(\n agentRequestId: string,\n planId: string,\n redeemFrom: Address,\n creditsAmountToRedeem: string,\n ): Promise<NvmAPIResult> {\n const body = {\n agentRequestId,\n planId,\n redeemFrom,\n amount: creditsAmountToRedeem,\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_REDEEM_PLAN, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to redeem credits', await response.json())\n }\n\n return response.json()\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/common/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,eAAO,MAAM,KAAK,OAAQ,MAAM,qBAAsD,CAAA;AAEtF,eAAO,MAAM,YAAY,SAAU,GAAG,SAAS;IAAE,QAAQ,EAAE,MAAM,GAAG,CAAA;CAAE;cAAX,MAAM,GAAG;CAEnE,CAAA;AAED,eAAO,MAAM,2BAA2B,cAAe,QAAQ,EAAE,KAAG,MAOnE,CAAA"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/common/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,qBAAsD,CAAA;AAEtF,eAAO,MAAM,YAAY,GAAI,MAAM,GAAG,EAAE,OAAO;IAAE,QAAQ,EAAE,MAAM,GAAG,CAAA;CAAE;cAAX,MAAM,GAAG;CAEnE,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,WAAW,QAAQ,EAAE,KAAG,MAOnE,CAAA"}
@@ -12,7 +12,7 @@ export interface PaymentOptions {
12
12
  /**
13
13
  * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.
14
14
  * You can get your API key by logging in to the Nevermined App.
15
- * @see https://docs.nevermined.app/docs/tutorials/integration/nvm-api-keys
15
+ * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys
16
16
  */
17
17
  nvmApiKey: string;
18
18
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AA8HA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+DAAW,CAAA;IACX,yEAAgB,CAAA;IAChB,iFAAoB,CAAA;AACtB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,+DAAS,CAAA;IACT,uDAAK,CAAA;IACL,2DAAO,CAAA;AACT,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,mFAAoB,CAAA;IACpB,uEAAc,CAAA;IACd,+EAAkB,CAAA;IAClB,iFAAmB,CAAA;AACrB,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAoKD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAsB5B;;;OAGG;IACH,YAAY,OAAoC;QApBhD;;;WAGG;QACH,cAAS,GAAmB,MAAM,CAAA;QAClC;;;WAGG;QACH,SAAI,GAAG,CAAC,CAAA;QACR;;;WAGG;QACH,WAAM,GAAG,EAAE,CAAA;QAOT,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;YAC5B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAA;YAC5C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAA;YAC7B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAA;QACpC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,aAAa;QACX,MAAM,MAAM,GAA2B,EAAE,CAAA;QACzC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QAC7B,CAAC;QACD,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QACjC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;QAClC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;QAExC,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC/C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;AACrB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B","sourcesContent":["import { EnvironmentName } from '../environments.js'\n\n/**\n * Options to initialize the Payments class.\n */\nexport interface PaymentOptions {\n /**\n * The Nevermined environment to connect to.\n * If you are developing an agent it's recommended to use the \"sandbox\" environment.\n * When deploying to live use the \"live\" environment.\n */\n environment: EnvironmentName\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://docs.nevermined.app/docs/tutorials/integration/nvm-api-keys\n */\n nvmApiKey: string\n\n /**\n * The URL to return to the app after a successful login.\n */\n returnUrl?: string\n\n /**\n * The app id. This attribute is optional and helps to associate assets registered into Nevermined with a common identifier.\n */\n appId?: string\n\n /**\n * The version of the API to use.\n */\n version?: string\n}\n\nexport interface Endpoint {\n [verb: string]: string\n}\n\nexport interface ApiResponse<T> {\n success: boolean\n data?: T\n error?: string\n}\n\nexport type Address = `0x${string}`\n\n/**\n * Definition of the price configuration for a Payment Plan\n */\nexport interface PlanPriceConfig {\n /**\n * The address of the token (ERC20 or Native if zero address) for paying the plan\n */\n tokenAddress?: Address\n /**\n * The amounts to be paid for the plan\n */\n amounts: bigint[]\n /**\n * The receivers of the payments of the plan\n */\n receivers: string[]\n /**\n * The address of the smart contract that calculates the price\n */\n contractAddress?: Address\n /**\n * The address of the fee controller contract, if any\n * @remarks if not given, the fee controller is the default one\n */\n feeController?: Address\n /**\n * The address of the external price contract, if any\n */\n externalPriceAddress?: Address\n /**\n * The address of the template contract, if any\n */\n templateAddress?: Address\n /**\n * Whether this is a crypto payment (true) or fiat payment (false)\n */\n isCrypto: boolean\n}\n\n/**\n * Definition of the credits configuration for a payment plan\n */\nexport interface PlanCreditsConfig {\n /**\n * Whether the redemption amount is fixed (true) or dynamic (false)\n */\n isRedemptionAmountFixed: boolean\n /**\n * How the credits can be redeemed\n */\n redemptionType: PlanRedemptionType\n /**\n * Whether the credits burn proof signed by the user is required\n */\n proofRequired: boolean\n /**\n * The duration of the credits in seconds\n * @remarks 0 means non-expirable\n */\n durationSecs: bigint\n /**\n * The amount of credits that are granted when purchasing the plan (as string for API)\n */\n amount: bigint\n /**\n * The minimum number of credits redeemed when using the plan\n */\n minAmount: bigint\n /**\n * The maximum number of credits redeemed when using the plan\n */\n maxAmount: bigint\n /**\n * The address of the NFT contract that represents the plan's credits\n */\n nftAddress?: Address\n}\n\n/**\n * Different types of prices that can be configured for a plan\n * @remarks 0 - FIXED_PRICE, 1 - FIXED_FIAT_PRICE, 2 - SMART_CONTRACT_PRICE\n * If FIXED_PRICE it means the plan can be paid in crypto by a fixed amount of a ERC20 or Native token\n * If FIXED_FIAT_PRICE it means the plan can be paid in fiat by a fixed amount (typically USD)\n * 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\n */\nexport enum PlanPriceType {\n FIXED_PRICE,\n FIXED_FIAT_PRICE,\n SMART_CONTRACT_PRICE,\n}\n\n/**\n * Different types of credits that can be obtained when purchasing a plan\n * @remarks 0 - EXPIRABLE, 1 - FIXED, 2 - DYNAMIC\n * If EXPIRABLE it means the credits can be used for a fixed amount of time (calculated in seconds)\n * If FIXED it means the credits can be used for a fixed amount of times\n * If DYNAMIC it means the credits can be used but the redemption amount is dynamic\n */\nexport enum PlanCreditsType {\n EXPIRABLE,\n FIXED,\n DYNAMIC,\n}\n\n/**\n * Different types of redemptions criterias that can be used when redeeming credits\n * @remarks 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER\n * If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE`\n * If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan\n * If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan\n * If ONLY_SUBSCRIBER means only the subscriber (the one who holds the credits NFT) can redeem\n */\nexport enum PlanRedemptionType {\n ONLY_GLOBAL_ROLE = 0, // NVM Proxy can burn\n ONLY_OWNER = 1, // Agent can burn\n ONLY_PLAN_ROLE = 2,\n ONLY_SUBSCRIBER = 4, // Subscriber who ordered the plan can redeem\n}\n\nexport interface PlanBalance {\n planId: string\n planName: string\n planType: string\n holderAddress: Address\n balance: bigint\n creditsContract: Address\n isSubscriber: boolean\n pricePerCredit: number\n}\n\nexport interface StartAgentRequest {\n agentRequestId: string\n agentName: string\n agentId: string\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n batch: boolean\n}\n\nexport interface ValidationAgentRequest {\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n}\n\nexport interface AgentAccessCredentials {\n accessToken: string\n proxies?: string[]\n}\n\nexport interface SubscriberRequestStatus {\n planId: string\n agentId: string\n isValid: boolean\n code: number\n message?: string\n}\n\nexport interface NvmAPIResult {\n success: boolean\n message?: string\n txHash?: string\n httpStatus?: number\n data?: APIOutputData\n when?: Date\n}\n\nexport interface APIOutputData {\n [key: string]: any\n}\n\nexport interface StripeCheckoutResult {\n stripeCheckoutSessionId: string\n checkoutLink: string\n clientReferenceId: string\n paymentStatus?: string\n linkCreatedAt: number\n linkExpiresAt: number\n}\n\n/**\n * Metadata attributes describing the AI Agent.\n */\nexport interface AgentMetadata {\n /**\n * Name of the Agent\n */\n name: string\n /**\n * Description of the Agent\n */\n description?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n author?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n license?: string\n /**\n * Tags describing the AI Agent\n */\n tags?: string[]\n /**\n * Some description or instructions about how to integrate the Agent.\n */\n integration?: string\n /**\n * A link to some same usage of the Agent.\n */\n sampleLink?: string\n /**\n * Text describing the API of the Agent.\n */\n apiDescription?: string\n /**\n * The date when the Agent was created.\n */\n dateCreated?: Date\n\n // internalAttributes?: any\n}\n\n/**\n * Metadata attributes describing the Payment Plan.\n */\nexport interface PlanMetadata extends AgentMetadata {\n /**\n * Indicates if a payment plan is a Trial plan.\n * A Trial plan is a plan that allows users to test the AI Agents associated with it typically without any cost.\n * @remarks A Trial plan only can be purchased once by a user.\n */\n isTrialPlan?: boolean\n /**\n * Indicates if a payment plan is limited by credits.\n * If 'time', the plan will be limited by time.\n * If 'credits', the plan will be limited by credits.\n */\n accessLimit?: 'credits' | 'time'\n}\n\n/**\n * It describes the API exposed by an AI Agent.\n * This information is necessary to query the AI Agent and to know which endpoints are available.\n */\nexport interface AgentAPIAttributes {\n /**\n * The list endpoints of the upstream service. All these endpoints are protected and only accessible to subscribers of the Payment Plan.\n */\n endpoints: Endpoint[]\n /**\n * 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.\n */\n openEndpoints?: string[]\n /**\n * The URL to the agent definition. Can be an OpenAPI spec, MCP Manifest, or A2A agent card. This field is mandatory and defines how the agent/service can be discovered and queried.\n */\n agentDefinitionUrl: string\n\n /////// AUTHORIZATION ///////\n\n /**\n * The upstream agent/service authentication type ('none', 'basic', 'bearer' or 'oauth').\n */\n authType?: 'none' | 'basic' | 'oauth' | 'bearer'\n /**\n * The upstream agent/service username for authentication. Only if `authType` is 'basic'.\n */\n username?: string\n /**\n * The upstream agent/service password for authentication. Only if `authType` is 'basic'.\n */\n password?: string\n /**\n * The upstream agent/service bearer token for authentication. Only if `authType` is 'bearer' or 'oauth'.\n */\n token?: string\n}\n\n/**\n * Options for pagination in API requests to the Nevermined API.\n */\nexport class PaginationOptions {\n /**\n * The field to sort the results by.\n * If not provided, the default sorting defined by the API will be applied.\n */\n sortBy?: string\n /**\n * The order in which to sort the results.\n * Default is 'desc' (descending).\n */\n sortOrder: 'asc' | 'desc' = 'desc'\n /**\n * The page number to retrieve.\n * Default is 1.\n */\n page = 1\n /**\n * The number of items per page.\n * Default is 10.\n */\n offset = 10\n\n /**\n * Constructs a new PaginationOptions instance.\n * @param options - Optional initial values for the pagination options.\n */\n constructor(options?: Partial<PaginationOptions>) {\n if (options) {\n this.sortBy = options.sortBy\n this.sortOrder = options.sortOrder || 'desc'\n this.page = options.page || 1\n this.offset = options.offset || 10\n }\n }\n\n /**\n * It returns a string representation of the pagination options\n * @returns A string representation of the pagination options as URL query parameters.\n * This can be used to append to API requests for pagination.\n */\n asQueryParams(): string {\n const params: Record<string, string> = {}\n if (this.sortBy) {\n params.sortBy = this.sortBy\n }\n params.sortOrder = this.sortOrder\n params.page = this.page.toString()\n params.pageSize = this.offset.toString()\n\n return new URLSearchParams(params).toString()\n }\n}\n\n/**\n * Status of an agent task\n */\nexport enum AgentTaskStatus {\n SUCCESS = 'SUCCESS',\n FAILED = 'FAILED',\n PENDING = 'PENDING',\n}\n\n/**\n * Data transfer object for tracking agent sub tasks\n */\nexport interface TrackAgentSubTaskDto {\n /**\n * The unique identifier of the agent task\n */\n agentRequestId: string\n\n /**\n * The number of credits burned in this agent sub task (optional)\n * @defaultValue 0\n */\n creditsToRedeem?: number\n\n /**\n * A tag to categorize this agent sub task (optional)\n */\n tag?: string\n\n /**\n * A description of this agent sub task (optional)\n */\n description?: string\n\n /**\n * The status of the agent sub task (optional)\n */\n status?: AgentTaskStatus\n}\n\nexport type SimulationRequestOptions = {\n agentName?: string\n planName?: string\n batch?: boolean\n pricePerCredit?: number\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AA8HA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+DAAW,CAAA;IACX,yEAAgB,CAAA;IAChB,iFAAoB,CAAA;AACtB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,+DAAS,CAAA;IACT,uDAAK,CAAA;IACL,2DAAO,CAAA;AACT,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,mFAAoB,CAAA;IACpB,uEAAc,CAAA;IACd,+EAAkB,CAAA;IAClB,iFAAmB,CAAA;AACrB,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAoKD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAsB5B;;;OAGG;IACH,YAAY,OAAoC;QApBhD;;;WAGG;QACH,cAAS,GAAmB,MAAM,CAAA;QAClC;;;WAGG;QACH,SAAI,GAAG,CAAC,CAAA;QACR;;;WAGG;QACH,WAAM,GAAG,EAAE,CAAA;QAOT,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;YAC5B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAA;YAC5C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAA;YAC7B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAA;QACpC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,aAAa;QACX,MAAM,MAAM,GAA2B,EAAE,CAAA;QACzC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QAC7B,CAAC;QACD,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QACjC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;QAClC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;QAExC,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC/C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;AACrB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B","sourcesContent":["import { EnvironmentName } from '../environments.js'\n\n/**\n * Options to initialize the Payments class.\n */\nexport interface PaymentOptions {\n /**\n * The Nevermined environment to connect to.\n * If you are developing an agent it's recommended to use the \"sandbox\" environment.\n * When deploying to live use the \"live\" environment.\n */\n environment: EnvironmentName\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys\n */\n nvmApiKey: string\n\n /**\n * The URL to return to the app after a successful login.\n */\n returnUrl?: string\n\n /**\n * The app id. This attribute is optional and helps to associate assets registered into Nevermined with a common identifier.\n */\n appId?: string\n\n /**\n * The version of the API to use.\n */\n version?: string\n}\n\nexport interface Endpoint {\n [verb: string]: string\n}\n\nexport interface ApiResponse<T> {\n success: boolean\n data?: T\n error?: string\n}\n\nexport type Address = `0x${string}`\n\n/**\n * Definition of the price configuration for a Payment Plan\n */\nexport interface PlanPriceConfig {\n /**\n * The address of the token (ERC20 or Native if zero address) for paying the plan\n */\n tokenAddress?: Address\n /**\n * The amounts to be paid for the plan\n */\n amounts: bigint[]\n /**\n * The receivers of the payments of the plan\n */\n receivers: string[]\n /**\n * The address of the smart contract that calculates the price\n */\n contractAddress?: Address\n /**\n * The address of the fee controller contract, if any\n * @remarks if not given, the fee controller is the default one\n */\n feeController?: Address\n /**\n * The address of the external price contract, if any\n */\n externalPriceAddress?: Address\n /**\n * The address of the template contract, if any\n */\n templateAddress?: Address\n /**\n * Whether this is a crypto payment (true) or fiat payment (false)\n */\n isCrypto: boolean\n}\n\n/**\n * Definition of the credits configuration for a payment plan\n */\nexport interface PlanCreditsConfig {\n /**\n * Whether the redemption amount is fixed (true) or dynamic (false)\n */\n isRedemptionAmountFixed: boolean\n /**\n * How the credits can be redeemed\n */\n redemptionType: PlanRedemptionType\n /**\n * Whether the credits burn proof signed by the user is required\n */\n proofRequired: boolean\n /**\n * The duration of the credits in seconds\n * @remarks 0 means non-expirable\n */\n durationSecs: bigint\n /**\n * The amount of credits that are granted when purchasing the plan (as string for API)\n */\n amount: bigint\n /**\n * The minimum number of credits redeemed when using the plan\n */\n minAmount: bigint\n /**\n * The maximum number of credits redeemed when using the plan\n */\n maxAmount: bigint\n /**\n * The address of the NFT contract that represents the plan's credits\n */\n nftAddress?: Address\n}\n\n/**\n * Different types of prices that can be configured for a plan\n * @remarks 0 - FIXED_PRICE, 1 - FIXED_FIAT_PRICE, 2 - SMART_CONTRACT_PRICE\n * If FIXED_PRICE it means the plan can be paid in crypto by a fixed amount of a ERC20 or Native token\n * If FIXED_FIAT_PRICE it means the plan can be paid in fiat by a fixed amount (typically USD)\n * 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\n */\nexport enum PlanPriceType {\n FIXED_PRICE,\n FIXED_FIAT_PRICE,\n SMART_CONTRACT_PRICE,\n}\n\n/**\n * Different types of credits that can be obtained when purchasing a plan\n * @remarks 0 - EXPIRABLE, 1 - FIXED, 2 - DYNAMIC\n * If EXPIRABLE it means the credits can be used for a fixed amount of time (calculated in seconds)\n * If FIXED it means the credits can be used for a fixed amount of times\n * If DYNAMIC it means the credits can be used but the redemption amount is dynamic\n */\nexport enum PlanCreditsType {\n EXPIRABLE,\n FIXED,\n DYNAMIC,\n}\n\n/**\n * Different types of redemptions criterias that can be used when redeeming credits\n * @remarks 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER\n * If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE`\n * If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan\n * If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan\n * If ONLY_SUBSCRIBER means only the subscriber (the one who holds the credits NFT) can redeem\n */\nexport enum PlanRedemptionType {\n ONLY_GLOBAL_ROLE = 0, // NVM Proxy can burn\n ONLY_OWNER = 1, // Agent can burn\n ONLY_PLAN_ROLE = 2,\n ONLY_SUBSCRIBER = 4, // Subscriber who ordered the plan can redeem\n}\n\nexport interface PlanBalance {\n planId: string\n planName: string\n planType: string\n holderAddress: Address\n balance: bigint\n creditsContract: Address\n isSubscriber: boolean\n pricePerCredit: number\n}\n\nexport interface StartAgentRequest {\n agentRequestId: string\n agentName: string\n agentId: string\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n batch: boolean\n}\n\nexport interface ValidationAgentRequest {\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n}\n\nexport interface AgentAccessCredentials {\n accessToken: string\n proxies?: string[]\n}\n\nexport interface SubscriberRequestStatus {\n planId: string\n agentId: string\n isValid: boolean\n code: number\n message?: string\n}\n\nexport interface NvmAPIResult {\n success: boolean\n message?: string\n txHash?: string\n httpStatus?: number\n data?: APIOutputData\n when?: Date\n}\n\nexport interface APIOutputData {\n [key: string]: any\n}\n\nexport interface StripeCheckoutResult {\n stripeCheckoutSessionId: string\n checkoutLink: string\n clientReferenceId: string\n paymentStatus?: string\n linkCreatedAt: number\n linkExpiresAt: number\n}\n\n/**\n * Metadata attributes describing the AI Agent.\n */\nexport interface AgentMetadata {\n /**\n * Name of the Agent\n */\n name: string\n /**\n * Description of the Agent\n */\n description?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n author?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n license?: string\n /**\n * Tags describing the AI Agent\n */\n tags?: string[]\n /**\n * Some description or instructions about how to integrate the Agent.\n */\n integration?: string\n /**\n * A link to some same usage of the Agent.\n */\n sampleLink?: string\n /**\n * Text describing the API of the Agent.\n */\n apiDescription?: string\n /**\n * The date when the Agent was created.\n */\n dateCreated?: Date\n\n // internalAttributes?: any\n}\n\n/**\n * Metadata attributes describing the Payment Plan.\n */\nexport interface PlanMetadata extends AgentMetadata {\n /**\n * Indicates if a payment plan is a Trial plan.\n * A Trial plan is a plan that allows users to test the AI Agents associated with it typically without any cost.\n * @remarks A Trial plan only can be purchased once by a user.\n */\n isTrialPlan?: boolean\n /**\n * Indicates if a payment plan is limited by credits.\n * If 'time', the plan will be limited by time.\n * If 'credits', the plan will be limited by credits.\n */\n accessLimit?: 'credits' | 'time'\n}\n\n/**\n * It describes the API exposed by an AI Agent.\n * This information is necessary to query the AI Agent and to know which endpoints are available.\n */\nexport interface AgentAPIAttributes {\n /**\n * The list endpoints of the upstream service. All these endpoints are protected and only accessible to subscribers of the Payment Plan.\n */\n endpoints: Endpoint[]\n /**\n * 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.\n */\n openEndpoints?: string[]\n /**\n * The URL to the agent definition. Can be an OpenAPI spec, MCP Manifest, or A2A agent card. This field is mandatory and defines how the agent/service can be discovered and queried.\n */\n agentDefinitionUrl: string\n\n /////// AUTHORIZATION ///////\n\n /**\n * The upstream agent/service authentication type ('none', 'basic', 'bearer' or 'oauth').\n */\n authType?: 'none' | 'basic' | 'oauth' | 'bearer'\n /**\n * The upstream agent/service username for authentication. Only if `authType` is 'basic'.\n */\n username?: string\n /**\n * The upstream agent/service password for authentication. Only if `authType` is 'basic'.\n */\n password?: string\n /**\n * The upstream agent/service bearer token for authentication. Only if `authType` is 'bearer' or 'oauth'.\n */\n token?: string\n}\n\n/**\n * Options for pagination in API requests to the Nevermined API.\n */\nexport class PaginationOptions {\n /**\n * The field to sort the results by.\n * If not provided, the default sorting defined by the API will be applied.\n */\n sortBy?: string\n /**\n * The order in which to sort the results.\n * Default is 'desc' (descending).\n */\n sortOrder: 'asc' | 'desc' = 'desc'\n /**\n * The page number to retrieve.\n * Default is 1.\n */\n page = 1\n /**\n * The number of items per page.\n * Default is 10.\n */\n offset = 10\n\n /**\n * Constructs a new PaginationOptions instance.\n * @param options - Optional initial values for the pagination options.\n */\n constructor(options?: Partial<PaginationOptions>) {\n if (options) {\n this.sortBy = options.sortBy\n this.sortOrder = options.sortOrder || 'desc'\n this.page = options.page || 1\n this.offset = options.offset || 10\n }\n }\n\n /**\n * It returns a string representation of the pagination options\n * @returns A string representation of the pagination options as URL query parameters.\n * This can be used to append to API requests for pagination.\n */\n asQueryParams(): string {\n const params: Record<string, string> = {}\n if (this.sortBy) {\n params.sortBy = this.sortBy\n }\n params.sortOrder = this.sortOrder\n params.page = this.page.toString()\n params.pageSize = this.offset.toString()\n\n return new URLSearchParams(params).toString()\n }\n}\n\n/**\n * Status of an agent task\n */\nexport enum AgentTaskStatus {\n SUCCESS = 'SUCCESS',\n FAILED = 'FAILED',\n PENDING = 'PENDING',\n}\n\n/**\n * Data transfer object for tracking agent sub tasks\n */\nexport interface TrackAgentSubTaskDto {\n /**\n * The unique identifier of the agent task\n */\n agentRequestId: string\n\n /**\n * The number of credits burned in this agent sub task (optional)\n * @defaultValue 0\n */\n creditsToRedeem?: number\n\n /**\n * A tag to categorize this agent sub task (optional)\n */\n tag?: string\n\n /**\n * A description of this agent sub task (optional)\n */\n description?: string\n\n /**\n * The status of the agent sub task (optional)\n */\n status?: AgentTaskStatus\n}\n\nexport type SimulationRequestOptions = {\n agentName?: string\n planName?: string\n batch?: boolean\n pricePerCredit?: number\n}\n"]}
@@ -27,14 +27,14 @@ export declare class PaywallAuthenticator {
27
27
  * Authenticate an MCP request
28
28
  */
29
29
  authenticate(extra: any, options: {
30
- planId?: string | undefined;
30
+ planId?: string;
31
31
  } | undefined, agentId: string, serverName: string, name: string, kind: 'tool' | 'resource' | 'prompt', argsOrVars: any): Promise<AuthResult>;
32
32
  /**
33
33
  * Authenticate generic MCP meta operations (e.g., initialize, tools/list, resources/list, prompts/list).
34
34
  * Returns an AuthResult compatible with paywall flows (without redeem step).
35
35
  */
36
36
  authenticateMeta(extra: any, options: {
37
- planId?: string | undefined;
37
+ planId?: string;
38
38
  } | undefined, agentId: string, serverName: string, method: string): Promise<AuthResult>;
39
39
  }
40
40
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/mcp/core/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGjD,OAAO,EAAE,UAAU,EAAE,MAA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C,UAAU,EAAE,GAAG,GACd,OAAO,CAAC,UAAU,CAAC;IAuItB;;;OAGG;IACG,gBAAgB,CACpB,KAAK,EAAE,GAAG,EACV,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,YAAK,EACjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC;CA8GvB"}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  /**
3
2
  * HTTP handlers for MCP endpoints.
4
3
  * Provides POST, GET, and DELETE handlers for the /mcp endpoint.
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-handler.d.ts","sourceRoot":"","sources":["../../../src/mcp/http/mcp-handler.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG1E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,mCAA0C,CAAA;AAE5E;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,GAAG,SAAS,CAErE;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,cAAc,EAAE,cAAc,CAAA;IAC9B,wDAAwD;IACxD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,sBAAsB;IACtB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AAsCD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,SAGjB,OAAO,OAAO,QAAQ,KAAG,QAAQ,IAAI,CAAC,CA6DjF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,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H,wBAAgB,2BAA2B,KACH,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,UAgCtF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,IAOrC,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,UAyCtF"}
@@ -1,4 +1,3 @@
1
- /// <reference types="express" />
2
1
  /**
3
2
  * MCP (Model Context Protocol) integration module for Nevermined Payments.
4
3
  *
@@ -150,7 +149,7 @@ export declare function buildMcpIntegration(paymentsService: Payments): {
150
149
  configure: (options: ExtendedMcpConfig) => void;
151
150
  withPaywall: {
152
151
  <TArgs = any>(handler: (args: TArgs, extra?: any, context?: PaywallContext) => Promise<any> | any, options: ToolOptions | PromptOptions): (args: TArgs, extra?: any) => Promise<any>;
153
- <TArgs_1 = any>(handler: (args: TArgs_1, extra?: any, context?: PaywallContext) => Promise<any> | any): (args: TArgs_1, extra?: any) => Promise<any>;
152
+ <TArgs = any>(handler: (args: TArgs, extra?: any, context?: PaywallContext) => Promise<any> | any): (args: TArgs, extra?: any) => Promise<any>;
154
153
  (handler: (uri: URL, variables: Record<string, string | string[]>, extra?: any, context?: PaywallContext) => Promise<any> | any, options: ResourceOptions): (uri: URL, variables: Record<string, string | string[]>, extra?: any) => Promise<any>;
155
154
  };
156
155
  attach: (server: {
@@ -158,22 +157,22 @@ export declare function buildMcpIntegration(paymentsService: Payments): {
158
157
  registerResource: (name: string, template: any, config: any, handler: any) => void;
159
158
  registerPrompt: (name: string, config: any, handler: any) => void;
160
159
  }) => {
161
- registerTool<TArgs_2 = any>(name: string, config: any, handler: (args: TArgs_2, extra?: any, context?: PaywallContext) => Promise<any> | any, options?: Omit<ToolOptions, 'kind' | 'name'>): void;
162
- registerResource(name: string, template: any, config: any, handler: (uri: URL, variables: Record<string, string | string[]>, extra?: any, context?: PaywallContext) => Promise<any> | any, options?: Omit<ResourceOptions, 'kind' | 'name'>): void;
163
- registerPrompt<TArgs_3 = any>(name: string, config: any, handler: (args: TArgs_3, extra?: any, context?: PaywallContext) => Promise<any> | any, options?: Omit<PromptOptions, 'kind' | 'name'>): void;
160
+ registerTool<TArgs = any>(name: string, config: any, handler: (args: TArgs, extra?: any, context?: PaywallContext) => Promise<any> | any, options?: Omit<ToolOptions, "kind" | "name">): void;
161
+ registerResource(name: string, template: any, config: any, handler: (uri: URL, variables: Record<string, string | string[]>, extra?: any, context?: PaywallContext) => Promise<any> | any, options?: Omit<ResourceOptions, "kind" | "name">): void;
162
+ registerPrompt<TArgs = any>(name: string, config: any, handler: (args: TArgs, extra?: any, context?: PaywallContext) => Promise<any> | any, options?: Omit<PromptOptions, "kind" | "name">): void;
164
163
  };
165
164
  authenticateMeta: (extra: any, options: {
166
- planId?: string | undefined;
165
+ planId?: string;
167
166
  } | undefined, method: string) => Promise<import("./types/paywall.types.js").AuthResult>;
168
167
  createRouter: (options: CreateRouterOptions) => import("express").Router;
169
- createApp: (options: Omit<CreateRouterOptions, 'agentId'> & {
168
+ createApp: (options: Omit<CreateRouterOptions, "agentId"> & {
170
169
  agentId?: string;
171
170
  }) => import("express").Application;
172
171
  startServer: (options: StartServerOptions) => Promise<HttpServerResult>;
173
172
  getConfig: () => ExtendedMcpConfig;
174
173
  registerTool: <Args = any>(name: string, config: McpToolConfig, handler: ToolHandler<Args>, options?: McpRegistrationOptions) => void;
175
174
  registerResource: (name: string, uriOrTemplate: string, config: McpResourceConfig, handler: ResourceHandler, options?: McpRegistrationOptions) => void;
176
- registerPrompt: <Args_1 = any>(name: string, config: McpPromptConfig, handler: PromptHandler<Args_1>, options?: McpRegistrationOptions) => void;
175
+ registerPrompt: <Args = any>(name: string, config: McpPromptConfig, handler: PromptHandler<Args>, options?: McpRegistrationOptions) => void;
177
176
  start: (config: McpServerConfig) => Promise<McpServerResult>;
178
177
  stop: () => Promise<void>;
179
178
  };
@@ -1 +1 @@
1
- {"version":3,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@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  /**
3
2
  * Type definitions for MCP HTTP server and OAuth 2.1 integration.
4
3
  * These types configure the automatic OAuth endpoints and HTTP server functionality.
@@ -1 +1 @@
1
- {"version":3,"file":"http.types.d.ts","sourceRoot":"","sources":["../../../src/mcp/types/http.types.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,gBAAgB,EAAE,MAAM,CAAA;IACxB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,iFAOvB,CAAA;AAEV,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,WAAW,EAAE,eAAe,CAAA;IAC5B,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC9B,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,2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E,MAAM,CAAA;IACtB,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,KAAK,CAAC,EAAE;QACN,6BAA6B,EAAE,MAAM,CAAA;QACrC,2BAA2B,EAAE,MAAM,CAAA;QACnC,oBAAoB,EAAE,MAAM,CAAA;QAC5B,sBAAsB,EAAE,MAAM,CAAA;QAC9B,cAAc,EAAE,MAAM,CAAA;QACtB,QAAQ,EAAE,MAAM,CAAA;QAChB,qBAAqB,CAAC,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,MAAM,EAAE,CAAA;KACjB,CAAA;IACD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB"}
@@ -1,4 +1,3 @@
1
- /// <reference types="express" />
2
1
  import { AIQueryApi } from './api/query-api.js';
3
2
  import { PaymentOptions } from './common/types.js';
4
3
  import { BasePaymentsAPI } from './api/base-payments.js';
@@ -52,7 +51,7 @@ export declare class Payments extends BasePaymentsAPI {
52
51
  * Starts the A2A server with payment integration.
53
52
  * @param options - Server options.
54
53
  */
55
- start: (options: Omit<PaymentsA2AServerOptions, 'paymentsService'>) => PaymentsA2AServerResult;
54
+ start: (options: Omit<PaymentsA2AServerOptions, "paymentsService">) => PaymentsA2AServerResult;
56
55
  /**
57
56
  * Gets (or creates) a RegisteredPaymentsClient for the given alias.
58
57
  * The registry is initialized only on first use.
@@ -67,31 +66,31 @@ export declare class Payments extends BasePaymentsAPI {
67
66
  get mcp(): {
68
67
  configure: (options: mcpModule.ExtendedMcpConfig) => void;
69
68
  withPaywall: {
70
- <TArgs = any>(handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext | undefined) => any, options: import("./mcp/types/paywall.types.js").ToolOptions | import("./mcp/types/paywall.types.js").PromptOptions): (args: TArgs, extra?: any) => Promise<any>;
71
- <TArgs_1 = any>(handler: (args: TArgs_1, extra?: any, context?: mcpModule.PaywallContext | undefined) => any): (args: TArgs_1, extra?: any) => Promise<any>;
72
- (handler: (uri: URL, variables: Record<string, string | string[]>, extra?: any, context?: mcpModule.PaywallContext | undefined) => any, options: import("./mcp/types/paywall.types.js").ResourceOptions): (uri: URL, variables: Record<string, string | string[]>, extra?: any) => Promise<any>;
69
+ <TArgs = any>(handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext) => Promise<any> | any, options: import("./mcp/types/paywall.types.js").ToolOptions | import("./mcp/types/paywall.types.js").PromptOptions): (args: TArgs, extra?: any) => Promise<any>;
70
+ <TArgs = any>(handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext) => Promise<any> | any): (args: TArgs, extra?: any) => Promise<any>;
71
+ (handler: (uri: URL, variables: Record<string, string | string[]>, extra?: any, context?: mcpModule.PaywallContext) => Promise<any> | any, options: import("./mcp/types/paywall.types.js").ResourceOptions): (uri: URL, variables: Record<string, string | string[]>, extra?: any) => Promise<any>;
73
72
  };
74
73
  attach: (server: {
75
74
  registerTool: (name: string, config: any, handler: any) => void;
76
75
  registerResource: (name: string, template: any, config: any, handler: any) => void;
77
76
  registerPrompt: (name: string, config: any, handler: any) => void;
78
77
  }) => {
79
- registerTool<TArgs_2 = any>(name: string, config: any, handler: (args: TArgs_2, extra?: any, context?: mcpModule.PaywallContext | undefined) => any, options?: Omit<import("./mcp/types/paywall.types.js").ToolOptions, "kind" | "name"> | undefined): void;
80
- registerResource(name: string, template: any, config: any, handler: (uri: URL, variables: Record<string, string | string[]>, extra?: any, context?: mcpModule.PaywallContext | undefined) => any, options?: Omit<import("./mcp/types/paywall.types.js").ResourceOptions, "kind" | "name"> | undefined): void;
81
- registerPrompt<TArgs_3 = any>(name: string, config: any, handler: (args: TArgs_3, extra?: any, context?: mcpModule.PaywallContext | undefined) => any, options?: Omit<import("./mcp/types/paywall.types.js").PromptOptions, "kind" | "name"> | undefined): void;
78
+ registerTool<TArgs = any>(name: string, config: any, handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext) => Promise<any> | any, options?: Omit<import("./mcp/types/paywall.types.js").ToolOptions, "kind" | "name">): void;
79
+ registerResource(name: string, template: any, config: any, handler: (uri: URL, variables: Record<string, string | string[]>, extra?: any, context?: mcpModule.PaywallContext) => Promise<any> | any, options?: Omit<import("./mcp/types/paywall.types.js").ResourceOptions, "kind" | "name">): void;
80
+ registerPrompt<TArgs = any>(name: string, config: any, handler: (args: TArgs, extra?: any, context?: mcpModule.PaywallContext) => Promise<any> | any, options?: Omit<import("./mcp/types/paywall.types.js").PromptOptions, "kind" | "name">): void;
82
81
  };
83
82
  authenticateMeta: (extra: any, options: {
84
- planId?: string | undefined;
83
+ planId?: string;
85
84
  } | undefined, method: string) => Promise<mcpModule.AuthResult>;
86
85
  createRouter: (options: mcpModule.CreateRouterOptions) => import("express").Router;
87
86
  createApp: (options: Omit<mcpModule.CreateRouterOptions, "agentId"> & {
88
- agentId?: string | undefined;
87
+ agentId?: string;
89
88
  }) => import("express").Application;
90
89
  startServer: (options: mcpModule.StartServerOptions) => Promise<mcpModule.HttpServerResult>;
91
90
  getConfig: () => mcpModule.ExtendedMcpConfig;
92
- registerTool: <Args = any>(name: string, config: mcpModule.McpToolConfig, handler: mcpModule.ToolHandler<Args>, options?: mcpModule.McpRegistrationOptions | undefined) => void;
93
- registerResource: (name: string, uriOrTemplate: string, config: mcpModule.McpResourceConfig, handler: mcpModule.ResourceHandler, options?: mcpModule.McpRegistrationOptions | undefined) => void;
94
- registerPrompt: <Args_1 = any>(name: string, config: mcpModule.McpPromptConfig, handler: mcpModule.PromptHandler<Args_1>, options?: mcpModule.McpRegistrationOptions | undefined) => void;
91
+ registerTool: <Args = any>(name: string, config: mcpModule.McpToolConfig, handler: mcpModule.ToolHandler<Args>, options?: mcpModule.McpRegistrationOptions) => void;
92
+ registerResource: (name: string, uriOrTemplate: string, config: mcpModule.McpResourceConfig, handler: mcpModule.ResourceHandler, options?: mcpModule.McpRegistrationOptions) => void;
93
+ registerPrompt: <Args = any>(name: string, config: mcpModule.McpPromptConfig, handler: mcpModule.PromptHandler<Args>, options?: mcpModule.McpRegistrationOptions) => void;
95
94
  start: (config: mcpModule.McpServerConfig) => Promise<mcpModule.McpServerResult>;
96
95
  stop: () => Promise<void>;
97
96
  };
@@ -1 +1 @@
1
- {"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAE/E,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAExF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,KAAK,SAAS,MAAM,g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CAAA;AAKD,eAAO,MAAM,4BAA4B,GAAI,SAAS,MAAM,EAAE,YAAY,MAAM,KAAG,MAKlF,CAAA;AAGD,eAAO,MAAM,iBAAiB,QAAO,MAEpC,CAAA;AAGD,eAAO,MAAM,cAAc,GACzB,SAAS,MAAM,EACf,WAAW,MAAM,EACjB,kBAAqC,KACpC,IAsCF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nevermined-io/payments",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Typescript SDK to interact with the Nevermined Payments Protocol",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -36,6 +36,7 @@
36
36
  "scripts": {
37
37
  "clean": "rm -rf ./dist/ ./doc/ ./.nyc_output",
38
38
  "build": "tsc",
39
+ "build:all": "yarn build && yarn cli:build",
39
40
  "lint": "eslint ./src",
40
41
  "test": "jest --verbose --config ./tests/jest.config.json",
41
42
  "test:unit": "jest --verbose --config ./tests/jest.config.json --testPathPattern=tests/unit",
@@ -43,7 +44,11 @@
43
44
  "test:e2e": "jest --verbose --config ./tests/jest.config.json --testPathPattern=tests/e2e --runInBand",
44
45
  "format": "prettier --check ./src",
45
46
  "prepublishOnly": "yarn build",
46
- "doc": "typedoc --out docs ./src"
47
+ "doc": "typedoc --out docs ./src",
48
+ "cli:build": "cd cli && yarn build",
49
+ "cli:dev": "cd cli && yarn dev",
50
+ "cli:test": "cd cli && yarn test",
51
+ "cli:install": "cd cli && yarn install"
47
52
  },
48
53
  "devDependencies": {
49
54
  "@anthropic-ai/sdk": "^0.65.0",