agentsla 2.0.1 → 2.0.2

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 (4) hide show
  1. package/README.md +26 -25
  2. package/index.js +74 -158
  3. package/package.json +19 -12
  4. package/test.js +0 -32
package/README.md CHANGED
@@ -1,14 +1,13 @@
1
- # AgentSLA SDK (v2.0.0)
1
+ # AgentSLA (`agentsla` v2.0.2)
2
2
 
3
- Official M2M JavaScript/TypeScript SDK for **AgentSLA** (https://agentsla.io) — the autonomous API telemetry directory, EIP-712 cryptographic SLA oracle, Streamable HTTP MCP server, and Circle USDC escrow protocol on **Base Mainnet (Chain ID 8453)**.
3
+ **The Autonomous M2M SLA Oracle, 17,901+ API & MCP Directory, and Circle USDC Escrow Protocol on Base Mainnet (Chain ID: `8453`).**
4
4
 
5
- ## Production Infrastructure (Base Mainnet)
6
-
7
- - **Verified Escrow Contract:** [0x6ca6cDDd6EC59D75Ea0a36882AC57fc199Ba79CD](https://basescan.org/address/0x6ca6cDDd6EC59D75Ea0a36882AC57fc199Ba79CD)
8
- - **Settlement Token (Circle USDC):** [0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913](https://basescan.org/token/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) (6 decimals)
9
- - **Streamable HTTP MCP Endpoint:** https://agentsla.io/mcp
10
- - **LLM Discovery Manifests:** https://agentsla.io/llms.txt | https://agentsla.io/llms-full.txt
11
- - **OpenAPI 3.1.0 Spec:** https://agentsla.io/openapi.json
5
+ - **Live Portal & Console:** [https://agentsla.io](https://agentsla.io)
6
+ - **Streamable HTTP MCP Server:** `https://agentsla.io/mcp`
7
+ - **MCP Auto-Discovery Manifest:** [https://agentsla.io/.well-known/mcp.json](https://agentsla.io/.well-known/mcp.json)
8
+ - **LLM Manifests:** [https://agentsla.io/llms.txt](https://agentsla.io/llms.txt) | [https://agentsla.io/llms-full.txt](https://agentsla.io/llms-full.txt)
9
+ - **Base Mainnet Escrow Contract:** `0x6ca6cDDd6EC59D75Ea0a36882AC57fc199Ba79CD`
10
+ - **Official Circle USDC (Base):** `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`
12
11
 
13
12
  ## Installation
14
13
 
@@ -16,35 +15,37 @@ Official M2M JavaScript/TypeScript SDK for **AgentSLA** (https://agentsla.io)
16
15
  npm install agentsla ethers
17
16
  ```
18
17
 
19
- ## Quick Start
18
+ ## Quick Start (Search 17,901+ Monitored APIs & MCP Connectors)
20
19
 
21
20
  ```javascript
22
- import { ethers } from "ethers";
23
21
  import { AgentSLA } from "agentsla";
24
22
 
25
- const provider = new ethers.JsonRpcProvider("https://mainnet.base.org");
26
- const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
27
- const client = new AgentSLA({ signer: wallet });
28
-
29
- // 1. Discover top-ranked APIs by category
30
- const directory = await client.discover("ai-models");
23
+ const sla = new AgentSLA();
31
24
 
32
- // 2. Probe an endpoint and receive a signed EIP-712 SLA attestation
33
- const proof = await client.verify("https://mainnet.base.org");
25
+ // Search across 17,901+ indexed APIs & MCP connectors across 21 categories
26
+ const result = await sla.discoverApis({
27
+ category: "mcp-connectors",
28
+ search: "solana",
29
+ limit: 10
30
+ });
34
31
 
35
- // 3. Lock Circle USDC in Base Mainnet Escrow for an M2M API task
36
- const receipt = await client.lockEscrowUsdc(wallet.address, 1, "0.01");
32
+ console.log(result.totalMonitoredApis, result.agents);
37
33
  ```
38
34
 
39
- ## Streamable HTTP MCP Configuration
35
+ ## Connect Claude Desktop, Cursor, or Windsurf
40
36
 
41
37
  ```json
42
38
  {
43
39
  "mcpServers": {
44
- "agentsla": {
45
- "type": "streamable-http",
40
+ "agentsla-oracle": {
46
41
  "url": "https://agentsla.io/mcp"
47
42
  }
48
43
  }
49
44
  }
50
- ```
45
+ ```
46
+
47
+ ## Enterprise API Provider & Turnkey MCP Tiers
48
+
49
+ - **M2M Oracle Pass ($5 USDC / 7 Days):** Unlimited on-demand `/v1/verify` and MCP `verify_endpoint_sla` EIP-712 probes.
50
+ - **Verified Priority API Provider ($199 USDC/mo or $499 Lifetime):** Rank #1 in your category across `/v1/directory`, `/llms-full.txt`, and `/mcp`.
51
+ - **Turnkey Custom MCP + Base USDC 402 Paywall ($1,500 USDC Flat):** Custom Cloudflare Edge Streamable HTTP MCP server + Circle USDC 402 paywall + npm SDK delivered in 48 hours.
package/index.js CHANGED
@@ -1,192 +1,108 @@
1
1
  import { ethers } from "ethers";
2
2
 
3
- export const DEFAULT_ORACLE_URL = "https://agentsla-oracle.agentsla-dev.workers.dev";
4
- export const DEFAULT_MCP_URL = "https://agentsla.io/mcp";
5
- export const ESCROW_ADDRESS = "0x6ca6cDDd6EC59D75Ea0a36882AC57fc199Ba79CD";
6
- export const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
7
- export const BASE_CHAIN_ID = 8453;
8
-
9
- export const ESCROW_ABI = [
10
- "function owner() view returns (address)",
11
- "function payoutWallet() view returns (address)",
12
- "function usdcToken() view returns (address)",
13
- "function nextJobId() view returns (uint256)",
14
- "function accumulatedFees() view returns (uint256)",
15
- "function isSubscribed(address) view returns (bool)",
16
- "function jobs(uint256) view returns (address creator, address agent, uint256 apiId, uint256 lockedAmount, bool isActive)",
17
- "function paySubscription() external",
3
+ export const AGENTSLA_CONFIG = {
4
+ ORACLE_URL: "https://agentsla-oracle.agentsla-dev.workers.dev",
5
+ MCP_URL: "https://agentsla.io/mcp",
6
+ CHAIN_ID: 8453,
7
+ RPC_URL: "https://mainnet.base.org",
8
+ ESCROW_CONTRACT: "0x6ca6cDDd6EC59D75Ea0a36882AC57fc199Ba79CD",
9
+ USDC_TOKEN: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
10
+ TREASURY_WALLET: "0x9A0d2dD2402991eC8095fE2Be0d96A59d9DCF13C"
11
+ };
12
+
13
+ const ESCROW_ABI = [
18
14
  "function createJob(address _agent, uint256 _apiId, uint256 _lockedAmount) external returns (uint256)",
19
- "function resolveJob(uint256 _jobId, bool _slaMet) external"
15
+ "function paySubscription() external"
20
16
  ];
21
17
 
22
- export const USDC_ABI = [
23
- "function balanceOf(address account) view returns (uint256)",
18
+ const USDC_ABI = [
19
+ "function approve(address spender, uint256 amount) external returns (bool)",
24
20
  "function allowance(address owner, address spender) view returns (uint256)",
25
- "function approve(address spender, uint256 amount) external returns (bool)"
21
+ "function balanceOf(address account) view returns (uint256)",
22
+ "function transfer(address to, uint256 amount) external returns (bool)"
26
23
  ];
27
24
 
28
25
  export class AgentSLA {
29
- /**
30
- * @param {Object} config
31
- * @param {string} [config.oracleUrl] - Custom AgentSLA Oracle Worker URL
32
- * @param {string} [config.mcpUrl] - Streamable HTTP MCP URL (https://agentsla.io/mcp)
33
- * @param {string} [config.escrowAddress] - Base Mainnet Escrow Contract Address
34
- * @param {string} [config.usdcAddress] - Base Mainnet Circle USDC Address
35
- * @param {string} [config.walletAddress] - Subscribed Base Mainnet wallet address (0x...)
36
- * @param {ethers.Signer|ethers.Provider} [config.signer] - Ethers v6 Signer or Provider
37
- */
38
- constructor(config = {}) {
39
- this.oracleUrl = config.oracleUrl || DEFAULT_ORACLE_URL;
40
- this.mcpUrl = config.mcpUrl || DEFAULT_MCP_URL;
41
- this.escrowAddress = config.escrowAddress || ESCROW_ADDRESS;
42
- this.usdcAddress = config.usdcAddress || USDC_ADDRESS;
43
- this.walletAddress = config.walletAddress || null;
44
- this.signer = config.signer || null;
45
-
46
- if (this.signer) {
47
- this.contract = new ethers.Contract(this.escrowAddress, ESCROW_ABI, this.signer);
48
- this.usdc = new ethers.Contract(this.usdcAddress, USDC_ABI, this.signer);
49
- }
26
+ constructor(options = {}) {
27
+ this.oracleUrl = options.oracleUrl || AGENTSLA_CONFIG.ORACLE_URL;
28
+ this.mcpUrl = options.mcpUrl || AGENTSLA_CONFIG.MCP_URL;
29
+ this.rpcUrl = options.rpcUrl || AGENTSLA_CONFIG.RPC_URL;
30
+ this.provider = new ethers.JsonRpcProvider(this.rpcUrl);
31
+ this.signer = options.privateKey ? new ethers.Wallet(options.privateKey, this.provider) : null;
50
32
  }
51
33
 
52
- async _resolveWallet(explicitWallet) {
53
- if (explicitWallet) return explicitWallet;
54
- if (this.walletAddress) return this.walletAddress;
55
- if (this.signer) {
56
- if (this.signer.address) return this.signer.address;
57
- if (typeof this.signer.getAddress === "function") {
58
- try { return await this.signer.getAddress(); } catch (e) {}
59
- }
34
+ /**
35
+ * Search and filter 17,901+ SLA-monitored M2M APIs & MCP connectors across 21 categories.
36
+ * @param {string|object} filter - Category string OR { category, search, limit, offset }
37
+ */
38
+ async discoverApis(filter = {}) {
39
+ const params = new URLSearchParams();
40
+ if (typeof filter === "string") {
41
+ if (filter && filter !== "all") params.set("category", filter);
42
+ } else if (filter && typeof filter === "object") {
43
+ if (filter.category && filter.category !== "all") params.set("category", filter.category);
44
+ if (filter.search) params.set("search", filter.search);
45
+ if (filter.limit) params.set("limit", String(filter.limit));
46
+ if (filter.offset) params.set("offset", String(filter.offset));
60
47
  }
61
- return undefined;
48
+ const qs = params.toString();
49
+ const res = await fetch(`${this.oracleUrl}/v1/directory${qs ? `?${qs}` : ""}`);
50
+ return await res.json();
62
51
  }
63
52
 
64
53
  /**
65
- * Probe an API endpoint via the AgentSLA Oracle, generate a signed EIP-712 SLA proof,
66
- * and optionally resolve an active on-chain Base Mainnet USDC escrow job.
67
- * @param {string} targetApiUrl - Target API endpoint to probe
68
- * @param {number} [jobId=0] - Active Base Mainnet escrow jobId (0 for probe-only)
69
- * @param {Object} [targetApiPayload] - Optional POST payload for the target API
70
- * @param {string} [walletAddress] - Optional subscribed Base Mainnet wallet address
54
+ * Call the remote Streamable HTTP MCP server at https://agentsla.io/mcp
71
55
  */
72
- async verify(targetApiUrl, jobId = 0, targetApiPayload = undefined, walletAddress = undefined) {
73
- if (!targetApiUrl) throw new Error("targetApiUrl is required.");
74
-
75
- const resolvedWallet = await this._resolveWallet(walletAddress);
76
-
77
- const response = await fetch(`${this.oracleUrl}/v1/verify`, {
56
+ async callMcpTool(name, args = {}) {
57
+ const res = await fetch(this.mcpUrl, {
78
58
  method: "POST",
79
59
  headers: { "Content-Type": "application/json" },
80
60
  body: JSON.stringify({
81
- jobId,
82
- targetApiUrl,
83
- targetApiPayload,
84
- walletAddress: resolvedWallet
61
+ jsonrpc: "2.0",
62
+ id: Date.now(),
63
+ method: "tools/call",
64
+ params: { name, arguments: args }
85
65
  })
86
66
  });
87
-
88
- const data = await response.json();
89
- if (!response.ok) {
90
- const err = new Error(data.error || "Failed to verify endpoint via AgentSLA Oracle.");
91
- err.status = response.status;
92
- err.paymentDetails = data;
93
- throw err;
94
- }
95
- return data;
96
- }
97
-
98
- /**
99
- * Approve Circle USDC (if needed) and lock USDC in Base Mainnet Escrow for an M2M API task.
100
- * @param {string} agentWallet - Provider agent wallet address
101
- * @param {number|bigint} apiId - Monitored API ID from the AgentSLA directory
102
- * @param {string|number} amountUsdc - Amount in USDC (e.g., "0.01" or "5.00")
103
- */
104
- async lockEscrowUsdc(agentWallet, apiId, amountUsdc) {
105
- if (!this.contract || !this.usdc || typeof this.signer.getAddress !== "function") {
106
- throw new Error("A connected ethers.js Signer is required to lock USDC in escrow.");
107
- }
108
-
109
- const amountUnits = ethers.parseUnits(amountUsdc.toString(), 6);
110
- const ownerAddress = await this.signer.getAddress();
111
- const currentAllowance = await this.usdc.allowance(ownerAddress, this.escrowAddress);
112
-
113
- if (currentAllowance < amountUnits) {
114
- const approveTx = await this.usdc.approve(this.escrowAddress, amountUnits);
115
- await approveTx.wait(1);
116
- }
117
-
118
- const createTx = await this.contract.createJob(agentWallet, BigInt(apiId), amountUnits);
119
- return await createTx.wait(1);
120
- }
121
-
122
- /**
123
- * Pay the 5 USDC 7-day autonomous oracle subscription on Base Mainnet.
124
- */
125
- async paySubscription() {
126
- if (!this.contract || !this.usdc || typeof this.signer.getAddress !== "function") {
127
- throw new Error("A connected ethers.js Signer is required to pay subscription.");
128
- }
129
-
130
- const feeUnits = ethers.parseUnits("5.0", 6);
131
- const ownerAddress = await this.signer.getAddress();
132
- const currentAllowance = await this.usdc.allowance(ownerAddress, this.escrowAddress);
133
-
134
- if (currentAllowance < feeUnits) {
135
- const approveTx = await this.usdc.approve(this.escrowAddress, feeUnits);
136
- await approveTx.wait(1);
137
- }
138
-
139
- const tx = await this.contract.paySubscription();
140
- return await tx.wait(1);
67
+ return await res.json();
141
68
  }
142
69
 
143
70
  /**
144
- * Discover ranked APIs in the AgentSLA directory.
145
- * @param {string} [category="all"]
71
+ * Probe an endpoint and generate a cryptographic EIP-712 SLA attestation.
146
72
  */
147
- async discover(category = "all") {
148
- const query = category && category !== "all" ? `?category=${encodeURIComponent(category)}` : "";
149
- const response = await fetch(`${this.oracleUrl}/v1/directory${query}`);
150
- return await response.json();
151
- }
152
-
153
- /**
154
- * Register a new API endpoint in the AgentSLA directory.
155
- */
156
- async register({ service_name, endpoint_url, category = "general", sla_threshold = 99.9, capabilities = [] }) {
157
- const response = await fetch(`${this.oracleUrl}/v1/directory`, {
73
+ async verifyEndpoint({ endpointUrl, jobId = 1, payload = {} }) {
74
+ const walletAddress = this.signer ? await this.signer.getAddress() : undefined;
75
+ const res = await fetch(`${this.oracleUrl}/v1/verify`, {
158
76
  method: "POST",
159
77
  headers: { "Content-Type": "application/json" },
160
- body: JSON.stringify({ service_name, endpoint_url, category, sla_threshold, capabilities })
78
+ body: JSON.stringify({
79
+ jobId,
80
+ targetApiUrl: endpointUrl,
81
+ targetApiPayload: payload,
82
+ walletAddress
83
+ })
161
84
  });
162
- return await response.json();
85
+ return await res.json();
163
86
  }
164
87
 
165
88
  /**
166
- * Fetch recent EIP-712 signed oracle attestations.
89
+ * Pay the 5.00 Circle USDC 7-day M2M Oracle Subscription on Base Mainnet (8453).
167
90
  */
168
- async getAttestations() {
169
- const response = await fetch(`${this.oracleUrl}/api/attestations`);
170
- return await response.json();
91
+ async subscribeSevenDays() {
92
+ if (!this.signer) throw new Error("Private key required to sign Base Mainnet USDC transactions.");
93
+ const userAddress = await this.signer.getAddress();
94
+ const usdc = new ethers.Contract(AGENTSLA_CONFIG.USDC_TOKEN, USDC_ABI, this.signer);
95
+ const escrow = new ethers.Contract(AGENTSLA_CONFIG.ESCROW_CONTRACT, ESCROW_ABI, this.signer);
96
+ const fee = ethers.parseUnits("5.0", 6);
97
+
98
+ const allowance = await usdc.allowance(userAddress, AGENTSLA_CONFIG.ESCROW_CONTRACT);
99
+ if (allowance < fee) {
100
+ const approveTx = await usdc.approve(AGENTSLA_CONFIG.ESCROW_CONTRACT, fee);
101
+ await approveTx.wait(1);
102
+ }
103
+ const tx = await escrow.paySubscription();
104
+ return await tx.wait(1);
171
105
  }
106
+ }
172
107
 
173
- /**
174
- * Call a tool directly on the hosted Streamable HTTP MCP server (https://agentsla.io/mcp).
175
- */
176
- async callMcpTool(name, args = {}) {
177
- const resolvedWallet = await this._resolveWallet(args.walletAddress);
178
- const finalArgs = resolvedWallet && !args.walletAddress ? { ...args, walletAddress: resolvedWallet } : args;
179
-
180
- const response = await fetch(this.mcpUrl, {
181
- method: "POST",
182
- headers: { "Content-Type": "application/json" },
183
- body: JSON.stringify({
184
- jsonrpc: "2.0",
185
- id: Date.now(),
186
- method: "tools/call",
187
- params: { name, arguments: finalArgs }
188
- })
189
- });
190
- return await response.json();
191
- }
192
- }
108
+ export default AgentSLA;
package/package.json CHANGED
@@ -1,27 +1,34 @@
1
1
  {
2
2
  "name": "agentsla",
3
- "version": "2.0.1",
4
- "description": "Official M2M SDK for the AgentSLA API Telemetry Directory, EIP-712 SLA Oracle, Streamable HTTP MCP Server, and Circle USDC Escrow Contract on Base Mainnet (8453).",
3
+ "version": "2.0.2",
4
+ "description": "Official M2M SDK & MCP Client for AgentSLA.io — Search 17,901+ SLA-monitored APIs & MCP connectors, verify EIP-712 latency proofs, and settle Base Mainnet Circle USDC escrow.",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "test": "node test.js"
9
9
  },
10
10
  "keywords": [
11
- "ai",
12
- "agents",
13
- "m2m",
14
11
  "mcp",
15
- "web3",
16
- "sla",
17
- "oracle",
12
+ "model-context-protocol",
13
+ "ai-agents",
14
+ "m2m",
15
+ "sla-oracle",
16
+ "base-mainnet",
18
17
  "usdc",
18
+ "x402",
19
19
  "eip-712",
20
- "base-mainnet"
20
+ "llmstxt",
21
+ "glama",
22
+ "smithery"
21
23
  ],
22
- "author": "AgentSLA (https://agentsla.io)",
24
+ "author": "AgentSLA.io <admin@agentsla.io> (https://agentsla.io)",
23
25
  "license": "MIT",
24
- "dependencies": {
25
- "ethers": "^6.7.0"
26
+ "homepage": "https://agentsla.io",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/agentsla/agentsla-sdk.git"
30
+ },
31
+ "peerDependencies": {
32
+ "ethers": "^6.0.0"
26
33
  }
27
34
  }
package/test.js DELETED
@@ -1,32 +0,0 @@
1
- import { AgentSLA } from "./index.js";
2
-
3
- async function main() {
4
- const unpaidClient = new AgentSLA();
5
-
6
- console.log("=== 1. Testing Free AgentSLA Directory Discovery ===");
7
- const dir = await unpaidClient.discover("ai-models");
8
- console.log(`Discovered ${dir.count} AI Model APIs (Escrow Contract: ${dir.escrowContract})`);
9
-
10
- console.log("\n=== 2. Testing Unpaid Call to /v1/verify (Verifying 402 Paywall) ===");
11
- try {
12
- await unpaidClient.verify("https://mainnet.base.org");
13
- } catch (err) {
14
- console.log(`Blocked with HTTP ${err.status}: ${err.message}`);
15
- }
16
-
17
- console.log("\n=== 3. Testing Authenticated Wallet Call to /v1/verify ===");
18
- const paidClient = new AgentSLA({
19
- walletAddress: "0x9A0d2dD2402991eC8095fE2Be0d96A59d9DCF13C"
20
- });
21
- const verification = await paidClient.verify("https://mainnet.base.org");
22
- console.log("Latency (ms) :", verification.latencyMs);
23
- console.log("SLA Met :", verification.slaMet);
24
- console.log("EIP-712 Signature:", verification.eip712Signature);
25
- console.log("Oracle Signer :", verification.oracleSigner);
26
-
27
- console.log("\n=== 4. Testing Hosted Streamable HTTP MCP Server (https://agentsla.io/mcp) ===");
28
- const mcpRes = await paidClient.callMcpTool("get_usdc_escrow_contract", {});
29
- console.log("MCP Tool Output :", mcpRes.result.content[0].text);
30
- }
31
-
32
- main().catch(console.error);