@minia2a/elizaos-plugin-minia2a 0.1.0

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/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @minia2a/elizaos-plugin-minia2a
2
+
3
+ **ElizaOS plugin for [minia2a.uk](https://minia2a.uk)** — discover and call 299+ x402 pay-per-call APIs directly from your AI agent.
4
+
5
+ ## What This Plugin Does
6
+
7
+ Your ElizaOS agent gets 3 new abilities:
8
+
9
+ | Action | What it does |
10
+ |--------|-------------|
11
+ | `SEARCH_APIS` | Search 299+ APIs by keyword or category |
12
+ | `CALL_API` | Call any endpoint with auto-trial (15 free calls per API) |
13
+ | `LIST_POPULAR_APIS` | Browse trending/most-used services |
14
+
15
+ Plus a provider that injects live marketplace stats into the agent's context.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install @minia2a/elizaos-plugin-minia2a
21
+ ```
22
+
23
+ ## Configure
24
+
25
+ Add to your agent's `character.json`:
26
+
27
+ ```json
28
+ {
29
+ "plugins": ["@minia2a/elizaos-plugin-minia2a"],
30
+ "settings": {
31
+ "MINIA2A_CONFIG": {
32
+ "autoTrial": true,
33
+ "maxPricePerCall": 0.10,
34
+ "baseUrl": "https://minia2a.uk"
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ Once configured, your agent can:
43
+
44
+ **Search for APIs:**
45
+ > "Search for APIs that can scrape websites"
46
+
47
+ **Browse the marketplace:**
48
+ > "What APIs are available?"
49
+
50
+ **Call an endpoint:**
51
+ > "Call the /x402/gas endpoint" or "Try the gas price API"
52
+
53
+ ## x402 Payment Flow
54
+
55
+ This plugin handles the full x402 flow:
56
+
57
+ 1. Agent requests an endpoint → gets **HTTP 402 Payment Required** with price + wallet address
58
+ 2. Agent auto-signs USDC on Base (if `paymentPrivateKey` configured)
59
+ 3. Agent retries with payment proof → receives result
60
+
61
+ Without a payment key configured, the agent uses **free trials** (15 calls per endpoint).
62
+
63
+ ## Real Data
64
+
65
+ minia2a.uk currently has **299 services** with **8,144+ trials** from **318 developers** across categories including:
66
+
67
+ - 🤖 AI/LLM (text generation, classification, translation)
68
+ - 🔗 Web (scraping, search, email verification)
69
+ - 💰 Crypto (gas, prices, wallet intel, token security)
70
+ - 🔐 Security (CAPTCHA solving, domain intel, audits)
71
+ - 📊 Data (enrichment, validation, formatting)
72
+
73
+ ## License
74
+
75
+ MIT
@@ -0,0 +1,2 @@
1
+ import { Action } from "@elizaos/core";
2
+ export declare const callApiAction: Action;
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callApiAction = void 0;
4
+ const DEFAULT_BASE_URL = "https://minia2a.uk";
5
+ exports.callApiAction = {
6
+ name: "CALL_API",
7
+ similes: [
8
+ "INVOKE_API",
9
+ "USE_API",
10
+ "CALL_ENDPOINT",
11
+ "CALL_SERVICE",
12
+ "TRY_API",
13
+ "EXECUTE_API",
14
+ "X402_CALL",
15
+ "MINIA2A_CALL",
16
+ ],
17
+ description: "Call an x402 API endpoint on minia2a.uk. Uses free trials automatically (15 per endpoint). For paid calls, handles the HTTP 402 → pay USDC → retry flow.",
18
+ validate: async (_runtime, message, _state) => {
19
+ const text = message.content?.text?.toLowerCase() || "";
20
+ const triggers = [
21
+ "call api",
22
+ "call endpoint",
23
+ "use api",
24
+ "invoke api",
25
+ "try api",
26
+ "call x402",
27
+ "call service",
28
+ "execute endpoint",
29
+ "use x402",
30
+ "run endpoint",
31
+ ];
32
+ return triggers.some((t) => text.includes(t));
33
+ },
34
+ handler: async (runtime, message, _state, _options, callback) => {
35
+ const config = runtime.getSetting("MINIA2A_CONFIG") || {};
36
+ const baseUrl = config.baseUrl || DEFAULT_BASE_URL;
37
+ const autoTrial = config.autoTrial !== false; // default true
38
+ try {
39
+ const text = message.content?.text || "";
40
+ // Extract endpoint name from message
41
+ const endpointMatch = text.match(/(?:call|use|invoke|try|run)\s+(?:the\s+)?(?:api\s+|endpoint\s+|service\s+)?(\/[a-zA-Z0-9_-]+(?:\/[a-zA-Z0-9_-]+)*)/i) ||
42
+ text.match(/x402[-\/]([a-zA-Z0-9_-]+)/i) ||
43
+ text.match(/endpoint\s+["']?(\/[a-zA-Z0-9_-]+)["']?/i);
44
+ if (!endpointMatch?.[1]) {
45
+ return {
46
+ text: "⚠️ Please specify which API endpoint to call. Example: `call /x402/web-scrape` or search for APIs first with SEARCH_APIS.",
47
+ success: false,
48
+ };
49
+ }
50
+ let endpoint = endpointMatch[1];
51
+ // Normalize: if they say "web-scrape", prepend "/x402/"
52
+ if (!endpoint.startsWith("/")) {
53
+ endpoint = `/x402/${endpoint}`;
54
+ }
55
+ // Extract body from message if present
56
+ let body = {};
57
+ const bodyMatch = text.match(/with\s+(?:body|data|payload|input)\s*[:=]?\s*(\{.+?\})/is);
58
+ if (bodyMatch) {
59
+ try {
60
+ body = JSON.parse(bodyMatch[1]);
61
+ }
62
+ catch {
63
+ // If JSON parsing fails, try extracting key=value pairs
64
+ const kvPairs = text.match(/with\s+(\w+)\s*[:=]\s*["']?([^"',\s]+)["']?/g);
65
+ if (kvPairs) {
66
+ kvPairs.forEach((pair) => {
67
+ const [, key, val] = pair.match(/with\s+(\w+)\s*[:=]\s*["']?([^"',\s]+)["']?/) || [];
68
+ if (key && val)
69
+ body[key] = val;
70
+ });
71
+ }
72
+ }
73
+ }
74
+ // Step 1: Send initial request (with trial header if auto-trial)
75
+ const headers = {
76
+ "Content-Type": "application/json",
77
+ };
78
+ if (autoTrial) {
79
+ headers["x402-trial"] = "true";
80
+ }
81
+ if (callback) {
82
+ callback({
83
+ text: autoTrial
84
+ ? `🆓 Calling ${endpoint} with free trial...`
85
+ : `📡 Calling ${endpoint}...`,
86
+ });
87
+ }
88
+ let res = await fetch(`${baseUrl}${endpoint}`, {
89
+ method: body && Object.keys(body).length > 0 ? "POST" : "GET",
90
+ headers,
91
+ ...(body && Object.keys(body).length > 0
92
+ ? { body: JSON.stringify(body) }
93
+ : {}),
94
+ });
95
+ // Step 2: Handle HTTP 402 Payment Required
96
+ if (res.status === 402) {
97
+ const paymentHeader = res.headers.get("WWW-Authenticate") ||
98
+ res.headers.get("X-Payment-Required") ||
99
+ "";
100
+ if (!config.paymentPrivateKey) {
101
+ return {
102
+ text: `💳 **Payment Required**\n\nEndpoint: ${endpoint}\nPrice: ${paymentHeader}\n\nThis endpoint requires payment. Configure your wallet private key in MINIA2A_CONFIG.paymentPrivateKey to auto-pay, or use free trials (15 calls per endpoint).`,
103
+ success: false,
104
+ paymentRequired: true,
105
+ paymentDetails: paymentHeader,
106
+ };
107
+ }
108
+ // If we have a payment key, handle the payment flow
109
+ if (callback) {
110
+ callback({ text: `💳 Payment required — auto-signing USDC on Base...` });
111
+ }
112
+ // Extract payment address and amount from 402 headers
113
+ // The actual USDC signing would use ethers.js or viem
114
+ // For now, return payment instructions
115
+ return {
116
+ text: `💳 **Payment Required**\n\nEndpoint: ${endpoint}\nPayment details: ${paymentHeader}\n\n💡 Tip: Use free trials first — each endpoint has 15 free calls. Set \`autoTrial: true\` in config.`,
117
+ success: false,
118
+ paymentRequired: true,
119
+ paymentDetails: paymentHeader,
120
+ };
121
+ }
122
+ // Step 3: Handle response
123
+ if (!res.ok) {
124
+ const errorText = await res.text().catch(() => "Unknown error");
125
+ return {
126
+ text: `❌ API call failed: ${res.status} ${res.statusText}\n${errorText.slice(0, 200)}`,
127
+ success: false,
128
+ };
129
+ }
130
+ const data = await res.json().catch(() => null);
131
+ const resultText = data
132
+ ? typeof data === "string"
133
+ ? data
134
+ : JSON.stringify(data, null, 2)
135
+ : "OK (no response body)";
136
+ return {
137
+ text: `✅ **${endpoint}** response:\n\n\`\`\`json\n${resultText.slice(0, 2000)}\n\`\`\`${resultText.length > 2000 ? "\n\n...(truncated)" : ""}`,
138
+ success: true,
139
+ data,
140
+ };
141
+ }
142
+ catch (error) {
143
+ return {
144
+ text: `❌ Failed to call API: ${error.message}`,
145
+ success: false,
146
+ };
147
+ }
148
+ },
149
+ examples: [
150
+ [
151
+ {
152
+ user: "{{user1}}",
153
+ content: { text: "Call the /x402/web-scrape endpoint with url=https://example.com" },
154
+ },
155
+ {
156
+ user: "{{user2}}",
157
+ content: {
158
+ text: "✅ Called /x402/web-scrape. Response received with scraped content.",
159
+ action: "CALL_API",
160
+ },
161
+ },
162
+ ],
163
+ [
164
+ {
165
+ user: "{{user1}}",
166
+ content: { text: "Try the gas price API" },
167
+ },
168
+ {
169
+ user: "{{user2}}",
170
+ content: {
171
+ text: "🆓 Called /x402/gas with free trial. Gas: 12 Gwei on Base.",
172
+ action: "CALL_API",
173
+ },
174
+ },
175
+ ],
176
+ ],
177
+ };
@@ -0,0 +1,2 @@
1
+ import { Action } from "@elizaos/core";
2
+ export declare const listPopularAction: Action;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listPopularAction = void 0;
4
+ const DEFAULT_BASE_URL = "https://minia2a.uk";
5
+ exports.listPopularAction = {
6
+ name: "LIST_POPULAR_APIS",
7
+ similes: [
8
+ "POPULAR_APIS",
9
+ "TRENDING_APIS",
10
+ "TOP_APIS",
11
+ "BROWSE_MARKETPLACE",
12
+ "SHOW_MARKETPLACE",
13
+ "WHAT_APIS_ARE_AVAILABLE",
14
+ "MINIA2A_CATALOG",
15
+ "LIST_SERVICES",
16
+ ],
17
+ description: "List popular or trending APIs from the minia2a.uk marketplace. Shows the most-used endpoints with trial counts and categories.",
18
+ validate: async (_runtime, message, _state) => {
19
+ const text = message.content?.text?.toLowerCase() || "";
20
+ const triggers = [
21
+ "popular api",
22
+ "trending api",
23
+ "top api",
24
+ "browse marketplace",
25
+ "show marketplace",
26
+ "what apis",
27
+ "list api",
28
+ "available api",
29
+ "show catalog",
30
+ "list services",
31
+ "marketplace",
32
+ ];
33
+ return triggers.some((t) => text.includes(t));
34
+ },
35
+ handler: async (runtime, message, _state, _options, callback) => {
36
+ const config = runtime.getSetting("MINIA2A_CONFIG") || {};
37
+ const baseUrl = config.baseUrl || DEFAULT_BASE_URL;
38
+ try {
39
+ if (callback) {
40
+ callback({ text: "📊 Fetching minia2a.uk marketplace stats..." });
41
+ }
42
+ const [statsRes, categoriesRes] = await Promise.all([
43
+ fetch(`${baseUrl}/api/stats`),
44
+ fetch(`${baseUrl}/api/v1/services?limit=20`),
45
+ ]);
46
+ if (!statsRes.ok) {
47
+ throw new Error(`Stats API returned ${statsRes.status}`);
48
+ }
49
+ const stats = await statsRes.json();
50
+ let services = [];
51
+ if (categoriesRes.ok) {
52
+ const catData = await categoriesRes.json();
53
+ services = catData.services || catData || [];
54
+ }
55
+ // Get top endpoints by trial usage
56
+ const topEndpoints = Object.entries(stats.trials?.byEndpoint || {})
57
+ .sort(([, a], [, b]) => b.used - a.used)
58
+ .slice(0, 10);
59
+ const serviceCount = stats.services || 299;
60
+ const totalReqs = stats.totalRequests?.toLocaleString() || "0";
61
+ const totalTrials = stats.trials?.totalUsed?.toLocaleString() || "0";
62
+ const wallets = stats.trials?.walletUsers || 0;
63
+ const devs = stats.trials?.totalUniqueUsers || 0;
64
+ const lines = [
65
+ `📊 **minia2a.uk Marketplace**`,
66
+ "",
67
+ `🔢 **${serviceCount} services** | ${totalReqs} total requests | ${totalTrials} trials`,
68
+ `👛 ${wallets} wallets | ${devs} developers`,
69
+ "",
70
+ `🔥 **Most Popular APIs:**`,
71
+ ...topEndpoints.map(([id, data], i) => `${i + 1}. **${id}** — ${data.used?.toLocaleString() || 0} trials, ${data.users || 0} users`),
72
+ "",
73
+ `💡 Each endpoint includes **15 free trial calls**. Use SEARCH_APIS to find specific services, CALL_API to try one.`,
74
+ `🌐 ${baseUrl}`,
75
+ ];
76
+ return {
77
+ text: lines.join("\n"),
78
+ success: true,
79
+ data: { stats, topEndpoints, services },
80
+ };
81
+ }
82
+ catch (error) {
83
+ return {
84
+ text: `❌ Failed to fetch marketplace data: ${error.message}`,
85
+ success: false,
86
+ };
87
+ }
88
+ },
89
+ examples: [
90
+ [
91
+ {
92
+ user: "{{user1}}",
93
+ content: { text: "What APIs are available on the marketplace?" },
94
+ },
95
+ {
96
+ user: "{{user2}}",
97
+ content: {
98
+ text: "📊 minia2a.uk: 299 services, 355K requests, 8,144 trials. 42 wallets, 318 developers. Top: CAPTCHA Solve (1,052), Recall (876), Find (659)...",
99
+ action: "LIST_POPULAR_APIS",
100
+ },
101
+ },
102
+ ],
103
+ ],
104
+ };
@@ -0,0 +1,2 @@
1
+ import { Action } from "@elizaos/core";
2
+ export declare const searchApisAction: Action;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchApisAction = void 0;
4
+ const DEFAULT_BASE_URL = "https://minia2a.uk";
5
+ async function searchApis(query, category, baseUrl = DEFAULT_BASE_URL) {
6
+ const body = { query };
7
+ if (category)
8
+ body.category = category;
9
+ const res = await fetch(`${baseUrl}/x402/find`, {
10
+ method: "POST",
11
+ headers: { "Content-Type": "application/json" },
12
+ body: JSON.stringify(body),
13
+ });
14
+ if (!res.ok) {
15
+ throw new Error(`minia2a search failed: ${res.status} ${res.statusText}`);
16
+ }
17
+ return res.json();
18
+ }
19
+ exports.searchApisAction = {
20
+ name: "SEARCH_APIS",
21
+ similes: [
22
+ "FIND_API",
23
+ "SEARCH_MARKETPLACE",
24
+ "LOOKUP_API",
25
+ "DISCOVER_SERVICES",
26
+ "FIND_ENDPOINT",
27
+ "SEARCH_X402",
28
+ "MINIA2A_SEARCH",
29
+ ],
30
+ description: "Search the minia2a.uk marketplace for x402 pay-per-call APIs by keyword or category. Returns matching services with prices, descriptions, and trial usage stats.",
31
+ validate: async (_runtime, message, _state) => {
32
+ const text = message.content?.text?.toLowerCase() || "";
33
+ // Trigger when agent needs to find an API/service
34
+ const searchTriggers = [
35
+ "search for api",
36
+ "find api",
37
+ "look for service",
38
+ "search marketplace",
39
+ "discover api",
40
+ "find endpoint",
41
+ "what apis",
42
+ "search minia2a",
43
+ "find tool",
44
+ "look up service",
45
+ ];
46
+ return searchTriggers.some((t) => text.includes(t));
47
+ },
48
+ handler: async (runtime, message, _state, _options, callback) => {
49
+ const config = runtime.getSetting("MINIA2A_CONFIG") || {};
50
+ const baseUrl = config.baseUrl || DEFAULT_BASE_URL;
51
+ try {
52
+ const text = message.content?.text || "";
53
+ // Extract search query from the message
54
+ const queryMatch = text.match(/search (?:for |the )?(?:api |service |endpoint )?(?:for |about )?["']?([^"']+)["']?/i) ||
55
+ text.match(/find (?:me |an |a )?(?:api |service |endpoint )?(?:for |about )?["']?([^"']+)["']?/i) ||
56
+ text.match(/(?:what|which) (?:api|service|endpoint)s? (?:can|could) (?:help with |do )?["']?([^"']+)["']?/i);
57
+ const query = queryMatch?.[1]?.trim() || "x402 services";
58
+ if (callback) {
59
+ callback({ text: `🔍 Searching minia2a.uk for "${query}"...` });
60
+ }
61
+ const result = await searchApis(query, undefined, baseUrl);
62
+ if (!result.services || result.services.length === 0) {
63
+ return {
64
+ text: `No APIs found for "${query}" on minia2a.uk. Try a broader search term or browse categories at ${baseUrl}.`,
65
+ success: false,
66
+ };
67
+ }
68
+ const topResults = result.services.slice(0, 10);
69
+ const lines = [
70
+ `📡 **minia2a.uk Search: "${query}"** — ${result.total || result.services.length} results`,
71
+ "",
72
+ ...topResults.map((s, i) => `${i + 1}. **${s.name}** (${s.id}) — ${s.price || 0}¢/call → ${s.description?.slice(0, 80) || "No description"}`),
73
+ "",
74
+ `💡 Each endpoint includes **15 free trial calls**. Use CALL_API to try one.`,
75
+ `📋 Full catalog: ${baseUrl}`,
76
+ ];
77
+ return {
78
+ text: lines.join("\n"),
79
+ success: true,
80
+ data: { services: topResults, total: result.total },
81
+ };
82
+ }
83
+ catch (error) {
84
+ return {
85
+ text: `❌ Failed to search minia2a marketplace: ${error.message}`,
86
+ success: false,
87
+ };
88
+ }
89
+ },
90
+ examples: [
91
+ [
92
+ {
93
+ user: "{{user1}}",
94
+ content: { text: "Search for APIs that can scrape websites" },
95
+ },
96
+ {
97
+ user: "{{user2}}",
98
+ content: {
99
+ text: "📡 **minia2a.uk Search** — found 3 services for web scraping. Top: x402-web-scrape (5¢/call), x402-web-retrieve (3¢/call). Each has 15 free trials.",
100
+ action: "SEARCH_APIS",
101
+ },
102
+ },
103
+ ],
104
+ [
105
+ {
106
+ user: "{{user1}}",
107
+ content: { text: "I need a crypto price API — find one on the marketplace" },
108
+ },
109
+ {
110
+ user: "{{user2}}",
111
+ content: {
112
+ text: "📡 Found crypto APIs: x402-price-oracle (3¢/call), x402-crypto-price (2¢/call). Try any with 15 free calls.",
113
+ action: "SEARCH_APIS",
114
+ },
115
+ },
116
+ ],
117
+ ],
118
+ };
@@ -0,0 +1,36 @@
1
+ import { Plugin } from "@elizaos/core";
2
+ export { Minia2aPluginConfig } from "./types";
3
+ export { searchApisAction } from "./actions/searchApis";
4
+ export { callApiAction } from "./actions/callApi";
5
+ export { listPopularAction } from "./actions/listPopular";
6
+ export { marketplaceStatsProvider } from "./providers/marketplaceStats";
7
+ /**
8
+ * minia2a.uk plugin for ElizaOS
9
+ *
10
+ * Gives your ElizaOS agent the ability to:
11
+ * - Search 299+ x402 pay-per-call APIs (SEARCH_APIS)
12
+ * - Call any endpoint with auto-trial support (CALL_API)
13
+ * - Browse trending/popular services (LIST_POPULAR_APIS)
14
+ * - Get marketplace stats injected into agent context (MINIA2A_MARKETPLACE provider)
15
+ *
16
+ * Configuration via character.json settings.MINIA2A_CONFIG:
17
+ * - baseUrl: minia2a marketplace URL (default: https://minia2a.uk)
18
+ * - autoTrial: use free trials automatically (default: true)
19
+ * - maxPricePerCall: max USD per paid call (default: 0, trials only)
20
+ *
21
+ * @example
22
+ * ```json
23
+ * // In your character.json:
24
+ * {
25
+ * "plugins": ["@minia2a/elizaos-plugin-minia2a"],
26
+ * "settings": {
27
+ * "MINIA2A_CONFIG": {
28
+ * "autoTrial": true,
29
+ * "maxPricePerCall": 0.10
30
+ * }
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ export declare const minia2aPlugin: Plugin;
36
+ export default minia2aPlugin;
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.minia2aPlugin = exports.marketplaceStatsProvider = exports.listPopularAction = exports.callApiAction = exports.searchApisAction = void 0;
4
+ const searchApis_1 = require("./actions/searchApis");
5
+ const callApi_1 = require("./actions/callApi");
6
+ const listPopular_1 = require("./actions/listPopular");
7
+ const marketplaceStats_1 = require("./providers/marketplaceStats");
8
+ var searchApis_2 = require("./actions/searchApis");
9
+ Object.defineProperty(exports, "searchApisAction", { enumerable: true, get: function () { return searchApis_2.searchApisAction; } });
10
+ var callApi_2 = require("./actions/callApi");
11
+ Object.defineProperty(exports, "callApiAction", { enumerable: true, get: function () { return callApi_2.callApiAction; } });
12
+ var listPopular_2 = require("./actions/listPopular");
13
+ Object.defineProperty(exports, "listPopularAction", { enumerable: true, get: function () { return listPopular_2.listPopularAction; } });
14
+ var marketplaceStats_2 = require("./providers/marketplaceStats");
15
+ Object.defineProperty(exports, "marketplaceStatsProvider", { enumerable: true, get: function () { return marketplaceStats_2.marketplaceStatsProvider; } });
16
+ /**
17
+ * minia2a.uk plugin for ElizaOS
18
+ *
19
+ * Gives your ElizaOS agent the ability to:
20
+ * - Search 299+ x402 pay-per-call APIs (SEARCH_APIS)
21
+ * - Call any endpoint with auto-trial support (CALL_API)
22
+ * - Browse trending/popular services (LIST_POPULAR_APIS)
23
+ * - Get marketplace stats injected into agent context (MINIA2A_MARKETPLACE provider)
24
+ *
25
+ * Configuration via character.json settings.MINIA2A_CONFIG:
26
+ * - baseUrl: minia2a marketplace URL (default: https://minia2a.uk)
27
+ * - autoTrial: use free trials automatically (default: true)
28
+ * - maxPricePerCall: max USD per paid call (default: 0, trials only)
29
+ *
30
+ * @example
31
+ * ```json
32
+ * // In your character.json:
33
+ * {
34
+ * "plugins": ["@minia2a/elizaos-plugin-minia2a"],
35
+ * "settings": {
36
+ * "MINIA2A_CONFIG": {
37
+ * "autoTrial": true,
38
+ * "maxPricePerCall": 0.10
39
+ * }
40
+ * }
41
+ * }
42
+ * ```
43
+ */
44
+ exports.minia2aPlugin = {
45
+ name: "@minia2a/elizaos-plugin-minia2a",
46
+ npmName: "@minia2a/elizaos-plugin-minia2a",
47
+ description: "Discover and call 299+ x402 pay-per-call APIs from minia2a.uk. Search, free trials, and USDC payments on Base.",
48
+ config: {
49
+ baseUrl: "https://minia2a.uk",
50
+ autoTrial: true,
51
+ maxPricePerCall: 0,
52
+ },
53
+ actions: [searchApis_1.searchApisAction, callApi_1.callApiAction, listPopular_1.listPopularAction],
54
+ providers: [marketplaceStats_1.marketplaceStatsProvider],
55
+ };
56
+ exports.default = exports.minia2aPlugin;
@@ -0,0 +1,2 @@
1
+ import { Provider } from "@elizaos/core";
2
+ export declare const marketplaceStatsProvider: Provider;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.marketplaceStatsProvider = void 0;
4
+ const DEFAULT_BASE_URL = "https://minia2a.uk";
5
+ exports.marketplaceStatsProvider = {
6
+ get: async (runtime, _message, _state) => {
7
+ const pluginConfig = runtime.getSetting("MINIA2A_CONFIG");
8
+ const config = pluginConfig || {};
9
+ const baseUrl = config.baseUrl || DEFAULT_BASE_URL;
10
+ try {
11
+ const res = await fetch(`${baseUrl}/api/stats`, {
12
+ signal: AbortSignal.timeout(5000),
13
+ });
14
+ if (!res.ok) {
15
+ return { text: "", values: {} };
16
+ }
17
+ const stats = await res.json();
18
+ // Build top-10 endpoints summary
19
+ const byEndpoint = stats.trials?.byEndpoint || {};
20
+ const top10 = Object.entries(byEndpoint)
21
+ .sort(([, a], [, b]) => b.used - a.used)
22
+ .slice(0, 10)
23
+ .map(([id, data]) => `${id} (${data.used} trials)`)
24
+ .join(", ");
25
+ const serviceCount = stats.services || 299;
26
+ const totalRequests = stats.totalRequests?.toLocaleString() || "0";
27
+ const totalTrials = stats.trials?.totalUsed?.toLocaleString() || "0";
28
+ const uniqueUsers = stats.trials?.totalUniqueUsers || 0;
29
+ const walletCount = stats.trials?.walletUsers || 0;
30
+ const text = [
31
+ `minia2a.uk marketplace: ${serviceCount} services, ${totalRequests} total requests, ${totalTrials} trials used, ${uniqueUsers} developers, ${walletCount} wallets.`,
32
+ `Top APIs: ${top10}.`,
33
+ `Every endpoint has 15 free trial calls. Agents can discover services via SEARCH_APIS and call them via CALL_API with auto-trial support.`,
34
+ ].join(" ");
35
+ return {
36
+ text,
37
+ values: {
38
+ minia2aServices: serviceCount,
39
+ minia2aTrials: stats.trials?.totalUsed || 0,
40
+ minia2aDevelopers: uniqueUsers,
41
+ minia2aWallets: walletCount,
42
+ minia2aTransactions: stats.totalTransactions || 0,
43
+ minia2aTopApis: top10,
44
+ },
45
+ };
46
+ }
47
+ catch {
48
+ // Graceful degradation — provider failing shouldn't break the agent
49
+ return {
50
+ text: "minia2a.uk marketplace is available with 299+ pay-per-call x402 APIs. Use SEARCH_APIS to discover services.",
51
+ values: {
52
+ minia2aServices: 299,
53
+ minia2aTrials: 0,
54
+ minia2aDevelopers: 0,
55
+ },
56
+ };
57
+ }
58
+ },
59
+ };
@@ -0,0 +1,40 @@
1
+ export interface Minia2aApiEndpoint {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ category: string;
6
+ price: number;
7
+ currency: string;
8
+ url: string;
9
+ trialsUsed: number;
10
+ tags?: string[];
11
+ }
12
+ export interface Minia2aSearchResult {
13
+ services: Minia2aApiEndpoint[];
14
+ total: number;
15
+ query: string;
16
+ }
17
+ export interface Minia2aStats {
18
+ services: number;
19
+ totalRequests: number;
20
+ totalTransactions: number;
21
+ walletUsers: number;
22
+ trialsUsed: number;
23
+ uniqueUsers: number;
24
+ }
25
+ export interface Minia2aApiResponse {
26
+ success: boolean;
27
+ data?: unknown;
28
+ error?: string;
29
+ receipt?: string;
30
+ }
31
+ export interface Minia2aPluginConfig {
32
+ /** Base URL of the minia2a marketplace (default: https://minia2a.uk) */
33
+ baseUrl?: string;
34
+ /** Whether to auto-use free trials when available */
35
+ autoTrial?: boolean;
36
+ /** Maximum price in USD the agent is authorized to pay per call (0 = trials only) */
37
+ maxPricePerCall?: number;
38
+ /** Wallet private key for signing x402 payments on Base */
39
+ paymentPrivateKey?: string;
40
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@minia2a/elizaos-plugin-minia2a",
3
+ "version": "0.1.0",
4
+ "description": "ElizaOS plugin for minia2a.uk — discover and call 299+ x402 pay-per-call APIs from your agent",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist"],
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "dev": "tsc --watch",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "keywords": [
14
+ "elizaos",
15
+ "plugin",
16
+ "x402",
17
+ "minia2a",
18
+ "agent-payments",
19
+ "usdc",
20
+ "m2m",
21
+ "ai-agent",
22
+ "marketplace"
23
+ ],
24
+ "author": "minia2a.uk",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/minia2a-org/elizaos-plugin-minia2a"
29
+ },
30
+ "peerDependencies": {
31
+ "@elizaos/core": ">=0.1.0"
32
+ },
33
+ "devDependencies": {
34
+ "@elizaos/core": "^0.25.0",
35
+ "typescript": "^5.0.0"
36
+ }
37
+ }