@apify/actors-mcp-server 0.9.16-beta.3 → 0.9.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 (253) hide show
  1. package/dist/actor/const.js +4 -1
  2. package/dist/actor/const.js.map +1 -1
  3. package/dist/actor/server.d.ts.map +1 -1
  4. package/dist/actor/server.js +11 -9
  5. package/dist/actor/server.js.map +1 -1
  6. package/dist/actor/types.js +4 -1
  7. package/dist/actor/types.js.map +1 -1
  8. package/dist/actor/utils.js +4 -1
  9. package/dist/actor/utils.js.map +1 -1
  10. package/dist/apify_client.d.ts +3 -13
  11. package/dist/apify_client.d.ts.map +1 -1
  12. package/dist/apify_client.js +8 -19
  13. package/dist/apify_client.js.map +1 -1
  14. package/dist/const.d.ts +1 -0
  15. package/dist/const.d.ts.map +1 -1
  16. package/dist/const.js +6 -1
  17. package/dist/const.js.map +1 -1
  18. package/dist/errors.js +4 -1
  19. package/dist/errors.js.map +1 -1
  20. package/dist/index.js +4 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/index_internals.d.ts +7 -1
  23. package/dist/index_internals.d.ts.map +1 -1
  24. package/dist/index_internals.js +10 -2
  25. package/dist/index_internals.js.map +1 -1
  26. package/dist/input.js +4 -1
  27. package/dist/input.js.map +1 -1
  28. package/dist/instrument.js +4 -1
  29. package/dist/instrument.js.map +1 -1
  30. package/dist/main.js +4 -1
  31. package/dist/main.js.map +1 -1
  32. package/dist/mcp/actors.js +4 -1
  33. package/dist/mcp/actors.js.map +1 -1
  34. package/dist/mcp/client.js +4 -1
  35. package/dist/mcp/client.js.map +1 -1
  36. package/dist/mcp/const.js +4 -1
  37. package/dist/mcp/const.js.map +1 -1
  38. package/dist/mcp/proxy.js +4 -1
  39. package/dist/mcp/proxy.js.map +1 -1
  40. package/dist/mcp/server.d.ts.map +1 -1
  41. package/dist/mcp/server.js +76 -46
  42. package/dist/mcp/server.js.map +1 -1
  43. package/dist/mcp/utils.js +4 -1
  44. package/dist/mcp/utils.js.map +1 -1
  45. package/dist/payments/helpers.d.ts +39 -0
  46. package/dist/payments/helpers.d.ts.map +1 -0
  47. package/dist/payments/helpers.js +45 -0
  48. package/dist/payments/helpers.js.map +1 -0
  49. package/dist/payments/index.d.ts +7 -0
  50. package/dist/payments/index.d.ts.map +1 -0
  51. package/dist/payments/index.js +8 -0
  52. package/dist/payments/index.js.map +1 -0
  53. package/dist/payments/resolve.d.ts +11 -0
  54. package/dist/payments/resolve.d.ts.map +1 -0
  55. package/dist/payments/resolve.js +24 -0
  56. package/dist/payments/resolve.js.map +1 -0
  57. package/dist/payments/skyfire.d.ts +20 -0
  58. package/dist/payments/skyfire.d.ts.map +1 -0
  59. package/dist/payments/skyfire.js +84 -0
  60. package/dist/payments/skyfire.js.map +1 -0
  61. package/dist/payments/types.d.ts +98 -0
  62. package/dist/payments/types.d.ts.map +1 -0
  63. package/dist/payments/types.js +5 -0
  64. package/dist/payments/types.js.map +1 -0
  65. package/dist/payments/x402.d.ts +56 -0
  66. package/dist/payments/x402.d.ts.map +1 -0
  67. package/dist/payments/x402.js +211 -0
  68. package/dist/payments/x402.js.map +1 -0
  69. package/dist/prompts/index.js +4 -1
  70. package/dist/prompts/index.js.map +1 -1
  71. package/dist/prompts/latest_news_on_topic.js +4 -1
  72. package/dist/prompts/latest_news_on_topic.js.map +1 -1
  73. package/dist/resources/resource_service.d.ts +2 -1
  74. package/dist/resources/resource_service.d.ts.map +1 -1
  75. package/dist/resources/resource_service.js +13 -8
  76. package/dist/resources/resource_service.js.map +1 -1
  77. package/dist/resources/widgets.js +4 -1
  78. package/dist/resources/widgets.js.map +1 -1
  79. package/dist/server_card.js +4 -1
  80. package/dist/server_card.js.map +1 -1
  81. package/dist/state.js +4 -1
  82. package/dist/state.js.map +1 -1
  83. package/dist/stdio.js +4 -1
  84. package/dist/stdio.js.map +1 -1
  85. package/dist/telemetry.js +4 -1
  86. package/dist/telemetry.js.map +1 -1
  87. package/dist/tools/build.js +4 -1
  88. package/dist/tools/build.js.map +1 -1
  89. package/dist/tools/categories.js +4 -1
  90. package/dist/tools/categories.js.map +1 -1
  91. package/dist/tools/common/abort_actor_run.d.ts.map +1 -1
  92. package/dist/tools/common/abort_actor_run.js +7 -9
  93. package/dist/tools/common/abort_actor_run.js.map +1 -1
  94. package/dist/tools/common/add_actor.js +4 -1
  95. package/dist/tools/common/add_actor.js.map +1 -1
  96. package/dist/tools/common/dataset_collection.js +4 -1
  97. package/dist/tools/common/dataset_collection.js.map +1 -1
  98. package/dist/tools/common/fetch_apify_docs.js +4 -1
  99. package/dist/tools/common/fetch_apify_docs.js.map +1 -1
  100. package/dist/tools/common/get_actor_output.d.ts.map +1 -1
  101. package/dist/tools/common/get_actor_output.js +7 -9
  102. package/dist/tools/common/get_actor_output.js.map +1 -1
  103. package/dist/tools/common/get_actor_run_log.d.ts.map +1 -1
  104. package/dist/tools/common/get_actor_run_log.js +7 -9
  105. package/dist/tools/common/get_actor_run_log.js.map +1 -1
  106. package/dist/tools/common/get_dataset.d.ts.map +1 -1
  107. package/dist/tools/common/get_dataset.js +7 -9
  108. package/dist/tools/common/get_dataset.js.map +1 -1
  109. package/dist/tools/common/get_dataset_items.d.ts.map +1 -1
  110. package/dist/tools/common/get_dataset_items.js +7 -9
  111. package/dist/tools/common/get_dataset_items.js.map +1 -1
  112. package/dist/tools/common/get_dataset_schema.d.ts.map +1 -1
  113. package/dist/tools/common/get_dataset_schema.js +7 -9
  114. package/dist/tools/common/get_dataset_schema.js.map +1 -1
  115. package/dist/tools/common/get_key_value_store.d.ts.map +1 -1
  116. package/dist/tools/common/get_key_value_store.js +7 -9
  117. package/dist/tools/common/get_key_value_store.js.map +1 -1
  118. package/dist/tools/common/get_key_value_store_keys.d.ts.map +1 -1
  119. package/dist/tools/common/get_key_value_store_keys.js +7 -9
  120. package/dist/tools/common/get_key_value_store_keys.js.map +1 -1
  121. package/dist/tools/common/get_key_value_store_record.d.ts.map +1 -1
  122. package/dist/tools/common/get_key_value_store_record.js +7 -9
  123. package/dist/tools/common/get_key_value_store_record.js.map +1 -1
  124. package/dist/tools/common/key_value_store_collection.js +4 -1
  125. package/dist/tools/common/key_value_store_collection.js.map +1 -1
  126. package/dist/tools/common/run_collection.js +4 -1
  127. package/dist/tools/common/run_collection.js.map +1 -1
  128. package/dist/tools/common/search_apify_docs.js +4 -1
  129. package/dist/tools/common/search_apify_docs.js.map +1 -1
  130. package/dist/tools/core/actor_execution.js +4 -1
  131. package/dist/tools/core/actor_execution.js.map +1 -1
  132. package/dist/tools/core/actor_response.js +4 -1
  133. package/dist/tools/core/actor_response.js.map +1 -1
  134. package/dist/tools/core/actor_tools_factory.d.ts.map +1 -1
  135. package/dist/tools/core/actor_tools_factory.js +7 -3
  136. package/dist/tools/core/actor_tools_factory.js.map +1 -1
  137. package/dist/tools/core/call_actor_common.d.ts +1 -4
  138. package/dist/tools/core/call_actor_common.d.ts.map +1 -1
  139. package/dist/tools/core/call_actor_common.js +13 -15
  140. package/dist/tools/core/call_actor_common.js.map +1 -1
  141. package/dist/tools/core/fetch_actor_details_common.js +4 -1
  142. package/dist/tools/core/fetch_actor_details_common.js.map +1 -1
  143. package/dist/tools/core/get_actor_run_common.js +6 -3
  144. package/dist/tools/core/get_actor_run_common.js.map +1 -1
  145. package/dist/tools/core/search_actors_common.js +4 -1
  146. package/dist/tools/core/search_actors_common.js.map +1 -1
  147. package/dist/tools/default/actor_executor.js +4 -1
  148. package/dist/tools/default/actor_executor.js.map +1 -1
  149. package/dist/tools/default/call_actor.d.ts.map +1 -1
  150. package/dist/tools/default/call_actor.js +6 -4
  151. package/dist/tools/default/call_actor.js.map +1 -1
  152. package/dist/tools/default/fetch_actor_details.js +5 -2
  153. package/dist/tools/default/fetch_actor_details.js.map +1 -1
  154. package/dist/tools/default/get_actor_run.d.ts.map +1 -1
  155. package/dist/tools/default/get_actor_run.js +5 -4
  156. package/dist/tools/default/get_actor_run.js.map +1 -1
  157. package/dist/tools/default/search_actors.js +5 -2
  158. package/dist/tools/default/search_actors.js.map +1 -1
  159. package/dist/tools/index.js +4 -1
  160. package/dist/tools/index.js.map +1 -1
  161. package/dist/tools/openai/actor_executor.js +4 -1
  162. package/dist/tools/openai/actor_executor.js.map +1 -1
  163. package/dist/tools/openai/call_actor.d.ts.map +1 -1
  164. package/dist/tools/openai/call_actor.js +6 -4
  165. package/dist/tools/openai/call_actor.js.map +1 -1
  166. package/dist/tools/openai/fetch_actor_details.js +4 -1
  167. package/dist/tools/openai/fetch_actor_details.js.map +1 -1
  168. package/dist/tools/openai/fetch_actor_details_internal.js +5 -2
  169. package/dist/tools/openai/fetch_actor_details_internal.js.map +1 -1
  170. package/dist/tools/openai/get_actor_run.d.ts.map +1 -1
  171. package/dist/tools/openai/get_actor_run.js +5 -4
  172. package/dist/tools/openai/get_actor_run.js.map +1 -1
  173. package/dist/tools/openai/search_actors.js +5 -2
  174. package/dist/tools/openai/search_actors.js.map +1 -1
  175. package/dist/tools/openai/search_actors_internal.js +5 -2
  176. package/dist/tools/openai/search_actors_internal.js.map +1 -1
  177. package/dist/tools/structured_output_schemas.js +4 -1
  178. package/dist/tools/structured_output_schemas.js.map +1 -1
  179. package/dist/tools/utils.js +4 -1
  180. package/dist/tools/utils.js.map +1 -1
  181. package/dist/tsconfig.tsbuildinfo +1 -1
  182. package/dist/types.d.ts +14 -8
  183. package/dist/types.d.ts.map +1 -1
  184. package/dist/types.js +4 -1
  185. package/dist/types.js.map +1 -1
  186. package/dist/utils/actor.js +4 -1
  187. package/dist/utils/actor.js.map +1 -1
  188. package/dist/utils/actor_card.js +4 -1
  189. package/dist/utils/actor_card.js.map +1 -1
  190. package/dist/utils/actor_details.d.ts +3 -2
  191. package/dist/utils/actor_details.d.ts.map +1 -1
  192. package/dist/utils/actor_details.js +10 -7
  193. package/dist/utils/actor_details.js.map +1 -1
  194. package/dist/utils/actor_search.d.ts +2 -1
  195. package/dist/utils/actor_search.d.ts.map +1 -1
  196. package/dist/utils/actor_search.js +6 -3
  197. package/dist/utils/actor_search.js.map +1 -1
  198. package/dist/utils/ajv.js +4 -1
  199. package/dist/utils/ajv.js.map +1 -1
  200. package/dist/utils/apify_docs.js +4 -1
  201. package/dist/utils/apify_docs.js.map +1 -1
  202. package/dist/utils/apify_properties.js +4 -1
  203. package/dist/utils/apify_properties.js.map +1 -1
  204. package/dist/utils/auth.js +4 -1
  205. package/dist/utils/auth.js.map +1 -1
  206. package/dist/utils/generic.js +4 -1
  207. package/dist/utils/generic.js.map +1 -1
  208. package/dist/utils/logging.js +4 -1
  209. package/dist/utils/logging.js.map +1 -1
  210. package/dist/utils/mcp.js +4 -1
  211. package/dist/utils/mcp.js.map +1 -1
  212. package/dist/utils/mcp_clients.js +4 -1
  213. package/dist/utils/mcp_clients.js.map +1 -1
  214. package/dist/utils/payment_errors.d.ts +27 -0
  215. package/dist/utils/payment_errors.d.ts.map +1 -0
  216. package/dist/utils/payment_errors.js +93 -0
  217. package/dist/utils/payment_errors.js.map +1 -0
  218. package/dist/utils/pricing_info.js +4 -1
  219. package/dist/utils/pricing_info.js.map +1 -1
  220. package/dist/utils/progress.js +4 -1
  221. package/dist/utils/progress.js.map +1 -1
  222. package/dist/utils/schema_generation.js +4 -1
  223. package/dist/utils/schema_generation.js.map +1 -1
  224. package/dist/utils/server-instructions/common.js +4 -1
  225. package/dist/utils/server-instructions/common.js.map +1 -1
  226. package/dist/utils/server-instructions/default.js +4 -1
  227. package/dist/utils/server-instructions/default.js.map +1 -1
  228. package/dist/utils/server-instructions/index.js +4 -1
  229. package/dist/utils/server-instructions/index.js.map +1 -1
  230. package/dist/utils/server-instructions/openai.js +4 -1
  231. package/dist/utils/server-instructions/openai.js.map +1 -1
  232. package/dist/utils/tool_categories_helpers.js +4 -1
  233. package/dist/utils/tool_categories_helpers.js.map +1 -1
  234. package/dist/utils/tool_status.js +4 -1
  235. package/dist/utils/tool_status.js.map +1 -1
  236. package/dist/utils/tools.js +4 -1
  237. package/dist/utils/tools.js.map +1 -1
  238. package/dist/utils/tools_loader.js +4 -1
  239. package/dist/utils/tools_loader.js.map +1 -1
  240. package/dist/utils/ttl_lru.js +4 -1
  241. package/dist/utils/ttl_lru.js.map +1 -1
  242. package/dist/utils/userid_cache.js +4 -1
  243. package/dist/utils/userid_cache.js.map +1 -1
  244. package/dist/utils/version.js +4 -1
  245. package/dist/utils/version.js.map +1 -1
  246. package/dist/web/dist/actor-detail-widget.js +2 -0
  247. package/dist/web/dist/actor-run-widget.js +2 -0
  248. package/dist/web/dist/search-actors-widget.js +2 -0
  249. package/package.json +2 -1
  250. package/dist/utils/skyfire.d.ts +0 -12
  251. package/dist/utils/skyfire.d.ts.map +0 -1
  252. package/dist/utils/skyfire.js +0 -19
  253. package/dist/utils/skyfire.js.map +0 -1
@@ -0,0 +1,45 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6ad1df9e-967a-5d8a-8965-d27fa4a73d32")}catch(e){}}();
3
+ import { ApifyClient } from '../apify_client.js';
4
+ import { buildPaymentRequiredResponse, registerPaymentRequiredInterceptor } from '../utils/payment_errors.js';
5
+ /**
6
+ * Prepares payment context for a tool call.
7
+ *
8
+ * This helper centralizes all payment processing:
9
+ * 1. Validates payment credentials (for tools with `paymentRequired: true`)
10
+ * 2. Strips payment fields from args (for clean ajv validation and Actor input)
11
+ * 3. Redacts sensitive fields for logging
12
+ * 4. Creates an ApifyClient with payment headers or standard token
13
+ *
14
+ * Call this BEFORE ajv validation so `cleanArgs` can be validated without
15
+ * the `additionalProperties: true` hack.
16
+ */
17
+ export function preparePayment(input) {
18
+ const { provider, tool, args, apifyToken, meta, requestHeaders } = input;
19
+ if (!provider) {
20
+ const client = new ApifyClient({ token: apifyToken });
21
+ registerPaymentRequiredInterceptor(client);
22
+ return {
23
+ cleanArgs: args,
24
+ logArgs: args,
25
+ client,
26
+ };
27
+ }
28
+ const error = tool.paymentRequired ? provider.validatePayment(args, meta, requestHeaders) : null;
29
+ const errorData = error && provider.getPaymentRequiredData ? provider.getPaymentRequiredData() : undefined;
30
+ const cleanArgs = provider.removePaymentFields(args);
31
+ const logArgs = provider.redactForLogging(args);
32
+ const paymentHeaders = provider.getPaymentHeaders(args, meta, requestHeaders);
33
+ const client = Object.keys(paymentHeaders).length > 0
34
+ ? new ApifyClient({ paymentHeaders })
35
+ : new ApifyClient({ token: apifyToken });
36
+ registerPaymentRequiredInterceptor(client);
37
+ return {
38
+ errorResult: error ? buildPaymentRequiredResponse(error, errorData) : undefined,
39
+ cleanArgs,
40
+ logArgs,
41
+ client,
42
+ };
43
+ }
44
+ //# sourceMappingURL=helpers.js.map
45
+ //# debugId=6ad1df9e-967a-5d8a-8965-d27fa4a73d32
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../src/payments/helpers.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,4BAA4B,EAAE,kCAAkC,EAAE,MAAM,4BAA4B,CAAC;AAkB9G;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,KAO9B;IACG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAEzE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACtD,kCAAkC,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO;YACH,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;YACb,MAAM;SACT,CAAC;IACN,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjG,MAAM,SAAS,GAAG,KAAK,IAAI,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,QAAQ,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3G,MAAM,SAAS,GAAG,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEhD,MAAM,cAAc,GAAG,QAAQ,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAC9E,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC;QACjD,CAAC,CAAC,IAAI,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;QACrC,CAAC,CAAC,IAAI,WAAW,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7C,kCAAkC,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAO;QACH,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,4BAA4B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;QAC/E,SAAS;QACT,OAAO;QACP,MAAM;KACT,CAAC;AACN,CAAC","debugId":"6ad1df9e-967a-5d8a-8965-d27fa4a73d32"}
@@ -0,0 +1,7 @@
1
+ export type { PaymentHeaders, PaymentMeta, PaymentProvider, PaymentProviderId, RequestHeaders } from './types.js';
2
+ export { SkyfirePaymentProvider } from './skyfire.js';
3
+ export { X402PaymentProvider } from './x402.js';
4
+ export { resolvePaymentProvider } from './resolve.js';
5
+ export { preparePayment } from './helpers.js';
6
+ export type { PreparePaymentResult } from './helpers.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClH,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eb04c18b-26b0-5d44-8465-c50b580f8d66")}catch(e){}}();
3
+ export { SkyfirePaymentProvider } from './skyfire.js';
4
+ export { X402PaymentProvider } from './x402.js';
5
+ export { resolvePaymentProvider } from './resolve.js';
6
+ export { preparePayment } from './helpers.js';
7
+ //# sourceMappingURL=index.js.map
8
+ //# debugId=eb04c18b-26b0-5d44-8465-c50b580f8d66
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/payments/index.ts"],"sourceRoot":"","names":[],"mappings":";;AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC","debugId":"eb04c18b-26b0-5d44-8465-c50b580f8d66"}
@@ -0,0 +1,11 @@
1
+ import type { PaymentProvider } from './types.js';
2
+ /**
3
+ * Resolves a payment provider from a `?payment=` query parameter value.
4
+ *
5
+ * Some providers require async initialization (e.g., fetching payment requirements
6
+ * from the Apify API), so this function is async.
7
+ *
8
+ * @returns A PaymentProvider instance, or undefined if the value is not a known provider.
9
+ */
10
+ export declare function resolvePaymentProvider(paymentParam: string | null | undefined): Promise<PaymentProvider | undefined>;
11
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/payments/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,YAAY,CAAC;AAGrE;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAU1H"}
@@ -0,0 +1,24 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e790249d-ede4-5b0d-9df7-943880f084da")}catch(e){}}();
3
+ import { SkyfirePaymentProvider } from './skyfire.js';
4
+ import { X402PaymentProvider } from './x402.js';
5
+ /**
6
+ * Resolves a payment provider from a `?payment=` query parameter value.
7
+ *
8
+ * Some providers require async initialization (e.g., fetching payment requirements
9
+ * from the Apify API), so this function is async.
10
+ *
11
+ * @returns A PaymentProvider instance, or undefined if the value is not a known provider.
12
+ */
13
+ export async function resolvePaymentProvider(paymentParam) {
14
+ if (!paymentParam)
15
+ return undefined;
16
+ const providers = {
17
+ skyfire: async () => SkyfirePaymentProvider.create(),
18
+ x402: async () => X402PaymentProvider.create(),
19
+ };
20
+ const factory = providers[paymentParam];
21
+ return factory === null || factory === void 0 ? void 0 : factory();
22
+ }
23
+ //# sourceMappingURL=resolve.js.map
24
+ //# debugId=e790249d-ede4-5b0d-9df7-943880f084da
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sources":["../../src/payments/resolve.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,YAAuC;IAChF,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IAEpC,MAAM,SAAS,GAA8D;QACzE,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,sBAAsB,CAAC,MAAM,EAAE;QACpD,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE;KACjD,CAAC;IAEF,MAAM,OAAO,GAAG,SAAS,CAAC,YAAiC,CAAC,CAAC;IAC7D,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,EAAI,CAAC;AACvB,CAAC","debugId":"e790249d-ede4-5b0d-9df7-943880f084da"}
@@ -0,0 +1,20 @@
1
+ import type { ToolEntry } from '../types.js';
2
+ import type { PaymentHeaders, PaymentProvider } from './types.js';
3
+ /**
4
+ * Skyfire payment provider.
5
+ *
6
+ * Injects `skyfire-pay-id` into eligible tool schemas and forwards the
7
+ * Skyfire PAY JWT token as a header on outbound Apify API requests.
8
+ */
9
+ export declare class SkyfirePaymentProvider implements PaymentProvider {
10
+ readonly id: "skyfire";
11
+ readonly allowsUnauthenticated = true;
12
+ static create(): Promise<SkyfirePaymentProvider>;
13
+ decorateToolSchema(tool: ToolEntry): ToolEntry;
14
+ validatePayment(args: Record<string, unknown>): string | null;
15
+ getPaymentHeaders(args: Record<string, unknown>): PaymentHeaders;
16
+ removePaymentFields(args: Record<string, unknown>): Record<string, unknown>;
17
+ getUsageGuide(): string | null;
18
+ redactForLogging(args: unknown): unknown;
19
+ }
20
+ //# sourceMappingURL=skyfire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skyfire.d.ts","sourceRoot":"","sources":["../../src/payments/skyfire.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlE;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC1D,QAAQ,CAAC,EAAE,EAAG,SAAS,CAAU;IACjC,QAAQ,CAAC,qBAAqB,QAAQ;WAEzB,MAAM,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAItD,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS;IAwB9C,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI;IAO7D,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc;IAWhE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAK3E,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;CAO3C"}
@@ -0,0 +1,84 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7defb7b6-8e7c-5871-b4a2-a7772d722263")}catch(e){}}();
3
+ import { SKYFIRE_PAY_ID_PROPERTY_DESCRIPTION, SKYFIRE_README_CONTENT, SKYFIRE_TOOL_INSTRUCTIONS, } from '../const.js';
4
+ import { redactSkyfirePayId } from '../utils/logging.js';
5
+ import { cloneToolEntry } from '../utils/tools.js';
6
+ const SKYFIRE_PAY_ID_KEY = 'skyfire-pay-id';
7
+ const PAYMENT_PROTOCOL_HEADER = 'x-apify-payment-protocol';
8
+ /**
9
+ * Skyfire payment provider.
10
+ *
11
+ * Injects `skyfire-pay-id` into eligible tool schemas and forwards the
12
+ * Skyfire PAY JWT token as a header on outbound Apify API requests.
13
+ */
14
+ export class SkyfirePaymentProvider {
15
+ constructor() {
16
+ Object.defineProperty(this, "id", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: 'skyfire'
21
+ });
22
+ Object.defineProperty(this, "allowsUnauthenticated", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: true
27
+ });
28
+ }
29
+ static async create() {
30
+ return new SkyfirePaymentProvider();
31
+ }
32
+ decorateToolSchema(tool) {
33
+ if (!tool.paymentRequired)
34
+ return tool;
35
+ const cloned = cloneToolEntry(tool);
36
+ // Append Skyfire instructions to description (idempotent)
37
+ if (cloned.description && !cloned.description.includes(SKYFIRE_TOOL_INSTRUCTIONS)) {
38
+ cloned.description += `\n\n${SKYFIRE_TOOL_INSTRUCTIONS}`;
39
+ }
40
+ // Add skyfire-pay-id property to inputSchema (idempotent)
41
+ if (cloned.inputSchema && 'properties' in cloned.inputSchema) {
42
+ const props = cloned.inputSchema.properties;
43
+ if (!props[SKYFIRE_PAY_ID_KEY]) {
44
+ props[SKYFIRE_PAY_ID_KEY] = {
45
+ type: 'string',
46
+ description: SKYFIRE_PAY_ID_PROPERTY_DESCRIPTION,
47
+ };
48
+ }
49
+ }
50
+ return Object.freeze(cloned);
51
+ }
52
+ validatePayment(args) {
53
+ if (args[SKYFIRE_PAY_ID_KEY] === undefined) {
54
+ return `Missing required "${SKYFIRE_PAY_ID_KEY}" field. Obtain a Skyfire PAY JWT token via the create-pay-token tool and pass it as "${SKYFIRE_PAY_ID_KEY}".`;
55
+ }
56
+ return null;
57
+ }
58
+ getPaymentHeaders(args) {
59
+ const payId = args[SKYFIRE_PAY_ID_KEY];
60
+ if (typeof payId === 'string') {
61
+ return {
62
+ [SKYFIRE_PAY_ID_KEY]: payId,
63
+ [PAYMENT_PROTOCOL_HEADER]: 'skyfire',
64
+ };
65
+ }
66
+ return {};
67
+ }
68
+ removePaymentFields(args) {
69
+ const { [SKYFIRE_PAY_ID_KEY]: _removed, ...rest } = args;
70
+ return rest;
71
+ }
72
+ getUsageGuide() {
73
+ return SKYFIRE_README_CONTENT;
74
+ }
75
+ redactForLogging(args) {
76
+ // TODO: redactSkyfirePayId is still exported and used directly by the internal MCP server repo.
77
+ // Once the internal repo migrates to using `paymentProvider.redactForLogging()`, we should
78
+ // remove the standalone function and centralize the redaction logic entirely inside this provider
79
+ // to make it more maintainable.
80
+ return redactSkyfirePayId(args);
81
+ }
82
+ }
83
+ //# sourceMappingURL=skyfire.js.map
84
+ //# debugId=7defb7b6-8e7c-5871-b4a2-a7772d722263
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skyfire.js","sources":["../../src/payments/skyfire.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,EACH,mCAAmC,EACnC,sBAAsB,EACtB,yBAAyB,GAC5B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAC5C,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QACa;;;;mBAAK,SAAkB;WAAC;QACxB;;;;mBAAwB,IAAI;WAAC;IAgE1C,CAAC;IA9DG,MAAM,CAAC,KAAK,CAAC,MAAM;QACf,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACxC,CAAC;IAED,kBAAkB,CAAC,IAAe;QAC9B,IAAI,CAAC,IAAI,CAAC,eAAe;YAAE,OAAO,IAAI,CAAC;QAEvC,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QAEpC,0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QACT,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED,gBAAgB,CAAC,IAAa;QAC1B,gGAAgG;QAChG,2FAA2F;QAC3F,kGAAkG;QAClG,gCAAgC;QAChC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACJ","debugId":"7defb7b6-8e7c-5871-b4a2-a7772d722263"}
@@ -0,0 +1,98 @@
1
+ import type { ToolEntry } from '../types.js';
2
+ /**
3
+ * Supported payment provider identifiers.
4
+ * - 'skyfire': Skyfire agentic payments (PAY token in tool args)
5
+ * - 'x402': x402 protocol (HTTP 402 + PAYMENT-SIGNATURE header)
6
+ */
7
+ export type PaymentProviderId = 'skyfire' | 'x402';
8
+ /**
9
+ * Headers to attach to outbound Apify API requests for payment forwarding.
10
+ * Keys are header names, values are header values.
11
+ */
12
+ export type PaymentHeaders = Record<string, string>;
13
+ /**
14
+ * Request metadata from the MCP `_meta` field.
15
+ * Passed to provider methods so payment schemes that use `_meta` (e.g., x402)
16
+ * can access their payment data without polluting tool arguments.
17
+ */
18
+ export type PaymentMeta = Record<string, unknown> | undefined;
19
+ /**
20
+ * Incoming HTTP request headers from the MCP transport.
21
+ * Passed to provider methods so payment schemes that use HTTP headers (e.g., x402 PAYMENT-SIGNATURE)
22
+ * can extract payment data from the transport layer.
23
+ * Undefined for non-HTTP transports (e.g., stdio).
24
+ */
25
+ export type RequestHeaders = Record<string, string | string[] | undefined> | undefined;
26
+ /**
27
+ * Interface for payment providers.
28
+ *
29
+ * Each payment scheme implements this interface to handle:
30
+ * - Tool schema decoration (e.g., adding payment fields to tool definitions)
31
+ * - Payment credential extraction from tool call arguments or request metadata
32
+ * - Apify API client configuration for forwarding payment credentials
33
+ * - Payment validation before tool execution
34
+ */
35
+ export type PaymentProvider = {
36
+ /** The identifier of this payment scheme */
37
+ readonly id: PaymentProviderId;
38
+ /**
39
+ * Decorate a tool definition schema for this payment scheme.
40
+ * Called when tools are registered/upserted in the MCP server.
41
+ *
42
+ * Only tools with `paymentRequired: true` should be decorated.
43
+ * Must be idempotent — calling twice on the same tool produces the same result.
44
+ *
45
+ * @returns The decorated tool (new object), or the original if no decoration needed.
46
+ */
47
+ decorateToolSchema(tool: ToolEntry): ToolEntry;
48
+ /**
49
+ * Validate that required payment credentials are present in tool call arguments, request metadata, or HTTP headers.
50
+ * Called before executing tools with `paymentRequired: true`.
51
+ *
52
+ * @param args - Tool call arguments
53
+ * @param meta - MCP request `_meta` field (used by x402 for `_meta["x402/payment"]`)
54
+ * @param requestHeaders - Incoming HTTP request headers (used by x402 for `PAYMENT-SIGNATURE` header)
55
+ * @returns A concise error message string if validation fails, or null if valid.
56
+ */
57
+ validatePayment(args: Record<string, unknown>, meta?: PaymentMeta, requestHeaders?: RequestHeaders): string | null;
58
+ /**
59
+ * Extract payment credentials from tool call arguments, request metadata, or HTTP headers
60
+ * and return headers for the Apify API client.
61
+ *
62
+ * @param args - Tool call arguments
63
+ * @param meta - MCP request `_meta` field
64
+ * @param requestHeaders - Incoming HTTP request headers
65
+ * @returns Headers to attach to outbound Apify API requests, or empty object if none.
66
+ */
67
+ getPaymentHeaders(args: Record<string, unknown>, meta?: PaymentMeta, requestHeaders?: RequestHeaders): PaymentHeaders;
68
+ /**
69
+ * Remove payment-specific fields from tool call arguments before passing
70
+ * them as Actor input. Returns cleaned args (new object).
71
+ */
72
+ removePaymentFields(args: Record<string, unknown>): Record<string, unknown>;
73
+ /**
74
+ * Whether this payment mode allows unauthenticated access (no Apify token required).
75
+ * Skyfire: true (uses PAY token instead)
76
+ * x402: true (uses blockchain payment instead)
77
+ */
78
+ readonly allowsUnauthenticated: boolean;
79
+ /**
80
+ * Optional: Return structured x402 PaymentRequired data for 402 tool results.
81
+ * Used by x402 to return PaymentRequired (x402Version + accepts) so that
82
+ * x402-compatible MCP clients can automatically handle the payment flow.
83
+ *
84
+ * @returns PaymentRequired object for structuredContent/content, or undefined if not supported.
85
+ */
86
+ getPaymentRequiredData?(): unknown;
87
+ /**
88
+ * Optional: Get a readme/usage guide resource for this payment mode.
89
+ * @returns Resource content string, or null if no guide is available.
90
+ */
91
+ getUsageGuide?(): string | null;
92
+ /**
93
+ * Redact sensitive payment fields from args for logging purposes.
94
+ * @returns A new object with sensitive fields replaced by '[REDACTED]'.
95
+ */
96
+ redactForLogging(args: unknown): unknown;
97
+ };
98
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/payments/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,MAAM,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;AAEvF;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC;IAE/B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAE/C;;;;;;;;OAQG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAAC;IAEnH;;;;;;;;OAQG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC;IAEtH;;;OAGG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5E;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;IAExC;;;;;;OAMG;IACH,sBAAsB,CAAC,IAAI,OAAO,CAAC;IAEnC;;;OAGG;IACH,aAAa,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC;IAEhC;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CAC5C,CAAA"}
@@ -0,0 +1,5 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0fe2f2a7-5a00-558f-b0c9-19a7bf9dc569")}catch(e){}}();
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
5
+ //# debugId=0fe2f2a7-5a00-558f-b0c9-19a7bf9dc569
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../src/payments/types.ts"],"sourceRoot":"","names":[],"mappings":"","debugId":"0fe2f2a7-5a00-558f-b0c9-19a7bf9dc569"}
@@ -0,0 +1,56 @@
1
+ import type { ToolEntry } from '../types.js';
2
+ import type { PaymentHeaders, PaymentMeta, PaymentProvider, RequestHeaders } from './types.js';
3
+ /**
4
+ * x402 payment requirements returned by the Apify API.
5
+ * Decoded from the base64 `payment-required` response header.
6
+ */
7
+ export type X402PaymentRequirements = Record<string, unknown>;
8
+ /**
9
+ * Fetches x402 payment requirements from the Apify API.
10
+ * Uses a module-level cache with a 30-minute TTL to prevent blocking SSE setup on every connection.
11
+ *
12
+ * Sends a request with `x-apify-payment-protocol: x402` header which triggers
13
+ * a 402 response containing the payment requirements in the `payment-required` header.
14
+ *
15
+ * @returns The decoded payment requirements, or undefined if the fetch fails.
16
+ */
17
+ export declare function fetchX402PaymentRequirements(): Promise<X402PaymentRequirements | undefined>;
18
+ /**
19
+ * x402 payment provider.
20
+ *
21
+ * Reads x402 payment signatures from MCP `_meta["x402/payment"]` or the incoming
22
+ * HTTP `PAYMENT-SIGNATURE` header, and forwards them as `PAYMENT-SIGNATURE`
23
+ * headers to the Apify API.
24
+ *
25
+ * Protocol flow:
26
+ * 1. Client reads `_meta.x402` from tool definitions to know payment is required
27
+ * 2. Client signs an EIP-3009 TransferWithAuthorization and includes it in
28
+ * `_meta["x402/payment"]` (JSON object) and/or the `PAYMENT-SIGNATURE` HTTP header (base64)
29
+ * 3. This provider extracts the payment (preferring `_meta`, falling back to HTTP header),
30
+ * base64-encodes it if needed, and forwards as PAYMENT-SIGNATURE header
31
+ * 4. The Apify API verifies and settles the payment
32
+ */
33
+ export declare class X402PaymentProvider implements PaymentProvider {
34
+ private readonly requirements?;
35
+ readonly id: "x402";
36
+ readonly allowsUnauthenticated = true;
37
+ constructor(requirements?: X402PaymentRequirements | undefined);
38
+ /**
39
+ * Creates an X402PaymentProvider, fetching payment requirements from the Apify API.
40
+ * Falls back to a provider without full requirements if the fetch fails.
41
+ */
42
+ static create(): Promise<X402PaymentProvider>;
43
+ /**
44
+ * Extracts the first accept entry from the full payment requirements.
45
+ * This is the flattened payment info that goes into _meta.x402 for tool schemas.
46
+ */
47
+ private getFirstAcceptEntry;
48
+ decorateToolSchema(tool: ToolEntry): ToolEntry;
49
+ validatePayment(_args: Record<string, unknown>, meta?: PaymentMeta, requestHeaders?: RequestHeaders): string | null;
50
+ getPaymentHeaders(_args: Record<string, unknown>, meta?: PaymentMeta, requestHeaders?: RequestHeaders): PaymentHeaders;
51
+ removePaymentFields(args: Record<string, unknown>): Record<string, unknown>;
52
+ getPaymentRequiredData(): X402PaymentRequirements | undefined;
53
+ getUsageGuide(): string | null;
54
+ redactForLogging(args: unknown): unknown;
55
+ }
56
+ //# sourceMappingURL=x402.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402.d.ts","sourceRoot":"","sources":["../../src/payments/x402.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuB/F;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAW9D;;;;;;;;GAQG;AACH,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CA+CjG;AA4BD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAI3C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAH1C,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAU;IAC9B,QAAQ,CAAC,qBAAqB,QAAQ;gBAET,YAAY,CAAC,EAAE,uBAAuB,YAAA;IAEnE;;;OAGG;WACU,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAKnD;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAO3B,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS;IAyB9C,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI;IAInH,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,cAAc;IAOtH,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAK3E,sBAAsB,IAAI,uBAAuB,GAAG,SAAS;IAI7D,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;CAI3C"}
@@ -0,0 +1,211 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c9aa96c4-1341-5e5b-aead-0f392c93631f")}catch(e){}}();
3
+ import log from '@apify/log';
4
+ import { getApifyAPIBaseUrl } from '../apify_client.js';
5
+ import { cloneToolEntry } from '../utils/tools.js';
6
+ /**
7
+ * Key used by MCP clients to pass x402 payment data in the JSON-RPC `_meta` field.
8
+ * The mcp-cli injects the decoded payment payload here (JSON object, not base64).
9
+ */
10
+ const X402_META_KEY = 'x402/payment';
11
+ /** HTTP header name for forwarding x402 payment signatures to the Apify API. */
12
+ const PAYMENT_SIGNATURE_HEADER = 'PAYMENT-SIGNATURE';
13
+ const PAYMENT_PROTOCOL_HEADER = 'x-apify-payment-protocol';
14
+ const PAYMENT_REQUIRED_HEADER = 'payment-required';
15
+ /** Timeout for fetching x402 payment requirements from the Apify API (ms). */
16
+ const FETCH_TIMEOUT_MS = 8000;
17
+ const X402_TOOL_INSTRUCTIONS = [
18
+ 'This tool requires an x402 payment.',
19
+ 'Include a valid x402 payment signature in the request metadata (_meta["x402/payment"]).',
20
+ 'Your MCP client must support the x402 payment protocol.',
21
+ ].join(' ');
22
+ // Module-level cache for X402 payment requirements.
23
+ // We cache the Promise itself (rather than just the JSON result) to prevent the "thundering herd"
24
+ // problem during server startup, where multiple concurrent incoming requests might otherwise
25
+ // trigger duplicate identical fetches to the Apify API before the first one finishes.
26
+ let cachedRequirementsPromise = null;
27
+ let lastFetchTime = 0;
28
+ // Cache TTL: 30 minutes
29
+ const CACHE_TTL_MS = 30 * 60 * 1000;
30
+ /**
31
+ * Fetches x402 payment requirements from the Apify API.
32
+ * Uses a module-level cache with a 30-minute TTL to prevent blocking SSE setup on every connection.
33
+ *
34
+ * Sends a request with `x-apify-payment-protocol: x402` header which triggers
35
+ * a 402 response containing the payment requirements in the `payment-required` header.
36
+ *
37
+ * @returns The decoded payment requirements, or undefined if the fetch fails.
38
+ */
39
+ export async function fetchX402PaymentRequirements() {
40
+ const now = Date.now();
41
+ // If we have a cached promise, and the TTL hasn't expired since it successfully resolved, return it.
42
+ // Note: During the very first fetch, lastFetchTime is 0, so this will be false and we will
43
+ // fall through to create the promise, which is expected. However, if multiple requests hit this
44
+ // block *while the first fetch is still in-flight*, they will also see lastFetchTime = 0 and
45
+ // create duplicate promises. This is a known minor flaw in this specific caching pattern, but
46
+ // acceptable since the overhead of a few duplicate calls during cold-start is negligible.
47
+ if (cachedRequirementsPromise && (now - lastFetchTime < CACHE_TTL_MS)) {
48
+ return cachedRequirementsPromise;
49
+ }
50
+ cachedRequirementsPromise = (async () => {
51
+ const apiBaseUrl = getApifyAPIBaseUrl();
52
+ const url = `${apiBaseUrl}/v2/acts/`;
53
+ const controller = new AbortController();
54
+ const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
55
+ try {
56
+ const response = await fetch(url, {
57
+ method: 'GET',
58
+ headers: { [PAYMENT_PROTOCOL_HEADER]: 'x402' },
59
+ signal: controller.signal,
60
+ });
61
+ const paymentRequiredBase64 = response.headers.get(PAYMENT_REQUIRED_HEADER);
62
+ if (!paymentRequiredBase64) {
63
+ log.warning('[x402] No payment-required header in API response', { status: response.status, url });
64
+ cachedRequirementsPromise = null;
65
+ return undefined;
66
+ }
67
+ const decoded = JSON.parse(Buffer.from(paymentRequiredBase64, 'base64').toString('utf-8'));
68
+ log.info('[x402] Fetched payment requirements from Apify API', { url });
69
+ lastFetchTime = Date.now();
70
+ return decoded;
71
+ }
72
+ catch (error) {
73
+ log.warning('[x402] Failed to fetch payment requirements — tools will advertise paymentRequired only', { url, error });
74
+ cachedRequirementsPromise = null;
75
+ return undefined;
76
+ }
77
+ finally {
78
+ clearTimeout(timeoutId);
79
+ }
80
+ })();
81
+ return cachedRequirementsPromise;
82
+ }
83
+ /**
84
+ * Extracts the PAYMENT-SIGNATURE value from incoming HTTP request headers.
85
+ * Header lookup is case-insensitive. Returns the first string value, or undefined.
86
+ */
87
+ function getPaymentSignatureFromHeader(requestHeaders) {
88
+ var _a;
89
+ if (!requestHeaders)
90
+ return undefined;
91
+ // HTTP headers are case-insensitive; the SDK may normalize to lowercase
92
+ const value = (_a = requestHeaders[PAYMENT_SIGNATURE_HEADER]) !== null && _a !== void 0 ? _a : requestHeaders[PAYMENT_SIGNATURE_HEADER.toLowerCase()];
93
+ if (typeof value === 'string' && value.length > 0)
94
+ return value;
95
+ if (Array.isArray(value) && typeof value[0] === 'string' && value[0].length > 0)
96
+ return value[0];
97
+ return undefined;
98
+ }
99
+ /**
100
+ * Gets the base64-encoded payment signature from either _meta (JSON object) or HTTP headers.
101
+ */
102
+ function getEncodedPaymentSignature(meta, requestHeaders) {
103
+ const metaPayment = meta === null || meta === void 0 ? void 0 : meta[X402_META_KEY];
104
+ if (metaPayment) {
105
+ return Buffer.from(JSON.stringify(metaPayment)).toString('base64');
106
+ }
107
+ return getPaymentSignatureFromHeader(requestHeaders);
108
+ }
109
+ /**
110
+ * x402 payment provider.
111
+ *
112
+ * Reads x402 payment signatures from MCP `_meta["x402/payment"]` or the incoming
113
+ * HTTP `PAYMENT-SIGNATURE` header, and forwards them as `PAYMENT-SIGNATURE`
114
+ * headers to the Apify API.
115
+ *
116
+ * Protocol flow:
117
+ * 1. Client reads `_meta.x402` from tool definitions to know payment is required
118
+ * 2. Client signs an EIP-3009 TransferWithAuthorization and includes it in
119
+ * `_meta["x402/payment"]` (JSON object) and/or the `PAYMENT-SIGNATURE` HTTP header (base64)
120
+ * 3. This provider extracts the payment (preferring `_meta`, falling back to HTTP header),
121
+ * base64-encodes it if needed, and forwards as PAYMENT-SIGNATURE header
122
+ * 4. The Apify API verifies and settles the payment
123
+ */
124
+ export class X402PaymentProvider {
125
+ constructor(requirements) {
126
+ Object.defineProperty(this, "requirements", {
127
+ enumerable: true,
128
+ configurable: true,
129
+ writable: true,
130
+ value: requirements
131
+ });
132
+ Object.defineProperty(this, "id", {
133
+ enumerable: true,
134
+ configurable: true,
135
+ writable: true,
136
+ value: 'x402'
137
+ });
138
+ Object.defineProperty(this, "allowsUnauthenticated", {
139
+ enumerable: true,
140
+ configurable: true,
141
+ writable: true,
142
+ value: true
143
+ });
144
+ }
145
+ /**
146
+ * Creates an X402PaymentProvider, fetching payment requirements from the Apify API.
147
+ * Falls back to a provider without full requirements if the fetch fails.
148
+ */
149
+ static async create() {
150
+ const requirements = await fetchX402PaymentRequirements();
151
+ return new X402PaymentProvider(requirements);
152
+ }
153
+ /**
154
+ * Extracts the first accept entry from the full payment requirements.
155
+ * This is the flattened payment info that goes into _meta.x402 for tool schemas.
156
+ */
157
+ getFirstAcceptEntry() {
158
+ if (!this.requirements)
159
+ return undefined;
160
+ const accepts = this.requirements.accepts;
161
+ if (!Array.isArray(accepts) || accepts.length === 0)
162
+ return undefined;
163
+ return accepts[0];
164
+ }
165
+ decorateToolSchema(tool) {
166
+ if (!tool.paymentRequired)
167
+ return tool;
168
+ const cloned = cloneToolEntry(tool);
169
+ // Add _meta.x402 to signal payment requirement to clients (idempotent)
170
+ // Only include the first accept entry (scheme, network, amount, asset, payTo, etc.)
171
+ // matching the demo server format — NOT the full API response
172
+ if (!cloned._meta) {
173
+ cloned._meta = {};
174
+ }
175
+ const metaRecord = cloned._meta;
176
+ if (!metaRecord.x402) {
177
+ const acceptEntry = this.getFirstAcceptEntry();
178
+ metaRecord.x402 = { paymentRequired: true, ...acceptEntry };
179
+ }
180
+ // Append x402 instructions to description (idempotent)
181
+ if (cloned.description && !cloned.description.includes(X402_TOOL_INSTRUCTIONS)) {
182
+ cloned.description += `\n\n${X402_TOOL_INSTRUCTIONS}`;
183
+ }
184
+ return Object.freeze(cloned);
185
+ }
186
+ validatePayment(_args, meta, requestHeaders) {
187
+ return getEncodedPaymentSignature(meta, requestHeaders) ? null : X402_TOOL_INSTRUCTIONS;
188
+ }
189
+ getPaymentHeaders(_args, meta, requestHeaders) {
190
+ const paymentSignature = getEncodedPaymentSignature(meta, requestHeaders);
191
+ return paymentSignature
192
+ ? { [PAYMENT_SIGNATURE_HEADER]: paymentSignature, [PAYMENT_PROTOCOL_HEADER]: 'x402' }
193
+ : {};
194
+ }
195
+ removePaymentFields(args) {
196
+ // x402 doesn't inject anything into tool arguments — payment is in _meta
197
+ return args;
198
+ }
199
+ getPaymentRequiredData() {
200
+ return this.requirements;
201
+ }
202
+ getUsageGuide() {
203
+ return null;
204
+ }
205
+ redactForLogging(args) {
206
+ // x402 doesn't put sensitive data in tool arguments
207
+ return args;
208
+ }
209
+ }
210
+ //# sourceMappingURL=x402.js.map
211
+ //# debugId=c9aa96c4-1341-5e5b-aead-0f392c93631f
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402.js","sources":["../../src/payments/x402.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;;GAGG;AACH,MAAM,aAAa,GAAG,cAAc,CAAC;AAErC,gFAAgF;AAChF,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AACrD,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAE3D,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAEnD,8EAA8E;AAC9E,MAAM,gBAAgB,GAAG,IAAK,CAAC;AAE/B,MAAM,sBAAsB,GAAG;IAC3B,qCAAqC;IACrC,yFAAyF;IACzF,yDAAyD;CAC5D,CAAC,IA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