rwagenthub-mcp 1.0.2 → 1.0.4
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/index.js +24 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -33,6 +33,11 @@ async function callGateway(api, inputs) {
|
|
|
33
33
|
headers: { "Content-Type": "application/json" },
|
|
34
34
|
body: JSON.stringify({ api, inputs }),
|
|
35
35
|
});
|
|
36
|
+
if (res.status === 402) {
|
|
37
|
+
const body = await res.json().catch(() => ({}));
|
|
38
|
+
const reason = body?.error?.invalidReason ?? body?.error ?? "payment_failed";
|
|
39
|
+
throw new Error(`payment_failed:${reason}`);
|
|
40
|
+
}
|
|
36
41
|
return res.json();
|
|
37
42
|
}
|
|
38
43
|
|
|
@@ -92,6 +97,25 @@ async function main() {
|
|
|
92
97
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
93
98
|
};
|
|
94
99
|
} catch (err) {
|
|
100
|
+
const msg = err.message ?? "";
|
|
101
|
+
const isPaymentError =
|
|
102
|
+
msg.startsWith("payment_failed") ||
|
|
103
|
+
msg.toLowerCase().includes("insufficient funds") ||
|
|
104
|
+
msg.toLowerCase().includes("insufficient_funds") ||
|
|
105
|
+
msg.toLowerCase().includes("failed to create payment payload");
|
|
106
|
+
if (isPaymentError) {
|
|
107
|
+
const isNoFunds =
|
|
108
|
+
msg.includes("insufficient_funds") ||
|
|
109
|
+
msg.toLowerCase().includes("insufficient funds") ||
|
|
110
|
+
msg.toLowerCase().includes("failed to create payment payload");
|
|
111
|
+
const detail = isNoFunds
|
|
112
|
+
? `Insufficient USDC balance on Base.\nWallet: ${account.address}\n\nTop up your wallet with USDC on Base and try again.`
|
|
113
|
+
: `Payment rejected by gateway (${msg.replace("payment_failed:", "")}).\nWallet: ${account.address}`;
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: "text", text: `Payment failed: ${detail}` }],
|
|
116
|
+
isError: true,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
95
119
|
return {
|
|
96
120
|
content: [{ type: "text", text: `Gateway error: ${err.message}` }],
|
|
97
121
|
isError: true,
|
package/package.json
CHANGED