agentic-x402 0.3.3 → 0.3.5

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/SKILL.md CHANGED
@@ -4,7 +4,7 @@ description: Make x402 payments to access gated APIs and content. Fetch paid res
4
4
  license: MIT
5
5
  compatibility: Requires Node.js 20+, network access to x402 facilitators and EVM chains
6
6
  homepage: https://www.npmjs.com/package/agentic-x402
7
- metadata: {"author": "monemetrics", "version": "0.3.3", "openclaw": {"requires": {"bins": ["x402"], "env": ["EVM_PRIVATE_KEY"]}, "primaryEnv": "EVM_PRIVATE_KEY", "install": [{"id": "node", "kind": "node", "package": "agentic-x402", "bins": ["x402"], "label": "Install agentic-x402 (npm)"}], "plugin": true}}
7
+ metadata: {"author": "monemetrics", "version": "0.3.5", "openclaw": {"requires": {"bins": ["x402"], "env": ["EVM_PRIVATE_KEY"]}, "primaryEnv": "EVM_PRIVATE_KEY", "install": [{"id": "node", "kind": "node", "package": "agentic-x402", "bins": ["x402"], "label": "Install agentic-x402 (npm)"}], "plugin": true}}
8
8
  allowed-tools: Bash(x402:*) Bash(npm:*) Read
9
9
  ---
10
10
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "agentic-x402",
3
3
  "name": "x402 Payments",
4
- "version": "0.3.3",
4
+ "version": "0.3.5",
5
5
  "description": "Agent skill for x402 payments — pay for and sell gated content with background payment watching",
6
6
  "skills": ["./skills/x402"],
7
7
  "configSchema": {
@@ -27,6 +27,10 @@
27
27
  "default": "https://21.cash",
28
28
  "description": "Base URL of the x402 links API (21.cash)"
29
29
  },
30
+ "hooksToken": {
31
+ "type": "string",
32
+ "description": "Bearer token for gateway hooks endpoint (must match hooks.token in gateway config). Falls back to OPENCLAW_HOOKS_TOKEN env var."
33
+ },
30
34
  "watcher": {
31
35
  "type": "object",
32
36
  "properties": {
@@ -68,6 +72,11 @@
68
72
  "x402LinksApiUrl": {
69
73
  "label": "21.cash API URL",
70
74
  "placeholder": "https://21.cash"
75
+ },
76
+ "hooksToken": {
77
+ "label": "Hooks Token",
78
+ "sensitive": true,
79
+ "placeholder": "your-hooks-secret"
71
80
  }
72
81
  }
73
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-x402",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Agent skill for x402 payments - pay for and sell gated content",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,6 +26,7 @@ export default {
26
26
  watcher = new PaymentWatcher({
27
27
  logger,
28
28
  gatewayPort,
29
+ hooksToken: pluginConfig.hooksToken,
29
30
  pollIntervalMs: pluginConfig.watcher?.pollIntervalMs,
30
31
  notifyOnPayment: pluginConfig.watcher?.notifyOnPayment,
31
32
  });
@@ -67,6 +67,7 @@ export interface X402PluginConfig {
67
67
  network?: 'mainnet' | 'testnet';
68
68
  maxPaymentUsd?: number;
69
69
  x402LinksApiUrl?: string;
70
+ hooksToken?: string;
70
71
  watcher?: {
71
72
  enabled?: boolean;
72
73
  pollIntervalMs?: number;
@@ -20,6 +20,7 @@ const ERC20_BALANCE_ABI = [{
20
20
  interface WatcherOptions {
21
21
  logger: PluginLogger;
22
22
  gatewayPort: number;
23
+ hooksToken?: string;
23
24
  pollIntervalMs?: number;
24
25
  notifyOnPayment?: boolean;
25
26
  }
@@ -29,6 +30,7 @@ export class PaymentWatcher implements PluginService {
29
30
 
30
31
  private logger: PluginLogger;
31
32
  private gatewayPort: number;
33
+ private hooksToken: string | undefined;
32
34
  private pollIntervalMs: number;
33
35
  private notifyOnPayment: boolean;
34
36
 
@@ -42,6 +44,7 @@ export class PaymentWatcher implements PluginService {
42
44
  constructor(options: WatcherOptions) {
43
45
  this.logger = options.logger;
44
46
  this.gatewayPort = options.gatewayPort;
47
+ this.hooksToken = options.hooksToken || process.env.OPENCLAW_HOOKS_TOKEN;
45
48
  this.pollIntervalMs = options.pollIntervalMs ?? 30_000;
46
49
  this.notifyOnPayment = options.notifyOnPayment ?? true;
47
50
  }
@@ -207,23 +210,34 @@ export class PaymentWatcher implements PluginService {
207
210
  }
208
211
 
209
212
  private async sendHook(event: PaymentEvent): Promise<void> {
210
- const hookUrl = `http://127.0.0.1:${this.gatewayPort}/hooks/agent`;
213
+ const port = this.gatewayPort || 18789;
214
+
215
+ if (!this.hooksToken) {
216
+ this.logger.warn('No hooks token configured — skipping hook delivery. Set hooksToken in plugin config or OPENCLAW_HOOKS_TOKEN env var.');
217
+ return;
218
+ }
219
+
220
+ const hookUrl = `http://127.0.0.1:${port}/hooks/agent`;
211
221
 
212
222
  try {
213
223
  const response = await fetch(hookUrl, {
214
224
  method: 'POST',
215
- headers: { 'Content-Type': 'application/json' },
225
+ headers: {
226
+ 'Content-Type': 'application/json',
227
+ 'Authorization': `Bearer ${this.hooksToken}`,
228
+ },
216
229
  body: JSON.stringify({
230
+ message: `Payment detected on ${event.routerName}: +${event.increase} USDC (${event.previousBalance} → ${event.newBalance}). Router: ${event.routerAddress}`,
217
231
  name: 'x402-payment',
218
232
  wakeMode: 'now',
219
- data: event,
220
233
  }),
221
234
  });
222
235
 
223
- if (!response.ok) {
224
- this.logger.warn(`Hook POST failed: ${response.status} ${response.statusText}`);
225
- } else {
236
+ // /hooks/agent returns 202 on success (async run started)
237
+ if (response.status === 202 || response.ok) {
226
238
  this.logger.debug(`Hook delivered for payment on ${event.routerName}`);
239
+ } else {
240
+ this.logger.warn(`Hook POST failed: ${response.status} ${response.statusText}`);
227
241
  }
228
242
  } catch (err) {
229
243
  this.logger.warn(`Hook POST error: ${err instanceof Error ? err.message : String(err)}`);
@@ -4,7 +4,7 @@ description: Make x402 payments to access gated APIs and content. Fetch paid res
4
4
  license: MIT
5
5
  compatibility: Requires Node.js 20+, network access to x402 facilitators and EVM chains
6
6
  homepage: https://www.npmjs.com/package/agentic-x402
7
- metadata: {"author": "monemetrics", "version": "0.3.3", "openclaw": {"requires": {"bins": ["x402"], "env": ["EVM_PRIVATE_KEY"]}, "primaryEnv": "EVM_PRIVATE_KEY", "install": [{"id": "node", "kind": "node", "package": "agentic-x402", "bins": ["x402"], "label": "Install agentic-x402 (npm)"}], "plugin": true}}
7
+ metadata: {"author": "monemetrics", "version": "0.3.5", "openclaw": {"requires": {"bins": ["x402"], "env": ["EVM_PRIVATE_KEY"]}, "primaryEnv": "EVM_PRIVATE_KEY", "install": [{"id": "node", "kind": "node", "package": "agentic-x402", "bins": ["x402"], "label": "Install agentic-x402 (npm)"}], "plugin": true}}
8
8
  allowed-tools: Bash(x402:*) Bash(npm:*) Read
9
9
  ---
10
10