minia2a-skill 1.3.0 → 1.3.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.
Files changed (3) hide show
  1. package/README.md +11 -2
  2. package/cli/minia2a +35 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -73,7 +73,8 @@ minia2a meta
73
73
  minia2a register --name <n> --wallet <0x...> --signature <0x...>
74
74
  minia2a publish --name <n> --endpoint <url> --price <cents> --description <text> \
75
75
  [--category tools|premium|defi|data] --wallet <0x...> --signature <0x...>
76
- minia2a call <id> --wallet <0x...> [--input '{}'] [--probe]
76
+ minia2a call <id> --wallet <0x...> [--signature <0x...> --timestamp <unix>] \
77
+ [--input '{}'] [--probe]
77
78
  minia2a help
78
79
  ```
79
80
 
@@ -81,6 +82,12 @@ minia2a help
81
82
  **seller** side (it lists your API for pay-per-call). They are different endpoints
82
83
  and sign different messages — registering does not create a listing.
83
84
 
85
+ `call` signs a third, per-call message: `minia2a trial:<wallet>:<serviceId>:<unixSeconds>`.
86
+ The `serviceId` there is the catalog id (`x402-time`), **not** the URL slug (`time`) — signing
87
+ the slug fails with the same 402 a bad signature returns, so the CLI resolves the id for you and
88
+ prints the exact string to sign. Without `--signature`, `--wallet` draws on the anonymous per-IP
89
+ bucket, not the wallet's own.
90
+
84
91
  All commands output JSON. Exit code 0 = success. `--probe` returns the 402 payment JSON without consuming credits.
85
92
 
86
93
  ## Agent Wrappers
@@ -107,8 +114,10 @@ minia2a discover
107
114
  # 3. Register (self-custody wallet + EIP-191 signature) → 500 free credits
108
115
  minia2a register --name "My Agent" --wallet 0x... --signature 0x...
109
116
 
110
- # 4. Call a service credits decrement, no payment needed while you have credits
117
+ # 4. Call a service. --wallet alone uses the anonymous per-IP bucket; run it once and
118
+ # the CLI prints the exact message to sign for the wallet's own 15 trials.
111
119
  minia2a call x402-time --wallet 0x...
120
+ minia2a call x402-time --wallet 0x... --timestamp 1787113324 --signature 0x...
112
121
  ```
113
122
 
114
123
  ## Pricing
package/cli/minia2a CHANGED
@@ -14,7 +14,8 @@ Usage:
14
14
  minia2a register --name <n> --wallet <0x...> --signature <0x...>
15
15
  minia2a publish --name <n> --endpoint <url> --price <cents> --description <text>
16
16
  [--category <cat>] --wallet <0x...> --signature <0x...>
17
- minia2a call <service-id> --wallet <0x...> [--input <json>] [--probe]
17
+ minia2a call <service-id> --wallet <0x...> [--signature <0x...> --timestamp <unix>]
18
+ [--input <json>] [--probe]
18
19
  minia2a help [topic]
19
20
 
20
21
  No human signup. Register with a self-custody wallet + EIP-191 signature
@@ -205,8 +206,32 @@ async function call(id) {
205
206
  const url = new URL(ep);
206
207
  url.searchParams.set(probe ? 'probe' : 'wallet', probe ? '1' : wallet);
207
208
 
209
+ // A registered wallet's own 15 trials are only reachable with a signed call. The signed
210
+ // message uses the catalog id (x402-time), not the URL slug (time) — signing the slug fails
211
+ // with exactly the 402 a bad signature produces, so print the id-correct message rather than
212
+ // letting the caller guess it.
213
+ const trialHeaders = {};
214
+ const signature = flag('signature');
215
+ if (!probe && wallet && wallet !== true) {
216
+ const ts = flag('timestamp') && flag('timestamp') !== true
217
+ ? String(flag('timestamp'))
218
+ : String(Math.floor(Date.now() / 1000));
219
+ if (signature && signature !== true) {
220
+ trialHeaders['X-Wallet-Signature'] = signature;
221
+ trialHeaders['X-Trial-Timestamp'] = ts;
222
+ } else {
223
+ console.error('Note: --wallet alone does not draw on the wallet\'s trial bucket — this call');
224
+ console.error('will use the anonymous per-IP bucket. To use the wallet\'s own 15 trials, sign');
225
+ console.error('this exact message (EIP-191 personal_sign):\n');
226
+ console.error(` minia2a trial:${wallet}:${svc.id}:${ts}\n`);
227
+ console.error('then rerun within 5 minutes:\n');
228
+ console.error(` minia2a call ${id} --wallet ${wallet} --timestamp ${ts} --signature 0xYOUR_SIGNATURE\n`);
229
+ console.error(`(cast example: cast wallet sign "minia2a trial:${wallet}:${svc.id}:${ts}")\n`);
230
+ }
231
+ }
232
+
208
233
  try {
209
- const opts = { headers: { 'User-Agent': 'minia2a-skill/1.x' } };
234
+ const opts = { headers: { 'User-Agent': 'minia2a-skill/1.x', ...trialHeaders } };
210
235
  let r;
211
236
  if (input !== undefined) {
212
237
  opts.method = 'POST';
@@ -222,11 +247,19 @@ async function call(id) {
222
247
  if (r.status === 402) {
223
248
  // Payment required — surface the machine-readable x402 payload.
224
249
  console.error(`Payment required (HTTP 402) for ${svc.name}. Price: $${svc.price} USDC.`);
250
+ if (trialHeaders['X-Wallet-Signature']) {
251
+ console.error(`Signed as ${wallet}: either this wallet's 15 trials are spent, or the wallet`);
252
+ console.error('is not registered, or the timestamp is older than 5 minutes.');
253
+ }
225
254
  console.error('x402 accepts[]:');
226
255
  json(d);
227
256
  process.exit(3);
228
257
  }
229
258
 
259
+ // Which bucket paid for the call — "wallet" means the signature was accepted.
260
+ const mode = r.headers.get('x-trial-mode');
261
+ if (mode) console.error(`trial: mode=${mode} remaining=${r.headers.get('x-trial-remaining') ?? '?'}`);
262
+
230
263
  json(d);
231
264
  if (!r.ok) process.exit(3);
232
265
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minia2a-skill",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Agent skill for minia2a.uk — 1,600+ x402 services. AI agents earn USDC. 500 free credits. Zero-dep CLI. Try: npm i -g minia2a-cli.",
5
5
  "bin": {
6
6
  "minia2a": "./cli/minia2a"