agentsla 2.0.0 → 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 +76 -132
  3. package/package.json +21 -14
  4. package/test.js +0 -36
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,164 +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 {
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;
32
+ }
33
+
29
34
  /**
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 {ethers.Signer|ethers.Provider} [config.signer] - Ethers v6 Signer or Provider
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 }
36
37
  */
37
- constructor(config = {}) {
38
- this.oracleUrl = config.oracleUrl || DEFAULT_ORACLE_URL;
39
- this.mcpUrl = config.mcpUrl || DEFAULT_MCP_URL;
40
- this.escrowAddress = config.escrowAddress || ESCROW_ADDRESS;
41
- this.usdcAddress = config.usdcAddress || USDC_ADDRESS;
42
- this.signer = config.signer || null;
43
-
44
- if (this.signer) {
45
- this.contract = new ethers.Contract(this.escrowAddress, ESCROW_ABI, this.signer);
46
- this.usdc = new ethers.Contract(this.usdcAddress, USDC_ABI, this.signer);
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));
47
47
  }
48
+ const qs = params.toString();
49
+ const res = await fetch(`${this.oracleUrl}/v1/directory${qs ? `?${qs}` : ""}`);
50
+ return await res.json();
48
51
  }
49
52
 
50
53
  /**
51
- * Probe an API endpoint via the AgentSLA Oracle, generate a signed EIP-712 SLA proof,
52
- * and optionally resolve an active on-chain Base Mainnet USDC escrow job.
53
- * @param {string} targetApiUrl - Target API endpoint to probe
54
- * @param {number} [jobId=0] - Active Base Mainnet escrow jobId (0 for probe-only)
55
- * @param {Object} [targetApiPayload] - Optional POST payload for the target API
54
+ * Call the remote Streamable HTTP MCP server at https://agentsla.io/mcp
56
55
  */
57
- async verify(targetApiUrl, jobId = 0, targetApiPayload = undefined) {
58
- if (!targetApiUrl) throw new Error("targetApiUrl is required.");
59
-
60
- const response = await fetch(`${this.oracleUrl}/v1/verify`, {
56
+ async callMcpTool(name, args = {}) {
57
+ const res = await fetch(this.mcpUrl, {
61
58
  method: "POST",
62
59
  headers: { "Content-Type": "application/json" },
63
- body: JSON.stringify({ jobId, targetApiUrl, targetApiPayload })
60
+ body: JSON.stringify({
61
+ jsonrpc: "2.0",
62
+ id: Date.now(),
63
+ method: "tools/call",
64
+ params: { name, arguments: args }
65
+ })
64
66
  });
65
-
66
- const data = await response.json();
67
- if (!response.ok) {
68
- throw new Error(data.error || "Failed to verify endpoint via AgentSLA Oracle.");
69
- }
70
- return data;
67
+ return await res.json();
71
68
  }
72
69
 
73
70
  /**
74
- * Approve Circle USDC (if needed) and lock USDC in Base Mainnet Escrow for an M2M API task.
75
- * @param {string} agentWallet - Provider agent wallet address
76
- * @param {number|bigint} apiId - Monitored API ID from the AgentSLA directory
77
- * @param {string|number} amountUsdc - Amount in USDC (e.g., "0.01" or "5.00")
71
+ * Probe an endpoint and generate a cryptographic EIP-712 SLA attestation.
78
72
  */
79
- async lockEscrowUsdc(agentWallet, apiId, amountUsdc) {
80
- if (!this.contract || !this.usdc || typeof this.signer.getAddress !== "function") {
81
- throw new Error("A connected ethers.js Signer is required to lock USDC in escrow.");
82
- }
83
-
84
- const amountUnits = ethers.parseUnits(amountUsdc.toString(), 6);
85
- const ownerAddress = await this.signer.getAddress();
86
- const currentAllowance = await this.usdc.allowance(ownerAddress, this.escrowAddress);
87
-
88
- if (currentAllowance < amountUnits) {
89
- const approveTx = await this.usdc.approve(this.escrowAddress, amountUnits);
90
- await approveTx.wait(1);
91
- }
92
-
93
- const createTx = await this.contract.createJob(agentWallet, BigInt(apiId), amountUnits);
94
- return await createTx.wait(1);
95
- }
96
-
97
- /**
98
- * Pay the 5 USDC 7-day autonomous oracle subscription on Base Mainnet.
99
- */
100
- async paySubscription() {
101
- if (!this.contract || !this.usdc || typeof this.signer.getAddress !== "function") {
102
- throw new Error("A connected ethers.js Signer is required to pay subscription.");
103
- }
104
-
105
- const feeUnits = ethers.parseUnits("5.0", 6);
106
- const ownerAddress = await this.signer.getAddress();
107
- const currentAllowance = await this.usdc.allowance(ownerAddress, this.escrowAddress);
108
-
109
- if (currentAllowance < feeUnits) {
110
- const approveTx = await this.usdc.approve(this.escrowAddress, feeUnits);
111
- await approveTx.wait(1);
112
- }
113
-
114
- const tx = await this.contract.paySubscription();
115
- return await tx.wait(1);
116
- }
117
-
118
- /**
119
- * Discover ranked APIs in the AgentSLA directory.
120
- * @param {string} [category="all"]
121
- */
122
- async discover(category = "all") {
123
- const query = category && category !== "all" ? `?category=${encodeURIComponent(category)}` : "";
124
- const response = await fetch(`${this.oracleUrl}/v1/directory${query}`);
125
- return await response.json();
126
- }
127
-
128
- /**
129
- * Register a new API endpoint in the AgentSLA directory.
130
- */
131
- async register({ service_name, endpoint_url, category = "general", sla_threshold = 99.9, capabilities = [] }) {
132
- 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`, {
133
76
  method: "POST",
134
77
  headers: { "Content-Type": "application/json" },
135
- 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
+ })
136
84
  });
137
- return await response.json();
85
+ return await res.json();
138
86
  }
139
87
 
140
88
  /**
141
- * Fetch recent EIP-712 signed oracle attestations.
89
+ * Pay the 5.00 Circle USDC 7-day M2M Oracle Subscription on Base Mainnet (8453).
142
90
  */
143
- async getAttestations() {
144
- const response = await fetch(`${this.oracleUrl}/api/attestations`);
145
- 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);
146
105
  }
106
+ }
147
107
 
148
- /**
149
- * Call a tool directly on the hosted Streamable HTTP MCP server (https://agentsla.io/mcp).
150
- */
151
- async callMcpTool(name, args = {}) {
152
- const response = await fetch(this.mcpUrl, {
153
- method: "POST",
154
- headers: { "Content-Type": "application/json" },
155
- body: JSON.stringify({
156
- jsonrpc: "2.0",
157
- id: Date.now(),
158
- method: "tools/call",
159
- params: { name, arguments: args }
160
- })
161
- });
162
- return await response.json();
163
- }
164
- }
108
+ export default AgentSLA;
package/package.json CHANGED
@@ -1,27 +1,34 @@
1
- {
1
+ {
2
2
  "name": "agentsla",
3
- "version": "2.0.0",
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,36 +0,0 @@
1
- import { ethers } from "ethers";
2
- import { AgentSLA, ESCROW_ADDRESS, USDC_ADDRESS } from "./index.js";
3
-
4
- async function main() {
5
- const provider = new ethers.JsonRpcProvider("https://mainnet.base.org");
6
- const client = new AgentSLA({ signer: provider });
7
-
8
- console.log("=== 1. Testing AgentSLA Directory Discovery ===");
9
- const dir = await client.discover("ai-models");
10
- console.log(`Discovered ${dir.count} AI Model APIs (Escrow Contract: ${dir.escrowContract})`);
11
-
12
- console.log("\n=== 2. Testing Live EIP-712 SLA Verification Probe ===");
13
- const verification = await client.verify("https://mainnet.base.org");
14
- console.log("Target Endpoint :", verification.targetApiUrl);
15
- console.log("Latency (ms) :", verification.latencyMs);
16
- console.log("SLA Met :", verification.slaMet);
17
- console.log("Oracle Signer :", verification.oracleSigner);
18
- console.log("EIP-712 Proof :", verification.eip712Signature.slice(0, 42) + "...");
19
-
20
- console.log("\n=== 3. Testing Hosted Streamable HTTP MCP Server (https://agentsla.io/mcp) ===");
21
- const mcpRes = await client.callMcpTool("get_usdc_escrow_contract");
22
- console.log("MCP Response :", mcpRes.result.content[0].text.replace(/\s+/g, " "));
23
-
24
- console.log("\n=== 4. Verifying Base Mainnet On-Chain Escrow State ===");
25
- const [nextJobId, fees] = await Promise.all([
26
- client.contract.nextJobId(),
27
- client.contract.accumulatedFees()
28
- ]);
29
- console.log("Base Mainnet Contract :", ESCROW_ADDRESS);
30
- console.log("Circle USDC Token :", USDC_ADDRESS);
31
- console.log("Settled Escrow Jobs :", (nextJobId - 1n).toString());
32
- console.log("Accumulated Fees :", ethers.formatUnits(fees, 6), "USDC");
33
- console.log("\nALL AGENTSLA v2.0.0 SDK CHECKS PASSED!");
34
- }
35
-
36
- main().catch(console.error);