@nevermined-io/openclaw-plugin 1.0.11 → 1.0.13
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/auth.d.ts +13 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +30 -1
- package/dist/auth.js.map +1 -1
- package/dist/index.d.ts +42 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -91
- package/dist/index.js.map +1 -1
- package/dist/tools.d.ts +16 -9
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +228 -215
- package/dist/tools.js.map +1 -1
- package/docs/commands.md +164 -0
- package/docs/getting-started.md +71 -0
- package/docs/links.md +38 -0
- package/docs/setup.md +64 -0
- package/openclaw.plugin.json +27 -68
- package/package.json +7 -1
package/dist/tools.js
CHANGED
|
@@ -1,218 +1,231 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Creates all Nevermined payment tools for the OpenClaw plugin.
|
|
3
|
+
* Each tool is an object with { name, description, parameters, execute }
|
|
4
|
+
* compatible with the OpenClaw AnyAgentTool interface.
|
|
5
|
+
*/
|
|
6
|
+
export function createTools(getPayments, config) {
|
|
7
|
+
return [
|
|
8
|
+
// --- Subscriber tools ---
|
|
9
|
+
{
|
|
10
|
+
name: 'nevermined_checkBalance',
|
|
11
|
+
label: 'Nevermined Check Balance',
|
|
12
|
+
description: 'Check the credit balance for a Nevermined payment plan',
|
|
13
|
+
parameters: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
planId: { type: 'string', description: 'The payment plan ID (uses config default if omitted)' },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
async execute(_id, params) {
|
|
20
|
+
const planId = str(params, 'planId') ?? config.planId;
|
|
21
|
+
if (!planId)
|
|
22
|
+
throw new Error('planId is required — provide it as a parameter or in the plugin config');
|
|
23
|
+
const balance = await getPayments().plans.getPlanBalance(planId);
|
|
24
|
+
return result({
|
|
25
|
+
planId: balance.planId,
|
|
26
|
+
planName: balance.planName,
|
|
27
|
+
balance: balance.balance.toString(),
|
|
28
|
+
isSubscriber: balance.isSubscriber,
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'nevermined_getAccessToken',
|
|
34
|
+
label: 'Nevermined Get Access Token',
|
|
35
|
+
description: 'Get an x402 access token for authenticating requests to a Nevermined agent',
|
|
36
|
+
parameters: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
planId: { type: 'string', description: 'The payment plan ID' },
|
|
40
|
+
agentId: { type: 'string', description: 'The agent ID' },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
async execute(_id, params) {
|
|
44
|
+
const planId = str(params, 'planId') ?? config.planId;
|
|
45
|
+
if (!planId)
|
|
46
|
+
throw new Error('planId is required — provide it as a parameter or in the plugin config');
|
|
47
|
+
const agentId = str(params, 'agentId') ?? config.agentId;
|
|
48
|
+
const token = await getPayments().x402.getX402AccessToken(planId, agentId);
|
|
49
|
+
return result({ accessToken: token.accessToken });
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'nevermined_orderPlan',
|
|
54
|
+
label: 'Nevermined Order Plan',
|
|
55
|
+
description: 'Order (purchase) a Nevermined payment plan',
|
|
56
|
+
parameters: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
planId: { type: 'string', description: 'The payment plan ID to order' },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
async execute(_id, params) {
|
|
63
|
+
const planId = str(params, 'planId') ?? config.planId;
|
|
64
|
+
if (!planId)
|
|
65
|
+
throw new Error('planId is required — provide it as a parameter or in the plugin config');
|
|
66
|
+
const res = await getPayments().plans.orderPlan(planId);
|
|
67
|
+
return result(res);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'nevermined_queryAgent',
|
|
72
|
+
label: 'Nevermined Query Agent',
|
|
73
|
+
description: 'Query a Nevermined AI agent end-to-end: acquires an x402 access token, sends the prompt to the agent, and returns the response',
|
|
74
|
+
parameters: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
agentUrl: { type: 'string', description: 'The URL of the agent to query' },
|
|
78
|
+
prompt: { type: 'string', description: 'The prompt to send to the agent' },
|
|
79
|
+
planId: { type: 'string', description: 'The payment plan ID' },
|
|
80
|
+
agentId: { type: 'string', description: 'The agent ID' },
|
|
81
|
+
method: { type: 'string', description: 'HTTP method (default: POST)' },
|
|
82
|
+
},
|
|
83
|
+
required: ['agentUrl', 'prompt'],
|
|
84
|
+
},
|
|
85
|
+
async execute(_id, params) {
|
|
86
|
+
const agentUrl = requireStr(params, 'agentUrl');
|
|
87
|
+
const prompt = requireStr(params, 'prompt');
|
|
88
|
+
const planId = str(params, 'planId') ?? config.planId;
|
|
89
|
+
if (!planId)
|
|
90
|
+
throw new Error('planId is required — provide it as a parameter or in the plugin config');
|
|
91
|
+
const agentId = str(params, 'agentId') ?? config.agentId;
|
|
92
|
+
const method = str(params, 'method') ?? 'POST';
|
|
93
|
+
const { accessToken } = await getPayments().x402.getX402AccessToken(planId, agentId);
|
|
94
|
+
const response = await fetch(agentUrl, {
|
|
95
|
+
method,
|
|
96
|
+
headers: {
|
|
97
|
+
'Content-Type': 'application/json',
|
|
98
|
+
'PAYMENT-SIGNATURE': accessToken,
|
|
99
|
+
},
|
|
100
|
+
body: method !== 'GET' ? JSON.stringify({ prompt }) : undefined,
|
|
101
|
+
});
|
|
102
|
+
if (response.status === 402) {
|
|
103
|
+
return result({
|
|
104
|
+
error: 'Payment required — insufficient credits. Order the plan first using nevermined_orderPlan.',
|
|
105
|
+
status: 402,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
return result({
|
|
110
|
+
error: `Agent returned HTTP ${response.status}: ${response.statusText}`,
|
|
111
|
+
status: response.status,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const body = await response.json();
|
|
115
|
+
return result(body);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
// --- Builder tools ---
|
|
119
|
+
{
|
|
120
|
+
name: 'nevermined_registerAgent',
|
|
121
|
+
label: 'Nevermined Register Agent',
|
|
122
|
+
description: 'Register a new AI agent with an associated payment plan on Nevermined',
|
|
123
|
+
parameters: {
|
|
124
|
+
type: 'object',
|
|
125
|
+
properties: {
|
|
126
|
+
name: { type: 'string', description: 'Agent name' },
|
|
127
|
+
description: { type: 'string', description: 'Agent description' },
|
|
128
|
+
agentUrl: { type: 'string', description: 'The endpoint URL for the agent' },
|
|
129
|
+
planName: { type: 'string', description: 'Name for the payment plan' },
|
|
130
|
+
priceAmounts: { type: 'string', description: 'Comma-separated price amounts in wei' },
|
|
131
|
+
priceReceivers: { type: 'string', description: 'Comma-separated receiver addresses' },
|
|
132
|
+
creditsAmount: { type: 'number', description: 'Number of credits in the plan' },
|
|
133
|
+
},
|
|
134
|
+
required: ['name', 'agentUrl', 'planName', 'priceAmounts', 'priceReceivers', 'creditsAmount'],
|
|
135
|
+
},
|
|
136
|
+
async execute(_id, params) {
|
|
137
|
+
const name = requireStr(params, 'name');
|
|
138
|
+
const description = str(params, 'description') ?? '';
|
|
139
|
+
const agentUrl = requireStr(params, 'agentUrl');
|
|
140
|
+
const planName = requireStr(params, 'planName');
|
|
141
|
+
const priceAmounts = requireStr(params, 'priceAmounts')
|
|
142
|
+
.split(',')
|
|
143
|
+
.map((s) => BigInt(s.trim()));
|
|
144
|
+
const priceReceivers = requireStr(params, 'priceReceivers')
|
|
145
|
+
.split(',')
|
|
146
|
+
.map((s) => s.trim());
|
|
147
|
+
const creditsAmount = Number(requireStr(params, 'creditsAmount'));
|
|
148
|
+
const res = await getPayments().agents.registerAgentAndPlan({ name, description }, { endpoints: [{ POST: agentUrl }], agentDefinitionUrl: agentUrl }, { name: planName }, { amounts: priceAmounts, receivers: priceReceivers, isCrypto: true }, {
|
|
149
|
+
isRedemptionAmountFixed: true,
|
|
150
|
+
redemptionType: 4,
|
|
151
|
+
proofRequired: false,
|
|
152
|
+
durationSecs: 0n,
|
|
153
|
+
amount: BigInt(creditsAmount),
|
|
154
|
+
minAmount: 1n,
|
|
155
|
+
maxAmount: BigInt(creditsAmount),
|
|
156
|
+
});
|
|
157
|
+
return result({ agentId: res.agentId, planId: res.planId, txHash: res.txHash });
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'nevermined_createPlan',
|
|
162
|
+
label: 'Nevermined Create Plan',
|
|
163
|
+
description: 'Create a new payment plan on Nevermined',
|
|
164
|
+
parameters: {
|
|
165
|
+
type: 'object',
|
|
166
|
+
properties: {
|
|
167
|
+
name: { type: 'string', description: 'Plan name' },
|
|
168
|
+
description: { type: 'string', description: 'Plan description' },
|
|
169
|
+
priceAmounts: { type: 'string', description: 'Comma-separated price amounts in wei' },
|
|
170
|
+
priceReceivers: { type: 'string', description: 'Comma-separated receiver addresses' },
|
|
171
|
+
creditsAmount: { type: 'number', description: 'Number of credits in the plan' },
|
|
172
|
+
accessLimit: { type: 'string', description: '"credits" or "time" (default: credits)' },
|
|
173
|
+
},
|
|
174
|
+
required: ['name', 'priceAmounts', 'priceReceivers', 'creditsAmount'],
|
|
175
|
+
},
|
|
176
|
+
async execute(_id, params) {
|
|
177
|
+
const name = requireStr(params, 'name');
|
|
178
|
+
const description = str(params, 'description') ?? '';
|
|
179
|
+
const priceAmounts = requireStr(params, 'priceAmounts')
|
|
180
|
+
.split(',')
|
|
181
|
+
.map((s) => BigInt(s.trim()));
|
|
182
|
+
const priceReceivers = requireStr(params, 'priceReceivers')
|
|
183
|
+
.split(',')
|
|
184
|
+
.map((s) => s.trim());
|
|
185
|
+
const creditsAmount = Number(requireStr(params, 'creditsAmount'));
|
|
186
|
+
const accessLimit = (str(params, 'accessLimit') ?? 'credits');
|
|
187
|
+
const res = await getPayments().plans.registerPlan({ name, description, accessLimit }, { amounts: priceAmounts, receivers: priceReceivers, isCrypto: true }, {
|
|
188
|
+
isRedemptionAmountFixed: true,
|
|
189
|
+
redemptionType: 4,
|
|
190
|
+
proofRequired: false,
|
|
191
|
+
durationSecs: 0n,
|
|
192
|
+
amount: BigInt(creditsAmount),
|
|
193
|
+
minAmount: 1n,
|
|
194
|
+
maxAmount: BigInt(creditsAmount),
|
|
195
|
+
}, undefined, accessLimit);
|
|
196
|
+
return result({ planId: res.planId });
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: 'nevermined_listPlans',
|
|
201
|
+
label: 'Nevermined List Plans',
|
|
202
|
+
description: "List the builder's payment plans on Nevermined",
|
|
203
|
+
parameters: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
properties: {},
|
|
206
|
+
},
|
|
207
|
+
async execute() {
|
|
208
|
+
const res = await getPayments().plans.getPlans();
|
|
209
|
+
return result(res);
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
];
|
|
7
213
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
214
|
+
function result(payload) {
|
|
215
|
+
return {
|
|
216
|
+
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function str(params, key) {
|
|
220
|
+
const v = params[key];
|
|
221
|
+
if (v === undefined || v === null || v === '')
|
|
222
|
+
return undefined;
|
|
223
|
+
return String(v);
|
|
224
|
+
}
|
|
225
|
+
function requireStr(params, key) {
|
|
226
|
+
const v = str(params, key);
|
|
227
|
+
if (!v)
|
|
228
|
+
throw new Error(`Missing required parameter: ${key}`);
|
|
229
|
+
return v;
|
|
14
230
|
}
|
|
15
|
-
// --- Subscriber tools ---
|
|
16
|
-
const checkBalance = {
|
|
17
|
-
name: 'nevermined.checkBalance',
|
|
18
|
-
description: 'Check the credit balance for a Nevermined payment plan',
|
|
19
|
-
params: [
|
|
20
|
-
{ name: 'planId', type: 'string', description: 'The payment plan ID', required: false },
|
|
21
|
-
],
|
|
22
|
-
handler: async (payments, config, params) => {
|
|
23
|
-
const planId = optionalParam(params, 'planId', config.planId);
|
|
24
|
-
if (!planId) {
|
|
25
|
-
throw new Error('planId is required — provide it as a parameter or in the plugin config');
|
|
26
|
-
}
|
|
27
|
-
const balance = await payments.plans.getPlanBalance(planId);
|
|
28
|
-
return {
|
|
29
|
-
planId: balance.planId,
|
|
30
|
-
planName: balance.planName,
|
|
31
|
-
balance: balance.balance.toString(),
|
|
32
|
-
isSubscriber: balance.isSubscriber,
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
const getAccessToken = {
|
|
37
|
-
name: 'nevermined.getAccessToken',
|
|
38
|
-
description: 'Get an x402 access token for authenticating requests to a Nevermined agent',
|
|
39
|
-
params: [
|
|
40
|
-
{ name: 'planId', type: 'string', description: 'The payment plan ID', required: false },
|
|
41
|
-
{ name: 'agentId', type: 'string', description: 'The agent ID', required: false },
|
|
42
|
-
],
|
|
43
|
-
handler: async (payments, config, params) => {
|
|
44
|
-
const planId = optionalParam(params, 'planId', config.planId);
|
|
45
|
-
if (!planId) {
|
|
46
|
-
throw new Error('planId is required — provide it as a parameter or in the plugin config');
|
|
47
|
-
}
|
|
48
|
-
const agentId = optionalParam(params, 'agentId', config.agentId);
|
|
49
|
-
const result = await payments.x402.getX402AccessToken(planId, agentId);
|
|
50
|
-
return { accessToken: result.accessToken };
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
const orderPlan = {
|
|
54
|
-
name: 'nevermined.orderPlan',
|
|
55
|
-
description: 'Order (purchase) a Nevermined payment plan',
|
|
56
|
-
params: [
|
|
57
|
-
{ name: 'planId', type: 'string', description: 'The payment plan ID to order', required: false },
|
|
58
|
-
],
|
|
59
|
-
handler: async (payments, config, params) => {
|
|
60
|
-
const planId = optionalParam(params, 'planId', config.planId);
|
|
61
|
-
if (!planId) {
|
|
62
|
-
throw new Error('planId is required — provide it as a parameter or in the plugin config');
|
|
63
|
-
}
|
|
64
|
-
const result = await payments.plans.orderPlan(planId);
|
|
65
|
-
return result;
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
const queryAgent = {
|
|
69
|
-
name: 'nevermined.queryAgent',
|
|
70
|
-
description: 'Query a Nevermined AI agent end-to-end: acquires an x402 access token, sends the prompt to the agent, and returns the response',
|
|
71
|
-
params: [
|
|
72
|
-
{ name: 'agentUrl', type: 'string', description: 'The URL of the agent to query', required: true },
|
|
73
|
-
{ name: 'prompt', type: 'string', description: 'The prompt to send to the agent', required: true },
|
|
74
|
-
{ name: 'planId', type: 'string', description: 'The payment plan ID', required: false },
|
|
75
|
-
{ name: 'agentId', type: 'string', description: 'The agent ID', required: false },
|
|
76
|
-
{ name: 'method', type: 'string', description: 'HTTP method (default: POST)', required: false },
|
|
77
|
-
],
|
|
78
|
-
handler: async (payments, config, params) => {
|
|
79
|
-
const agentUrl = requireParam(params, 'agentUrl');
|
|
80
|
-
const prompt = requireParam(params, 'prompt');
|
|
81
|
-
const planId = optionalParam(params, 'planId', config.planId);
|
|
82
|
-
if (!planId) {
|
|
83
|
-
throw new Error('planId is required — provide it as a parameter or in the plugin config');
|
|
84
|
-
}
|
|
85
|
-
const agentId = optionalParam(params, 'agentId', config.agentId);
|
|
86
|
-
const method = optionalParam(params, 'method', 'POST') ?? 'POST';
|
|
87
|
-
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId);
|
|
88
|
-
const response = await fetch(agentUrl, {
|
|
89
|
-
method,
|
|
90
|
-
headers: {
|
|
91
|
-
'Content-Type': 'application/json',
|
|
92
|
-
'PAYMENT-SIGNATURE': accessToken,
|
|
93
|
-
},
|
|
94
|
-
body: method !== 'GET' ? JSON.stringify({ prompt }) : undefined,
|
|
95
|
-
});
|
|
96
|
-
if (response.status === 402) {
|
|
97
|
-
return {
|
|
98
|
-
error: 'Payment required — insufficient credits. Order the plan first using nevermined.orderPlan.',
|
|
99
|
-
status: 402,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
if (!response.ok) {
|
|
103
|
-
return {
|
|
104
|
-
error: `Agent returned HTTP ${response.status}: ${response.statusText}`,
|
|
105
|
-
status: response.status,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
const body = await response.json();
|
|
109
|
-
return body;
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
// --- Builder tools ---
|
|
113
|
-
const registerAgent = {
|
|
114
|
-
name: 'nevermined.registerAgent',
|
|
115
|
-
description: 'Register a new AI agent with an associated payment plan on Nevermined',
|
|
116
|
-
params: [
|
|
117
|
-
{ name: 'name', type: 'string', description: 'Agent name', required: true },
|
|
118
|
-
{ name: 'description', type: 'string', description: 'Agent description', required: false },
|
|
119
|
-
{ name: 'agentUrl', type: 'string', description: 'The endpoint URL for the agent', required: true },
|
|
120
|
-
{ name: 'planName', type: 'string', description: 'Name for the payment plan', required: true },
|
|
121
|
-
{ name: 'priceAmounts', type: 'string', description: 'Comma-separated price amounts in wei', required: true },
|
|
122
|
-
{ name: 'priceReceivers', type: 'string', description: 'Comma-separated receiver addresses', required: true },
|
|
123
|
-
{ name: 'creditsAmount', type: 'number', description: 'Number of credits in the plan', required: true },
|
|
124
|
-
],
|
|
125
|
-
handler: async (payments, _config, params) => {
|
|
126
|
-
const name = requireParam(params, 'name');
|
|
127
|
-
const description = optionalParam(params, 'description', '');
|
|
128
|
-
const agentUrl = requireParam(params, 'agentUrl');
|
|
129
|
-
const planName = requireParam(params, 'planName');
|
|
130
|
-
const priceAmounts = requireParam(params, 'priceAmounts')
|
|
131
|
-
.split(',')
|
|
132
|
-
.map((s) => BigInt(s.trim()));
|
|
133
|
-
const priceReceivers = requireParam(params, 'priceReceivers')
|
|
134
|
-
.split(',')
|
|
135
|
-
.map((s) => s.trim());
|
|
136
|
-
const creditsAmount = Number(requireParam(params, 'creditsAmount'));
|
|
137
|
-
const result = await payments.agents.registerAgentAndPlan({ name, description }, {
|
|
138
|
-
endpoints: [{ POST: agentUrl }],
|
|
139
|
-
agentDefinitionUrl: agentUrl,
|
|
140
|
-
}, { name: planName }, {
|
|
141
|
-
amounts: priceAmounts,
|
|
142
|
-
receivers: priceReceivers,
|
|
143
|
-
isCrypto: true,
|
|
144
|
-
}, {
|
|
145
|
-
isRedemptionAmountFixed: true,
|
|
146
|
-
redemptionType: 4, // ONLY_SUBSCRIBER
|
|
147
|
-
proofRequired: false,
|
|
148
|
-
durationSecs: 0n,
|
|
149
|
-
amount: BigInt(creditsAmount),
|
|
150
|
-
minAmount: 1n,
|
|
151
|
-
maxAmount: BigInt(creditsAmount),
|
|
152
|
-
});
|
|
153
|
-
return {
|
|
154
|
-
agentId: result.agentId,
|
|
155
|
-
planId: result.planId,
|
|
156
|
-
txHash: result.txHash,
|
|
157
|
-
};
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
const createPlan = {
|
|
161
|
-
name: 'nevermined.createPlan',
|
|
162
|
-
description: 'Create a new payment plan on Nevermined',
|
|
163
|
-
params: [
|
|
164
|
-
{ name: 'name', type: 'string', description: 'Plan name', required: true },
|
|
165
|
-
{ name: 'description', type: 'string', description: 'Plan description', required: false },
|
|
166
|
-
{ name: 'priceAmounts', type: 'string', description: 'Comma-separated price amounts in wei', required: true },
|
|
167
|
-
{ name: 'priceReceivers', type: 'string', description: 'Comma-separated receiver addresses', required: true },
|
|
168
|
-
{ name: 'creditsAmount', type: 'number', description: 'Number of credits in the plan', required: true },
|
|
169
|
-
{ name: 'accessLimit', type: 'string', description: '"credits" or "time" (default: credits)', required: false },
|
|
170
|
-
],
|
|
171
|
-
handler: async (payments, _config, params) => {
|
|
172
|
-
const name = requireParam(params, 'name');
|
|
173
|
-
const description = optionalParam(params, 'description', '');
|
|
174
|
-
const priceAmounts = requireParam(params, 'priceAmounts')
|
|
175
|
-
.split(',')
|
|
176
|
-
.map((s) => BigInt(s.trim()));
|
|
177
|
-
const priceReceivers = requireParam(params, 'priceReceivers')
|
|
178
|
-
.split(',')
|
|
179
|
-
.map((s) => s.trim());
|
|
180
|
-
const creditsAmount = Number(requireParam(params, 'creditsAmount'));
|
|
181
|
-
const accessLimit = optionalParam(params, 'accessLimit', 'credits');
|
|
182
|
-
const result = await payments.plans.registerPlan({ name, description, accessLimit }, {
|
|
183
|
-
amounts: priceAmounts,
|
|
184
|
-
receivers: priceReceivers,
|
|
185
|
-
isCrypto: true,
|
|
186
|
-
}, {
|
|
187
|
-
isRedemptionAmountFixed: true,
|
|
188
|
-
redemptionType: 4,
|
|
189
|
-
proofRequired: false,
|
|
190
|
-
durationSecs: 0n,
|
|
191
|
-
amount: BigInt(creditsAmount),
|
|
192
|
-
minAmount: 1n,
|
|
193
|
-
maxAmount: BigInt(creditsAmount),
|
|
194
|
-
}, undefined, accessLimit);
|
|
195
|
-
return { planId: result.planId };
|
|
196
|
-
},
|
|
197
|
-
};
|
|
198
|
-
const listPlans = {
|
|
199
|
-
name: 'nevermined.listPlans',
|
|
200
|
-
description: "List the builder's payment plans on Nevermined",
|
|
201
|
-
params: [],
|
|
202
|
-
handler: async (payments) => {
|
|
203
|
-
const result = await payments.plans.getPlans();
|
|
204
|
-
return result;
|
|
205
|
-
},
|
|
206
|
-
};
|
|
207
|
-
export const allTools = [
|
|
208
|
-
// Subscriber
|
|
209
|
-
checkBalance,
|
|
210
|
-
getAccessToken,
|
|
211
|
-
orderPlan,
|
|
212
|
-
queryAgent,
|
|
213
|
-
// Builder
|
|
214
|
-
registerAgent,
|
|
215
|
-
createPlan,
|
|
216
|
-
listPlans,
|
|
217
|
-
];
|
|
218
231
|
//# sourceMappingURL=tools.js.map
|
package/dist/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":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,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Commands"
|
|
3
|
+
description: "All available tools and slash commands in the Nevermined OpenClaw plugin"
|
|
4
|
+
icon: "terminal"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Commands
|
|
8
|
+
|
|
9
|
+
The plugin provides slash commands for chat channels and gateway methods for programmatic access. Each command is available in both forms.
|
|
10
|
+
|
|
11
|
+
## Authentication
|
|
12
|
+
|
|
13
|
+
### `/nvm-login [environment]`
|
|
14
|
+
|
|
15
|
+
Authenticate with Nevermined via browser login.
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Required | Default | Description |
|
|
18
|
+
|-----------|------|----------|---------|-------------|
|
|
19
|
+
| `environment` | string | No | `sandbox` | `sandbox` or `live` |
|
|
20
|
+
|
|
21
|
+
**Gateway method:** `nevermined.login`
|
|
22
|
+
|
|
23
|
+
**Example:**
|
|
24
|
+
```
|
|
25
|
+
/nvm-login
|
|
26
|
+
/nvm-login live
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### `/nvm-logout`
|
|
32
|
+
|
|
33
|
+
Log out from Nevermined and remove the stored API key.
|
|
34
|
+
|
|
35
|
+
**Gateway method:** `nevermined.logout`
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Subscriber Tools
|
|
40
|
+
|
|
41
|
+
These tools are for users who want to subscribe to plans, check balances, and query agents.
|
|
42
|
+
|
|
43
|
+
### `nevermined.checkBalance`
|
|
44
|
+
|
|
45
|
+
Check the credit balance for a payment plan.
|
|
46
|
+
|
|
47
|
+
| Parameter | Type | Required | Default | Description |
|
|
48
|
+
|-----------|------|----------|---------|-------------|
|
|
49
|
+
| `planId` | string | No | Config `planId` | The payment plan ID to check |
|
|
50
|
+
|
|
51
|
+
**Returns:**
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"planId": "did:nv:abc123...",
|
|
55
|
+
"planName": "Basic Plan",
|
|
56
|
+
"balance": "95",
|
|
57
|
+
"isSubscriber": true
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### `nevermined.getAccessToken`
|
|
64
|
+
|
|
65
|
+
Get an x402 access token for authenticating requests to a Nevermined agent.
|
|
66
|
+
|
|
67
|
+
| Parameter | Type | Required | Default | Description |
|
|
68
|
+
|-----------|------|----------|---------|-------------|
|
|
69
|
+
| `planId` | string | No | Config `planId` | The payment plan ID |
|
|
70
|
+
| `agentId` | string | No | Config `agentId` | The agent ID |
|
|
71
|
+
|
|
72
|
+
**Returns:**
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"accessToken": "eyJhbG..."
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### `nevermined.orderPlan`
|
|
82
|
+
|
|
83
|
+
Purchase (order) a Nevermined payment plan.
|
|
84
|
+
|
|
85
|
+
| Parameter | Type | Required | Default | Description |
|
|
86
|
+
|-----------|------|----------|---------|-------------|
|
|
87
|
+
| `planId` | string | No | Config `planId` | The plan ID to purchase |
|
|
88
|
+
|
|
89
|
+
**Returns:** Order confirmation with transaction hash.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### `nevermined.queryAgent`
|
|
94
|
+
|
|
95
|
+
End-to-end agent query: acquires an x402 access token, sends the prompt to the agent URL with the `PAYMENT-SIGNATURE` header, and returns the response.
|
|
96
|
+
|
|
97
|
+
| Parameter | Type | Required | Default | Description |
|
|
98
|
+
|-----------|------|----------|---------|-------------|
|
|
99
|
+
| `agentUrl` | string | **Yes** | — | The URL of the agent to query |
|
|
100
|
+
| `prompt` | string | **Yes** | — | The prompt to send to the agent |
|
|
101
|
+
| `planId` | string | No | Config `planId` | The payment plan ID |
|
|
102
|
+
| `agentId` | string | No | Config `agentId` | The agent ID |
|
|
103
|
+
| `method` | string | No | `POST` | HTTP method |
|
|
104
|
+
|
|
105
|
+
If the agent returns a 402 (Payment Required) response, the tool returns an error indicating insufficient credits.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Builder Tools
|
|
110
|
+
|
|
111
|
+
These tools are for agent builders who want to register agents and create payment plans.
|
|
112
|
+
|
|
113
|
+
### `nevermined.registerAgent`
|
|
114
|
+
|
|
115
|
+
Register a new AI agent with an associated payment plan.
|
|
116
|
+
|
|
117
|
+
| Parameter | Type | Required | Description |
|
|
118
|
+
|-----------|------|----------|-------------|
|
|
119
|
+
| `name` | string | **Yes** | Agent name |
|
|
120
|
+
| `description` | string | No | Agent description |
|
|
121
|
+
| `agentUrl` | string | **Yes** | The endpoint URL for the agent |
|
|
122
|
+
| `planName` | string | **Yes** | Name for the payment plan |
|
|
123
|
+
| `priceAmounts` | string | **Yes** | Comma-separated price amounts in wei |
|
|
124
|
+
| `priceReceivers` | string | **Yes** | Comma-separated receiver addresses |
|
|
125
|
+
| `creditsAmount` | number | **Yes** | Number of credits in the plan |
|
|
126
|
+
|
|
127
|
+
**Returns:**
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"agentId": "did:nv:...",
|
|
131
|
+
"planId": "did:nv:...",
|
|
132
|
+
"txHash": "0x..."
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### `nevermined.createPlan`
|
|
139
|
+
|
|
140
|
+
Create a standalone payment plan (without an agent).
|
|
141
|
+
|
|
142
|
+
| Parameter | Type | Required | Description |
|
|
143
|
+
|-----------|------|----------|-------------|
|
|
144
|
+
| `name` | string | **Yes** | Plan name |
|
|
145
|
+
| `description` | string | No | Plan description |
|
|
146
|
+
| `priceAmounts` | string | **Yes** | Comma-separated price amounts in wei |
|
|
147
|
+
| `priceReceivers` | string | **Yes** | Comma-separated receiver addresses |
|
|
148
|
+
| `creditsAmount` | number | **Yes** | Number of credits in the plan |
|
|
149
|
+
| `accessLimit` | string | No | `"credits"` (default) or `"time"` |
|
|
150
|
+
|
|
151
|
+
**Returns:**
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"planId": "did:nv:..."
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `nevermined.listPlans`
|
|
161
|
+
|
|
162
|
+
List the builder's payment plans. No parameters required.
|
|
163
|
+
|
|
164
|
+
**Returns:** Array of plan objects.
|