agentsla 2.0.2 → 2.0.3
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 +51 -27
- package/index.js +40 -15
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -1,51 +1,75 @@
|
|
|
1
|
-
# AgentSLA (`agentsla` v2.0.
|
|
1
|
+
# AgentSLA (`agentsla` v2.0.3)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SDK and MCP client for **AgentSLA**: search indexed APIs and MCP servers, check any endpoint for free, get
|
|
4
|
+
EIP-712 signed SLA checks, and use refundable USDC escrow on **Base Mainnet (chain 8453)**.
|
|
4
5
|
|
|
5
|
-
- **
|
|
6
|
-
- **
|
|
7
|
-
- **MCP
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
6
|
+
- **Site:** [https://agentsla.io](https://agentsla.io)
|
|
7
|
+
- **MCP server (streamable HTTP):** `https://agentsla.io/mcp`
|
|
8
|
+
- **MCP config:** [https://agentsla.io/.well-known/mcp.json](https://agentsla.io/.well-known/mcp.json)
|
|
9
|
+
- **OpenAPI:** [https://agentsla.io/openapi.json](https://agentsla.io/openapi.json)
|
|
10
|
+
- **llms.txt:** [https://agentsla.io/llms.txt](https://agentsla.io/llms.txt)
|
|
11
|
+
- **Escrow contract (Base):** `0x5c8D11AB570D7384d01226bC80123D0dD103Fb57`
|
|
12
|
+
- **USDC (Base):** `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
> **Upgrade from 2.0.2 or earlier.** Those versions pointed at a retired escrow contract
|
|
15
|
+
> (`0x6ca6cDDd…99Ba79CD`) and sent `jobId: 1` with every `verifyEndpoint` call. 2.0.3 uses the current contract
|
|
16
|
+
> and only sends `jobId` when you pass one.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
13
19
|
|
|
14
20
|
```bash
|
|
15
21
|
npm install agentsla ethers
|
|
16
22
|
```
|
|
17
23
|
|
|
18
|
-
##
|
|
24
|
+
## Search the directory
|
|
19
25
|
|
|
20
26
|
```javascript
|
|
21
27
|
import { AgentSLA } from "agentsla";
|
|
22
28
|
|
|
23
29
|
const sla = new AgentSLA();
|
|
30
|
+
const result = await sla.discoverApis({ category: "mcp-connectors", search: "weather", limit: 10 });
|
|
31
|
+
console.log(result.matchedCount, result.agents); // listings are in `agents`
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Listings are indexed and periodically probed, not audited or endorsed.
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
const result = await sla.discoverApis({
|
|
27
|
-
category: "mcp-connectors",
|
|
28
|
-
search: "solana",
|
|
29
|
-
limit: 10
|
|
30
|
-
});
|
|
36
|
+
## Check an endpoint (free)
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
```javascript
|
|
39
|
+
const check = await sla.checkEndpoint({ endpointUrl: "https://api.example.com/health", maxLatencyMs: 1000 });
|
|
40
|
+
console.log(check.httpStatus, check.edgeLatencyMs, check.meetsSla);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Signed check (EIP-712)
|
|
44
|
+
|
|
45
|
+
A signed check needs one of: a 7-day pass (5 USDC), an active escrow job, or an x402 payment of 0.05 USDC per
|
|
46
|
+
check on `POST https://agentsla.io/v1/verify`.
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
const sla = new AgentSLA({ privateKey: process.env.AGENT_PRIVATE_KEY }); // the agent's own wallet
|
|
50
|
+
if (!(await sla.isSubscribed())) await sla.subscribeSevenDays(); // approves and pays 5 USDC on Base
|
|
51
|
+
const signed = await sla.verifyEndpoint({ endpointUrl: "https://api.example.com/health" });
|
|
52
|
+
console.log(signed.slaMet, signed.eip712Signature, signed.oracleSigner);
|
|
33
53
|
```
|
|
34
54
|
|
|
35
|
-
|
|
55
|
+
Without a pass the response has `paymentRequired: true` and the payment options. Verify a signature with
|
|
56
|
+
`ethers.verifyTypedData` using the domain and types from `GET https://agentsla.io/v1/attestations?url=...`.
|
|
57
|
+
|
|
58
|
+
## MCP tools
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
const res = await sla.callMcpTool("check_endpoint", { endpointUrl: "https://api.example.com" });
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Tools: `discover_monitored_apis` (free), `check_endpoint` (free), `verify_endpoint_sla` (pass required),
|
|
65
|
+
`get_usdc_escrow_contract` (free).
|
|
66
|
+
|
|
67
|
+
## Connect Claude Desktop, Cursor or Windsurf
|
|
36
68
|
|
|
37
69
|
```json
|
|
38
70
|
{
|
|
39
71
|
"mcpServers": {
|
|
40
|
-
"agentsla
|
|
41
|
-
"url": "https://agentsla.io/mcp"
|
|
42
|
-
}
|
|
72
|
+
"agentsla": { "url": "https://agentsla.io/mcp" }
|
|
43
73
|
}
|
|
44
74
|
}
|
|
45
75
|
```
|
|
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,11 +1,13 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
|
|
3
3
|
export const AGENTSLA_CONFIG = {
|
|
4
|
+
API_URL: "https://agentsla.io",
|
|
4
5
|
ORACLE_URL: "https://agentsla-oracle.agentsla-dev.workers.dev",
|
|
5
6
|
MCP_URL: "https://agentsla.io/mcp",
|
|
6
7
|
CHAIN_ID: 8453,
|
|
7
8
|
RPC_URL: "https://mainnet.base.org",
|
|
8
|
-
|
|
9
|
+
// Current escrow contract (the one the oracle settles). 2.0.2 and earlier pointed at the retired 0x6ca6cDDd... contract.
|
|
10
|
+
ESCROW_CONTRACT: "0x5c8D11AB570D7384d01226bC80123D0dD103Fb57",
|
|
9
11
|
USDC_TOKEN: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
10
12
|
TREASURY_WALLET: "0x9A0d2dD2402991eC8095fE2Be0d96A59d9DCF13C"
|
|
11
13
|
};
|
|
@@ -24,6 +26,7 @@ const USDC_ABI = [
|
|
|
24
26
|
|
|
25
27
|
export class AgentSLA {
|
|
26
28
|
constructor(options = {}) {
|
|
29
|
+
this.apiUrl = (options.apiUrl || AGENTSLA_CONFIG.API_URL).replace(/\/+$/, "");
|
|
27
30
|
this.oracleUrl = options.oracleUrl || AGENTSLA_CONFIG.ORACLE_URL;
|
|
28
31
|
this.mcpUrl = options.mcpUrl || AGENTSLA_CONFIG.MCP_URL;
|
|
29
32
|
this.rpcUrl = options.rpcUrl || AGENTSLA_CONFIG.RPC_URL;
|
|
@@ -32,7 +35,7 @@ export class AgentSLA {
|
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
|
-
* Search
|
|
38
|
+
* Search the AgentSLA directory of indexed APIs and MCP servers (indexed and probed, not audited).
|
|
36
39
|
* @param {string|object} filter - Category string OR { category, search, limit, offset }
|
|
37
40
|
*/
|
|
38
41
|
async discoverApis(filter = {}) {
|
|
@@ -56,7 +59,7 @@ export class AgentSLA {
|
|
|
56
59
|
async callMcpTool(name, args = {}) {
|
|
57
60
|
const res = await fetch(this.mcpUrl, {
|
|
58
61
|
method: "POST",
|
|
59
|
-
headers: { "Content-Type": "application/json" },
|
|
62
|
+
headers: { "Content-Type": "application/json", Accept: "application/json, text/event-stream" },
|
|
60
63
|
body: JSON.stringify({
|
|
61
64
|
jsonrpc: "2.0",
|
|
62
65
|
id: Date.now(),
|
|
@@ -68,21 +71,43 @@ export class AgentSLA {
|
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
/**
|
|
71
|
-
*
|
|
74
|
+
* Free, unsigned single check of any endpoint: HTTP status, latency and the SLA rule (2xx/3xx within maxLatencyMs).
|
|
75
|
+
*/
|
|
76
|
+
async checkEndpoint({ endpointUrl, maxLatencyMs = 1000 }) {
|
|
77
|
+
const qs = new URLSearchParams({ url: endpointUrl, max_latency_ms: String(maxLatencyMs) });
|
|
78
|
+
const res = await fetch(`${this.apiUrl}/v1/verify?${qs}`);
|
|
79
|
+
return await res.json();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Signed check: probes the endpoint and returns an EIP-712 SLA attestation from the oracle.
|
|
84
|
+
* Needs an active 7-day pass on the signer's wallet (subscribeSevenDays), unless jobId names an active escrow job
|
|
85
|
+
* (that probes the job's registered endpoint and settles the job). Without either, the response is HTTP 402 and
|
|
86
|
+
* explains how to pay (pass, escrow job, or x402 at 0.05 USDC per check).
|
|
87
|
+
* 2.0.2 and earlier sent jobId 1 by default, which tried to settle escrow job #1 instead of checking endpointUrl.
|
|
72
88
|
*/
|
|
73
|
-
async verifyEndpoint({ endpointUrl, jobId
|
|
74
|
-
const
|
|
75
|
-
const
|
|
89
|
+
async verifyEndpoint({ endpointUrl, jobId, payload, maxLatencyMs, walletAddress } = {}) {
|
|
90
|
+
const wallet = walletAddress || (this.signer ? await this.signer.getAddress() : undefined);
|
|
91
|
+
const body = { targetApiUrl: endpointUrl, walletAddress: wallet };
|
|
92
|
+
if (jobId) body.jobId = jobId;
|
|
93
|
+
if (payload && Object.keys(payload).length) body.targetApiPayload = payload;
|
|
94
|
+
if (maxLatencyMs) body.maxLatencyMs = maxLatencyMs;
|
|
95
|
+
const res = await fetch(`${this.apiUrl}/v1/verify`, {
|
|
76
96
|
method: "POST",
|
|
77
97
|
headers: { "Content-Type": "application/json" },
|
|
78
|
-
body: JSON.stringify(
|
|
79
|
-
jobId,
|
|
80
|
-
targetApiUrl: endpointUrl,
|
|
81
|
-
targetApiPayload: payload,
|
|
82
|
-
walletAddress
|
|
83
|
-
})
|
|
98
|
+
body: JSON.stringify(body)
|
|
84
99
|
});
|
|
85
|
-
|
|
100
|
+
const data = await res.json();
|
|
101
|
+
if (res.status === 402 && data && typeof data === "object") data.paymentRequired = true;
|
|
102
|
+
return data;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** True if the wallet (default: the signer) holds an active 7-day pass on the current escrow contract. */
|
|
106
|
+
async isSubscribed(address) {
|
|
107
|
+
const who = address || (this.signer ? await this.signer.getAddress() : null);
|
|
108
|
+
if (!who) throw new Error("Pass an address or construct AgentSLA with a privateKey.");
|
|
109
|
+
const escrow = new ethers.Contract(AGENTSLA_CONFIG.ESCROW_CONTRACT, ["function isSubscribed(address) view returns (bool)"], this.provider);
|
|
110
|
+
return await escrow.isSubscribed(who);
|
|
86
111
|
}
|
|
87
112
|
|
|
88
113
|
/**
|
|
@@ -105,4 +130,4 @@ export class AgentSLA {
|
|
|
105
130
|
}
|
|
106
131
|
}
|
|
107
132
|
|
|
108
|
-
export default AgentSLA;
|
|
133
|
+
export default AgentSLA;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentsla",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"description": "SDK and MCP client for AgentSLA: search indexed APIs and MCP servers, check endpoints, signed EIP-712 SLA checks, and refundable USDC escrow on Base.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -18,10 +18,9 @@
|
|
|
18
18
|
"x402",
|
|
19
19
|
"eip-712",
|
|
20
20
|
"llmstxt",
|
|
21
|
-
"glama"
|
|
22
|
-
"smithery"
|
|
21
|
+
"glama"
|
|
23
22
|
],
|
|
24
|
-
"author": "AgentSLA
|
|
23
|
+
"author": "AgentSLA (https://agentsla.io)",
|
|
25
24
|
"license": "MIT",
|
|
26
25
|
"homepage": "https://agentsla.io",
|
|
27
26
|
"repository": {
|
|
@@ -30,5 +29,9 @@
|
|
|
30
29
|
},
|
|
31
30
|
"peerDependencies": {
|
|
32
31
|
"ethers": "^6.0.0"
|
|
33
|
-
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"index.js",
|
|
35
|
+
"README.md"
|
|
36
|
+
]
|
|
34
37
|
}
|