@coinbase/agentkit 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +373 -234
- package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +15 -15
- package/dist/action-providers/cdp/cdpApiActionProvider.js +110 -63
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +205 -124
- package/dist/action-providers/cdp/index.d.ts +0 -1
- package/dist/action-providers/cdp/index.js +0 -1
- package/dist/action-providers/cdp/schemas.d.ts +9 -70
- package/dist/action-providers/cdp/schemas.js +12 -61
- package/dist/action-providers/cdp-legacy/index.d.ts +3 -0
- package/dist/action-providers/{cdp-v2 → cdp-legacy}/index.js +2 -1
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.d.ts +45 -0
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.js +130 -0
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.test.js +146 -0
- package/dist/action-providers/{cdp/cdpWalletActionProvider.d.ts → cdp-legacy/legacyCdpWalletActionProvider.d.ts} +8 -8
- package/dist/action-providers/{cdp/cdpWalletActionProvider.js → cdp-legacy/legacyCdpWalletActionProvider.js} +14 -14
- package/dist/action-providers/{cdp/cdpWalletActionProvider.test.js → cdp-legacy/legacyCdpWalletActionProvider.test.js} +3 -3
- package/dist/action-providers/cdp-legacy/schemas.d.ts +91 -0
- package/dist/action-providers/cdp-legacy/schemas.js +77 -0
- package/dist/action-providers/erc20/erc20ActionProvider.js +1 -1
- package/dist/action-providers/index.d.ts +1 -1
- package/dist/action-providers/index.js +1 -1
- package/dist/action-providers/jupiter/jupiterActionProvider.test.js +2 -4
- package/dist/action-providers/x402/schemas.d.ts +58 -11
- package/dist/action-providers/x402/schemas.js +60 -8
- package/dist/action-providers/x402/x402ActionProvider.d.ts +33 -16
- package/dist/action-providers/x402/x402ActionProvider.js +203 -153
- package/dist/action-providers/x402/x402ActionProvider.test.js +78 -225
- package/dist/agentkit.d.ts +1 -0
- package/dist/agentkit.js +3 -2
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.d.ts → cdpEvmWalletProvider.d.ts} +16 -7
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.js → cdpEvmWalletProvider.js} +50 -39
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.test.js → cdpEvmWalletProvider.test.js} +7 -7
- package/dist/wallet-providers/{cdpV2Shared.d.ts → cdpShared.d.ts} +15 -4
- package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +115 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.js +263 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.test.js +287 -0
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.d.ts → cdpSolanaWalletProvider.d.ts} +16 -7
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.js → cdpSolanaWalletProvider.js} +43 -32
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.js → cdpSolanaWalletProvider.test.js} +7 -7
- package/dist/wallet-providers/index.d.ts +6 -6
- package/dist/wallet-providers/index.js +6 -6
- package/dist/wallet-providers/{smartWalletProvider.d.ts → legacyCdpSmartWalletProvider.d.ts} +3 -3
- package/dist/wallet-providers/{smartWalletProvider.js → legacyCdpSmartWalletProvider.js} +21 -21
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/{smartWalletProvider.test.js → legacyCdpSmartWalletProvider.test.js} +2 -2
- package/dist/wallet-providers/{cdpWalletProvider.d.ts → legacyCdpWalletProvider.d.ts} +15 -11
- package/dist/wallet-providers/{cdpWalletProvider.js → legacyCdpWalletProvider.js} +72 -70
- package/dist/wallet-providers/legacyCdpWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/{cdpWalletProvider.test.js → legacyCdpWalletProvider.test.js} +10 -10
- package/package.json +3 -2
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +0 -34
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +0 -98
- package/dist/action-providers/cdp-v2/index.d.ts +0 -2
- package/dist/action-providers/cdp-v2/schemas.d.ts +0 -11
- package/dist/action-providers/cdp-v2/schemas.js +0 -13
- package/dist/wallet-providers/cdpV2WalletProvider.d.ts +0 -35
- package/dist/wallet-providers/cdpV2WalletProvider.js +0 -42
- /package/dist/action-providers/{cdp → cdp-legacy}/constants.d.ts +0 -0
- /package/dist/action-providers/{cdp → cdp-legacy}/constants.js +0 -0
- /package/dist/action-providers/{cdp/cdpWalletActionProvider.test.d.ts → cdp-legacy/legacyCdpApiActionProvider.test.d.ts} +0 -0
- /package/dist/{wallet-providers/cdpV2EvmWalletProvider.test.d.ts → action-providers/cdp-legacy/legacyCdpWalletActionProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.d.ts → cdpEvmWalletProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{cdpV2Shared.js → cdpShared.js} +0 -0
- /package/dist/wallet-providers/{cdpWalletProvider.test.d.ts → cdpSmartWalletProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{smartWalletProvider.test.d.ts → cdpSolanaWalletProvider.test.d.ts} +0 -0
|
@@ -22,217 +22,267 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
22
22
|
const x402_axios_1 = require("x402-axios");
|
|
23
23
|
const SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
|
|
24
24
|
/**
|
|
25
|
-
* X402ActionProvider
|
|
25
|
+
* X402ActionProvider provides actions for making HTTP requests, with optional x402 payment handling.
|
|
26
26
|
*/
|
|
27
27
|
class X402ActionProvider extends actionProvider_1.ActionProvider {
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Creates a new instance of X402ActionProvider.
|
|
30
|
+
* Initializes the provider with x402 capabilities.
|
|
30
31
|
*/
|
|
31
32
|
constructor() {
|
|
32
33
|
super("x402", []);
|
|
33
34
|
/**
|
|
34
|
-
* Checks if the
|
|
35
|
+
* Checks if the action provider supports the given network.
|
|
35
36
|
*
|
|
36
|
-
* @param network - The network to check
|
|
37
|
-
* @returns True if the
|
|
37
|
+
* @param network - The network to check support for
|
|
38
|
+
* @returns True if the network is supported, false otherwise
|
|
38
39
|
*/
|
|
39
40
|
this.supportsNetwork = (network) => network.protocolFamily === "evm" && SUPPORTED_NETWORKS.includes(network.networkId);
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
|
-
* Makes a
|
|
43
|
+
* Makes a basic HTTP request to an API endpoint.
|
|
43
44
|
*
|
|
44
|
-
* @param walletProvider - The wallet provider to use for
|
|
45
|
-
* @param args - The
|
|
46
|
-
* @returns A
|
|
45
|
+
* @param walletProvider - The wallet provider to use for potential payments
|
|
46
|
+
* @param args - The request parameters including URL, method, headers, and body
|
|
47
|
+
* @returns A JSON string containing the response or error details
|
|
47
48
|
*/
|
|
48
|
-
async
|
|
49
|
+
async makeHttpRequest(walletProvider, args) {
|
|
49
50
|
try {
|
|
50
|
-
|
|
51
|
-
const account = walletProvider.toSigner();
|
|
52
|
-
// Create an axios instance with the payment interceptor
|
|
53
|
-
const api = (0, x402_axios_1.withPaymentInterceptor)(axios_1.default.create({}), account);
|
|
54
|
-
// Make the request
|
|
55
|
-
const response = await api.request({
|
|
51
|
+
const response = await axios_1.default.request({
|
|
56
52
|
url: args.url,
|
|
57
|
-
method: args.method,
|
|
58
|
-
headers: args.headers,
|
|
53
|
+
method: args.method ?? "GET",
|
|
54
|
+
headers: args.headers ?? undefined,
|
|
59
55
|
data: args.body,
|
|
56
|
+
validateStatus: status => status === 402 || (status >= 200 && status < 300),
|
|
60
57
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
if (response.status !== 402) {
|
|
59
|
+
return JSON.stringify({
|
|
60
|
+
success: true,
|
|
61
|
+
url: args.url,
|
|
62
|
+
method: args.method,
|
|
63
|
+
status: response.status,
|
|
64
|
+
data: response.data,
|
|
65
|
+
}, null, 2);
|
|
66
|
+
}
|
|
67
|
+
return JSON.stringify({
|
|
68
|
+
status: "error_402_payment_required",
|
|
69
|
+
acceptablePaymentOptions: response.data.accepts,
|
|
70
|
+
nextSteps: [
|
|
71
|
+
"Inform the user that the requested server replied with a 402 Payment Required response.",
|
|
72
|
+
`The payment options are: ${response.data.accepts.map(option => `${option.asset} ${option.maxAmountRequired} ${option.network}`).join(", ")}`,
|
|
73
|
+
"Ask the user if they want to retry the request with payment.",
|
|
74
|
+
`Use retry_http_request_with_x402 to retry the request with payment.`,
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return this.handleHttpError(error, args.url);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Retries a request with x402 payment after receiving a 402 response.
|
|
84
|
+
*
|
|
85
|
+
* @param walletProvider - The wallet provider to use for making the payment
|
|
86
|
+
* @param args - The request parameters including URL, method, headers, body, and payment option
|
|
87
|
+
* @returns A JSON string containing the response with payment details or error information
|
|
88
|
+
*/
|
|
89
|
+
async retryWithX402(walletProvider, args) {
|
|
90
|
+
try {
|
|
91
|
+
// Make the request with payment handling
|
|
92
|
+
const account = walletProvider.toSigner();
|
|
93
|
+
const paymentSelector = (accepts) => {
|
|
94
|
+
const { scheme, network, maxAmountRequired, asset } = args.selectedPaymentOption;
|
|
95
|
+
let paymentRequirements = accepts.find(accept => accept.scheme === scheme &&
|
|
96
|
+
accept.network === network &&
|
|
97
|
+
accept.maxAmountRequired <= maxAmountRequired &&
|
|
98
|
+
accept.asset === asset);
|
|
99
|
+
if (paymentRequirements) {
|
|
100
|
+
return paymentRequirements;
|
|
67
101
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
paymentResponse = {
|
|
75
|
-
error: "Failed to decode payment response",
|
|
76
|
-
rawHeader: paymentResponseHeader,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
102
|
+
paymentRequirements = accepts.find(accept => accept.scheme === scheme &&
|
|
103
|
+
accept.network === network &&
|
|
104
|
+
accept.maxAmountRequired <= maxAmountRequired &&
|
|
105
|
+
accept.asset === asset);
|
|
106
|
+
if (paymentRequirements) {
|
|
107
|
+
return paymentRequirements;
|
|
79
108
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
109
|
+
return accepts[0];
|
|
110
|
+
};
|
|
111
|
+
const api = (0, x402_axios_1.withPaymentInterceptor)(axios_1.default.create({}), account, paymentSelector);
|
|
112
|
+
const response = await api.request({
|
|
84
113
|
url: args.url,
|
|
85
|
-
method: args.method,
|
|
86
|
-
|
|
114
|
+
method: args.method ?? "GET",
|
|
115
|
+
headers: args.headers ?? undefined,
|
|
116
|
+
data: args.body,
|
|
117
|
+
});
|
|
118
|
+
// Check for payment proof
|
|
119
|
+
const paymentProof = response.headers["x-payment-response"]
|
|
120
|
+
? (0, x402_axios_1.decodeXPaymentResponse)(response.headers["x-payment-response"])
|
|
121
|
+
: null;
|
|
122
|
+
return JSON.stringify({
|
|
123
|
+
status: "success",
|
|
87
124
|
data: response.data,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
125
|
+
message: "Request completed successfully with payment",
|
|
126
|
+
details: {
|
|
127
|
+
url: args.url,
|
|
128
|
+
method: args.method,
|
|
129
|
+
paymentUsed: {
|
|
130
|
+
network: args.selectedPaymentOption.network,
|
|
131
|
+
asset: args.selectedPaymentOption.asset,
|
|
132
|
+
amount: args.selectedPaymentOption.maxAmountRequired,
|
|
133
|
+
},
|
|
134
|
+
paymentProof: paymentProof
|
|
135
|
+
? {
|
|
136
|
+
transaction: paymentProof.transaction,
|
|
137
|
+
network: paymentProof.network,
|
|
138
|
+
payer: paymentProof.payer,
|
|
139
|
+
}
|
|
140
|
+
: null,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
91
143
|
}
|
|
92
144
|
catch (error) {
|
|
93
|
-
|
|
94
|
-
if (axiosError.response) {
|
|
95
|
-
return `Error making paid request to ${args.url}: HTTP ${axiosError.response.status} - ${axiosError.response.data?.error || axiosError.response.statusText}`;
|
|
96
|
-
}
|
|
97
|
-
else if (axiosError.request) {
|
|
98
|
-
return `Error making paid request to ${args.url}: Network error - ${axiosError.message}`;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
return `Error making paid request to ${args.url}: ${axiosError.message}`;
|
|
102
|
-
}
|
|
145
|
+
return this.handleHttpError(error, args.url);
|
|
103
146
|
}
|
|
104
147
|
}
|
|
105
148
|
/**
|
|
106
|
-
*
|
|
149
|
+
* Makes an HTTP request with automatic x402 payment handling.
|
|
107
150
|
*
|
|
108
|
-
* @param walletProvider - The wallet provider
|
|
109
|
-
* @param args - The
|
|
110
|
-
* @returns A
|
|
151
|
+
* @param walletProvider - The wallet provider to use for automatic payments
|
|
152
|
+
* @param args - The request parameters including URL, method, headers, and body
|
|
153
|
+
* @returns A JSON string containing the response with optional payment details or error information
|
|
111
154
|
*/
|
|
112
|
-
async
|
|
155
|
+
async makeHttpRequestWithX402(walletProvider, args) {
|
|
113
156
|
try {
|
|
114
|
-
|
|
115
|
-
const
|
|
157
|
+
const account = walletProvider.toSigner();
|
|
158
|
+
const api = (0, x402_axios_1.withPaymentInterceptor)(axios_1.default.create({}), account);
|
|
159
|
+
const response = await api.request({
|
|
116
160
|
url: args.url,
|
|
117
|
-
method: args.method,
|
|
118
|
-
headers: args.headers,
|
|
119
|
-
|
|
161
|
+
method: args.method ?? "GET",
|
|
162
|
+
headers: args.headers ?? undefined,
|
|
163
|
+
data: args.body,
|
|
120
164
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
165
|
+
// Check for payment proof
|
|
166
|
+
const paymentProof = response.headers["x-payment-response"]
|
|
167
|
+
? (0, x402_axios_1.decodeXPaymentResponse)(response.headers["x-payment-response"])
|
|
168
|
+
: null;
|
|
169
|
+
return JSON.stringify({
|
|
170
|
+
success: true,
|
|
171
|
+
message: "Request completed successfully (payment handled automatically if required)",
|
|
172
|
+
url: args.url,
|
|
173
|
+
method: args.method,
|
|
174
|
+
status: response.status,
|
|
175
|
+
data: response.data,
|
|
176
|
+
paymentProof: paymentProof
|
|
177
|
+
? {
|
|
178
|
+
transaction: paymentProof.transaction,
|
|
179
|
+
network: paymentProof.network,
|
|
180
|
+
payer: paymentProof.payer,
|
|
181
|
+
}
|
|
182
|
+
: null,
|
|
183
|
+
}, null, 2);
|
|
138
184
|
}
|
|
139
185
|
catch (error) {
|
|
140
|
-
|
|
141
|
-
if (axiosError.response) {
|
|
142
|
-
if (axiosError.response.status === 402) {
|
|
143
|
-
// Handle 402 responses that axios might treat as errors
|
|
144
|
-
const paymentResponseHeader = axiosError.response.headers["x-payment-response"];
|
|
145
|
-
let paymentDetails = null;
|
|
146
|
-
if (paymentResponseHeader) {
|
|
147
|
-
try {
|
|
148
|
-
paymentDetails = (0, x402_axios_1.decodeXPaymentResponse)(paymentResponseHeader);
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
// Fall back to JSON parsing if decodeXPaymentResponse fails
|
|
152
|
-
try {
|
|
153
|
-
paymentDetails = JSON.parse(paymentResponseHeader);
|
|
154
|
-
}
|
|
155
|
-
catch {
|
|
156
|
-
paymentDetails = {
|
|
157
|
-
error: "Failed to decode payment response",
|
|
158
|
-
rawHeader: paymentResponseHeader,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return JSON.stringify({
|
|
164
|
-
paymentRequired: true,
|
|
165
|
-
url: args.url,
|
|
166
|
-
status: 402,
|
|
167
|
-
paymentDetails: paymentDetails,
|
|
168
|
-
data: axiosError.response.data,
|
|
169
|
-
}, null, 2);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
return `Error fetching payment info from ${args.url}: HTTP ${axiosError.response.status} - ${axiosError.response.data?.error || axiosError.response.statusText}`;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else if (axiosError.request) {
|
|
176
|
-
return `Error fetching payment info from ${args.url}: Network error - ${axiosError.message}`;
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
return `Error fetching payment info from ${args.url}: ${axiosError.message}`;
|
|
180
|
-
}
|
|
186
|
+
return this.handleHttpError(error, args.url);
|
|
181
187
|
}
|
|
182
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Helper method to handle HTTP errors consistently.
|
|
191
|
+
*
|
|
192
|
+
* @param error - The axios error to handle
|
|
193
|
+
* @param url - The URL that was being accessed when the error occurred
|
|
194
|
+
* @returns A JSON string containing formatted error details
|
|
195
|
+
*/
|
|
196
|
+
handleHttpError(error, url) {
|
|
197
|
+
if (error.response) {
|
|
198
|
+
return JSON.stringify({
|
|
199
|
+
error: true,
|
|
200
|
+
message: `HTTP ${error.response.status} error when accessing ${url}`,
|
|
201
|
+
details: error.response.data?.error || error.response.statusText,
|
|
202
|
+
suggestion: "Check if the URL is correct and the API is available.",
|
|
203
|
+
}, null, 2);
|
|
204
|
+
}
|
|
205
|
+
if (error.request) {
|
|
206
|
+
return JSON.stringify({
|
|
207
|
+
error: true,
|
|
208
|
+
message: `Network error when accessing ${url}`,
|
|
209
|
+
details: error.message,
|
|
210
|
+
suggestion: "Check your internet connection and verify the API endpoint is accessible.",
|
|
211
|
+
}, null, 2);
|
|
212
|
+
}
|
|
213
|
+
return JSON.stringify({
|
|
214
|
+
error: true,
|
|
215
|
+
message: `Error making request to ${url}`,
|
|
216
|
+
details: error.message,
|
|
217
|
+
suggestion: "Please check the request parameters and try again.",
|
|
218
|
+
}, null, 2);
|
|
219
|
+
}
|
|
183
220
|
}
|
|
184
221
|
exports.X402ActionProvider = X402ActionProvider;
|
|
185
222
|
__decorate([
|
|
186
223
|
(0, actionDecorator_1.CreateAction)({
|
|
187
|
-
name: "
|
|
224
|
+
name: "make_http_request",
|
|
188
225
|
description: `
|
|
189
|
-
|
|
226
|
+
Makes a basic HTTP request to an API endpoint. If the endpoint requires payment (returns 402),
|
|
227
|
+
it will return payment details that can be used with retry_http_request_with_x402.
|
|
228
|
+
|
|
229
|
+
EXAMPLES:
|
|
230
|
+
- Production API: make_http_request("https://api.example.com/weather")
|
|
231
|
+
- Local development: make_http_request("http://localhost:3000/api/data")
|
|
232
|
+
- Testing x402: make_http_request("http://localhost:3000/protected")
|
|
190
233
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
234
|
+
If you receive a 402 Payment Required response, use retry_http_request_with_x402 to handle the payment.`,
|
|
235
|
+
schema: schemas_1.HttpRequestSchema,
|
|
236
|
+
}),
|
|
237
|
+
__metadata("design:type", Function),
|
|
238
|
+
__metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
|
|
239
|
+
__metadata("design:returntype", Promise)
|
|
240
|
+
], X402ActionProvider.prototype, "makeHttpRequest", null);
|
|
241
|
+
__decorate([
|
|
242
|
+
(0, actionDecorator_1.CreateAction)({
|
|
243
|
+
name: "retry_http_request_with_x402",
|
|
244
|
+
description: `
|
|
245
|
+
Retries an HTTP request with x402 payment after receiving a 402 Payment Required response.
|
|
246
|
+
This should be used after make_http_request returns a 402 response.
|
|
196
247
|
|
|
197
|
-
|
|
198
|
-
1.
|
|
199
|
-
2. If a 402
|
|
200
|
-
3.
|
|
201
|
-
4. Return the API response data
|
|
248
|
+
EXAMPLE WORKFLOW:
|
|
249
|
+
1. First call make_http_request("http://localhost:3000/protected")
|
|
250
|
+
2. If you get a 402 response, use this action to retry with payment
|
|
251
|
+
3. Pass the entire original response to this action
|
|
202
252
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
schema: schemas_1.PaidRequestSchema,
|
|
253
|
+
DO NOT use this action directly without first trying make_http_request!`,
|
|
254
|
+
schema: schemas_1.RetryWithX402Schema,
|
|
206
255
|
}),
|
|
207
256
|
__metadata("design:type", Function),
|
|
208
257
|
__metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
|
|
209
258
|
__metadata("design:returntype", Promise)
|
|
210
|
-
], X402ActionProvider.prototype, "
|
|
259
|
+
], X402ActionProvider.prototype, "retryWithX402", null);
|
|
211
260
|
__decorate([
|
|
212
261
|
(0, actionDecorator_1.CreateAction)({
|
|
213
|
-
name: "
|
|
262
|
+
name: "make_http_request_with_x402",
|
|
214
263
|
description: `
|
|
215
|
-
|
|
264
|
+
⚠️ WARNING: This action automatically handles payments without asking for confirmation!
|
|
265
|
+
Only use this when explicitly told to skip the confirmation flow.
|
|
216
266
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
- headers: Optional additional headers to include in the request
|
|
267
|
+
For most cases, you should:
|
|
268
|
+
1. First try make_http_request
|
|
269
|
+
2. Then use retry_http_request_with_x402 if payment is required
|
|
221
270
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
271
|
+
This action combines both steps into one, which means:
|
|
272
|
+
- No chance to review payment details before paying
|
|
273
|
+
- No confirmation step
|
|
274
|
+
- Automatic payment processing
|
|
226
275
|
|
|
227
|
-
|
|
276
|
+
EXAMPLES:
|
|
277
|
+
- Production: make_http_request_with_x402("https://api.example.com/data")
|
|
278
|
+
- Local dev: make_http_request_with_x402("http://localhost:3000/protected")
|
|
228
279
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
schema: schemas_1.FetchPaymentInfoSchema,
|
|
280
|
+
Unless specifically instructed otherwise, prefer the two-step approach with make_http_request first.`,
|
|
281
|
+
schema: schemas_1.DirectX402RequestSchema,
|
|
232
282
|
}),
|
|
233
283
|
__metadata("design:type", Function),
|
|
234
284
|
__metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
|
|
235
285
|
__metadata("design:returntype", Promise)
|
|
236
|
-
], X402ActionProvider.prototype, "
|
|
286
|
+
], X402ActionProvider.prototype, "makeHttpRequestWithX402", null);
|
|
237
287
|
const x402ActionProvider = () => new X402ActionProvider();
|
|
238
288
|
exports.x402ActionProvider = x402ActionProvider;
|