agentic-x402 0.3.4 → 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 +1 -1
- package/openclaw.plugin.json +10 -1
- package/package.json +1 -1
- package/scripts/plugin/index.ts +1 -0
- package/scripts/plugin/types.ts +1 -0
- package/scripts/plugin/watcher.ts +18 -5
- package/skills/x402/SKILL.md +1 -1
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.
|
|
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
|
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "agentic-x402",
|
|
3
3
|
"name": "x402 Payments",
|
|
4
|
-
"version": "0.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
package/scripts/plugin/index.ts
CHANGED
package/scripts/plugin/types.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -208,23 +211,33 @@ export class PaymentWatcher implements PluginService {
|
|
|
208
211
|
|
|
209
212
|
private async sendHook(event: PaymentEvent): Promise<void> {
|
|
210
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
|
+
|
|
211
220
|
const hookUrl = `http://127.0.0.1:${port}/hooks/agent`;
|
|
212
221
|
|
|
213
222
|
try {
|
|
214
223
|
const response = await fetch(hookUrl, {
|
|
215
224
|
method: 'POST',
|
|
216
|
-
headers: {
|
|
225
|
+
headers: {
|
|
226
|
+
'Content-Type': 'application/json',
|
|
227
|
+
'Authorization': `Bearer ${this.hooksToken}`,
|
|
228
|
+
},
|
|
217
229
|
body: JSON.stringify({
|
|
230
|
+
message: `Payment detected on ${event.routerName}: +${event.increase} USDC (${event.previousBalance} → ${event.newBalance}). Router: ${event.routerAddress}`,
|
|
218
231
|
name: 'x402-payment',
|
|
219
232
|
wakeMode: 'now',
|
|
220
|
-
data: event,
|
|
221
233
|
}),
|
|
222
234
|
});
|
|
223
235
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
} else {
|
|
236
|
+
// /hooks/agent returns 202 on success (async run started)
|
|
237
|
+
if (response.status === 202 || response.ok) {
|
|
227
238
|
this.logger.debug(`Hook delivered for payment on ${event.routerName}`);
|
|
239
|
+
} else {
|
|
240
|
+
this.logger.warn(`Hook POST failed: ${response.status} ${response.statusText}`);
|
|
228
241
|
}
|
|
229
242
|
} catch (err) {
|
|
230
243
|
this.logger.warn(`Hook POST error: ${err instanceof Error ? err.message : String(err)}`);
|
package/skills/x402/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.
|
|
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
|
|