wolverine-ai 5.5.0 → 5.5.2
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/package.json +1 -1
- package/src/brain/brain.js +3 -3
- package/src/core/init-server.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wolverine-ai",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.2",
|
|
4
4
|
"description": "Self-healing Node.js server framework powered by AI. Catches crashes, diagnoses errors, generates fixes, verifies, and restarts — automatically.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
package/src/brain/brain.js
CHANGED
|
@@ -190,15 +190,15 @@ const SEED_DOCS = [
|
|
|
190
190
|
metadata: { topic: "notifications" },
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
|
-
text: "x402 paid APIs — turn any route into a paid API with one flag. Register the plugin: fastify.register(require('wolverine-ai/src/middleware/x402-fastify')). Add { config: { x402: { price: '$0.10' } } } to any route. Routes WITHOUT x402 config are unaffected. Two modes: (1) Fixed price: { x402: { price: '$0.10' } }. (2) Variable price: { x402: { variable: true, min: '$1', max: '$10000', priceField: 'dollars' } }. Uses @coinbase/x402 facilitator
|
|
193
|
+
text: "x402 paid APIs — turn any route into a paid API with one flag. Register the plugin: fastify.register(require('wolverine-ai/src/middleware/x402-fastify')). Add { config: { x402: { price: '$0.10' } } } to any route. Routes WITHOUT x402 config are unaffected. Two modes: (1) Fixed price: { x402: { price: '$0.10' } }. (2) Variable price: { x402: { variable: true, min: '$1', max: '$10000', priceField: 'dollars' } }. Uses x402 v2 protocol: @x402/core SDK (x402ResourceServer + ExactEvmScheme) with @coinbase/x402 facilitator for CDP auth. The trick: pass @coinbase/x402's facilitator config to @x402/core's HTTPFacilitatorClient — this gives v2 protocol with working CDP JWT auth. Network is CAIP-2 format 'eip155:8453' (Base mainnet). Payment header: X-PAYMENT or payment-signature (base64 JSON). Verify AND settle both happen in preHandler — handler only runs after USDC moves on-chain. Vault wallet auto-detected as payTo. Requires: Node 22+, CDP_API_KEY_ID + CDP_API_KEY_SECRET in .env.local (free at cdp.coinbase.com), npm packages @coinbase/x402 + @x402/core + @x402/evm + viem. Auto-installed on startup when vault exists. CRITICAL: (1) Do NOT set facilitator URL in settings.json. (2) paymentRequirements uses 'amount' field (v2) not 'maxAmountRequired' (v1). (3) paymentRequirements.extra = { name: 'USD Coin', version: '2' } for EIP-712. (4) Frontend payload: { x402Version: 2, scheme: 'exact', network: 'eip155:8453', payload: { authorization: { from, to, value (decimal string), validAfter (string), validBefore (string), nonce (0x hex) }, signature } }. (5) Values must be decimal strings not hex. Dashboard tracks x402 payments, revenue by route, USDC/ETH balances.",
|
|
194
194
|
metadata: { topic: "x402-paid-apis" },
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
|
-
text: "x402 examples — making a paid API is as simple as adding a route. FREE route: fastify.get('/api/data', async (req) => { return getData(); }). PAID route: fastify.get('/api/premium', { config: { x402: { price: '$0.01' } } }, async (req) => { return { data: 'premium', paid: req.x402
|
|
197
|
+
text: "x402 examples — making a paid API is as simple as adding a route. FREE route: fastify.get('/api/data', async (req) => { return getData(); }). PAID route: fastify.get('/api/premium', { config: { x402: { price: '$0.01' } } }, async (req) => { return { data: 'premium', paid: req.x402.amount, txHash: req.x402.txHash }; }). CREDIT PURCHASE: fastify.post('/buy', { config: { x402: { variable: true, min: '$1', max: '$10000', priceField: 'dollars' } } }, async (req) => { const credits = parseFloat(req.x402.amount.replace('$','')) * 100; return { credits, txHash: req.x402.txHash }; }). Frontend integration: sign EIP-3009 TransferWithAuthorization with eth_signTypedData_v4. v2 payload format: { x402Version: 2, payload: { authorization: { from, to, value (decimal string), validAfter (string), validBefore (string), nonce (0x hex) }, signature }, accepted: { scheme: 'exact', network: 'eip155:8453', amount: usdcAtomicUnits, asset: USDC_ADDRESS, payTo: receiverAddress, maxTimeoutSeconds: 60, extra: { name: 'USD Coin', version: '2' } } }. CRITICAL: the 'accepted' field is required for v2 — it contains the payment requirements the client accepted. Without it the facilitator returns 400 'paymentPayload is invalid'. Base64 encode the payload and send as X-PAYMENT header. Values MUST be decimal strings ('1000000' for $1) NOT hex. validAfter = String(now - 600), validBefore = String(now + 300). Both verify + settle happen in preHandler BEFORE handler runs. Handler only executes after USDC moves on-chain. req.x402 = { paid: true, amount: '$5.00', from: '0x...', txHash: '0x...', settled: true }.",
|
|
198
198
|
metadata: { topic: "x402-examples" },
|
|
199
199
|
},
|
|
200
200
|
{
|
|
201
|
-
text: "x402 troubleshooting — common issues and fixes. (1) '
|
|
201
|
+
text: "x402 troubleshooting — common issues and fixes. (1) 'Unauthorized' from CDP facilitator: the @coinbase/x402 package handles JWT auth internally using CDP_API_KEY_ID + CDP_API_KEY_SECRET from env vars — do NOT set a facilitator URL in settings.json. (2) '400 Bad Request': payload format mismatch — v2 uses x402Version:2, network:'eip155:8453', amount (not maxAmountRequired). Parse base64 JSON directly, don't use decodePayment(). (3) 'invalid_exact_evm_payload_signature': EIP-712 signature wrong — check domain (name:'USD Coin', version:'2', chainId:8453, verifyingContract:USDC). (4) USDC not moving: old middleware only verified without settling — must use x402ResourceServer.verifyPayment() + settlePayment() which goes through the CDP facilitator. (5) Frontend value as hex (0xf4240): must use decimal strings ('1000000'). (6) ESM errors: @coinbase/x402 needs Node 22+. (7) Packages disappearing after --update: they're in package.json dependencies + auto-installed on startup when vault exists. (8) Credits granted before settlement: verify+settle must both be in preHandler, not onSend. (9) v2 auth trick: pass @coinbase/x402's facilitator config to @x402/core HTTPFacilitatorClient — this gives v2 protocol with CDP auth that actually works.",
|
|
202
202
|
metadata: { topic: "x402-troubleshooting" },
|
|
203
203
|
},
|
|
204
204
|
{
|
package/src/core/init-server.js
CHANGED
|
@@ -77,7 +77,7 @@ function ensureX402Deps(cwd) {
|
|
|
77
77
|
console.log(chalk.blue(" 📦 Installing x402 payment dependencies..."));
|
|
78
78
|
try {
|
|
79
79
|
const { execSync } = require("child_process");
|
|
80
|
-
execSync("npm install @coinbase/x402 x402 viem --no-save --ignore-engines 2>/dev/null", {
|
|
80
|
+
execSync("npm install @coinbase/x402 @x402/core @x402/evm x402 viem --no-save --ignore-engines 2>/dev/null", {
|
|
81
81
|
cwd,
|
|
82
82
|
stdio: "pipe",
|
|
83
83
|
timeout: 60000,
|