@nevermined-io/openclaw-plugin 1.1.0 → 1.1.1
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/dist/config.d.ts +76 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +203 -22
- package/dist/index.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +97 -12
- package/dist/tools.js.map +1 -1
- package/docs/commands.md +142 -30
- package/docs/getting-started.md +16 -4
- package/docs/guide.md +50 -10
- package/docs/setup.md +7 -1
- package/openclaw.plugin.json +47 -2
- package/package.json +3 -3
- package/skills/nevermined/SKILL.md +21 -5
package/docs/guide.md
CHANGED
|
@@ -12,22 +12,24 @@ This guide walks through building a **Weather Oracle** — a paid agent that ser
|
|
|
12
12
|
|
|
13
13
|
## What You Get
|
|
14
14
|
|
|
15
|
-
The plugin adds
|
|
15
|
+
The plugin adds 9 payment tools and 2 slash commands to your OpenClaw gateway:
|
|
16
16
|
|
|
17
17
|
**Subscriber tools** — for users who consume paid services:
|
|
18
18
|
|
|
19
19
|
| Tool | Purpose |
|
|
20
20
|
|------|---------|
|
|
21
21
|
| `nevermined_checkBalance` | Check remaining credits on a plan |
|
|
22
|
-
| `nevermined_getAccessToken` | Get an x402 token for authenticating requests |
|
|
23
|
-
| `nevermined_orderPlan` | Purchase a payment plan |
|
|
24
|
-
| `
|
|
22
|
+
| `nevermined_getAccessToken` | Get an x402 token for authenticating requests (crypto or fiat) |
|
|
23
|
+
| `nevermined_orderPlan` | Purchase a crypto payment plan |
|
|
24
|
+
| `nevermined_orderFiatPlan` | Purchase a fiat payment plan (returns Stripe checkout URL) |
|
|
25
|
+
| `nevermined_listPaymentMethods` | List enrolled credit cards for fiat payments |
|
|
26
|
+
| `nevermined_queryAgent` | Send a paid query to an agent (crypto or fiat) |
|
|
25
27
|
|
|
26
28
|
**Builder tools** — for developers who create paid services:
|
|
27
29
|
|
|
28
30
|
| Tool | Purpose |
|
|
29
31
|
|------|---------|
|
|
30
|
-
| `nevermined_registerAgent` | Register an agent with a payment plan |
|
|
32
|
+
| `nevermined_registerAgent` | Register an agent with a payment plan (crypto or fiat) |
|
|
31
33
|
| `nevermined_createPlan` | Create a standalone payment plan |
|
|
32
34
|
| `nevermined_listPlans` | List your payment plans |
|
|
33
35
|
|
|
@@ -60,7 +62,7 @@ openclaw gateway restart
|
|
|
60
62
|
You should see in the logs:
|
|
61
63
|
|
|
62
64
|
```
|
|
63
|
-
Registered
|
|
65
|
+
Registered 9 Nevermined payment tools
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
## Step 2: Authenticate
|
|
@@ -133,7 +135,7 @@ Add the returned IDs and enable the paid endpoint in your gateway config (`~/.op
|
|
|
133
135
|
Restart the gateway. You should see:
|
|
134
136
|
|
|
135
137
|
```
|
|
136
|
-
Registered
|
|
138
|
+
Registered 9 Nevermined payment tools
|
|
137
139
|
Registered paid endpoint at /nevermined/agent
|
|
138
140
|
```
|
|
139
141
|
|
|
@@ -189,6 +191,38 @@ The Claw calls `nevermined_queryAgent`, which:
|
|
|
189
191
|
|
|
190
192
|
Should show 4 credits — one was consumed.
|
|
191
193
|
|
|
194
|
+
## Fiat Payments (Credit Card)
|
|
195
|
+
|
|
196
|
+
The plugin supports fiat payments via credit card delegation, allowing users who have enrolled a card through the [Nevermined App](https://nevermined.app) to pay for agent queries without cryptocurrency.
|
|
197
|
+
|
|
198
|
+
### 1. Enroll a card
|
|
199
|
+
|
|
200
|
+
Users enroll a credit card via the Nevermined App under Settings > Payment Methods.
|
|
201
|
+
|
|
202
|
+
### 2. List enrolled cards
|
|
203
|
+
|
|
204
|
+
> List my payment methods
|
|
205
|
+
|
|
206
|
+
The Claw calls `nevermined_listPaymentMethods` and returns the enrolled cards with brand, last 4 digits, and expiration.
|
|
207
|
+
|
|
208
|
+
### 3. Order a fiat plan
|
|
209
|
+
|
|
210
|
+
> Order the fiat plan `<plan-id>`
|
|
211
|
+
|
|
212
|
+
The Claw calls `nevermined_orderFiatPlan`, which returns a Stripe checkout URL. The user completes payment in a browser.
|
|
213
|
+
|
|
214
|
+
### 4. Query an agent with fiat
|
|
215
|
+
|
|
216
|
+
> Ask the Weather Oracle at `http://localhost:18789/nevermined/agent` about the weather in Paris, pay with my credit card
|
|
217
|
+
|
|
218
|
+
The Claw calls `nevermined_queryAgent` with `paymentType: fiat`. The plugin:
|
|
219
|
+
1. Looks up enrolled payment methods (or uses the specified `paymentMethodId`)
|
|
220
|
+
2. Gets an x402 access token using the `nvm:card-delegation` scheme
|
|
221
|
+
3. Sends the request with the `PAYMENT-SIGNATURE` header
|
|
222
|
+
4. The agent verifies and settles as usual
|
|
223
|
+
|
|
224
|
+
You can also set `paymentType: fiat` in the plugin config to make fiat the default for all calls.
|
|
225
|
+
|
|
192
226
|
## Custom Agent Handlers
|
|
193
227
|
|
|
194
228
|
The plugin includes a mock weather handler for demonstration. To use your own logic, pass a custom `agentHandler` when registering the plugin:
|
|
@@ -216,12 +250,18 @@ The balance is cached for 60 seconds to avoid excessive API calls.
|
|
|
216
250
|
|
|
217
251
|
## How It Works
|
|
218
252
|
|
|
219
|
-
The plugin implements the [x402 payment protocol](https://nevermined.ai/docs/api-reference/typescript/x402-protocol) for agent-to-agent payments:
|
|
253
|
+
The plugin implements the [x402 payment protocol](https://nevermined.ai/docs/api-reference/typescript/x402-protocol) for agent-to-agent payments. It supports two payment schemes:
|
|
254
|
+
|
|
255
|
+
- **Crypto** (`nvm:erc4337`) — on-chain payments using session keys and smart accounts
|
|
256
|
+
- **Fiat** (`nvm:card-delegation`) — credit card payments via Stripe delegation
|
|
257
|
+
|
|
258
|
+
Both schemes follow the same token flow:
|
|
220
259
|
|
|
221
260
|
```
|
|
222
261
|
Subscriber Claw Builder Claw (Gateway)
|
|
223
262
|
│ │
|
|
224
|
-
│ 1. getX402AccessToken(planId
|
|
263
|
+
│ 1. getX402AccessToken(planId, │
|
|
264
|
+
│ tokenOptions) │
|
|
225
265
|
│─────────────────────────────────────>│ Nevermined API
|
|
226
266
|
│<─────────────────────────────────────│ returns token
|
|
227
267
|
│ │
|
|
@@ -236,7 +276,7 @@ Subscriber Claw Builder Claw (Gateway)
|
|
|
236
276
|
│<─────────────────────────────────────│
|
|
237
277
|
```
|
|
238
278
|
|
|
239
|
-
|
|
279
|
+
For crypto, credits are managed on-chain through the Nevermined Protocol. For fiat, credits are charged against the delegated card via Stripe. In both cases, `verifyPermissions` checks the subscriber's balance without consuming credits, and `settlePermissions` consumes them only after successful processing.
|
|
240
280
|
|
|
241
281
|
## Next Steps
|
|
242
282
|
|
package/docs/setup.md
CHANGED
|
@@ -23,7 +23,10 @@ The plugin reads its configuration from the `plugins.nevermined` section of your
|
|
|
23
23
|
"agentId": "did:nv:def456...",
|
|
24
24
|
"creditsPerRequest": 1,
|
|
25
25
|
"enablePaidEndpoint": false,
|
|
26
|
-
"agentEndpointPath": "/nevermined/agent"
|
|
26
|
+
"agentEndpointPath": "/nevermined/agent",
|
|
27
|
+
"paymentType": "crypto",
|
|
28
|
+
"defaultSpendingLimitCents": 1000,
|
|
29
|
+
"defaultDelegationDurationSecs": 3600
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
}
|
|
@@ -42,6 +45,9 @@ The plugin reads its configuration from the `plugins.nevermined` section of your
|
|
|
42
45
|
| `creditsPerRequest` | No | `1` | Number of credits consumed per request. |
|
|
43
46
|
| `enablePaidEndpoint` | No | `false` | Enable the x402 paid HTTP endpoint on the gateway. |
|
|
44
47
|
| `agentEndpointPath` | No | `/nevermined/agent` | HTTP path for the paid agent endpoint. |
|
|
48
|
+
| `paymentType` | No | `crypto` | Default payment type: `crypto` (nvm:erc4337) or `fiat` (nvm:card-delegation). |
|
|
49
|
+
| `defaultSpendingLimitCents` | No | `1000` | Default max spend in cents ($10) for fiat payments. |
|
|
50
|
+
| `defaultDelegationDurationSecs` | No | `3600` | Default delegation duration in seconds (1 hour) for fiat payments. |
|
|
45
51
|
|
|
46
52
|
### Environment Details
|
|
47
53
|
|
package/openclaw.plugin.json
CHANGED
|
@@ -18,7 +18,31 @@
|
|
|
18
18
|
},
|
|
19
19
|
"planId": {
|
|
20
20
|
"type": "string",
|
|
21
|
-
"description": "
|
|
21
|
+
"description": "(Deprecated) Single default plan ID. Use 'plans' array instead."
|
|
22
|
+
},
|
|
23
|
+
"fiatPlanId": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "(Deprecated) Single fiat plan ID. Use 'plans' array instead."
|
|
26
|
+
},
|
|
27
|
+
"plans": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"description": "Available payment plans. Each entry has a planId, optional name, and paymentType (crypto or fiat).",
|
|
30
|
+
"items": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"planId": { "type": "string", "description": "The Nevermined plan ID" },
|
|
34
|
+
"name": { "type": "string", "description": "Human-readable plan name" },
|
|
35
|
+
"paymentType": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": ["crypto", "fiat"],
|
|
38
|
+
"default": "crypto",
|
|
39
|
+
"description": "crypto (nvm:erc4337) or fiat (nvm:card-delegation)"
|
|
40
|
+
},
|
|
41
|
+
"credits": { "type": "number", "description": "Number of credits this plan grants" },
|
|
42
|
+
"price": { "type": "string", "description": "Human-readable price (e.g. '$1', '2 USDC')" }
|
|
43
|
+
},
|
|
44
|
+
"required": ["planId"]
|
|
45
|
+
}
|
|
22
46
|
},
|
|
23
47
|
"agentId": {
|
|
24
48
|
"type": "string",
|
|
@@ -27,7 +51,12 @@
|
|
|
27
51
|
"creditsPerRequest": {
|
|
28
52
|
"type": "number",
|
|
29
53
|
"default": 1,
|
|
30
|
-
"description": "Number of credits consumed per request"
|
|
54
|
+
"description": "Number of credits consumed per non-calendar tool request"
|
|
55
|
+
},
|
|
56
|
+
"creditsPerMinute": {
|
|
57
|
+
"type": "number",
|
|
58
|
+
"default": 1,
|
|
59
|
+
"description": "Credits consumed per minute of calendar meeting duration"
|
|
31
60
|
},
|
|
32
61
|
"enablePaidEndpoint": {
|
|
33
62
|
"type": "boolean",
|
|
@@ -38,6 +67,22 @@
|
|
|
38
67
|
"type": "string",
|
|
39
68
|
"default": "/nevermined/agent",
|
|
40
69
|
"description": "HTTP path for the paid agent endpoint"
|
|
70
|
+
},
|
|
71
|
+
"paymentType": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"enum": ["crypto", "fiat"],
|
|
74
|
+
"default": "crypto",
|
|
75
|
+
"description": "Default payment type for tools: crypto (nvm:erc4337) or fiat (nvm:card-delegation)"
|
|
76
|
+
},
|
|
77
|
+
"defaultSpendingLimitCents": {
|
|
78
|
+
"type": "number",
|
|
79
|
+
"default": 1000,
|
|
80
|
+
"description": "Default max spend in cents ($10) for fiat payments"
|
|
81
|
+
},
|
|
82
|
+
"defaultDelegationDurationSecs": {
|
|
83
|
+
"type": "number",
|
|
84
|
+
"default": 3600,
|
|
85
|
+
"description": "Default delegation duration in seconds (1 hour) for fiat payments"
|
|
41
86
|
}
|
|
42
87
|
}
|
|
43
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nevermined-io/openclaw-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "OpenClaw plugin for Nevermined — exposes subscriber and builder tools as gateway methods",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"lint": "eslint src/ tests/ --ext .ts"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@nevermined-io/payments": ">= 1.
|
|
27
|
+
"@nevermined-io/payments": ">= 1.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@nevermined-io/payments": "^1.0
|
|
30
|
+
"@nevermined-io/payments": "^1.1.0",
|
|
31
31
|
"@types/jest": "^29.5.0",
|
|
32
32
|
"jest": "^29.7.0",
|
|
33
33
|
"ts-jest": "^29.1.0",
|
|
@@ -7,7 +7,7 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Nevermined Tools
|
|
9
9
|
|
|
10
|
-
This plugin provides gateway tools for interacting with Nevermined AI agent payments.
|
|
10
|
+
This plugin provides gateway tools for interacting with Nevermined AI agent payments. Supports both crypto (on-chain) and fiat (credit card) payment flows.
|
|
11
11
|
|
|
12
12
|
## Authentication
|
|
13
13
|
|
|
@@ -25,21 +25,36 @@ Check credit balance for a payment plan.
|
|
|
25
25
|
- `planId` (optional if set in config) — the plan to check
|
|
26
26
|
|
|
27
27
|
### `nevermined_getAccessToken`
|
|
28
|
-
Get an x402 access token for authenticating agent requests.
|
|
28
|
+
Get an x402 access token for authenticating agent requests. Supports crypto and fiat payment types.
|
|
29
29
|
- `planId` (optional if set in config)
|
|
30
30
|
- `agentId` (optional if set in config)
|
|
31
|
+
- `paymentType` (optional) — `"crypto"` (default) or `"fiat"`
|
|
32
|
+
- `paymentMethodId` (optional) — Stripe payment method ID for fiat. Auto-selects first enrolled card if omitted.
|
|
33
|
+
- `spendingLimitCents` (optional) — max spend in cents for fiat (default: 1000)
|
|
34
|
+
- `delegationDurationSecs` (optional) — delegation duration in seconds for fiat (default: 3600)
|
|
31
35
|
|
|
32
36
|
### `nevermined_orderPlan`
|
|
33
|
-
Purchase a payment plan.
|
|
37
|
+
Purchase a crypto payment plan.
|
|
34
38
|
- `planId` (optional if set in config)
|
|
35
39
|
|
|
40
|
+
### `nevermined_orderFiatPlan`
|
|
41
|
+
Order a fiat payment plan — returns a Stripe checkout URL.
|
|
42
|
+
- `planId` (optional if set in config)
|
|
43
|
+
|
|
44
|
+
### `nevermined_listPaymentMethods`
|
|
45
|
+
List enrolled credit cards available for fiat payments. No parameters.
|
|
46
|
+
|
|
36
47
|
### `nevermined_queryAgent`
|
|
37
|
-
End-to-end agent query — acquires a token, calls the agent, returns the response.
|
|
48
|
+
End-to-end agent query — acquires a token, calls the agent, returns the response. Supports crypto and fiat.
|
|
38
49
|
- `agentUrl` (required) — the agent endpoint URL
|
|
39
50
|
- `prompt` (required) — the prompt to send
|
|
40
51
|
- `planId` (optional if set in config)
|
|
41
52
|
- `agentId` (optional if set in config)
|
|
42
53
|
- `method` (optional, default `POST`)
|
|
54
|
+
- `paymentType` (optional) — `"crypto"` (default) or `"fiat"`
|
|
55
|
+
- `paymentMethodId` (optional) — Stripe payment method ID for fiat
|
|
56
|
+
- `spendingLimitCents` (optional) — max spend in cents for fiat
|
|
57
|
+
- `delegationDurationSecs` (optional) — delegation duration in seconds for fiat
|
|
43
58
|
|
|
44
59
|
## Builder Tools
|
|
45
60
|
|
|
@@ -48,10 +63,11 @@ Register a new AI agent with a payment plan.
|
|
|
48
63
|
- `name` (required) — agent name
|
|
49
64
|
- `agentUrl` (required) — agent endpoint
|
|
50
65
|
- `planName` (required) — plan name
|
|
51
|
-
- `priceAmounts` (required) — comma-separated prices in wei
|
|
66
|
+
- `priceAmounts` (required) — comma-separated prices in wei (crypto) or cents (fiat)
|
|
52
67
|
- `priceReceivers` (required) — comma-separated receiver addresses
|
|
53
68
|
- `creditsAmount` (required) — number of credits
|
|
54
69
|
- `tokenAddress` (optional) — ERC20 token address (e.g. USDC). Omit for native token.
|
|
70
|
+
- `pricingType` (optional) — `"crypto"` (default), `"erc20"`, or `"fiat"`
|
|
55
71
|
|
|
56
72
|
### `nevermined_createPlan`
|
|
57
73
|
Create a standalone payment plan. Supports fiat (Stripe), ERC20 tokens (USDC), and native crypto pricing.
|