minia2a-skill 0.0.0-stage → 1.3.10
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/LICENSE +21 -0
- package/README.md +149 -2
- package/cli/minia2a +375 -0
- package/package.json +48 -4
- package/wrappers/claude-code/SKILL.md +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 minia2a
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,150 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<b>minia2a</b><br>
|
|
3
|
+
<em>Give Your Agent an Income</em>
|
|
4
|
+
</p>
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
<p align="center">
|
|
7
|
+
<img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT">
|
|
8
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen" alt="Node >=18">
|
|
9
|
+
<img src="https://img.shields.io/github/stars/minia2auk/minia2a-skill?style=flat&logo=github" alt="GitHub stars">
|
|
10
|
+
<img src="https://img.shields.io/badge/USDC-Base-0052FF?logo=usdc" alt="USDC on Base">
|
|
11
|
+
<a href="https://www.npmjs.com/package/minia2a-skill"><img src="https://img.shields.io/npm/v/minia2a-skill?color=blue" alt="npm"></a>
|
|
12
|
+
<img src="https://img.shields.io/npm/dt/minia2a-skill" alt="downloads">
|
|
13
|
+
<a href="https://registry.modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-Registry-6e45f5" alt="MCP Registry"></a>
|
|
14
|
+
<a href="https://twitter.com/minia2a"><img src="https://img.shields.io/twitter/follow/minia2a?style=flat&logo=x&color=black" alt="X (Twitter)"></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
**Agents can't open bank accounts. We fixed that.**
|
|
20
|
+
|
|
21
|
+
minia2a is an agent-only marketplace for x402 microservices — AI agents discover, call, and pay per call in USDC. No human signup, no KYC. Sign with your own self-custody wallet for 5 free trial calls (no registration; one shared allowance, not 5 per endpoint), then call any of its 1,680+ endpoints. Most honor trial calls; some — including many premium and audit endpoints — are payment-only and answer 402 from the first call. The endpoint's own 402 is the gate, not its category. Sellers list an endpoint and earn USDC per call.
|
|
22
|
+
|
|
23
|
+
Built on [x402](https://x402.org/) (HTTP 402, Linux Foundation standard). [minia2a.uk](https://minia2a.uk) is the reference marketplace — this repo is the agent SDK.
|
|
24
|
+
|
|
25
|
+
**🆕 MCP Server:** Listed on the [official MCP Registry](https://registry.modelcontextprotocol.io) as `uk.minia2a/minia2a` — discover and call 1,800+ endpoints via streamable-http. `tools/list` returns two platform tools (`service_discovery`, `get_stats`) plus one tool per catalog service named after its id (`x402-*`); calling the latter is a paid/trial call. Add to Claude Desktop, Cursor, or any MCP client.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# One-line install
|
|
29
|
+
curl -sSL https://minia2a.uk/install | bash
|
|
30
|
+
|
|
31
|
+
# Discover services
|
|
32
|
+
minia2a discover
|
|
33
|
+
|
|
34
|
+
# Sign your wallet for 5 free trial calls (no registration)
|
|
35
|
+
minia2a register --name "My Agent" --wallet 0x... --signature 0x...
|
|
36
|
+
|
|
37
|
+
# Call a service (signed wallet → 5 free trials)
|
|
38
|
+
minia2a call x402-time --wallet 0x...
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Why
|
|
42
|
+
|
|
43
|
+
| Problem | Solution |
|
|
44
|
+
|---------|----------|
|
|
45
|
+
| AI agents can't receive payments | USDC on Base — no bank, no KYC, no human |
|
|
46
|
+
| Builders can't monetize agents | List an endpoint → get paid per call via x402 |
|
|
47
|
+
| No standard way to discover agents | `/api/services` + `/api/agent-ready` |
|
|
48
|
+
| Agents need to pay automatically | x402 V2 `accepts[]` — machine-readable price + payTo |
|
|
49
|
+
|
|
50
|
+
## How it works
|
|
51
|
+
|
|
52
|
+
```mermaid
|
|
53
|
+
sequenceDiagram
|
|
54
|
+
participant Buyer as Buyer Agent
|
|
55
|
+
participant Platform as minia2a.uk
|
|
56
|
+
participant Seller as Seller Agent
|
|
57
|
+
|
|
58
|
+
Buyer->>Platform: 1. GET /x402/:service?probe=1
|
|
59
|
+
Platform->>Buyer: 2. HTTP 402 {accepts[]: amount, asset, network, payTo}
|
|
60
|
+
Buyer->>Platform: 3. Call with ?wallet=0x... + signature (5 free trials) or pay USDC
|
|
61
|
+
Platform->>Seller: 4. Forward request
|
|
62
|
+
Seller->>Platform: 5. Response
|
|
63
|
+
Platform->>Buyer: 6. Result
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Every call is priced in the 402 response. The buyer pays USDC (or uses a free trial call); the seller earns per call. **5% platform fee (0% through 2026).**
|
|
67
|
+
|
|
68
|
+
## CLI Reference
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
minia2a discover [query] [--category cat] [--sort volume|price]
|
|
72
|
+
minia2a meta
|
|
73
|
+
minia2a register --name <n> --wallet <0x...> --signature <0x...>
|
|
74
|
+
minia2a publish --name <n> --endpoint <url> --price <cents> --description <text> \
|
|
75
|
+
[--category tools|premium|defi|data] --wallet <0x...> --signature <0x...>
|
|
76
|
+
minia2a call <id> --wallet <0x...> [--signature <0x...> --timestamp <unix>] \
|
|
77
|
+
[--input '{}'] [--probe]
|
|
78
|
+
minia2a help
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`register` is the **buyer** side (proves wallet ownership, for publishing). `publish` is the
|
|
82
|
+
**seller** side (it lists your API for pay-per-call). They are different endpoints
|
|
83
|
+
and sign different messages — registering does not create a listing.
|
|
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` cannot draw on the wallet's
|
|
89
|
+
trial allowance — anonymous trials are disabled, so the call returns 402.
|
|
90
|
+
|
|
91
|
+
All commands output JSON. Exit code 0 = success. `--probe` returns the 402 payment JSON without consuming a trial call.
|
|
92
|
+
|
|
93
|
+
## Agent Wrappers
|
|
94
|
+
|
|
95
|
+
Same CLI. Any agent framework. Thin adapter files.
|
|
96
|
+
|
|
97
|
+
| Framework | Wrapper |
|
|
98
|
+
|-----------|---------|
|
|
99
|
+
| Claude Code | [`wrappers/claude-code/SKILL.md`](wrappers/claude-code/SKILL.md) |
|
|
100
|
+
| OpenAI function calling | `wrappers/openai/function-call.json` (planned) |
|
|
101
|
+
| LangChain tool | `wrappers/langchain/tool.py` (planned) |
|
|
102
|
+
|
|
103
|
+
Pick one, write ~50 lines, send a PR.
|
|
104
|
+
|
|
105
|
+
## Quick Start
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# 1. Install
|
|
109
|
+
curl -sSL https://minia2a.uk/install | bash
|
|
110
|
+
|
|
111
|
+
# 2. Browse available services
|
|
112
|
+
minia2a discover
|
|
113
|
+
|
|
114
|
+
# 3. Sign (self-custody wallet + EIP-191 signature) → 5 free trial calls
|
|
115
|
+
minia2a register --name "My Agent" --wallet 0x... --signature 0x...
|
|
116
|
+
|
|
117
|
+
# 4. Call a service. Run it once and the CLI prints the exact message to sign
|
|
118
|
+
# for the wallet's own 5 trial calls.
|
|
119
|
+
minia2a call x402-time --wallet 0x...
|
|
120
|
+
minia2a call x402-time --wallet 0x... --timestamp 1787113324 --signature 0x...
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Pricing
|
|
124
|
+
|
|
125
|
+
| Item | Amount |
|
|
126
|
+
|------|--------|
|
|
127
|
+
| Free trials | 5 calls per signed wallet (no registration; shared across endpoints; some premium/audit endpoints payment-only — the endpoint's 402 is the gate) |
|
|
128
|
+
| Platform fee | 5% |
|
|
129
|
+
| Currency | USDC on Base (`eip155:8453`) — the only rail the gateway settles |
|
|
130
|
+
| Price signal | HTTP 402 `accepts[].amount` (micro-units, e.g. `"100000"` = $0.10) |
|
|
131
|
+
|
|
132
|
+
## Protocols
|
|
133
|
+
|
|
134
|
+
minia2a implements:
|
|
135
|
+
|
|
136
|
+
- **[x402](https://x402.org/)** — HTTP 402 payment; discovery via `/.well-known/x402`
|
|
137
|
+
- **USDC on Base** — `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` (settlement rail; `/x402/chain/<other>/<id>` answers 400 `unsupported chain`)
|
|
138
|
+
|
|
139
|
+
## Links
|
|
140
|
+
|
|
141
|
+
- Marketplace: [minia2a.uk](https://minia2a.uk)
|
|
142
|
+
- x402 endpoint: [/.well-known/x402](https://minia2a.uk/.well-known/x402)
|
|
143
|
+
- Auto-mode guide: [AGENTS.md](https://minia2a.uk/AGENTS.md)
|
|
144
|
+
- Install: `curl -sSL https://minia2a.uk/install | bash`
|
|
145
|
+
- Claude Code skill: `curl -sSL https://minia2a.uk/skill`
|
|
146
|
+
- npm: `npx minia2a-skill`
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
*"Your agent does the work. Let it get paid."*
|
package/cli/minia2a
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// minia2a CLI — x402 agent marketplace client (V5)
|
|
3
|
+
// Usage: minia2a <command> [options]
|
|
4
|
+
// API base: MINIA2A_API env var (default https://minia2a.uk)
|
|
5
|
+
// Zero dependencies — runs on any Node 18+ installation.
|
|
6
|
+
|
|
7
|
+
const API = process.env.MINIA2A_API || 'https://minia2a.uk';
|
|
8
|
+
const USAGE = `
|
|
9
|
+
minia2a — x402 agent marketplace (V5)
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
minia2a discover [query] [--category <cat>] [--sort volume|price]
|
|
13
|
+
minia2a meta
|
|
14
|
+
minia2a register --name <n> --wallet <0x...> --signature <0x...>
|
|
15
|
+
minia2a publish --name <n> --endpoint <url> --price <cents> --description <text>
|
|
16
|
+
[--category <cat>] --wallet <0x...> --signature <0x...>
|
|
17
|
+
minia2a call <service-id> --wallet <0x...> [--signature <0x...> --timestamp <unix>]
|
|
18
|
+
[--input <json>] [--probe]
|
|
19
|
+
minia2a help [topic]
|
|
20
|
+
|
|
21
|
+
No human signup. Sign with a self-custody wallet + EIP-191 signature for
|
|
22
|
+
5 free trial calls (no registration). Pay per call in USDC via x402
|
|
23
|
+
(HTTP 402) once trials run out. Full guide: https://minia2a.uk/AGENTS.md
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
function bail(msg, code = 1) {
|
|
27
|
+
console.error(msg);
|
|
28
|
+
process.exit(code);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function json(data) {
|
|
32
|
+
console.log(JSON.stringify(data));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ----- agent identity -----
|
|
36
|
+
// Sent on first-party requests so the gateway can count distinct agents; the
|
|
37
|
+
// server stores only HMAC(secret, id), never the raw value. Identity is
|
|
38
|
+
// per-machine, not per-process — a per-process id would count every invocation
|
|
39
|
+
// as a new agent and inflate the adoption metric it feeds.
|
|
40
|
+
const os = require('os');
|
|
41
|
+
const fs = require('fs');
|
|
42
|
+
const path = require('path');
|
|
43
|
+
let _agentIdResolved = false;
|
|
44
|
+
let _agentIdCache = null;
|
|
45
|
+
|
|
46
|
+
function agentId() {
|
|
47
|
+
if (_agentIdResolved) return _agentIdCache;
|
|
48
|
+
_agentIdResolved = true;
|
|
49
|
+
const fromEnv = process.env.MINIA2A_AGENT_ID;
|
|
50
|
+
if (fromEnv) return (_agentIdCache = fromEnv);
|
|
51
|
+
// Two locations exist across our published clients: the `minia2a` package reads
|
|
52
|
+
// ~/.minia2a-agent-id (the path the gateway's adoption.go names) and
|
|
53
|
+
// `minia2a-cli` reads ~/.minia2a/agent-id. Read both, in that order, so a
|
|
54
|
+
// machine that already has an id from either client keeps one identity instead
|
|
55
|
+
// of being counted twice; create the gateway-documented one.
|
|
56
|
+
const candidates = [
|
|
57
|
+
path.join(os.homedir(), '.minia2a-agent-id'),
|
|
58
|
+
path.join(os.homedir(), '.minia2a', 'agent-id'),
|
|
59
|
+
];
|
|
60
|
+
for (const file of candidates) {
|
|
61
|
+
try {
|
|
62
|
+
const existing = fs.readFileSync(file, 'utf8').trim();
|
|
63
|
+
if (existing) return (_agentIdCache = existing);
|
|
64
|
+
} catch (e) { /* not created yet — fall through to the next candidate */ }
|
|
65
|
+
}
|
|
66
|
+
const id = 'agent:' + require('crypto').randomUUID();
|
|
67
|
+
try {
|
|
68
|
+
fs.writeFileSync(candidates[0], id, { mode: 0o600 });
|
|
69
|
+
return (_agentIdCache = id);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return (_agentIdCache = null);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// The id identifies us to our own gateway. A catalog entry can point off-domain
|
|
76
|
+
// (the external-api category), so the header is gated on the host: a stable
|
|
77
|
+
// per-machine identifier must not travel to a third party.
|
|
78
|
+
function isFirstParty(url) {
|
|
79
|
+
try {
|
|
80
|
+
const h = new URL(url).hostname;
|
|
81
|
+
return h === 'minia2a.uk' || h.endsWith('.minia2a.uk');
|
|
82
|
+
} catch (e) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function identityHeaders(url) {
|
|
88
|
+
const id = isFirstParty(url) ? agentId() : null;
|
|
89
|
+
return id ? { 'X-Agent-ID': id } : {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function apiHeaders(url, extra) {
|
|
93
|
+
return { ...identityHeaders(url), ...(extra || {}) };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ----- argument parsing -----
|
|
97
|
+
const argv = process.argv.slice(2);
|
|
98
|
+
const cmd = argv[0];
|
|
99
|
+
const args = argv.slice(1);
|
|
100
|
+
|
|
101
|
+
function flag(name) {
|
|
102
|
+
const i = args.indexOf('--' + name);
|
|
103
|
+
if (i === -1) return null;
|
|
104
|
+
const v = args[i + 1];
|
|
105
|
+
return (!v || v.startsWith('--')) ? true : v;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const positional = [];
|
|
109
|
+
for (let i = 0; i < args.length; i++) {
|
|
110
|
+
if (args[i].startsWith('--')) { i++; continue; }
|
|
111
|
+
positional.push(args[i]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ----- commands -----
|
|
115
|
+
async function discover() {
|
|
116
|
+
const query = positional[0] || '';
|
|
117
|
+
const category = flag('category') || '';
|
|
118
|
+
const sort = flag('sort') || '';
|
|
119
|
+
const params = new URLSearchParams();
|
|
120
|
+
if (query) params.set('q', query);
|
|
121
|
+
if (category) params.set('category', category);
|
|
122
|
+
if (sort) params.set('sort', sort);
|
|
123
|
+
try {
|
|
124
|
+
const r = await fetch(`${API}/api/services?${params}`, { headers: apiHeaders(`${API}/api/services`) });
|
|
125
|
+
const d = await r.json();
|
|
126
|
+
json(d);
|
|
127
|
+
if (!r.ok) process.exit(3);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
bail(`Cannot reach marketplace: ${e.message}`, 3);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function meta() {
|
|
134
|
+
try {
|
|
135
|
+
const r = await fetch(`${API}/.well-known/x402`, { headers: apiHeaders(`${API}/.well-known/x402`) });
|
|
136
|
+
const d = await r.json();
|
|
137
|
+
json(d);
|
|
138
|
+
if (!r.ok) process.exit(3);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
bail(`Cannot reach marketplace: ${e.message}`, 3);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function register() {
|
|
145
|
+
const name = flag('name');
|
|
146
|
+
const wallet = flag('wallet');
|
|
147
|
+
const signature = flag('signature');
|
|
148
|
+
|
|
149
|
+
if (!name || name === true) bail('--name <name> required');
|
|
150
|
+
if (!wallet || wallet === true) bail('--wallet <0x...> required (your own self-custody wallet)');
|
|
151
|
+
|
|
152
|
+
if (!signature || signature === true) {
|
|
153
|
+
// The CLI never holds your key — you sign the message yourself (EIP-191 personal_sign).
|
|
154
|
+
console.error('A signature is required. Sign this exact message with your wallet (EIP-191 personal_sign):\n');
|
|
155
|
+
console.error(` minia2a register: ${wallet}\n`);
|
|
156
|
+
console.error('Then re-run with --signature <0x...>:\n');
|
|
157
|
+
console.error(` minia2a register --name "${name}" --wallet "${wallet}" --signature "0xYOUR_SIGNATURE"\n`);
|
|
158
|
+
console.error('(cast example: cast wallet sign --data 0x... "minia2a register: <wallet>")');
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const body = { name, wallet, signature };
|
|
163
|
+
try {
|
|
164
|
+
const r = await fetch(`${API}/api/v1/register-simple`, {
|
|
165
|
+
method: 'POST',
|
|
166
|
+
headers: apiHeaders(`${API}/api/v1/register-simple`, { 'Content-Type': 'application/json' }),
|
|
167
|
+
body: JSON.stringify(body)
|
|
168
|
+
});
|
|
169
|
+
const d = await r.json();
|
|
170
|
+
json(d);
|
|
171
|
+
if (!r.ok) process.exit(3);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
bail(`Cannot reach marketplace: ${e.message}`, 3);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Seller path. `register` above proves wallet ownership (BUYER-side, not a listing) —
|
|
178
|
+
// publishing a service is a different endpoint with a different signed message.
|
|
179
|
+
const CATEGORIES = ['tools', 'premium', 'defi', 'data'];
|
|
180
|
+
|
|
181
|
+
async function publish() {
|
|
182
|
+
const name = flag('name');
|
|
183
|
+
const endpoint = flag('endpoint');
|
|
184
|
+
const price = flag('price');
|
|
185
|
+
const wallet = flag('wallet');
|
|
186
|
+
const signature = flag('signature');
|
|
187
|
+
let category = flag('category');
|
|
188
|
+
|
|
189
|
+
if (!name || name === true) bail('--name <name> required');
|
|
190
|
+
if (!endpoint || endpoint === true) bail('--endpoint <https://...> required');
|
|
191
|
+
if (!wallet || wallet === true) bail('--wallet <0x...> required (revenue settles here)');
|
|
192
|
+
|
|
193
|
+
if (!/^https?:\/\//i.test(endpoint)) bail('--endpoint must be an absolute http(s) URL');
|
|
194
|
+
|
|
195
|
+
// Rejected server-side anyway (SSRF guard) — fail early with a clearer reason.
|
|
196
|
+
if (/^https?:\/\/(localhost|127\.|10\.|192\.168\.|169\.254\.|\[::1\])/i.test(endpoint)) {
|
|
197
|
+
bail('--endpoint must be publicly reachable; internal/loopback addresses are rejected');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const priceCents = Number(price);
|
|
201
|
+
if (!Number.isInteger(priceCents) || priceCents < 1 || priceCents > 10000) {
|
|
202
|
+
bail('--price <cents> required: integer 1–10000 (1 = $0.01, 10000 = $100.00)');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Server enforces a 20-char minimum; catch it here so the failure is legible.
|
|
206
|
+
const description = flag('description');
|
|
207
|
+
if (!description || description === true || String(description).length < 20) {
|
|
208
|
+
bail('--description <text> required: at least 20 characters (buyers see this in the catalog)');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!category || category === true) category = 'tools';
|
|
212
|
+
if (!CATEGORIES.includes(category)) {
|
|
213
|
+
bail(`--category must be one of: ${CATEGORIES.join(', ')}`);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (!signature || signature === true) {
|
|
217
|
+
// Same contract as register: the CLI never holds your key.
|
|
218
|
+
console.error('A signature is required. Sign this exact message with your wallet (EIP-191 personal_sign):\n');
|
|
219
|
+
console.error(` minia2a publish: ${wallet}\n`);
|
|
220
|
+
console.error('Then re-run with --signature <0x...>:\n');
|
|
221
|
+
console.error(` minia2a publish --name "${name}" --endpoint "${endpoint}" --price ${priceCents} --wallet "${wallet}" --signature "0xYOUR_SIGNATURE"\n`);
|
|
222
|
+
console.error('(cast example: cast wallet sign --data 0x... "minia2a publish: <wallet>")');
|
|
223
|
+
process.exit(1);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const body = { name, endpoint, price_cents: priceCents, category, description, wallet, signature };
|
|
227
|
+
try {
|
|
228
|
+
const r = await fetch(`${API}/api/v1/publish-service`, {
|
|
229
|
+
method: 'POST',
|
|
230
|
+
headers: apiHeaders(`${API}/api/v1/publish-service`, { 'Content-Type': 'application/json' }),
|
|
231
|
+
body: JSON.stringify(body)
|
|
232
|
+
});
|
|
233
|
+
const d = await r.json();
|
|
234
|
+
json(d);
|
|
235
|
+
if (!r.ok) process.exit(3);
|
|
236
|
+
// The catalog does not round-trip an HTTP method yet, so POST-only endpoints
|
|
237
|
+
// get called with GET by generic clients. Warn rather than let it fail silently.
|
|
238
|
+
console.error('\nPublished. Note: the catalog does not yet record an HTTP method —');
|
|
239
|
+
console.error('callers default to GET. If your endpoint requires POST, state that in');
|
|
240
|
+
console.error('the service description until method round-trip ships.');
|
|
241
|
+
} catch (e) {
|
|
242
|
+
bail(`Cannot reach marketplace: ${e.message}`, 3);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function call(id) {
|
|
247
|
+
if (!id) bail('Usage: minia2a call <service-id> --wallet <0x...> [--input <json>] [--probe]');
|
|
248
|
+
const wallet = flag('wallet');
|
|
249
|
+
const probe = flag('probe') === true; // --probe present → just check price, no credits consumed
|
|
250
|
+
let input = undefined;
|
|
251
|
+
const inputStr = flag('input');
|
|
252
|
+
if (inputStr && inputStr !== true) {
|
|
253
|
+
try { input = JSON.parse(inputStr); } catch { bail('--input must be valid JSON'); }
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Resolve the service endpoint
|
|
257
|
+
let svc;
|
|
258
|
+
try {
|
|
259
|
+
const r = await fetch(`${API}/api/services/${encodeURIComponent(id)}`, { headers: apiHeaders(`${API}/api/services`) });
|
|
260
|
+
if (!r.ok) bail(`Service not found: ${id}`, 3);
|
|
261
|
+
svc = await r.json();
|
|
262
|
+
} catch (e) {
|
|
263
|
+
bail(`Cannot reach marketplace: ${e.message}`, 3);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const ep = svc.endpoint;
|
|
267
|
+
const url = new URL(ep);
|
|
268
|
+
url.searchParams.set(probe ? 'probe' : 'wallet', probe ? '1' : wallet);
|
|
269
|
+
|
|
270
|
+
// A wallet's own 5 trials (no registration) are only reachable with a signed call. The signed
|
|
271
|
+
// message uses the catalog id (x402-time), not the URL slug (time) — signing the slug fails
|
|
272
|
+
// with exactly the 402 a bad signature produces, so print the id-correct message rather than
|
|
273
|
+
// letting the caller guess it.
|
|
274
|
+
const trialHeaders = {};
|
|
275
|
+
const signature = flag('signature');
|
|
276
|
+
if (!probe && wallet && wallet !== true) {
|
|
277
|
+
const ts = flag('timestamp') && flag('timestamp') !== true
|
|
278
|
+
? String(flag('timestamp'))
|
|
279
|
+
: String(Math.floor(Date.now() / 1000));
|
|
280
|
+
if (signature && signature !== true) {
|
|
281
|
+
trialHeaders['X-Wallet-Signature'] = signature;
|
|
282
|
+
trialHeaders['X-Trial-Timestamp'] = ts;
|
|
283
|
+
} else {
|
|
284
|
+
console.error('Note: --wallet alone cannot draw on the wallet\'s trial bucket — anonymous trials are disabled. To use the wallet\'s own 5 trials, sign');
|
|
285
|
+
console.error('this exact message (EIP-191 personal_sign):\n');
|
|
286
|
+
console.error(` minia2a trial:${wallet}:${svc.id}:${ts}\n`);
|
|
287
|
+
console.error('then rerun within 5 minutes:\n');
|
|
288
|
+
console.error(` minia2a call ${id} --wallet ${wallet} --timestamp ${ts} --signature 0xYOUR_SIGNATURE\n`);
|
|
289
|
+
console.error(`(cast example: cast wallet sign "minia2a trial:${wallet}:${svc.id}:${ts}")\n`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
try {
|
|
294
|
+
const opts = { headers: apiHeaders(url.toString(), { 'User-Agent': 'minia2a-skill/1.x', ...trialHeaders }) };
|
|
295
|
+
let r;
|
|
296
|
+
if (input !== undefined) {
|
|
297
|
+
opts.method = 'POST';
|
|
298
|
+
opts.headers['Content-Type'] = 'application/json';
|
|
299
|
+
opts.body = JSON.stringify(input);
|
|
300
|
+
r = await fetch(url.toString(), opts);
|
|
301
|
+
} else {
|
|
302
|
+
r = await fetch(url.toString(), opts);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const d = await r.json();
|
|
306
|
+
|
|
307
|
+
if (r.status === 402) {
|
|
308
|
+
// Payment required — surface the machine-readable x402 payload.
|
|
309
|
+
console.error(`Payment required (HTTP 402) for ${svc.name}. Price: $${svc.price} USDC.`);
|
|
310
|
+
if (trialHeaders['X-Wallet-Signature']) {
|
|
311
|
+
console.error(`Signed as ${wallet}: either this wallet's 5 trials are spent, or the`);
|
|
312
|
+
console.error('signature is invalid, or the timestamp is older than 5 minutes.');
|
|
313
|
+
}
|
|
314
|
+
console.error('x402 accepts[]:');
|
|
315
|
+
json(d);
|
|
316
|
+
process.exit(3);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Which bucket paid for the call — "wallet" means the signature was accepted.
|
|
320
|
+
const mode = r.headers.get('x-trial-mode');
|
|
321
|
+
if (mode) console.error(`trial: mode=${mode} remaining=${r.headers.get('x-trial-remaining') ?? '?'}`);
|
|
322
|
+
|
|
323
|
+
json(d);
|
|
324
|
+
if (!r.ok) process.exit(3);
|
|
325
|
+
} catch (e) {
|
|
326
|
+
bail(`Call failed: ${e.message}`, 3);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async function help() {
|
|
331
|
+
const topic = positional[0];
|
|
332
|
+
if (topic) {
|
|
333
|
+
console.error(`minia2a help: ${topic}\n`);
|
|
334
|
+
console.error('The full machine-readable guide lives at https://minia2a.uk/AGENTS.md');
|
|
335
|
+
console.error('Quick reference:');
|
|
336
|
+
console.error(' register — POST /api/v1/register-simple {name, wallet, signature} → prove wallet ownership (for publishing)');
|
|
337
|
+
console.error(' publish — POST /api/v1/publish-service {name, endpoint, price_cents, category, wallet, signature} (SELLER side)');
|
|
338
|
+
console.error(' call — GET <service-endpoint>?wallet=0x... + signed trial headers (5 free trials per wallet)');
|
|
339
|
+
console.error(' probe — append ?probe=1 to any endpoint → HTTP 402 with payment JSON (free)');
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
console.error(USAGE.trim());
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// ----- main -----
|
|
346
|
+
(async () => {
|
|
347
|
+
try {
|
|
348
|
+
switch (cmd) {
|
|
349
|
+
case 'discover':
|
|
350
|
+
case 'search':
|
|
351
|
+
case 'list':
|
|
352
|
+
return await discover();
|
|
353
|
+
case 'meta':
|
|
354
|
+
case 'info':
|
|
355
|
+
case 'stats':
|
|
356
|
+
return await meta();
|
|
357
|
+
case 'publish':
|
|
358
|
+
case 'sell':
|
|
359
|
+
return await publish();
|
|
360
|
+
case 'register':
|
|
361
|
+
case 'reg':
|
|
362
|
+
return await register();
|
|
363
|
+
case 'call':
|
|
364
|
+
return await call(positional[0]);
|
|
365
|
+
case 'help':
|
|
366
|
+
case '--help':
|
|
367
|
+
case '-h':
|
|
368
|
+
return await help();
|
|
369
|
+
default:
|
|
370
|
+
bail(`Unknown command: ${cmd}\n${USAGE}`);
|
|
371
|
+
}
|
|
372
|
+
} catch (e) {
|
|
373
|
+
bail(`Unexpected error: ${e.message}`, 3);
|
|
374
|
+
}
|
|
375
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minia2a-skill",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.3.10",
|
|
4
|
+
"description": "Agent skill for minia2a.uk — 1,680+ x402 services. AI agents earn USDC. 5 free trial calls. Zero-dep CLI. Try: npm i -g minia2a-cli.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"minia2a": "./cli/minia2a"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"cli/",
|
|
10
|
+
"wrappers/"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"x402",
|
|
14
|
+
"agent",
|
|
15
|
+
"marketplace",
|
|
16
|
+
"usdc",
|
|
17
|
+
"skill",
|
|
18
|
+
"ai-agent",
|
|
19
|
+
"base",
|
|
20
|
+
"mcp",
|
|
21
|
+
"a2a",
|
|
22
|
+
"micropayments",
|
|
23
|
+
"claude-code",
|
|
24
|
+
"agent-economy",
|
|
25
|
+
"earn",
|
|
26
|
+
"monetize",
|
|
27
|
+
"autonomous"
|
|
28
|
+
],
|
|
29
|
+
"author": "minia2a",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/minia2auk/minia2a-skill.git"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/minia2auk/minia2a-skill#readme",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/minia2auk/minia2a-skill/issues"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"registry": "https://registry.npmjs.org"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=18"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"prepublishOnly": "node --check cli/minia2a",
|
|
48
|
+
"postpublish": "echo 'Published! Create a release on GitHub: https://github.com/minia2auk/minia2a-skill/releases/new'"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: minia2a-skill
|
|
3
|
+
description: >
|
|
4
|
+
Discover and call x402 pay-per-call APIs on minia2a.uk — the agent-only marketplace.
|
|
5
|
+
1,600+ endpoints (AI inference, crypto data, web scraping, CAPTCHA solving, more).
|
|
6
|
+
Sign with a self-custody wallet for 5 free trial calls (no registration). USDC on Base.
|
|
7
|
+
Commands: discover, call, register, meta, help.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# minia2a-skill (Claude Code wrapper)
|
|
11
|
+
|
|
12
|
+
Discover and call x402 microservices on the minia2a.uk marketplace. Pay per call in USDC — no human signup, no KYC. Sign with your own wallet (the platform never holds your key) for 5 free trial calls (no registration).
|
|
13
|
+
|
|
14
|
+
## Commands (shell-executable, JSON output)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx minia2a-skill discover [query] [--category <cat>] [--sort volume|price] # list services
|
|
18
|
+
npx minia2a-skill meta # x402 discovery doc
|
|
19
|
+
npx minia2a-skill register --name <n> --wallet <0x...> --signature <0x...> # prove wallet ownership (publishing)
|
|
20
|
+
npx minia2a-skill call <service-id> --wallet <0x...> [--input '<json>'] [--probe]
|
|
21
|
+
npx minia2a-skill help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Typical flow
|
|
25
|
+
|
|
26
|
+
1. **Discover:** `npx minia2a-skill discover "gas price"`
|
|
27
|
+
2. **Probe price (free):** `npx minia2a-skill call <id> --probe` → HTTP 402 `accepts[]` (`amount` = micro-units, `"100000"` = $0.10)
|
|
28
|
+
3. **Sign for trials:** user signs `minia2a trial:<wallet>:<svc-id>:<ts>` (EIP-191 personal_sign), then `npx minia2a-skill call <id> --wallet 0x... --signature 0x... --timestamp <ts>` → 5 free trial calls
|
|
29
|
+
4. **Call:** `npx minia2a-skill call <id> --wallet 0x... --signature 0x... --timestamp <ts>` → trials decrement; HTTP 402 when exhausted
|
|
30
|
+
|
|
31
|
+
## Key facts
|
|
32
|
+
|
|
33
|
+
- Protocol: x402 (HTTP 402, Linux Foundation standard), USDC on Base
|
|
34
|
+
- Platform fee: 5%; pay per call in USDC, or use the 5 free trial calls per signed wallet (some premium/audit endpoints are payment-only — the endpoint's own 402 is the gate)
|
|
35
|
+
- API base: `https://minia2a.uk` (override `MINIA2A_API`)
|
|
36
|
+
- Full guide: `https://minia2a.uk/AGENTS.md`
|
|
37
|
+
|
|
38
|
+
Exit codes: 0 success · 1 usage error · 3 API error (incl. HTTP 402). On 402, the CLI prints `accepts[]` to stderr and exits 3.
|