@nevermined-io/payments 1.0.0-rc2 → 1.0.0-rc4

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/dist/index.d.ts CHANGED
@@ -5,7 +5,5 @@ export * from './common/types';
5
5
  export * from './common/payments.error';
6
6
  export * from './common/helper';
7
7
  export * from './api/query-api';
8
- export * as a2a from './a2a';
9
8
  export { BackendApiOptions } from './api/nvm-api';
10
- export type { AgentCard, TaskHandlerResult, TaskStatusUpdateEvent, ExecutionEventBus, AgentExecutor, RequestContext, PushNotificationConfig, } from './a2a/types';
11
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEjD,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,sBAAsB,GACvB,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA"}
package/dist/index.js CHANGED
@@ -10,23 +10,10 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
15
  };
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
16
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.a2a = void 0;
30
17
  __exportStar(require("./environments"), exports);
31
18
  __exportStar(require("./payments"), exports);
32
19
  __exportStar(require("./utils"), exports);
@@ -34,5 +21,4 @@ __exportStar(require("./common/types"), exports);
34
21
  __exportStar(require("./common/payments.error"), exports);
35
22
  __exportStar(require("./common/helper"), exports);
36
23
  __exportStar(require("./api/query-api"), exports);
37
- exports.a2a = __importStar(require("./a2a"));
38
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,6CAA0B;AAC1B,0CAAuB;AACvB,iDAA8B;AAC9B,0DAAuC;AACvC,kDAA+B;AAC/B,kDAA+B;AAC/B,6CAA4B","sourcesContent":["export * from './environments'\nexport * from './payments'\nexport * from './utils'\nexport * from './common/types'\nexport * from './common/payments.error'\nexport * from './common/helper'\nexport * from './api/query-api'\nexport * as a2a from './a2a'\nexport { BackendApiOptions } from './api/nvm-api'\n\nexport type {\n AgentCard,\n TaskHandlerResult,\n TaskStatusUpdateEvent,\n ExecutionEventBus,\n AgentExecutor,\n RequestContext,\n PushNotificationConfig,\n} from './a2a/types'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,6CAA0B;AAC1B,0CAAuB;AACvB,iDAA8B;AAC9B,0DAAuC;AACvC,kDAA+B;AAC/B,kDAA+B","sourcesContent":["export * from './environments'\nexport * from './payments'\nexport * from './utils'\nexport * from './common/types'\nexport * from './common/payments.error'\nexport * from './common/helper'\nexport * from './api/query-api'\nexport { BackendApiOptions } from './api/nvm-api'\n"]}
@@ -1,6 +1,5 @@
1
1
  import { AIQueryApi } from './api/query-api';
2
2
  import { PaymentOptions } from './common/types';
3
- import type { PaymentsA2AServerOptions, PaymentsA2AServerResult } from './a2a/server';
4
3
  import { BasePaymentsAPI } from './api/base-payments';
5
4
  import { PlansAPI } from './api/plans-api';
6
5
  import { AgentsAPI } from './api/agents-api';
@@ -11,34 +10,17 @@ import { AgentRequestsAPI } from './api/requests-api';
11
10
  * @remarks This API requires a Nevermined API Key, which can be obtained by logging in to the Nevermined App.
12
11
  *
13
12
  * The library provides methods to manage AI Agents, Plans & process AI Agent Requests.
14
- * Additionally to it, the library provides an integration with Google Agent2Agent (A2A) framework, allowing AI Agents to communicate with each other and using Nevermined as payment and access control.
15
13
  *
16
14
  * Each of these functionalities is encapsulated in its own API class:
17
15
  * - `plans`: Manages AI Plans, including registration and ordering and retrieving plan details.
18
16
  * - `agents`: Handles AI Agents, including registration of AI Agents and access token generation.
19
17
  * - `requests`: Manages requests received by AI Agents, including validation and tracking.
20
- * - `a2a`: Exposes A2A agent/server functionality for this Payments instance.
21
18
  */
22
19
  export declare class Payments extends BasePaymentsAPI {
23
20
  query: AIQueryApi;
24
21
  plans: PlansAPI;
25
22
  agents: AgentsAPI;
26
23
  requests: AgentRequestsAPI;
27
- /**
28
- * Exposes A2A agent/server functionality for this Payments instance.
29
- * @example
30
- * ```
31
- * payments.a2a.start({ agentCard, executor, port, ... })
32
- * ```
33
- */
34
- readonly a2a: {
35
- /**
36
- * Starts the A2A server using this Payments instance for payment logic.
37
- * @param options - All PaymentsA2AServerOptions except 'paymentsService'.
38
- * @returns Server result containing app, server, adapter, and handler instances.
39
- */
40
- start: (options: Omit<PaymentsA2AServerOptions, 'paymentsService'>) => PaymentsA2AServerResult;
41
- };
42
24
  /**
43
25
  * Get an instance of the Payments class for server-side usage.
44
26
  *
@@ -1 +1 @@
1
- {"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;;;;;;;;;;;GAaG;AACH,qBAAa,QAAS,SAAQ,eAAe;IACpC,KAAK,EAAG,UAAU,CAAA;IAClB,KAAK,EAAG,QAAQ,CAAA;IAChB,MAAM,EAAG,SAAS,CAAA;IAClB,QAAQ,EAAG,gBAAgB,CAAA;IAElC;;;;;;OAMG;IACH,SAAgB,GAAG,EAAE;QACnB;;;;WAIG;QACH,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,KAAK,uBAAuB,CAAA;KAC/F,CAAA;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,WAAW,CAAC,OA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 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.Payments = void 0;
27
4
  const query_api_1 = require("./api/query-api");
28
5
  const payments_error_1 = require("./common/payments.error");
29
- const a2aModule = __importStar(require("./a2a"));
30
6
  const base_payments_1 = require("./api/base-payments");
31
7
  const plans_api_1 = require("./api/plans-api");
32
8
  const agents_api_1 = require("./api/agents-api");
@@ -37,13 +13,11 @@ const requests_api_1 = require("./api/requests-api");
37
13
  * @remarks This API requires a Nevermined API Key, which can be obtained by logging in to the Nevermined App.
38
14
  *
39
15
  * The library provides methods to manage AI Agents, Plans & process AI Agent Requests.
40
- * Additionally to it, the library provides an integration with Google Agent2Agent (A2A) framework, allowing AI Agents to communicate with each other and using Nevermined as payment and access control.
41
16
  *
42
17
  * Each of these functionalities is encapsulated in its own API class:
43
18
  * - `plans`: Manages AI Plans, including registration and ordering and retrieving plan details.
44
19
  * - `agents`: Handles AI Agents, including registration of AI Agents and access token generation.
45
20
  * - `requests`: Manages requests received by AI Agents, including validation and tracking.
46
- * - `a2a`: Exposes A2A agent/server functionality for this Payments instance.
47
21
  */
48
22
  class Payments extends base_payments_1.BasePaymentsAPI {
49
23
  /**
@@ -111,17 +85,6 @@ class Payments extends base_payments_1.BasePaymentsAPI {
111
85
  super(options);
112
86
  this.isBrowserInstance = isBrowserInstance;
113
87
  this.initializeApi(options);
114
- // ---
115
- // Attach the a2a server API to this instance
116
- this.a2a = {
117
- start: (options) => {
118
- return a2aModule.PaymentsA2AServer.start({
119
- ...options,
120
- paymentsService: this,
121
- });
122
- },
123
- };
124
- // ---
125
88
  }
126
89
  /**
127
90
  * Initializes the AI Query Protocol API.
@@ -1 +1 @@
1
- {"version":3,"file":"payments.js","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4C;AAC5C,4DAAuD;AAEvD,iDAAkC;AAElC,uDAAqD;AACrD,+CAA0C;AAC1C,iDAA4C;AAC5C,qDAAqD;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAa,QAAS,SAAQ,+BAAe;IAsB3C;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,WAAW,CAAC,OAAuB;QACxC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,8BAAa,CAAC,gCAAgC,CAAC,CAAA;QAC3D,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACrC,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,kBAAkB,CAAC,OAAuB;QAC/C,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,8BAAa,CAAC,uBAAuB,CAAC,CAAA;QAClD,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACzC,MAAM,YAAY,GAAG,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,CAAA;QACrD,IAAI,CAAC,KAAK,GAAG,sBAAU,CAAC,WAAW,EAAE,CAAA;IACvC,CAAC;IAED;;;;;;;;;;OAUG;IACI,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,iBAAiB;YAAE,OAAM;QACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,oBAAoB,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACpF,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvC,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM;QACX,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;IAClC,CAAC;CACF;AA9JD,4BA8JC","sourcesContent":["import { AIQueryApi } from './api/query-api'\nimport { PaymentsError } from './common/payments.error'\nimport { PaymentOptions } from './common/types'\nimport * as a2aModule from './a2a'\nimport type { PaymentsA2AServerOptions, PaymentsA2AServerResult } from './a2a/server'\nimport { BasePaymentsAPI } from './api/base-payments'\nimport { PlansAPI } from './api/plans-api'\nimport { AgentsAPI } from './api/agents-api'\nimport { AgentRequestsAPI } from './api/requests-api'\n\n/**\n * Main class that interacts with the Nevermined payments API.\n * Use `Payments.getInstance` for server-side usage or `Payments.getBrowserInstance` for browser usage.\n * @remarks This API requires a Nevermined API Key, which can be obtained by logging in to the Nevermined App.\n *\n * The library provides methods to manage AI Agents, Plans & process AI Agent Requests.\n * Additionally to it, the library provides an integration with Google Agent2Agent (A2A) framework, allowing AI Agents to communicate with each other and using Nevermined as payment and access control.\n *\n * Each of these functionalities is encapsulated in its own API class:\n * - `plans`: Manages AI Plans, including registration and ordering and retrieving plan details.\n * - `agents`: Handles AI Agents, including registration of AI Agents and access token generation.\n * - `requests`: Manages requests received by AI Agents, including validation and tracking.\n * - `a2a`: Exposes A2A agent/server functionality for this Payments instance.\n */\nexport class Payments extends BasePaymentsAPI {\n public query!: AIQueryApi\n public plans!: PlansAPI\n public agents!: AgentsAPI\n public requests!: AgentRequestsAPI\n\n /**\n * Exposes A2A agent/server functionality for this Payments instance.\n * @example\n * ```\n * payments.a2a.start({ agentCard, executor, port, ... })\n * ```\n */\n public readonly a2a: {\n /**\n * Starts the A2A server using this Payments instance for payment logic.\n * @param options - All PaymentsA2AServerOptions except 'paymentsService'.\n * @returns Server result containing app, server, adapter, and handler instances.\n */\n start: (options: Omit<PaymentsA2AServerOptions, 'paymentsService'>) => PaymentsA2AServerResult\n }\n\n /**\n * Get an instance of the Payments class for server-side usage.\n *\n * @param options - The options to initialize the payments class.\n * @example\n * ```\n * const payments = Payments.getInstance({1\n * nvmApiKey: 'your-nvm-api-key',\n * environment: 'testing'\n * })\n * ```\n * @returns An instance of {@link Payments}\n * @throws PaymentsError if nvmApiKey is missing.\n */\n static getInstance(options: PaymentOptions) {\n if (!options.nvmApiKey) {\n throw new PaymentsError('Nevermined API Key is required')\n }\n return new Payments(options, false)\n }\n\n /**\n * Get an instance of the Payments class for browser usage.\n *\n * @remarks\n * This is a browser-only function.\n *\n * @param options - The options to initialize the payments class.\n * @example\n * ```\n * const payments = Payments.getBrowserInstance({\n * returnUrl: 'https://mysite.example',\n * environment: 'testing',\n * appId: 'my-app-id',\n * version: '1.0.0'\n * })\n * ```\n * @returns An instance of {@link Payments}\n * @throws PaymentsError if returnUrl is missing.\n */\n static getBrowserInstance(options: PaymentOptions) {\n if (!options.returnUrl) {\n throw new PaymentsError('returnUrl is required')\n }\n const url = new URL(window.location.href)\n const urlNvmApiKey = url.searchParams.get('nvmApiKey') as string\n if (urlNvmApiKey) {\n url.searchParams.delete('nvmApiKey')\n }\n\n const urlAccountAddress = url.searchParams.get('accountAddress') as string\n if (urlAccountAddress) {\n url.searchParams.delete('accountAddress')\n }\n\n history.replaceState(history.state, '', url.toString())\n\n return new Payments(options, true)\n }\n\n /**\n * Initializes the Payments class.\n *\n * @param options - The options to initialize the payments class.\n * @param isBrowserInstance - Whether this instance is for browser usage.\n */\n private constructor(options: PaymentOptions, isBrowserInstance = true) {\n super(options)\n\n this.isBrowserInstance = isBrowserInstance\n this.initializeApi(options)\n // ---\n // Attach the a2a server API to this instance\n this.a2a = {\n start: (options) => {\n return a2aModule.PaymentsA2AServer.start({\n ...options,\n paymentsService: this,\n })\n },\n }\n // ---\n }\n\n /**\n * Initializes the AI Query Protocol API.\n */\n private initializeApi(options: PaymentOptions) {\n this.plans = PlansAPI.getInstance(options)\n this.agents = AgentsAPI.getInstance(options)\n this.requests = AgentRequestsAPI.getInstance(options)\n this.query = AIQueryApi.getInstance()\n }\n\n /**\n * Initiates the connect flow. The user's browser will be redirected to\n * the Nevermined App login page.\n *\n * @remarks\n * This is a browser-only function.\n * @example\n * ```\n * payments.connect()\n * ```\n */\n public connect() {\n if (!this.isBrowserInstance) return\n const url = new URL(`/login?returnUrl=${this.returnUrl}`, this.environment.frontend)\n window.location.href = url.toString()\n }\n\n /**\n * Logs out the user by removing the NVM API key.\n *\n * @remarks\n * This is a browser-only function.\n * @example\n * ```\n * payments.logout()\n * ```\n */\n public logout() {\n this.nvmApiKey = ''\n }\n\n /**\n * Checks if a user is logged in.\n * @example\n * ```\n * payments.isLoggedIn\n * ```\n * @returns True if the user is logged in.\n */\n get isLoggedIn(): boolean {\n return this.nvmApiKey.length > 0\n }\n}\n"]}
1
+ {"version":3,"file":"payments.js","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,4DAAuD;AAEvD,uDAAqD;AACrD,+CAA0C;AAC1C,iDAA4C;AAC5C,qDAAqD;AAErD;;;;;;;;;;;GAWG;AACH,MAAa,QAAS,SAAQ,+BAAe;IAM3C;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,WAAW,CAAC,OAAuB;QACxC,IAAI,CAAC,OAAO,CAAC,S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,KAAK,GAAG,oBAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAC1C,IAAI,CAAC,MAAM,GAAG,sBAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ,GAAG,+BAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACrD,IAAI,CAAC,KAAK,GAAG,sBAAU,CAAC,WAAW,EAAE,CAAA;IACvC,CAAC;IAED;;;;;;;;;;OAUG;IACI,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,iBAAiB;YAAE,OAAM;QACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,oBAAoB,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACpF,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvC,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM;QACX,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;IAClC,CAAC;CACF;AAnID,4BAmIC","sourcesContent":["import { AIQueryApi } from './api/query-api'\nimport { PaymentsError } from './common/payments.error'\nimport { PaymentOptions } from './common/types'\nimport { BasePaymentsAPI } from './api/base-payments'\nimport { PlansAPI } from './api/plans-api'\nimport { AgentsAPI } from './api/agents-api'\nimport { AgentRequestsAPI } from './api/requests-api'\n\n/**\n * Main class that interacts with the Nevermined payments API.\n * Use `Payments.getInstance` for server-side usage or `Payments.getBrowserInstance` for browser usage.\n * @remarks This API requires a Nevermined API Key, which can be obtained by logging in to the Nevermined App.\n *\n * The library provides methods to manage AI Agents, Plans & process AI Agent Requests.\n *\n * Each of these functionalities is encapsulated in its own API class:\n * - `plans`: Manages AI Plans, including registration and ordering and retrieving plan details.\n * - `agents`: Handles AI Agents, including registration of AI Agents and access token generation.\n * - `requests`: Manages requests received by AI Agents, including validation and tracking.\n */\nexport class Payments extends BasePaymentsAPI {\n public query!: AIQueryApi\n public plans!: PlansAPI\n public agents!: AgentsAPI\n public requests!: AgentRequestsAPI\n\n /**\n * Get an instance of the Payments class for server-side usage.\n *\n * @param options - The options to initialize the payments class.\n * @example\n * ```\n * const payments = Payments.getInstance({1\n * nvmApiKey: 'your-nvm-api-key',\n * environment: 'testing'\n * })\n * ```\n * @returns An instance of {@link Payments}\n * @throws PaymentsError if nvmApiKey is missing.\n */\n static getInstance(options: PaymentOptions) {\n if (!options.nvmApiKey) {\n throw new PaymentsError('Nevermined API Key is required')\n }\n return new Payments(options, false)\n }\n\n /**\n * Get an instance of the Payments class for browser usage.\n *\n * @remarks\n * This is a browser-only function.\n *\n * @param options - The options to initialize the payments class.\n * @example\n * ```\n * const payments = Payments.getBrowserInstance({\n * returnUrl: 'https://mysite.example',\n * environment: 'testing',\n * appId: 'my-app-id',\n * version: '1.0.0'\n * })\n * ```\n * @returns An instance of {@link Payments}\n * @throws PaymentsError if returnUrl is missing.\n */\n static getBrowserInstance(options: PaymentOptions) {\n if (!options.returnUrl) {\n throw new PaymentsError('returnUrl is required')\n }\n const url = new URL(window.location.href)\n const urlNvmApiKey = url.searchParams.get('nvmApiKey') as string\n if (urlNvmApiKey) {\n url.searchParams.delete('nvmApiKey')\n }\n\n const urlAccountAddress = url.searchParams.get('accountAddress') as string\n if (urlAccountAddress) {\n url.searchParams.delete('accountAddress')\n }\n\n history.replaceState(history.state, '', url.toString())\n\n return new Payments(options, true)\n }\n\n /**\n * Initializes the Payments class.\n *\n * @param options - The options to initialize the payments class.\n * @param isBrowserInstance - Whether this instance is for browser usage.\n */\n private constructor(options: PaymentOptions, isBrowserInstance = true) {\n super(options)\n\n this.isBrowserInstance = isBrowserInstance\n this.initializeApi(options)\n }\n\n /**\n * Initializes the AI Query Protocol API.\n */\n private initializeApi(options: PaymentOptions) {\n this.plans = PlansAPI.getInstance(options)\n this.agents = AgentsAPI.getInstance(options)\n this.requests = AgentRequestsAPI.getInstance(options)\n this.query = AIQueryApi.getInstance()\n }\n\n /**\n * Initiates the connect flow. The user's browser will be redirected to\n * the Nevermined App login page.\n *\n * @remarks\n * This is a browser-only function.\n * @example\n * ```\n * payments.connect()\n * ```\n */\n public connect() {\n if (!this.isBrowserInstance) return\n const url = new URL(`/login?returnUrl=${this.returnUrl}`, this.environment.frontend)\n window.location.href = url.toString()\n }\n\n /**\n * Logs out the user by removing the NVM API key.\n *\n * @remarks\n * This is a browser-only function.\n * @example\n * ```\n * payments.logout()\n * ```\n */\n public logout() {\n this.nvmApiKey = ''\n }\n\n /**\n * Checks if a user is logged in.\n * @example\n * ```\n * payments.isLoggedIn\n * ```\n * @returns True if the user is logged in.\n */\n get isLoggedIn(): boolean {\n return this.nvmApiKey.length > 0\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nevermined-io/payments",
3
- "version": "1.0.0-rc2",
3
+ "version": "1.0.0-rc4",
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",
@@ -53,7 +53,6 @@
53
53
  "typescript": "^5.3.3"
54
54
  },
55
55
  "dependencies": {
56
- "@a2a-js/sdk": "^0.2.2",
57
56
  "axios": "^1.7.7",
58
57
  "express": "^5.1.0",
59
58
  "jose": "^5.2.4",
@@ -1,85 +0,0 @@
1
- /**
2
- * Helper to build an AgentCard with payment/pricing metadata for A2A agents.
3
- *
4
- * This module provides utilities for creating A2A agent cards that include
5
- * payment and pricing information in a standardized way. The payment metadata
6
- * is embedded in the agent card's capabilities.extensions field following
7
- * the A2A standard for extensibility.
8
- *
9
- * The payment extension uses the URI 'urn:nevermined:payment' and includes
10
- * information about pricing, credits, and payment configuration.
11
- */
12
- import type { AgentCard } from './types';
13
- /**
14
- * Payment/pricing information to be included in the AgentCard extensions.
15
- *
16
- * This interface defines the structure for payment metadata that will be
17
- * embedded in the agent card. The metadata includes information about:
18
- * - Payment type (fixed or dynamic pricing)
19
- * - Credit requirements
20
- * - Plan identification
21
- * - Cost descriptions
22
- *
23
- * Must be compatible with `{[key: string]: unknown}` to comply with A2A standard.
24
- */
25
- export interface PaymentAgentCardMetadata {
26
- /** Type of payment model - 'fixed' for set prices, 'dynamic' for variable pricing */
27
- paymentType: 'fixed' | 'dynamic';
28
- /** Number of credits required for this agent's services */
29
- credits: number;
30
- /** Optional plan ID associated with this agent */
31
- planId?: string;
32
- /** The agent ID for payment validation and tracking */
33
- agentId: string;
34
- /** Human-readable description of the cost */
35
- costDescription?: string;
36
- /** Additional payment-related metadata */
37
- [key: string]: unknown;
38
- }
39
- /**
40
- * Builds an AgentCard with payment/pricing metadata in the capabilities.extensions field.
41
- *
42
- * This function takes a base agent card and payment metadata, then creates a new
43
- * agent card that includes the payment information in a standardized extension.
44
- * The payment extension follows the A2A standard for extensibility and uses the
45
- * URI 'urn:nevermined:payment' to identify payment-related capabilities.
46
- *
47
- * The resulting agent card can be used with the PaymentsA2AServer to provide
48
- * payment-enabled A2A agent functionality.
49
- *
50
- * @param baseCard - The base AgentCard (without payment info)
51
- * @param paymentMetadata - The payment/pricing metadata to include
52
- * @returns The AgentCard with payment info in capabilities.extensions
53
- *
54
- * @example
55
- * ```typescript
56
- * const baseCard: AgentCard = {
57
- * name: 'My AI Assistant',
58
- * description: 'An AI assistant that helps with various tasks',
59
- * capabilities: {
60
- * tools: ['text-generation', 'image-analysis'],
61
- * extensions: []
62
- * }
63
- * }
64
- *
65
- * const paymentMetadata: PaymentAgentCardMetadata = {
66
- * paymentType: 'fixed',
67
- * credits: 10,
68
- * agentId: 'agent-123',
69
- * planId: 'plan-456',
70
- * costDescription: '10 credits per request'
71
- * }
72
- *
73
- * const paymentCard = buildPaymentAgentCard(baseCard, paymentMetadata)
74
- *
75
- * // Use with PaymentsA2AServer
76
- * PaymentsA2AServer.start({
77
- * agentCard: paymentCard,
78
- * executor: new MyExecutor(),
79
- * paymentsService: payments,
80
- * port: 41242
81
- * })
82
- * ```
83
- */
84
- export declare function buildPaymentAgentCard(baseCard: AgentCard, paymentMetadata: PaymentAgentCardMetadata): AgentCard;
85
- //# sourceMappingURL=agent-card.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-card.d.ts","sourceRoot":"","sources":["../../src/a2a/agent-card.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,wBAAwB;IACvC,qFAAqF;IACrF,WAAW,EAAE,OAAO,GAAG,SAAS,CAAA;IAChC,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAA;IACf,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,0CAA0C;IAC1C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,EACnB,eAAe,EAAE,wBAAwB,GACxC,SAAS,CAiBX"}
@@ -1,79 +0,0 @@
1
- "use strict";
2
- /**
3
- * Helper to build an AgentCard with payment/pricing metadata for A2A agents.
4
- *
5
- * This module provides utilities for creating A2A agent cards that include
6
- * payment and pricing information in a standardized way. The payment metadata
7
- * is embedded in the agent card's capabilities.extensions field following
8
- * the A2A standard for extensibility.
9
- *
10
- * The payment extension uses the URI 'urn:nevermined:payment' and includes
11
- * information about pricing, credits, and payment configuration.
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.buildPaymentAgentCard = void 0;
15
- /**
16
- * Builds an AgentCard with payment/pricing metadata in the capabilities.extensions field.
17
- *
18
- * This function takes a base agent card and payment metadata, then creates a new
19
- * agent card that includes the payment information in a standardized extension.
20
- * The payment extension follows the A2A standard for extensibility and uses the
21
- * URI 'urn:nevermined:payment' to identify payment-related capabilities.
22
- *
23
- * The resulting agent card can be used with the PaymentsA2AServer to provide
24
- * payment-enabled A2A agent functionality.
25
- *
26
- * @param baseCard - The base AgentCard (without payment info)
27
- * @param paymentMetadata - The payment/pricing metadata to include
28
- * @returns The AgentCard with payment info in capabilities.extensions
29
- *
30
- * @example
31
- * ```typescript
32
- * const baseCard: AgentCard = {
33
- * name: 'My AI Assistant',
34
- * description: 'An AI assistant that helps with various tasks',
35
- * capabilities: {
36
- * tools: ['text-generation', 'image-analysis'],
37
- * extensions: []
38
- * }
39
- * }
40
- *
41
- * const paymentMetadata: PaymentAgentCardMetadata = {
42
- * paymentType: 'fixed',
43
- * credits: 10,
44
- * agentId: 'agent-123',
45
- * planId: 'plan-456',
46
- * costDescription: '10 credits per request'
47
- * }
48
- *
49
- * const paymentCard = buildPaymentAgentCard(baseCard, paymentMetadata)
50
- *
51
- * // Use with PaymentsA2AServer
52
- * PaymentsA2AServer.start({
53
- * agentCard: paymentCard,
54
- * executor: new MyExecutor(),
55
- * paymentsService: payments,
56
- * port: 41242
57
- * })
58
- * ```
59
- */
60
- function buildPaymentAgentCard(baseCard, paymentMetadata) {
61
- return {
62
- ...baseCard,
63
- capabilities: {
64
- ...baseCard.capabilities,
65
- extensions: [
66
- ...(baseCard.capabilities?.extensions || []),
67
- {
68
- uri: 'urn:nevermined:payment',
69
- description: paymentMetadata.costDescription,
70
- required: false,
71
- // explicit type assertion to satisfy {[key: string]: unknown}
72
- params: paymentMetadata,
73
- },
74
- ],
75
- },
76
- };
77
- }
78
- exports.buildPaymentAgentCard = buildPaymentAgentCard;
79
- //# sourceMappingURL=agent-card.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-card.js","sourceRoot":"","sources":["../../src/a2a/agent-card.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AA+BH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,SAAgB,qBAAqB,CACnC,QAAmB,EACnB,eAAyC;IAEzC,OAAO;QACL,GAAG,QAAQ;QACX,YAAY,EAAE;YACZ,GAAG,QAAQ,CAAC,YAAY;YACxB,UAAU,EAAE;gBACV,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,UAAU,IAAI,EAAE,CAAC;gBAC5C;oBACE,GAAG,EAAE,wBAAwB;oBAC7B,WAAW,EAAE,eAAe,CAAC,eAAe;oBAC5C,QAAQ,EAAE,KAAK;oBACf,8DAA8D;oBAC9D,MAAM,EAAE,eAA6C;iBACtD;aACF;SACF;KACF,CAAA;AACH,CAAC;AApBD,sDAoBC","sourcesContent":["/**\n * Helper to build an AgentCard with payment/pricing metadata for A2A agents.\n *\n * This module provides utilities for creating A2A agent cards that include\n * payment and pricing information in a standardized way. The payment metadata\n * is embedded in the agent card's capabilities.extensions field following\n * the A2A standard for extensibility.\n *\n * The payment extension uses the URI 'urn:nevermined:payment' and includes\n * information about pricing, credits, and payment configuration.\n */\n\nimport type { AgentCard } from './types'\n\n/**\n * Payment/pricing information to be included in the AgentCard extensions.\n *\n * This interface defines the structure for payment metadata that will be\n * embedded in the agent card. The metadata includes information about:\n * - Payment type (fixed or dynamic pricing)\n * - Credit requirements\n * - Plan identification\n * - Cost descriptions\n *\n * Must be compatible with `{[key: string]: unknown}` to comply with A2A standard.\n */\nexport interface PaymentAgentCardMetadata {\n /** Type of payment model - 'fixed' for set prices, 'dynamic' for variable pricing */\n paymentType: 'fixed' | 'dynamic'\n /** Number of credits required for this agent's services */\n credits: number\n /** Optional plan ID associated with this agent */\n planId?: string\n /** The agent ID for payment validation and tracking */\n agentId: string\n /** Human-readable description of the cost */\n costDescription?: string\n /** Additional payment-related metadata */\n [key: string]: unknown // For compatibility with AgentExtension.params\n}\n\n/**\n * Builds an AgentCard with payment/pricing metadata in the capabilities.extensions field.\n *\n * This function takes a base agent card and payment metadata, then creates a new\n * agent card that includes the payment information in a standardized extension.\n * The payment extension follows the A2A standard for extensibility and uses the\n * URI 'urn:nevermined:payment' to identify payment-related capabilities.\n *\n * The resulting agent card can be used with the PaymentsA2AServer to provide\n * payment-enabled A2A agent functionality.\n *\n * @param baseCard - The base AgentCard (without payment info)\n * @param paymentMetadata - The payment/pricing metadata to include\n * @returns The AgentCard with payment info in capabilities.extensions\n *\n * @example\n * ```typescript\n * const baseCard: AgentCard = {\n * name: 'My AI Assistant',\n * description: 'An AI assistant that helps with various tasks',\n * capabilities: {\n * tools: ['text-generation', 'image-analysis'],\n * extensions: []\n * }\n * }\n *\n * const paymentMetadata: PaymentAgentCardMetadata = {\n * paymentType: 'fixed',\n * credits: 10,\n * agentId: 'agent-123',\n * planId: 'plan-456',\n * costDescription: '10 credits per request'\n * }\n *\n * const paymentCard = buildPaymentAgentCard(baseCard, paymentMetadata)\n *\n * // Use with PaymentsA2AServer\n * PaymentsA2AServer.start({\n * agentCard: paymentCard,\n * executor: new MyExecutor(),\n * paymentsService: payments,\n * port: 41242\n * })\n * ```\n */\nexport function buildPaymentAgentCard(\n baseCard: AgentCard,\n paymentMetadata: PaymentAgentCardMetadata,\n): AgentCard {\n return {\n ...baseCard,\n capabilities: {\n ...baseCard.capabilities,\n extensions: [\n ...(baseCard.capabilities?.extensions || []),\n {\n uri: 'urn:nevermined:payment',\n description: paymentMetadata.costDescription,\n required: false,\n // explicit type assertion to satisfy {[key: string]: unknown}\n params: paymentMetadata as { [key: string]: unknown },\n },\n ],\n },\n }\n}\n"]}
@@ -1,23 +0,0 @@
1
- /**
2
- * Public API for the payments A2A integration module.
3
- *
4
- * This module provides a complete A2A (Agent-to-Agent) protocol implementation
5
- * with integrated payment functionality. It allows users to create payment-enabled
6
- * A2A agents without dealing directly with the underlying A2A SDK.
7
- */
8
- /**
9
- * Main server class for starting A2A agents with payment integration.
10
- * Provides complete A2A protocol implementation with credit validation and burning.
11
- */
12
- export { PaymentsA2AServer } from './server';
13
- /**
14
- * Helper function for creating payment-enabled agent cards.
15
- * Embeds payment metadata in agent cards following A2A standards.
16
- */
17
- export { buildPaymentAgentCard } from './agent-card';
18
- /**
19
- * Core types and interfaces for the A2A payments integration.
20
- * Includes TaskContext, TaskHandlerResult, PaymentMetadata, and A2A SDK types.
21
- */
22
- export * from './types';
23
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/a2a/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE5C;;;GAGG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAEpD;;;GAGG;AACH,cAAc,SAAS,CAAA"}
package/dist/a2a/index.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- /**
3
- * Public API for the payments A2A integration module.
4
- *
5
- * This module provides a complete A2A (Agent-to-Agent) protocol implementation
6
- * with integrated payment functionality. It allows users to create payment-enabled
7
- * A2A agents without dealing directly with the underlying A2A SDK.
8
- */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.buildPaymentAgentCard = exports.PaymentsA2AServer = void 0;
25
- /**
26
- * Main server class for starting A2A agents with payment integration.
27
- * Provides complete A2A protocol implementation with credit validation and burning.
28
- */
29
- var server_1 = require("./server");
30
- Object.defineProperty(exports, "PaymentsA2AServer", { enumerable: true, get: function () { return server_1.PaymentsA2AServer; } });
31
- /**
32
- * Helper function for creating payment-enabled agent cards.
33
- * Embeds payment metadata in agent cards following A2A standards.
34
- */
35
- var agent_card_1 = require("./agent-card");
36
- Object.defineProperty(exports, "buildPaymentAgentCard", { enumerable: true, get: function () { return agent_card_1.buildPaymentAgentCard; } });
37
- /**
38
- * Core types and interfaces for the A2A payments integration.
39
- * Includes TaskContext, TaskHandlerResult, PaymentMetadata, and A2A SDK types.
40
- */
41
- __exportStar(require("./types"), exports);
42
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/a2a/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;AAEH;;;GAGG;AACH,mCAA4C;AAAnC,2GAAA,iBAAiB,OAAA;AAE1B;;;GAGG;AACH,2CAAoD;AAA3C,mHAAA,qBAAqB,OAAA;AAE9B;;;GAGG;AACH,0CAAuB","sourcesContent":["/**\n * Public API for the payments A2A integration module.\n *\n * This module provides a complete A2A (Agent-to-Agent) protocol implementation\n * with integrated payment functionality. It allows users to create payment-enabled\n * A2A agents without dealing directly with the underlying A2A SDK.\n */\n\n/**\n * Main server class for starting A2A agents with payment integration.\n * Provides complete A2A protocol implementation with credit validation and burning.\n */\nexport { PaymentsA2AServer } from './server'\n\n/**\n * Helper function for creating payment-enabled agent cards.\n * Embeds payment metadata in agent cards following A2A standards.\n */\nexport { buildPaymentAgentCard } from './agent-card'\n\n/**\n * Core types and interfaces for the A2A payments integration.\n * Includes TaskContext, TaskHandlerResult, PaymentMetadata, and A2A SDK types.\n */\nexport * from './types'\n"]}
@@ -1,107 +0,0 @@
1
- import type { AgentCard, MessageSendParams, ExecutionEventBusManager, TaskStore, TaskStatusUpdateEvent, Task } from '@a2a-js/sdk';
2
- import { AgentExecutor, DefaultRequestHandler } from '@a2a-js/sdk';
3
- /**
4
- * HTTP context associated with a task or message.
5
- */
6
- type HttpRequestContext = {
7
- bearerToken?: string;
8
- urlRequested?: string;
9
- httpMethodRequested?: string;
10
- };
11
- /**
12
- * PaymentsRequestHandler extends DefaultRequestHandler to add payments validation and burning.
13
- * It validates credits before executing a task and burns credits after successful execution.
14
- * It also sends push notifications when a task reaches a terminal state.
15
- */
16
- export declare class PaymentsRequestHandler extends DefaultRequestHandler {
17
- private paymentsService;
18
- /**
19
- * Map to store HTTP context by taskId.
20
- */
21
- private httpContextByTaskId;
22
- /**
23
- * Map to store temporary HTTP context by messageId (before taskId is known).
24
- */
25
- private httpContextByMessageId;
26
- /**
27
- * Set to track which tasks already have a finalization listener attached.
28
- */
29
- private finalizedTasksWithListener;
30
- /**
31
- * Store HTTP context temporarily by messageId (used in middleware when taskId is not yet available).
32
- * @param messageId - The messageId from the incoming message
33
- * @param ctx - The HTTP context (bearerToken, url, method)
34
- */
35
- setHttpRequestContextForMessage(messageId: string, ctx: HttpRequestContext): void;
36
- /**
37
- * Store HTTP context by taskId (used in middleware when taskId is available).
38
- * @param taskId - The taskId of the task
39
- * @param ctx - The HTTP context (bearerToken, url, method)
40
- */
41
- setHttpRequestContextForTask(taskId: string, ctx: HttpRequestContext): void;
42
- /**
43
- * @param agentCard - The agent card
44
- * @param taskStore - The task store
45
- * @param agentExecutor - The business logic executor
46
- * @param paymentsService - The payments service for validation and burning
47
- * @param eventBusManager - The event bus manager (optional)
48
- */
49
- constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, paymentsService: any, eventBusManager?: ExecutionEventBusManager);
50
- /**
51
- * Retrieve the HTTP context for a given taskId.
52
- * @param taskId - The taskId of the task
53
- * @returns The HTTP context (bearerToken, url, method) or undefined
54
- */
55
- private getHttpRequestContextForTask;
56
- /**
57
- * Retrieve the HTTP context for a given messageId.
58
- * @param messageId - The messageId of the message
59
- * @returns The HTTP context (bearerToken, url, method) or undefined
60
- */
61
- private getHttpRequestContextForMessage;
62
- /**
63
- * Sends a message, validating credits before execution and burning credits after.
64
- * Also sends a push notification if the task reaches a terminal state.
65
- * @param params - Message send parameters
66
- * @returns The resulting message or task
67
- */
68
- sendMessage(params: MessageSendParams): Promise<import("@a2a-js/sdk").Message | Task>;
69
- /**
70
- * Handles credits burning and push notification when a task reaches a terminal state.
71
- * This is called asynchronously from the eventBus listener.
72
- * @param event - The status-update event with final state
73
- * @param bearerToken - The bearer token for payment validation
74
- */
75
- private handleTaskFinalization;
76
- /**
77
- * Streams messages and events for a task, with payments validation.
78
- * Also sends a push notification if a terminal status-update event is emitted.
79
- * @param params - Message send parameters
80
- * @returns Async generator of events
81
- */
82
- sendMessageStream(params: MessageSendParams): AsyncGenerator<import("@a2a-js/sdk").Message | Task | TaskStatusUpdateEvent | import("@a2a-js/sdk").TaskArtifactUpdateEvent, void, unknown>;
83
- private sendPushNotification;
84
- /**
85
- * Migrates the HTTP context from a messageId to a taskId and deletes the temporary messageId context.
86
- * @param messageId - The messageId to migrate from
87
- * @param taskId - The taskId to migrate to
88
- */
89
- migrateHttpRequestContextFromMessageToTask(messageId: string, taskId: string): void;
90
- /**
91
- * Deletes the HTTP context associated with a messageId.
92
- * @param messageId - The messageId to delete context for
93
- */
94
- deleteHttpRequestContextForMessage(messageId: string): void;
95
- /**
96
- * Protected getter to access the private taskStore property from the parent class.
97
- * This is a workaround due to SDK limitations.
98
- */
99
- protected getTaskStore(): TaskStore;
100
- /**
101
- * Protected getter to access the private eventBusManager property from the parent class.
102
- * This is a workaround due to SDK limitations.
103
- */
104
- protected getEventBusManager(): ExecutionEventBusManager;
105
- }
106
- export {};
107
- //# sourceMappingURL=paymentsRequestHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paymentsRequestHandler.d.ts","sourceRoot":"","sources":["../../src/a2a/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