agentpay-mcp 4.1.10 → 4.1.16

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 (59) hide show
  1. package/README.md +13 -1
  2. package/dist/index.js +2 -2
  3. package/dist/utils/authorized-cybersecurity-scan-profile.d.ts +216 -0
  4. package/dist/utils/authorized-cybersecurity-scan-profile.d.ts.map +1 -0
  5. package/dist/utils/authorized-cybersecurity-scan-profile.js +130 -0
  6. package/dist/utils/authorized-cybersecurity-scan-profile.js.map +1 -0
  7. package/dist/utils/paid-provider-health-proof.d.ts +4 -4
  8. package/dist/utils/paid-tool-quality-threshold.d.ts +261 -0
  9. package/dist/utils/paid-tool-quality-threshold.d.ts.map +1 -0
  10. package/dist/utils/paid-tool-quality-threshold.js +155 -0
  11. package/dist/utils/paid-tool-quality-threshold.js.map +1 -0
  12. package/dist/utils/post-quantum-spend-envelope-compatibility.d.ts +22 -0
  13. package/dist/utils/post-quantum-spend-envelope-compatibility.d.ts.map +1 -0
  14. package/dist/utils/post-quantum-spend-envelope-compatibility.js +61 -0
  15. package/dist/utils/post-quantum-spend-envelope-compatibility.js.map +1 -0
  16. package/dist/utils/wallet-action-preflight-profile.d.ts +70 -0
  17. package/dist/utils/wallet-action-preflight-profile.d.ts.map +1 -0
  18. package/dist/utils/wallet-action-preflight-profile.js +151 -0
  19. package/dist/utils/wallet-action-preflight-profile.js.map +1 -0
  20. package/dist/utils/x402-chain-neutral-gateway-profile.d.ts +66 -0
  21. package/dist/utils/x402-chain-neutral-gateway-profile.d.ts.map +1 -0
  22. package/dist/utils/x402-chain-neutral-gateway-profile.js +145 -0
  23. package/dist/utils/x402-chain-neutral-gateway-profile.js.map +1 -0
  24. package/dist/utils/x402-dynamic-paid-mcp-manifest-drift.d.ts +82 -0
  25. package/dist/utils/x402-dynamic-paid-mcp-manifest-drift.d.ts.map +1 -0
  26. package/dist/utils/x402-dynamic-paid-mcp-manifest-drift.js +158 -0
  27. package/dist/utils/x402-dynamic-paid-mcp-manifest-drift.js.map +1 -0
  28. package/dist/utils/x402-multi-ledger-receipt.d.ts +64 -0
  29. package/dist/utils/x402-multi-ledger-receipt.d.ts.map +1 -0
  30. package/dist/utils/x402-multi-ledger-receipt.js +150 -0
  31. package/dist/utils/x402-multi-ledger-receipt.js.map +1 -0
  32. package/docs/agentpay-escrow-reputation-boundary.md +64 -0
  33. package/docs/agentpay-five-tool-parity-proof.json +56 -0
  34. package/docs/agentpay-five-tool-parity-proof.md +64 -0
  35. package/docs/agentpay-machine-payment-directory-listing-pack.md +101 -0
  36. package/docs/agentpay-machine-payment-directory-listing.json +41 -0
  37. package/docs/agentpay-paid-proxy-discovery-listing.json +42 -0
  38. package/docs/authorized-cybersecurity-scan-profile.md +56 -0
  39. package/docs/fixtures/authorized-cybersecurity-scan-profile-agentaegis-2026-05-04.json +43 -0
  40. package/docs/fixtures/chain-neutral-gateway-profile-rugmunch-2026-05-03.json +43 -0
  41. package/docs/fixtures/dynamic-paid-mcp-manifest-rugmunch-2026-05-04-baseline.json +67 -0
  42. package/docs/fixtures/dynamic-paid-mcp-manifest-rugmunch-2026-05-04.json +67 -0
  43. package/docs/fixtures/multi-ledger-receipt-xrpl-utilities-2026-05-04.json +35 -0
  44. package/docs/fixtures/paid-tool-quality-threshold-strale-2026-05-04.json +53 -0
  45. package/docs/fixtures/wallet-action-preflight-merx-2026-05-04.json +54 -0
  46. package/docs/paid-mcp-proxy-discovery-readiness.md +70 -0
  47. package/docs/paid-tool-quality-thresholds.md +47 -0
  48. package/docs/post-quantum-spend-envelope-compatibility.md +37 -0
  49. package/docs/smithery-paid-mcp-installation.md +180 -0
  50. package/docs/wallet-action-preflight-profile.md +57 -0
  51. package/docs/x402-chain-neutral-gateway-profile.md +65 -0
  52. package/docs/x402-chain-neutral-gateway-profile.schema.json +75 -0
  53. package/docs/x402-dynamic-paid-mcp-manifest-drift.md +41 -0
  54. package/docs/x402-dynamic-paid-mcp-manifest-drift.schema.json +193 -0
  55. package/docs/x402-multi-ledger-receipt-normalization.md +57 -0
  56. package/docs/x402-multi-ledger-receipt-normalization.schema.json +67 -0
  57. package/examples/smithery-paid-mcp-installation/README.md +63 -0
  58. package/llms.txt +4 -0
  59. package/package.json +2 -1
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ /**
3
+ * Wallet-action MCP preflight helpers.
4
+ *
5
+ * Wallet-action MCP servers can expose transfers, swaps, energy buys, and other
6
+ * irreversible actions. Buyer agents should require simulation, spend caps,
7
+ * resource caps, allowlists, and approval copy before any signature is made.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.evaluateWalletActionPreflight = evaluateWalletActionPreflight;
11
+ exports.buildTronWalletActionPreflightExample = buildTronWalletActionPreflightExample;
12
+ function parseAmount(value) {
13
+ const cleaned = value.replace(/,/g, '').trim();
14
+ const parsed = Number(cleaned);
15
+ return Number.isFinite(parsed) ? parsed : Number.NaN;
16
+ }
17
+ function includesCaseInsensitive(values, value) {
18
+ return values.map((entry) => entry.toLowerCase()).includes(value.toLowerCase());
19
+ }
20
+ function requireText(value, label, failures) {
21
+ if (!value || !value.trim())
22
+ failures.push(`${label} is required.`);
23
+ }
24
+ function evaluateWalletActionPreflight(profile) {
25
+ const failures = [];
26
+ const warnings = [];
27
+ if (profile.schema !== 'agentpay-wallet-action-preflight/v1')
28
+ failures.push('schema must be agentpay-wallet-action-preflight/v1.');
29
+ requireText(profile.source.name, 'source.name', failures);
30
+ requireText(profile.source.observedAt, 'source.observedAt', failures);
31
+ requireText(profile.action.asset, 'action.asset', failures);
32
+ requireText(profile.action.amount, 'action.amount', failures);
33
+ requireText(profile.action.recipient, 'action.recipient', failures);
34
+ requireText(profile.simulation.expectedOutcome, 'simulation.expectedOutcome', failures);
35
+ requireText(profile.approvalCopy.title, 'approvalCopy.title', failures);
36
+ requireText(profile.approvalCopy.summary, 'approvalCopy.summary', failures);
37
+ requireText(profile.approvalCopy.irreversibleWarning, 'approvalCopy.irreversibleWarning', failures);
38
+ if (!profile.simulation.required)
39
+ failures.push('simulation.required must be true.');
40
+ if (profile.simulation.status !== 'passed')
41
+ failures.push(`simulation status ${profile.simulation.status} is not passed.`);
42
+ if (profile.action.irreversible !== true)
43
+ failures.push('wallet-action preflight applies to irreversible actions and must declare irreversible=true.');
44
+ const actionAmount = parseAmount(profile.action.amount);
45
+ const perActionCap = parseAmount(profile.policy.perActionSpendCap);
46
+ const networkFee = parseAmount(profile.simulation.resourceEstimate.maxNetworkFee);
47
+ const maxNetworkFee = parseAmount(profile.policy.resourceCaps.maxNetworkFee);
48
+ if (Number.isNaN(actionAmount))
49
+ failures.push('action.amount must be numeric.');
50
+ if (Number.isNaN(perActionCap))
51
+ failures.push('policy.perActionSpendCap must be numeric.');
52
+ if (!Number.isNaN(actionAmount) && !Number.isNaN(perActionCap) && actionAmount > perActionCap) {
53
+ failures.push(`action amount ${profile.action.amount} exceeds per-action cap ${profile.policy.perActionSpendCap}.`);
54
+ }
55
+ if (Number.isNaN(networkFee))
56
+ failures.push('simulation.resourceEstimate.maxNetworkFee must be numeric.');
57
+ if (Number.isNaN(maxNetworkFee))
58
+ failures.push('policy.resourceCaps.maxNetworkFee must be numeric.');
59
+ if (!Number.isNaN(networkFee) && !Number.isNaN(maxNetworkFee) && networkFee > maxNetworkFee) {
60
+ failures.push(`network fee ${profile.simulation.resourceEstimate.maxNetworkFee} exceeds cap ${profile.policy.resourceCaps.maxNetworkFee}.`);
61
+ }
62
+ if (profile.policy.resourceCaps.maxEnergy !== undefined && profile.simulation.resourceEstimate.energy !== undefined && profile.simulation.resourceEstimate.energy > profile.policy.resourceCaps.maxEnergy) {
63
+ failures.push(`energy ${profile.simulation.resourceEstimate.energy} exceeds cap ${profile.policy.resourceCaps.maxEnergy}.`);
64
+ }
65
+ if (profile.policy.resourceCaps.maxBandwidth !== undefined && profile.simulation.resourceEstimate.bandwidth !== undefined && profile.simulation.resourceEstimate.bandwidth > profile.policy.resourceCaps.maxBandwidth) {
66
+ failures.push(`bandwidth ${profile.simulation.resourceEstimate.bandwidth} exceeds cap ${profile.policy.resourceCaps.maxBandwidth}.`);
67
+ }
68
+ if (!includesCaseInsensitive(profile.policy.allowedAssets, profile.action.asset)) {
69
+ failures.push(`asset ${profile.action.asset} is not allowlisted.`);
70
+ }
71
+ if (!includesCaseInsensitive(profile.policy.allowedRecipients, profile.action.recipient)) {
72
+ failures.push(`recipient ${profile.action.recipient} is not allowlisted.`);
73
+ }
74
+ if (profile.approvalCopy.lineItems.length < 4) {
75
+ failures.push('approvalCopy.lineItems must include recipient, amount, simulation, and resource-cost lines.');
76
+ }
77
+ if (!profile.policy.requireHumanApproval) {
78
+ warnings.push('Human approval is disabled. Irreversible wallet actions should normally require approval copy review.');
79
+ }
80
+ const approvalPrompt = [
81
+ profile.approvalCopy.title,
82
+ profile.approvalCopy.summary,
83
+ ...profile.approvalCopy.lineItems.map((item) => `- ${item}`),
84
+ profile.approvalCopy.irreversibleWarning,
85
+ ].join('\n');
86
+ const ok = failures.length === 0;
87
+ return {
88
+ ok,
89
+ decision: ok ? 'allow' : 'deny',
90
+ failures,
91
+ warnings,
92
+ approvalPrompt,
93
+ };
94
+ }
95
+ function buildTronWalletActionPreflightExample() {
96
+ return {
97
+ schema: 'agentpay-wallet-action-preflight/v1',
98
+ source: {
99
+ name: 'merx-mcp market signal',
100
+ repo: 'nicosmall503/merx-mcp',
101
+ evidenceUrl: 'https://github.com/nicosmall503/merx-mcp',
102
+ observedAt: '2026-05-05T01:10:00.000Z',
103
+ },
104
+ action: {
105
+ kind: 'resource_purchase',
106
+ chainNamespace: 'tvm',
107
+ chainId: 'tron-mainnet',
108
+ asset: 'TRX',
109
+ amount: '12.5',
110
+ recipient: 'TAllowlistedRecipient111111111111111111111',
111
+ nonce: 'simulation-required-before-nonce-lock',
112
+ irreversible: true,
113
+ },
114
+ simulation: {
115
+ required: true,
116
+ status: 'passed',
117
+ simulationId: 'merx-style-tron-resource-sim-2026-05-05',
118
+ expectedOutcome: 'Buy bandwidth or energy for one allowlisted wallet action without transferring custody.',
119
+ resourceEstimate: {
120
+ feeAsset: 'TRX',
121
+ maxNetworkFee: '1.0',
122
+ energy: 25000,
123
+ bandwidth: 600,
124
+ },
125
+ },
126
+ policy: {
127
+ perActionSpendCap: '25',
128
+ dailyChainSpendCap: '100',
129
+ allowedRecipients: ['TAllowlistedRecipient111111111111111111111'],
130
+ allowedAssets: ['TRX', 'USDT', 'USDC', 'USDD'],
131
+ resourceCaps: {
132
+ maxNetworkFee: '2.5',
133
+ maxEnergy: 50000,
134
+ maxBandwidth: 1000,
135
+ },
136
+ requireHumanApproval: true,
137
+ },
138
+ approvalCopy: {
139
+ title: 'Approve TRON wallet resource purchase?',
140
+ summary: 'AgentPay detected an irreversible wallet-action request. Simulation passed and policy caps are satisfied.',
141
+ lineItems: [
142
+ 'Recipient: TAllowlistedRecipient111111111111111111111',
143
+ 'Amount: 12.5 TRX, cap 25 TRX per action',
144
+ 'Simulation: merx-style-tron-resource-sim-2026-05-05 passed',
145
+ 'Resource cost: max 1.0 TRX network fee, 25,000 energy, 600 bandwidth',
146
+ ],
147
+ irreversibleWarning: 'Signing will authorize an irreversible TRON resource purchase. Decline if recipient, amount, or resource estimate differs from the intended task.',
148
+ },
149
+ };
150
+ }
151
+ //# sourceMappingURL=wallet-action-preflight-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-action-preflight-profile.js","sourceRoot":"","sources":["../../src/utils/wallet-action-preflight-profile.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA+EH,sEA2EC;AAED,sFAuDC;AAlJD,SAAS,WAAW,CAAC,KAAa;IAChC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAA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K,EAAE,wCAAwC;YAC/C,OAAO,EAAE,2GAA2G;YACpH,SAAS,EAAE;gBACT,uDAAuD;gBACvD,yCAAyC;gBACzC,4DAA4D;gBAC5D,sEAAsE;aACvE;YACD,mBAAmB,EAAE,mJAAmJ;SACzK;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Chain-neutral x402 gateway profile helpers.
3
+ *
4
+ * Paid MCP discovery is moving from one Base endpoint to profile documents that
5
+ * describe every supported payment rail, settlement/facilitator boundary,
6
+ * trial/refund policy, and directory manifest path. These helpers validate that
7
+ * profile shape without assuming every x402 payment rail is EVM-compatible.
8
+ */
9
+ export type X402NetworkNamespace = 'eip155' | 'solana' | 'tvm' | 'ton' | 'other';
10
+ export type X402NetworkDescriptor = {
11
+ network: string;
12
+ name: string;
13
+ gateway: string;
14
+ namespace?: X402NetworkNamespace;
15
+ settlementAsset?: string;
16
+ settlementChainId?: number | string;
17
+ notes?: string;
18
+ };
19
+ export type X402TrialPolicy = {
20
+ enabled: boolean;
21
+ calls?: number;
22
+ description: string;
23
+ };
24
+ export type X402RefundPolicy = {
25
+ supported: boolean;
26
+ mode: 'automatic' | 'manual' | 'none';
27
+ description: string;
28
+ };
29
+ export type X402DirectoryManifests = {
30
+ wellKnownX402: string;
31
+ glama?: string;
32
+ smithery?: string;
33
+ mcpCatalog?: string;
34
+ openapi?: string;
35
+ llmsTxt?: string;
36
+ };
37
+ export type X402ChainNeutralGatewayProfile = {
38
+ serviceName: string;
39
+ x402Version: number | string;
40
+ paymentHeader: 'Payment-Signature';
41
+ receiptHeader: 'payment-response';
42
+ networks: X402NetworkDescriptor[];
43
+ facilitator?: string;
44
+ settlement: {
45
+ custody: 'non-custodial' | 'facilitator' | 'managed' | 'unknown';
46
+ description: string;
47
+ };
48
+ trial: X402TrialPolicy;
49
+ refund: X402RefundPolicy;
50
+ manifests: X402DirectoryManifests;
51
+ };
52
+ export type X402ChainNeutralGatewayProfileReport = {
53
+ serviceName: string;
54
+ networkNamespaces: X402NetworkNamespace[];
55
+ hasEvmNetwork: boolean;
56
+ hasNonEvmNetwork: boolean;
57
+ hasDirectoryManifests: boolean;
58
+ hasExplicitTrialPolicy: boolean;
59
+ hasExplicitRefundPolicy: boolean;
60
+ hasSettlementMetadata: boolean;
61
+ issues: string[];
62
+ };
63
+ export declare function inferX402NetworkNamespace(network: string): X402NetworkNamespace;
64
+ export declare function validateX402ChainNeutralGatewayProfile(profile: X402ChainNeutralGatewayProfile): X402ChainNeutralGatewayProfileReport;
65
+ export declare function buildAgentPayChainNeutralGatewayProfile(): X402ChainNeutralGatewayProfile;
66
+ //# sourceMappingURL=x402-chain-neutral-gateway-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-chain-neutral-gateway-profile.d.ts","sourceRoot":"","sources":["../../src/utils/x402-chain-neutral-gateway-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;AAEjF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtC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AA8B,GACtC,oCAAoC,CAmDtC;AAED,wBAAgB,uCAAuC,IAAI,8BAA8B,CA6CxF"}
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ /**
3
+ * Chain-neutral x402 gateway profile helpers.
4
+ *
5
+ * Paid MCP discovery is moving from one Base endpoint to profile documents that
6
+ * describe every supported payment rail, settlement/facilitator boundary,
7
+ * trial/refund policy, and directory manifest path. These helpers validate that
8
+ * profile shape without assuming every x402 payment rail is EVM-compatible.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.inferX402NetworkNamespace = inferX402NetworkNamespace;
12
+ exports.validateX402ChainNeutralGatewayProfile = validateX402ChainNeutralGatewayProfile;
13
+ exports.buildAgentPayChainNeutralGatewayProfile = buildAgentPayChainNeutralGatewayProfile;
14
+ const CAIP2_PREFIX_RE = /^([a-z0-9-]+):(.+)$/i;
15
+ function inferX402NetworkNamespace(network) {
16
+ const match = network.match(CAIP2_PREFIX_RE);
17
+ if (!match)
18
+ return 'other';
19
+ const namespace = match[1].toLowerCase();
20
+ if (namespace === 'eip155')
21
+ return 'eip155';
22
+ if (namespace === 'solana')
23
+ return 'solana';
24
+ if (namespace === 'tvm')
25
+ return 'tvm';
26
+ if (namespace === 'ton')
27
+ return 'ton';
28
+ return 'other';
29
+ }
30
+ function isHttpsUrl(value) {
31
+ try {
32
+ return new URL(value).protocol === 'https:';
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }
38
+ function unique(values) {
39
+ return Array.from(new Set(values));
40
+ }
41
+ function validateX402ChainNeutralGatewayProfile(profile) {
42
+ const issues = [];
43
+ const namespaces = unique(profile.networks.map((network) => network.namespace ?? inferX402NetworkNamespace(network.network)));
44
+ const hasEvmNetwork = namespaces.includes('eip155');
45
+ const hasNonEvmNetwork = namespaces.some((namespace) => namespace !== 'eip155');
46
+ if (!profile.serviceName.trim())
47
+ issues.push('serviceName is required');
48
+ if (profile.paymentHeader !== 'Payment-Signature')
49
+ issues.push('paymentHeader must be Payment-Signature');
50
+ if (profile.receiptHeader !== 'payment-response')
51
+ issues.push('receiptHeader must be payment-response');
52
+ if (profile.networks.length === 0)
53
+ issues.push('at least one supported network descriptor is required');
54
+ for (const [index, network] of profile.networks.entries()) {
55
+ const namespace = network.namespace ?? inferX402NetworkNamespace(network.network);
56
+ if (!network.name.trim())
57
+ issues.push(`networks[${index}].name is required`);
58
+ if (namespace === 'other')
59
+ issues.push(`networks[${index}].network should use a known CAIP-2 namespace`);
60
+ if (!isHttpsUrl(network.gateway))
61
+ issues.push(`networks[${index}].gateway must be an https URL`);
62
+ }
63
+ const manifestUrls = [
64
+ profile.manifests.wellKnownX402,
65
+ profile.manifests.glama,
66
+ profile.manifests.smithery,
67
+ profile.manifests.mcpCatalog,
68
+ profile.manifests.openapi,
69
+ profile.manifests.llmsTxt,
70
+ ].filter((value) => Boolean(value));
71
+ if (!isHttpsUrl(profile.manifests.wellKnownX402))
72
+ issues.push('manifests.wellKnownX402 must be an https URL');
73
+ if (manifestUrls.some((url) => !isHttpsUrl(url)))
74
+ issues.push('all directory manifest URLs must use https');
75
+ const hasDirectoryManifests = Boolean(profile.manifests.wellKnownX402 && (profile.manifests.glama || profile.manifests.smithery || profile.manifests.mcpCatalog));
76
+ const hasExplicitTrialPolicy = typeof profile.trial.enabled === 'boolean' && Boolean(profile.trial.description.trim());
77
+ const hasExplicitRefundPolicy = typeof profile.refund.supported === 'boolean' && Boolean(profile.refund.description.trim()) && profile.refund.mode !== undefined;
78
+ const hasSettlementMetadata = Boolean(profile.settlement.description.trim()) && Boolean(profile.facilitator || profile.settlement.custody === 'non-custodial');
79
+ if (!hasDirectoryManifests)
80
+ issues.push('profile must include .well-known/x402 plus Glama, Smithery, or MCP catalog metadata');
81
+ if (!hasExplicitTrialPolicy)
82
+ issues.push('trial policy must be explicit, including no-trial cases');
83
+ if (!hasExplicitRefundPolicy)
84
+ issues.push('refund policy must be explicit, including no-refund cases');
85
+ if (!hasSettlementMetadata)
86
+ issues.push('settlement metadata must identify custody or facilitator boundary');
87
+ return {
88
+ serviceName: profile.serviceName,
89
+ networkNamespaces: namespaces,
90
+ hasEvmNetwork,
91
+ hasNonEvmNetwork,
92
+ hasDirectoryManifests,
93
+ hasExplicitTrialPolicy,
94
+ hasExplicitRefundPolicy,
95
+ hasSettlementMetadata,
96
+ issues,
97
+ };
98
+ }
99
+ function buildAgentPayChainNeutralGatewayProfile() {
100
+ return {
101
+ serviceName: 'AgentPay MCP',
102
+ x402Version: '2.11-compatible',
103
+ paymentHeader: 'Payment-Signature',
104
+ receiptHeader: 'payment-response',
105
+ networks: [
106
+ {
107
+ network: 'eip155:8453',
108
+ name: 'Base mainnet',
109
+ gateway: 'https://www.npmjs.com/package/agentpay-mcp',
110
+ namespace: 'eip155',
111
+ settlementAsset: 'USDC',
112
+ settlementChainId: 8453,
113
+ notes: 'Current production x402 signing path for AgentPay MCP.',
114
+ },
115
+ {
116
+ network: 'solana:extension-point',
117
+ name: 'Solana extension point',
118
+ gateway: 'https://github.com/up2itnow0822/agentpay-mcp/blob/main/docs/x402-chain-neutral-gateway-profile.md',
119
+ namespace: 'solana',
120
+ notes: 'Documented as fail-closed until Solana signing, asset, facilitator, receipt, and refund semantics are deliberately implemented.',
121
+ },
122
+ ],
123
+ settlement: {
124
+ custody: 'non-custodial',
125
+ description: 'AgentPay signs only after local policy approval. New non-EVM rails must preserve non-custodial signing and audit rows before support is advertised.',
126
+ },
127
+ trial: {
128
+ enabled: false,
129
+ description: 'AgentPay does not advertise free trials. Buyers should set explicit per-call and daily caps before signing.',
130
+ },
131
+ refund: {
132
+ supported: false,
133
+ mode: 'none',
134
+ description: 'AgentPay treats refunds as provider-specific settlement events that must be captured in receipts before buyer agents rely on them.',
135
+ },
136
+ manifests: {
137
+ wellKnownX402: 'https://github.com/up2itnow0822/agentpay-mcp/blob/main/docs/x402-chain-neutral-gateway-profile.md',
138
+ glama: 'https://glama.ai/mcp/servers/up2itnow0822/claw-pay-mcp',
139
+ smithery: 'https://github.com/up2itnow0822/agentpay-mcp/blob/main/smithery.yaml',
140
+ mcpCatalog: 'https://github.com/up2itnow0822/agentpay-mcp/blob/main/docs/mcp-registry-listing.json',
141
+ llmsTxt: 'https://github.com/up2itnow0822/agentpay-mcp/blob/main/llms.txt',
142
+ },
143
+ };
144
+ }
145
+ //# sourceMappingURL=x402-chain-neutral-gateway-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-chain-neutral-gateway-profile.js","sourceRoot":"","sources":["../../src/utils/x402-chain-neutral-gateway-profile.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAiEH,8DASC;AAcD,wFAqDC;AAED,0FA6CC;AA7HD,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAE/C,SAAgB,yBAAyB,CAAC,OAAe;IACvD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC3B,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACzC,IAAI,SAAS,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC5C,IAAI,SAAS,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC5C,IAAI,SAAS,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,SAAS,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAI,MAAW;IAC5B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,C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;gBAC5G,SAAS,EAAE,QAAQ;gBACnB,KAAK,EAAE,iIAAiI;aACzI;SACF;QACD,UAAU,EAAE;YACV,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,qJAAqJ;SACnK;QACD,KAAK,EAAE;YACL,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,6GAA6G;SAC3H;QACD,MAAM,EAAE;YACN,SAAS,EAAE,KAAK;YAChB,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,oIAAoI;SAClJ;QACD,SAAS,EAAE;YACT,aAAa,EAAE,mGAAmG;YAClH,KAAK,EAAE,wDAAwD;YAC/D,QAAQ,EAAE,sEAAsE;YAChF,UAAU,EAAE,uFAAuF;YACnG,OAAO,EAAE,iEAAiE;SAC3E;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Dynamic paid MCP manifest drift helpers.
3
+ *
4
+ * Paid MCP gateways can change discovery metadata during launch week without a
5
+ * package version bump. Buyers need to validate the live .well-known/x402
6
+ * snapshot before routing, not trust a launch article or stale directory card.
7
+ */
8
+ export type DriftSeverity = 'info' | 'warning' | 'critical';
9
+ export type DriftFinding = {
10
+ severity: DriftSeverity;
11
+ field: string;
12
+ message: string;
13
+ };
14
+ export type PaidMcpNetworkDescriptor = {
15
+ network: string;
16
+ name: string;
17
+ gateway: string;
18
+ };
19
+ export type PaidMcpTrialPolicySnapshot = {
20
+ enabled: boolean;
21
+ description: string;
22
+ };
23
+ export type PaidMcpPricingSnapshot = {
24
+ endpointCount: number;
25
+ endpointsWithPrice: number;
26
+ endpointsWithPriceAtomic: number;
27
+ minimumPriceUsd?: string;
28
+ distinctPrices: string[];
29
+ };
30
+ export type PaidMcpDirectorySnapshot = {
31
+ wellKnownX402: string;
32
+ openapi?: string;
33
+ documentation?: string;
34
+ mcpCatalog?: string;
35
+ frameworks: Record<string, string>;
36
+ };
37
+ export type DynamicPaidMcpManifestSnapshot = {
38
+ snapshotId: string;
39
+ sourceUrl: string;
40
+ capturedAt: string;
41
+ commitSha?: string;
42
+ x402Version: number | string;
43
+ organization: string;
44
+ primaryNetwork: string;
45
+ supportedNetworks: PaidMcpNetworkDescriptor[];
46
+ facilitator?: string;
47
+ hasPayTo: boolean;
48
+ capabilities: string[];
49
+ mcp: {
50
+ totalTools: number;
51
+ totalServices?: number;
52
+ protocol?: string;
53
+ catalog?: string;
54
+ };
55
+ trial: PaidMcpTrialPolicySnapshot;
56
+ pricing: PaidMcpPricingSnapshot;
57
+ directories: PaidMcpDirectorySnapshot;
58
+ };
59
+ export type DynamicPaidMcpManifestValidationOptions = {
60
+ now?: Date;
61
+ maxSnapshotAgeHours?: number;
62
+ };
63
+ export type DynamicPaidMcpManifestValidationReport = {
64
+ snapshotId: string;
65
+ ageHours: number;
66
+ stale: boolean;
67
+ hasSupportedNetworks: boolean;
68
+ hasPricingClarity: boolean;
69
+ hasTrialPolicyClarity: boolean;
70
+ hasDirectoryEndpointFreshness: boolean;
71
+ findings: DriftFinding[];
72
+ };
73
+ export type DynamicPaidMcpManifestDriftReport = {
74
+ fromSnapshotId: string;
75
+ toSnapshotId: string;
76
+ changedFields: string[];
77
+ findings: DriftFinding[];
78
+ };
79
+ export declare function validateDynamicPaidMcpManifestSnapshot(snapshot: DynamicPaidMcpManifestSnapshot, options?: DynamicPaidMcpManifestValidationOptions): DynamicPaidMcpManifestValidationReport;
80
+ export declare function compareDynamicPaidMcpManifestSnapshots(before: DynamicPaidMcpManifestSnapshot, after: DynamicPaidMcpManifestSnapshot): DynamicPaidMcpManifestDriftReport;
81
+ export declare function assertNoStaticPaidMcpManifestAssumptions(baseline: DynamicPaidMcpManifestSnapshot, latest: DynamicPaidMcpManifestSnapshot): DynamicPaidMcpManifestDriftReport;
82
+ //# sourceMappingURL=x402-dynamic-paid-mcp-manifest-drift.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-dynamic-paid-mcp-manifest-drift.d.ts","sourceRoot":"","sources":["../../src/utils/x402-dynamic-paid-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QAAQ,EAAE,8BAA8B,EACxC,MAAM,EAAE,8BAA8B,GACrC,iCAAiC,CAOnC"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ /**
3
+ * Dynamic paid MCP manifest drift helpers.
4
+ *
5
+ * Paid MCP gateways can change discovery metadata during launch week without a
6
+ * package version bump. Buyers need to validate the live .well-known/x402
7
+ * snapshot before routing, not trust a launch article or stale directory card.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.validateDynamicPaidMcpManifestSnapshot = validateDynamicPaidMcpManifestSnapshot;
11
+ exports.compareDynamicPaidMcpManifestSnapshots = compareDynamicPaidMcpManifestSnapshots;
12
+ exports.assertNoStaticPaidMcpManifestAssumptions = assertNoStaticPaidMcpManifestAssumptions;
13
+ const DEFAULT_MAX_SNAPSHOT_AGE_HOURS = 24;
14
+ function isHttpsUrl(value) {
15
+ if (!value)
16
+ return false;
17
+ try {
18
+ return new URL(value).protocol === 'https:';
19
+ }
20
+ catch {
21
+ return false;
22
+ }
23
+ }
24
+ function hoursBetween(later, earlier) {
25
+ return Math.max(0, (later.getTime() - earlier.getTime()) / (1000 * 60 * 60));
26
+ }
27
+ function pushFinding(findings, severity, field, message) {
28
+ findings.push({ severity, field, message });
29
+ }
30
+ function validateDynamicPaidMcpManifestSnapshot(snapshot, options = {}) {
31
+ const findings = [];
32
+ const now = options.now ?? new Date();
33
+ const maxSnapshotAgeHours = options.maxSnapshotAgeHours ?? DEFAULT_MAX_SNAPSHOT_AGE_HOURS;
34
+ const capturedAt = new Date(snapshot.capturedAt);
35
+ const ageHours = Number.isFinite(capturedAt.getTime()) ? hoursBetween(now, capturedAt) : Number.POSITIVE_INFINITY;
36
+ const stale = ageHours > maxSnapshotAgeHours;
37
+ if (!snapshot.snapshotId.trim())
38
+ pushFinding(findings, 'critical', 'snapshotId', 'snapshotId is required');
39
+ if (!isHttpsUrl(snapshot.sourceUrl))
40
+ pushFinding(findings, 'critical', 'sourceUrl', 'sourceUrl must be an https URL');
41
+ if (!Number.isFinite(capturedAt.getTime()))
42
+ pushFinding(findings, 'critical', 'capturedAt', 'capturedAt must be an ISO timestamp');
43
+ if (stale)
44
+ pushFinding(findings, 'warning', 'capturedAt', `snapshot is older than ${maxSnapshotAgeHours} hours; refresh before buyer routing`);
45
+ if (!snapshot.organization.trim())
46
+ pushFinding(findings, 'critical', 'organization', 'organization is required');
47
+ if (!snapshot.primaryNetwork.trim())
48
+ pushFinding(findings, 'critical', 'primaryNetwork', 'primaryNetwork is required');
49
+ const hasSupportedNetworks = snapshot.supportedNetworks.length > 0;
50
+ if (!hasSupportedNetworks)
51
+ pushFinding(findings, 'critical', 'supportedNetworks', 'at least one supported network descriptor is required');
52
+ for (const [index, network] of snapshot.supportedNetworks.entries()) {
53
+ if (!network.network.trim())
54
+ pushFinding(findings, 'critical', `supportedNetworks[${index}].network`, 'network is required');
55
+ if (!network.name.trim())
56
+ pushFinding(findings, 'warning', `supportedNetworks[${index}].name`, 'network name should be explicit');
57
+ if (!isHttpsUrl(network.gateway))
58
+ pushFinding(findings, 'critical', `supportedNetworks[${index}].gateway`, 'gateway must be an https URL');
59
+ }
60
+ if (!snapshot.facilitator)
61
+ pushFinding(findings, 'warning', 'facilitator', 'facilitator metadata is missing');
62
+ if (!snapshot.hasPayTo)
63
+ pushFinding(findings, 'critical', 'hasPayTo', 'payTo recipient must be present before payment');
64
+ if (snapshot.mcp.totalTools <= 0)
65
+ pushFinding(findings, 'critical', 'mcp.totalTools', 'totalTools must be greater than zero');
66
+ if (snapshot.mcp.totalServices !== undefined && snapshot.mcp.totalServices <= 0) {
67
+ pushFinding(findings, 'warning', 'mcp.totalServices', 'totalServices should be greater than zero when present');
68
+ }
69
+ if (snapshot.pricing.endpointCount > 0 && snapshot.pricing.endpointCount !== snapshot.mcp.totalTools) {
70
+ pushFinding(findings, 'info', 'pricing.endpointCount', 'priced HTTP endpoint count differs from MCP totalTools; do not assume a one-to-one mapping');
71
+ }
72
+ const hasPricingClarity = snapshot.pricing.endpointCount > 0 &&
73
+ snapshot.pricing.endpointsWithPrice === snapshot.pricing.endpointCount &&
74
+ snapshot.pricing.endpointsWithPriceAtomic === snapshot.pricing.endpointCount &&
75
+ snapshot.pricing.distinctPrices.length > 0;
76
+ if (!hasPricingClarity) {
77
+ pushFinding(findings, 'critical', 'pricing', 'pricing fields must be present for every paid endpoint in the snapshot');
78
+ }
79
+ const hasTrialPolicyClarity = typeof snapshot.trial.enabled === 'boolean' && Boolean(snapshot.trial.description.trim());
80
+ if (!hasTrialPolicyClarity) {
81
+ pushFinding(findings, 'critical', 'trial', 'trial policy must be explicit, including no-trial cases');
82
+ }
83
+ if (!snapshot.trial.enabled && snapshot.capabilities.some((capability) => capability.toLowerCase().includes('free_trial'))) {
84
+ pushFinding(findings, 'warning', 'capabilities.free_trial', 'capabilities still advertises free_trial while trial.enabled is false; buyer agents should trust the explicit trial object and refresh directory cards');
85
+ }
86
+ if (snapshot.trial.enabled && /0 free|no free/i.test(snapshot.trial.description)) {
87
+ pushFinding(findings, 'critical', 'trial.description', 'trial.enabled conflicts with no-trial description');
88
+ }
89
+ const frameworkUrls = Object.values(snapshot.directories.frameworks);
90
+ const hasDirectoryEndpointFreshness = isHttpsUrl(snapshot.directories.wellKnownX402) &&
91
+ isHttpsUrl(snapshot.directories.mcpCatalog) &&
92
+ isHttpsUrl(snapshot.directories.openapi) &&
93
+ isHttpsUrl(snapshot.directories.documentation) &&
94
+ frameworkUrls.length > 0 &&
95
+ frameworkUrls.every(isHttpsUrl);
96
+ if (!hasDirectoryEndpointFreshness) {
97
+ pushFinding(findings, 'critical', 'directories', 'well-known, MCP catalog, OpenAPI, documentation, and framework endpoints must be https URLs');
98
+ }
99
+ return {
100
+ snapshotId: snapshot.snapshotId,
101
+ ageHours,
102
+ stale,
103
+ hasSupportedNetworks,
104
+ hasPricingClarity,
105
+ hasTrialPolicyClarity,
106
+ hasDirectoryEndpointFreshness,
107
+ findings,
108
+ };
109
+ }
110
+ function changed(field, before, after, changedFields) {
111
+ const didChange = JSON.stringify(before) !== JSON.stringify(after);
112
+ if (didChange)
113
+ changedFields.push(field);
114
+ return didChange;
115
+ }
116
+ function compareDynamicPaidMcpManifestSnapshots(before, after) {
117
+ const changedFields = [];
118
+ const findings = [];
119
+ if (changed('mcp.totalTools', before.mcp.totalTools, after.mcp.totalTools, changedFields)) {
120
+ pushFinding(findings, 'warning', 'mcp.totalTools', `tool count changed from ${before.mcp.totalTools} to ${after.mcp.totalTools}`);
121
+ }
122
+ if (changed('mcp.totalServices', before.mcp.totalServices, after.mcp.totalServices, changedFields)) {
123
+ pushFinding(findings, 'warning', 'mcp.totalServices', `service count changed from ${before.mcp.totalServices ?? 'unknown'} to ${after.mcp.totalServices ?? 'unknown'}`);
124
+ }
125
+ if (changed('trial.enabled', before.trial.enabled, after.trial.enabled, changedFields)) {
126
+ pushFinding(findings, 'critical', 'trial.enabled', `trial policy changed from ${before.trial.enabled} to ${after.trial.enabled}`);
127
+ }
128
+ if (changed('trial.description', before.trial.description, after.trial.description, changedFields)) {
129
+ pushFinding(findings, 'warning', 'trial.description', 'trial policy description changed; refresh buyer-facing directory metadata');
130
+ }
131
+ if (changed('pricing.distinctPrices', before.pricing.distinctPrices, after.pricing.distinctPrices, changedFields)) {
132
+ pushFinding(findings, 'warning', 'pricing.distinctPrices', 'advertised price surface changed');
133
+ }
134
+ if (changed('supportedNetworks', before.supportedNetworks, after.supportedNetworks, changedFields)) {
135
+ pushFinding(findings, 'warning', 'supportedNetworks', 'supported network descriptors changed');
136
+ }
137
+ if (changed('directories', before.directories, after.directories, changedFields)) {
138
+ pushFinding(findings, 'warning', 'directories', 'directory or framework endpoint URLs changed');
139
+ }
140
+ if (changed('commitSha', before.commitSha, after.commitSha, changedFields)) {
141
+ pushFinding(findings, 'info', 'commitSha', 'source commit changed; use the newer snapshot for routing');
142
+ }
143
+ return {
144
+ fromSnapshotId: before.snapshotId,
145
+ toSnapshotId: after.snapshotId,
146
+ changedFields,
147
+ findings,
148
+ };
149
+ }
150
+ function assertNoStaticPaidMcpManifestAssumptions(baseline, latest) {
151
+ const drift = compareDynamicPaidMcpManifestSnapshots(baseline, latest);
152
+ const changedCriticalFields = new Set(drift.changedFields);
153
+ if (changedCriticalFields.has('mcp.totalTools') || changedCriticalFields.has('trial.enabled') || changedCriticalFields.has('directories')) {
154
+ return drift;
155
+ }
156
+ return drift;
157
+ }
158
+ //# sourceMappingURL=x402-dynamic-paid-mcp-manifest-drift.js.map