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

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.
Files changed (71) hide show
  1. package/dist/a2a/agent-card.d.ts +85 -0
  2. package/dist/a2a/agent-card.d.ts.map +1 -0
  3. package/dist/a2a/agent-card.js +79 -0
  4. package/dist/a2a/agent-card.js.map +1 -0
  5. package/dist/a2a/index.d.ts +23 -0
  6. package/dist/a2a/index.d.ts.map +1 -0
  7. package/dist/a2a/index.js +42 -0
  8. package/dist/a2a/index.js.map +1 -0
  9. package/dist/a2a/paymentsRequestHandler.d.ts +107 -0
  10. package/dist/a2a/paymentsRequestHandler.d.ts.map +1 -0
  11. package/dist/a2a/paymentsRequestHandler.js +333 -0
  12. package/dist/a2a/paymentsRequestHandler.js.map +1 -0
  13. package/dist/a2a/server.d.ts +126 -0
  14. package/dist/a2a/server.d.ts.map +1 -0
  15. package/dist/a2a/server.js +189 -0
  16. package/dist/a2a/server.js.map +1 -0
  17. package/dist/a2a/types.d.ts +91 -0
  18. package/dist/a2a/types.d.ts.map +1 -0
  19. package/dist/a2a/types.js +16 -0
  20. package/dist/a2a/types.js.map +1 -0
  21. package/dist/api/agents-api.d.ts +196 -0
  22. package/dist/api/agents-api.d.ts.map +1 -0
  23. package/dist/api/agents-api.js +281 -0
  24. package/dist/api/agents-api.js.map +1 -0
  25. package/dist/api/base-payments.d.ts +35 -0
  26. package/dist/api/base-payments.d.ts.map +1 -0
  27. package/dist/api/base-payments.js +62 -0
  28. package/dist/api/base-payments.js.map +1 -0
  29. package/dist/api/nvm-api.d.ts +12 -12
  30. package/dist/api/nvm-api.d.ts.map +1 -1
  31. package/dist/api/nvm-api.js +57 -59
  32. package/dist/api/nvm-api.js.map +1 -1
  33. package/dist/api/plans-api.d.ts +349 -0
  34. package/dist/api/plans-api.d.ts.map +1 -0
  35. package/dist/api/plans-api.js +465 -0
  36. package/dist/api/plans-api.js.map +1 -0
  37. package/dist/api/query-api.d.ts +12 -41
  38. package/dist/api/query-api.d.ts.map +1 -1
  39. package/dist/api/query-api.js +17 -46
  40. package/dist/api/query-api.js.map +1 -1
  41. package/dist/api/requests-api.d.ts +108 -0
  42. package/dist/api/requests-api.d.ts.map +1 -0
  43. package/dist/api/requests-api.js +171 -0
  44. package/dist/api/requests-api.js.map +1 -0
  45. package/dist/common/helper.js.map +1 -1
  46. package/dist/common/payments.error.d.ts +31 -1
  47. package/dist/common/payments.error.d.ts.map +1 -1
  48. package/dist/common/payments.error.js +39 -1
  49. package/dist/common/payments.error.js.map +1 -1
  50. package/dist/common/types.d.ts +57 -3
  51. package/dist/common/types.d.ts.map +1 -1
  52. package/dist/common/types.js +10 -1
  53. package/dist/common/types.js.map +1 -1
  54. package/dist/environments.d.ts +1 -1
  55. package/dist/environments.d.ts.map +1 -1
  56. package/dist/environments.js +19 -28
  57. package/dist/environments.js.map +1 -1
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +14 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/payments.d.ts +35 -408
  63. package/dist/payments.d.ts.map +1 -1
  64. package/dist/payments.js +71 -618
  65. package/dist/payments.js.map +1 -1
  66. package/dist/plans.js.map +1 -1
  67. package/dist/utils.d.ts +30 -0
  68. package/dist/utils.d.ts.map +1 -1
  69. package/dist/utils.js +74 -1
  70. package/dist/utils.js.map +1 -1
  71. package/package.json +13 -6
@@ -0,0 +1,85 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,79 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,23 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,42 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,107 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paymentsRequestHandler.d.ts","sourceRoot":"","sources":["../../src/a2a/paymentsRequestHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EAEjB,wBAAwB,EACxB,SAAS,EAET,qBAAqB,EACrB,IAAI,EACL,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAMlE;;GAEG;AACH,KAAK,kBAAkB,GAAG;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,qBAAqB;IAC/D,OAAO,CAAC,eAAe,CAAK;IAE5B;;OAEG;IACH,OAAO,CAAC,mBAAmB,CAA6C;IAExE;;OAEG;IACH,OAAO,CAAC,sBAAsB,CAA6C;IAE3E;;OAEG;IACH,OAAO,CAAC,0BAA0B,CAAyB;IAE3D;;;;OAIG;IACI,+BAA+B,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB;IAIjF;;;;OAIG;IACI,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB;IAI3E;;;;;;OAMG;gBAED,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,GAAG,EACpB,eAAe,CAAC,EAAE,wBAAwB;IAM5C;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAIpC;;;;OAIG;IACH,OAAO,CAAC,+BAA+B;IAIvC;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAqE3C;;;;;OAKG;YACW,sBAAsB;IAiCpC;;;;;OAKG;IACI,iBAAiB,CAAC,MAAM,EAAE,iBAAiB;YAwHpC,oBAAoB;IAoClC;;;;OAIG;IACI,0CAA0C,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ1F;;;OAGG;IACI,kCAAkC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIlE;;;OAGG;IACH,SAAS,CAAC,YAAY,IAAI,SAAS;IAInC;;;OAGG;IACH,SAAS,CAAC,kBAAkB,IAAI,wBAAwB;CAGzD"}