@coinbase/agentkit 0.8.2 → 0.9.1

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 (103) hide show
  1. package/README.md +404 -235
  2. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +15 -15
  3. package/dist/action-providers/cdp/cdpApiActionProvider.js +110 -63
  4. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +205 -124
  5. package/dist/action-providers/cdp/index.d.ts +0 -1
  6. package/dist/action-providers/cdp/index.js +0 -1
  7. package/dist/action-providers/cdp/schemas.d.ts +9 -70
  8. package/dist/action-providers/cdp/schemas.js +12 -61
  9. package/dist/action-providers/cdp-legacy/index.d.ts +3 -0
  10. package/dist/action-providers/cdp-legacy/index.js +19 -0
  11. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.d.ts +45 -0
  12. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.js +130 -0
  13. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.test.js +146 -0
  14. package/dist/action-providers/{cdp/cdpWalletActionProvider.d.ts → cdp-legacy/legacyCdpWalletActionProvider.d.ts} +8 -8
  15. package/dist/action-providers/{cdp/cdpWalletActionProvider.js → cdp-legacy/legacyCdpWalletActionProvider.js} +14 -14
  16. package/dist/action-providers/{cdp/cdpWalletActionProvider.test.js → cdp-legacy/legacyCdpWalletActionProvider.test.js} +3 -3
  17. package/dist/action-providers/cdp-legacy/schemas.d.ts +91 -0
  18. package/dist/action-providers/cdp-legacy/schemas.js +77 -0
  19. package/dist/action-providers/erc20/erc20ActionProvider.js +1 -1
  20. package/dist/action-providers/farcaster/farcasterActionProvider.js +2 -0
  21. package/dist/action-providers/farcaster/farcasterActionProvider.test.js +55 -0
  22. package/dist/action-providers/farcaster/schemas.d.ts +13 -0
  23. package/dist/action-providers/farcaster/schemas.js +6 -0
  24. package/dist/action-providers/index.d.ts +3 -1
  25. package/dist/action-providers/index.js +3 -1
  26. package/dist/action-providers/jupiter/jupiterActionProvider.test.js +2 -4
  27. package/dist/action-providers/truemarkets/constants.d.ts +179 -0
  28. package/dist/action-providers/truemarkets/constants.js +46 -0
  29. package/dist/action-providers/truemarkets/index.d.ts +1 -0
  30. package/dist/action-providers/truemarkets/index.js +17 -0
  31. package/dist/action-providers/truemarkets/schemas.d.ts +21 -0
  32. package/dist/action-providers/truemarkets/schemas.js +29 -0
  33. package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +51 -0
  34. package/dist/action-providers/truemarkets/truemarketsActionProvider.js +469 -0
  35. package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +217 -0
  36. package/dist/action-providers/truemarkets/utils.d.ts +10 -0
  37. package/dist/action-providers/truemarkets/utils.js +9 -0
  38. package/dist/action-providers/twitter/schemas.d.ts +16 -0
  39. package/dist/action-providers/twitter/schemas.js +23 -1
  40. package/dist/action-providers/twitter/twitterActionProvider.d.ts +8 -1
  41. package/dist/action-providers/twitter/twitterActionProvider.js +56 -5
  42. package/dist/action-providers/twitter/twitterActionProvider.test.js +52 -2
  43. package/dist/action-providers/weth/constants.d.ts +9 -0
  44. package/dist/action-providers/weth/constants.js +12 -0
  45. package/dist/action-providers/weth/schemas.d.ts +7 -0
  46. package/dist/action-providers/weth/schemas.js +7 -1
  47. package/dist/action-providers/weth/wethActionProvider.d.ts +9 -1
  48. package/dist/action-providers/weth/wethActionProvider.js +50 -1
  49. package/dist/action-providers/weth/wethActionProvider.test.js +60 -0
  50. package/dist/action-providers/x402/schemas.d.ts +58 -11
  51. package/dist/action-providers/x402/schemas.js +60 -8
  52. package/dist/action-providers/x402/x402ActionProvider.d.ts +33 -16
  53. package/dist/action-providers/x402/x402ActionProvider.js +203 -153
  54. package/dist/action-providers/x402/x402ActionProvider.test.js +78 -225
  55. package/dist/action-providers/zora/index.d.ts +3 -0
  56. package/dist/action-providers/{cdp-v2 → zora}/index.js +2 -1
  57. package/dist/action-providers/zora/schemas.d.ts +29 -0
  58. package/dist/action-providers/zora/schemas.js +31 -0
  59. package/dist/action-providers/zora/utils.d.ts +28 -0
  60. package/dist/action-providers/zora/utils.js +200 -0
  61. package/dist/action-providers/zora/zoraActionProvider.d.ts +36 -0
  62. package/dist/action-providers/zora/zoraActionProvider.js +151 -0
  63. package/dist/action-providers/zora/zoraActionProvider.test.js +205 -0
  64. package/dist/agentkit.d.ts +1 -0
  65. package/dist/agentkit.js +3 -2
  66. package/dist/wallet-providers/{cdpV2EvmWalletProvider.d.ts → cdpEvmWalletProvider.d.ts} +16 -7
  67. package/dist/wallet-providers/{cdpV2EvmWalletProvider.js → cdpEvmWalletProvider.js} +50 -39
  68. package/dist/wallet-providers/{cdpV2EvmWalletProvider.test.js → cdpEvmWalletProvider.test.js} +7 -7
  69. package/dist/wallet-providers/{cdpV2Shared.d.ts → cdpShared.d.ts} +15 -4
  70. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +115 -0
  71. package/dist/wallet-providers/cdpSmartWalletProvider.js +263 -0
  72. package/dist/wallet-providers/cdpSmartWalletProvider.test.d.ts +1 -0
  73. package/dist/wallet-providers/cdpSmartWalletProvider.test.js +287 -0
  74. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.d.ts → cdpSolanaWalletProvider.d.ts} +16 -7
  75. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.js → cdpSolanaWalletProvider.js} +43 -32
  76. package/dist/wallet-providers/cdpSolanaWalletProvider.test.d.ts +1 -0
  77. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.js → cdpSolanaWalletProvider.test.js} +7 -7
  78. package/dist/wallet-providers/index.d.ts +6 -6
  79. package/dist/wallet-providers/index.js +6 -6
  80. package/dist/wallet-providers/{smartWalletProvider.d.ts → legacyCdpSmartWalletProvider.d.ts} +3 -3
  81. package/dist/wallet-providers/{smartWalletProvider.js → legacyCdpSmartWalletProvider.js} +21 -21
  82. package/dist/wallet-providers/legacyCdpSmartWalletProvider.test.d.ts +1 -0
  83. package/dist/wallet-providers/{smartWalletProvider.test.js → legacyCdpSmartWalletProvider.test.js} +2 -2
  84. package/dist/wallet-providers/{cdpWalletProvider.d.ts → legacyCdpWalletProvider.d.ts} +15 -11
  85. package/dist/wallet-providers/{cdpWalletProvider.js → legacyCdpWalletProvider.js} +72 -70
  86. package/dist/wallet-providers/legacyCdpWalletProvider.test.d.ts +1 -0
  87. package/dist/wallet-providers/{cdpWalletProvider.test.js → legacyCdpWalletProvider.test.js} +10 -10
  88. package/package.json +4 -2
  89. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +0 -34
  90. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +0 -98
  91. package/dist/action-providers/cdp-v2/index.d.ts +0 -2
  92. package/dist/action-providers/cdp-v2/schemas.d.ts +0 -11
  93. package/dist/action-providers/cdp-v2/schemas.js +0 -13
  94. package/dist/wallet-providers/cdpV2WalletProvider.d.ts +0 -35
  95. package/dist/wallet-providers/cdpV2WalletProvider.js +0 -42
  96. /package/dist/action-providers/{cdp → cdp-legacy}/constants.d.ts +0 -0
  97. /package/dist/action-providers/{cdp → cdp-legacy}/constants.js +0 -0
  98. /package/dist/action-providers/{cdp/cdpWalletActionProvider.test.d.ts → cdp-legacy/legacyCdpApiActionProvider.test.d.ts} +0 -0
  99. /package/dist/{wallet-providers/cdpV2EvmWalletProvider.test.d.ts → action-providers/cdp-legacy/legacyCdpWalletActionProvider.test.d.ts} +0 -0
  100. /package/dist/{wallet-providers/cdpV2SolanaWalletProvider.test.d.ts → action-providers/truemarkets/truemarketsActionProvider.test.d.ts} +0 -0
  101. /package/dist/{wallet-providers/cdpWalletProvider.test.d.ts → action-providers/zora/zoraActionProvider.test.d.ts} +0 -0
  102. /package/dist/wallet-providers/{smartWalletProvider.test.d.ts → cdpEvmWalletProvider.test.d.ts} +0 -0
  103. /package/dist/wallet-providers/{cdpV2Shared.js → cdpShared.js} +0 -0
@@ -58,6 +58,30 @@ class WethActionProvider extends actionProvider_1.ActionProvider {
58
58
  return `Error wrapping ETH: ${error}`;
59
59
  }
60
60
  }
61
+ /**
62
+ * Unwraps WETH to ETH.
63
+ *
64
+ * @param walletProvider - The wallet provider to use for the action.
65
+ * @param args - The input arguments for the action.
66
+ * @returns A message containing the transaction hash.
67
+ */
68
+ async unwrapEth(walletProvider, args) {
69
+ try {
70
+ const hash = await walletProvider.sendTransaction({
71
+ to: constants_1.WETH_ADDRESS,
72
+ data: (0, viem_1.encodeFunctionData)({
73
+ abi: constants_1.WETH_ABI,
74
+ functionName: "withdraw",
75
+ args: [BigInt(args.amountToUnwrap)],
76
+ }),
77
+ });
78
+ await walletProvider.waitForTransactionReceipt(hash);
79
+ return `Unwrapped WETH with transaction hash: ${hash}`;
80
+ }
81
+ catch (error) {
82
+ return `Error unwrapping WETH: ${error}`;
83
+ }
84
+ }
61
85
  }
62
86
  exports.WethActionProvider = WethActionProvider;
63
87
  __decorate([
@@ -74,7 +98,7 @@ Important notes:
74
98
  - The amount is a string and cannot have any decimal points, since the unit of measurement is wei.
75
99
  - Make sure to use the exact amount provided, and if there's any doubt, check by getting more information before continuing with the action.
76
100
  - 1 wei = 0.000000000000000001 WETH
77
- - Minimum purchase amount is 100000000000000 wei (0.0000001 WETH)
101
+ - Minimum purchase amount is 100000000000 wei (0.0000001 WETH)
78
102
  - Only supported on the following networks:
79
103
  - Base Sepolia (ie, 'base-sepolia')
80
104
  - Base Mainnet (ie, 'base', 'base-mainnet')
@@ -85,5 +109,30 @@ Important notes:
85
109
  __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
86
110
  __metadata("design:returntype", Promise)
87
111
  ], WethActionProvider.prototype, "wrapEth", null);
112
+ __decorate([
113
+ (0, actionDecorator_1.CreateAction)({
114
+ name: "unwrap_eth",
115
+ description: `
116
+ This tool can only be used to unwrap WETH to ETH.
117
+ Do not use this tool for any other purpose, or trading other assets.
118
+
119
+ Inputs:
120
+ - Amount of WETH to unwrap.
121
+
122
+ Important notes:
123
+ - The amount is a string and cannot have any decimal points, since the unit of measurement is wei.
124
+ - Make sure to use the exact amount provided, and if there's any doubt, check by getting more information before continuing with the action.
125
+ - 1 wei = 0.000000000000000001 WETH
126
+ - Minimum unwrap amount is 100000000000 wei (0.0000001 WETH)
127
+ - Only supported on the following networks:
128
+ - Base Sepolia (ie, 'base-sepolia')
129
+ - Base Mainnet (ie, 'base', 'base-mainnet')
130
+ `,
131
+ schema: schemas_1.UnwrapEthSchema,
132
+ }),
133
+ __metadata("design:type", Function),
134
+ __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
135
+ __metadata("design:returntype", Promise)
136
+ ], WethActionProvider.prototype, "unwrapEth", null);
88
137
  const wethActionProvider = () => new WethActionProvider();
89
138
  exports.wethActionProvider = wethActionProvider;
@@ -21,6 +21,21 @@ describe("Wrap Eth Schema", () => {
21
21
  expect(result.success).toBe(false);
22
22
  });
23
23
  });
24
+ describe("Unwrap Eth Schema", () => {
25
+ it("should successfully parse valid input", () => {
26
+ const validInput = {
27
+ amountToUnwrap: MOCK_AMOUNT,
28
+ };
29
+ const result = schemas_1.UnwrapEthSchema.safeParse(validInput);
30
+ expect(result.success).toBe(true);
31
+ expect(result.data).toEqual(validInput);
32
+ });
33
+ it("should fail parsing empty input", () => {
34
+ const emptyInput = {};
35
+ const result = schemas_1.UnwrapEthSchema.safeParse(emptyInput);
36
+ expect(result.success).toBe(false);
37
+ });
38
+ });
24
39
  describe("Wrap Eth Action", () => {
25
40
  let mockWallet;
26
41
  const actionProvider = (0, wethActionProvider_1.wethActionProvider)();
@@ -66,6 +81,51 @@ describe("Wrap Eth Action", () => {
66
81
  expect(response).toContain(`Error wrapping ETH: ${error}`);
67
82
  });
68
83
  });
84
+ describe("Unwrap Eth Action", () => {
85
+ let mockWallet;
86
+ const actionProvider = (0, wethActionProvider_1.wethActionProvider)();
87
+ beforeEach(async () => {
88
+ mockWallet = {
89
+ getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
90
+ sendTransaction: jest.fn(),
91
+ waitForTransactionReceipt: jest.fn(),
92
+ };
93
+ });
94
+ it("should successfully respond", async () => {
95
+ const args = {
96
+ amountToUnwrap: MOCK_AMOUNT,
97
+ };
98
+ const hash = "0x1234567890123456789012345678901234567890";
99
+ mockWallet.sendTransaction.mockResolvedValue(hash);
100
+ const response = await actionProvider.unwrapEth(mockWallet, args);
101
+ expect(mockWallet.sendTransaction).toHaveBeenCalledWith({
102
+ to: constants_1.WETH_ADDRESS,
103
+ data: (0, viem_1.encodeFunctionData)({
104
+ abi: constants_1.WETH_ABI,
105
+ functionName: "withdraw",
106
+ args: [BigInt(MOCK_AMOUNT)],
107
+ }),
108
+ });
109
+ expect(response).toContain(`Unwrapped WETH with transaction hash: ${hash}`);
110
+ });
111
+ it("should fail with an error", async () => {
112
+ const args = {
113
+ amountToUnwrap: MOCK_AMOUNT,
114
+ };
115
+ const error = new Error("Failed to unwrap WETH");
116
+ mockWallet.sendTransaction.mockRejectedValue(error);
117
+ const response = await actionProvider.unwrapEth(mockWallet, args);
118
+ expect(mockWallet.sendTransaction).toHaveBeenCalledWith({
119
+ to: constants_1.WETH_ADDRESS,
120
+ data: (0, viem_1.encodeFunctionData)({
121
+ abi: constants_1.WETH_ABI,
122
+ functionName: "withdraw",
123
+ args: [BigInt(MOCK_AMOUNT)],
124
+ }),
125
+ });
126
+ expect(response).toContain(`Error unwrapping WETH: ${error}`);
127
+ });
128
+ });
69
129
  describe("supportsNetwork", () => {
70
130
  const actionProvider = (0, wethActionProvider_1.wethActionProvider)();
71
131
  it("should return true for base-mainnet", () => {
@@ -1,30 +1,77 @@
1
1
  import { z } from "zod";
2
- export declare const PaidRequestSchema: z.ZodObject<{
2
+ export declare const HttpRequestSchema: z.ZodObject<{
3
3
  url: z.ZodString;
4
- method: z.ZodDefault<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>;
4
+ method: z.ZodDefault<z.ZodNullable<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>>;
5
+ headers: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
6
+ body: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null;
9
+ url: string;
10
+ body?: any;
11
+ headers?: Record<string, string> | null | undefined;
12
+ }, {
13
+ url: string;
14
+ method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null | undefined;
15
+ body?: any;
16
+ headers?: Record<string, string> | null | undefined;
17
+ }>;
18
+ export declare const RetryWithX402Schema: z.ZodObject<{
19
+ url: z.ZodString;
20
+ method: z.ZodDefault<z.ZodNullable<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>>;
5
21
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
6
22
  body: z.ZodOptional<z.ZodAny>;
23
+ selectedPaymentOption: z.ZodObject<{
24
+ scheme: z.ZodString;
25
+ network: z.ZodString;
26
+ maxAmountRequired: z.ZodString;
27
+ asset: z.ZodString;
28
+ }, "strip", z.ZodTypeAny, {
29
+ scheme: string;
30
+ network: string;
31
+ asset: string;
32
+ maxAmountRequired: string;
33
+ }, {
34
+ scheme: string;
35
+ network: string;
36
+ asset: string;
37
+ maxAmountRequired: string;
38
+ }>;
7
39
  }, "strip", z.ZodTypeAny, {
8
- method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH";
40
+ method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null;
9
41
  url: string;
42
+ selectedPaymentOption: {
43
+ scheme: string;
44
+ network: string;
45
+ asset: string;
46
+ maxAmountRequired: string;
47
+ };
10
48
  body?: any;
11
49
  headers?: Record<string, string> | undefined;
12
50
  }, {
13
51
  url: string;
14
- method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | undefined;
52
+ selectedPaymentOption: {
53
+ scheme: string;
54
+ network: string;
55
+ asset: string;
56
+ maxAmountRequired: string;
57
+ };
58
+ method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null | undefined;
15
59
  body?: any;
16
60
  headers?: Record<string, string> | undefined;
17
61
  }>;
18
- export declare const FetchPaymentInfoSchema: z.ZodObject<{
62
+ export declare const DirectX402RequestSchema: z.ZodObject<{
19
63
  url: z.ZodString;
20
- method: z.ZodDefault<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>;
21
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
64
+ method: z.ZodDefault<z.ZodNullable<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>>;
65
+ headers: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
66
+ body: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
22
67
  }, "strip", z.ZodTypeAny, {
23
- method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH";
68
+ method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null;
24
69
  url: string;
25
- headers?: Record<string, string> | undefined;
70
+ body?: any;
71
+ headers?: Record<string, string> | null | undefined;
26
72
  }, {
27
73
  url: string;
28
- method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | undefined;
29
- headers?: Record<string, string> | undefined;
74
+ method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null | undefined;
75
+ body?: any;
76
+ headers?: Record<string, string> | null | undefined;
30
77
  }>;
@@ -1,27 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FetchPaymentInfoSchema = exports.PaidRequestSchema = void 0;
3
+ exports.DirectX402RequestSchema = exports.RetryWithX402Schema = exports.HttpRequestSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- exports.PaidRequestSchema = zod_1.z
5
+ // Schema for initial HTTP request
6
+ exports.HttpRequestSchema = zod_1.z
6
7
  .object({
7
- url: zod_1.z.string().url().describe("The URL of the x402-protected API endpoint"),
8
+ url: zod_1.z
9
+ .string()
10
+ .url()
11
+ .describe("The URL of the API endpoint (can be localhost for development)"),
8
12
  method: zod_1.z
9
13
  .enum(["GET", "POST", "PUT", "DELETE", "PATCH"])
14
+ .nullable()
15
+ .default("GET")
16
+ .describe("The HTTP method to use for the request"),
17
+ headers: zod_1.z
18
+ .record(zod_1.z.string())
19
+ .optional()
20
+ .nullable()
21
+ .describe("Optional headers to include in the request"),
22
+ body: zod_1.z
23
+ .any()
24
+ .optional()
25
+ .nullable()
26
+ .describe("Optional request body for POST/PUT/PATCH requests"),
27
+ })
28
+ .strip()
29
+ .describe("Instructions for making a basic HTTP request");
30
+ // Schema for retrying a failed request with x402 payment
31
+ exports.RetryWithX402Schema = zod_1.z
32
+ .object({
33
+ url: zod_1.z
34
+ .string()
35
+ .url()
36
+ .describe("The URL of the API endpoint (can be localhost for development)"),
37
+ method: zod_1.z
38
+ .enum(["GET", "POST", "PUT", "DELETE", "PATCH"])
39
+ .nullable()
10
40
  .default("GET")
11
41
  .describe("The HTTP method to use for the request"),
12
42
  headers: zod_1.z.record(zod_1.z.string()).optional().describe("Optional headers to include in the request"),
13
43
  body: zod_1.z.any().optional().describe("Optional request body for POST/PUT/PATCH requests"),
44
+ selectedPaymentOption: zod_1.z
45
+ .object({
46
+ scheme: zod_1.z.string(),
47
+ network: zod_1.z.string(),
48
+ maxAmountRequired: zod_1.z.string(),
49
+ asset: zod_1.z.string(),
50
+ })
51
+ .describe("The payment option to use for this request"),
14
52
  })
15
53
  .strip()
16
- .describe("Instructions for making a paid request to an x402-protected API");
17
- exports.FetchPaymentInfoSchema = zod_1.z
54
+ .describe("Instructions for retrying a request with x402 payment after receiving a 402 response");
55
+ // Schema for direct x402 payment request (with warning)
56
+ exports.DirectX402RequestSchema = zod_1.z
18
57
  .object({
19
- url: zod_1.z.string().url().describe("The URL of the x402-protected API endpoint"),
58
+ url: zod_1.z
59
+ .string()
60
+ .url()
61
+ .describe("The URL of the API endpoint (can be localhost for development)"),
20
62
  method: zod_1.z
21
63
  .enum(["GET", "POST", "PUT", "DELETE", "PATCH"])
64
+ .nullable()
22
65
  .default("GET")
23
66
  .describe("The HTTP method to use for the request"),
24
- headers: zod_1.z.record(zod_1.z.string()).optional().describe("Optional headers to include in the request"),
67
+ headers: zod_1.z
68
+ .record(zod_1.z.string())
69
+ .optional()
70
+ .nullable()
71
+ .describe("Optional headers to include in the request"),
72
+ body: zod_1.z
73
+ .any()
74
+ .optional()
75
+ .nullable()
76
+ .describe("Optional request body for POST/PUT/PATCH requests"),
25
77
  })
26
78
  .strip()
27
- .describe("Instructions for fetching payment information from an x402-protected API endpoint");
79
+ .describe("Instructions for making an HTTP request with automatic x402 payment handling. WARNING: This bypasses user confirmation - only use when explicitly told to skip confirmation!");
@@ -1,38 +1,55 @@
1
1
  import { z } from "zod";
2
2
  import { ActionProvider } from "../actionProvider";
3
3
  import { Network } from "../../network";
4
- import { PaidRequestSchema, FetchPaymentInfoSchema } from "./schemas";
4
+ import { HttpRequestSchema, RetryWithX402Schema, DirectX402RequestSchema } from "./schemas";
5
5
  import { EvmWalletProvider } from "../../wallet-providers";
6
6
  /**
7
- * X402ActionProvider is an action provider for making paid requests to x402-protected APIs.
7
+ * X402ActionProvider provides actions for making HTTP requests, with optional x402 payment handling.
8
8
  */
9
9
  export declare class X402ActionProvider extends ActionProvider<EvmWalletProvider> {
10
10
  /**
11
- * Constructor for the X402ActionProvider.
11
+ * Creates a new instance of X402ActionProvider.
12
+ * Initializes the provider with x402 capabilities.
12
13
  */
13
14
  constructor();
14
15
  /**
15
- * Makes a paid request to an x402-protected API endpoint.
16
+ * Makes a basic HTTP request to an API endpoint.
16
17
  *
17
- * @param walletProvider - The wallet provider to use for payment signing.
18
- * @param args - The input arguments for the action.
19
- * @returns A message containing the API response data.
18
+ * @param walletProvider - The wallet provider to use for potential payments
19
+ * @param args - The request parameters including URL, method, headers, and body
20
+ * @returns A JSON string containing the response or error details
20
21
  */
21
- paidRequest(walletProvider: EvmWalletProvider, args: z.infer<typeof PaidRequestSchema>): Promise<string>;
22
+ makeHttpRequest(walletProvider: EvmWalletProvider, args: z.infer<typeof HttpRequestSchema>): Promise<string>;
22
23
  /**
23
- * Fetches payment information from an x402-protected API endpoint without making the payment.
24
+ * Retries a request with x402 payment after receiving a 402 response.
24
25
  *
25
- * @param walletProvider - The wallet provider (not used for this action but required by interface).
26
- * @param args - The input arguments for the action.
27
- * @returns A message containing the payment requirements and endpoint information.
26
+ * @param walletProvider - The wallet provider to use for making the payment
27
+ * @param args - The request parameters including URL, method, headers, body, and payment option
28
+ * @returns A JSON string containing the response with payment details or error information
28
29
  */
29
- fetchPaymentInfo(walletProvider: EvmWalletProvider, args: z.infer<typeof FetchPaymentInfoSchema>): Promise<string>;
30
+ retryWithX402(walletProvider: EvmWalletProvider, args: z.infer<typeof RetryWithX402Schema>): Promise<string>;
30
31
  /**
31
- * Checks if the X402 action provider supports the given network.
32
+ * Makes an HTTP request with automatic x402 payment handling.
32
33
  *
33
- * @param network - The network to check.
34
- * @returns True if the X402 action provider supports the network, false otherwise.
34
+ * @param walletProvider - The wallet provider to use for automatic payments
35
+ * @param args - The request parameters including URL, method, headers, and body
36
+ * @returns A JSON string containing the response with optional payment details or error information
37
+ */
38
+ makeHttpRequestWithX402(walletProvider: EvmWalletProvider, args: z.infer<typeof DirectX402RequestSchema>): Promise<string>;
39
+ /**
40
+ * Checks if the action provider supports the given network.
41
+ *
42
+ * @param network - The network to check support for
43
+ * @returns True if the network is supported, false otherwise
35
44
  */
36
45
  supportsNetwork: (network: Network) => boolean;
46
+ /**
47
+ * Helper method to handle HTTP errors consistently.
48
+ *
49
+ * @param error - The axios error to handle
50
+ * @param url - The URL that was being accessed when the error occurred
51
+ * @returns A JSON string containing formatted error details
52
+ */
53
+ private handleHttpError;
37
54
  }
38
55
  export declare const x402ActionProvider: () => X402ActionProvider;