@agether/sdk 2.6.0 → 2.7.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 +39 -27
- package/dist/cli.js +49 -33
- package/dist/index.d.mts +43 -19
- package/dist/index.d.ts +43 -19
- package/dist/index.js +60 -29
- package/dist/index.mjs +57 -29
- package/package.json +2 -2
- package/dist/cli.d.ts +0 -27
- package/dist/cli.d.ts.map +0 -1
- package/dist/clients/AgentIdentityClient.d.ts +0 -188
- package/dist/clients/AgentIdentityClient.d.ts.map +0 -1
- package/dist/clients/AgentIdentityClient.js +0 -337
- package/dist/clients/AgetherClient.d.ts +0 -74
- package/dist/clients/AgetherClient.d.ts.map +0 -1
- package/dist/clients/AgetherClient.js +0 -172
- package/dist/clients/MorphoClient.d.ts +0 -482
- package/dist/clients/MorphoClient.d.ts.map +0 -1
- package/dist/clients/MorphoClient.js +0 -1717
- package/dist/clients/ScoringClient.d.ts +0 -89
- package/dist/clients/ScoringClient.d.ts.map +0 -1
- package/dist/clients/ScoringClient.js +0 -93
- package/dist/clients/X402Client.d.ts +0 -168
- package/dist/clients/X402Client.d.ts.map +0 -1
- package/dist/clients/X402Client.js +0 -378
- package/dist/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -132
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -46
- package/dist/utils/abis.d.ts +0 -29
- package/dist/utils/abis.d.ts.map +0 -1
- package/dist/utils/abis.js +0 -139
- package/dist/utils/config.d.ts +0 -36
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -168
- package/dist/utils/format.d.ts +0 -44
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js +0 -75
package/README.md
CHANGED
|
@@ -242,42 +242,45 @@ Client for liquidity providers.
|
|
|
242
242
|
|
|
243
243
|
### ScoringClient
|
|
244
244
|
|
|
245
|
-
Client for the off-chain scoring service.
|
|
245
|
+
Client for the off-chain scoring service. Supports multi-chain via optional `chainId` parameter.
|
|
246
246
|
|
|
247
247
|
#### Methods
|
|
248
248
|
|
|
249
249
|
| Method | Returns | Description |
|
|
250
250
|
|--------|---------|-------------|
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
253
|
-
| `
|
|
251
|
+
| `requestScore(agentId, chainId?)` | `Promise<ScoreResult>` | x402-gated: compute & submit score onchain |
|
|
252
|
+
| `getCurrentScore(agentId, chainId?)` | `Promise<{score, timestamp, ...}>` | Free: read current onchain score |
|
|
253
|
+
| `getAgentDetails(agentId, chainId?)` | `Promise<{agentId, owner, ...}>` | Agent details from backend |
|
|
254
|
+
| `getAgentCount(chainId?)` | `Promise<{totalAgents, totalAccounts}>` | Agent count |
|
|
255
|
+
| `getHealth()` | `Promise<{status, timestamp}>` | Service health check |
|
|
256
|
+
| `getStatus()` | `Promise<{status, chain, ...}>` | Detailed service status |
|
|
254
257
|
|
|
255
258
|
#### Usage
|
|
256
259
|
|
|
257
260
|
```typescript
|
|
258
|
-
import { ScoringClient } from '@agether/sdk';
|
|
261
|
+
import { ScoringClient, ChainId } from '@agether/sdk';
|
|
259
262
|
|
|
260
|
-
const scoring = new ScoringClient(
|
|
263
|
+
const scoring = new ScoringClient({
|
|
264
|
+
endpoint: 'https://api.agether.ai',
|
|
265
|
+
chainId: ChainId.Ethereum, // default chain for all calls
|
|
266
|
+
// x402: { ... } // optional: for paid scoring
|
|
267
|
+
});
|
|
261
268
|
|
|
262
|
-
//
|
|
263
|
-
const
|
|
269
|
+
// Get current score (free) — uses default chain
|
|
270
|
+
const score = await scoring.getCurrentScore(BigInt(123));
|
|
271
|
+
console.log('Score:', score.score);
|
|
264
272
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
console.log('Would approve:', risk.wouldApprove);
|
|
273
|
+
// Get score on a specific chain (overrides default)
|
|
274
|
+
const baseScore = await scoring.getCurrentScore(BigInt(123), ChainId.Base);
|
|
268
275
|
|
|
269
|
-
// Get
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
requestedLimit: parseUnits('1000', 6),
|
|
273
|
-
context: {
|
|
274
|
-
purpose: 'API payments',
|
|
275
|
-
},
|
|
276
|
-
});
|
|
276
|
+
// Get agent details
|
|
277
|
+
const details = await scoring.getAgentDetails(BigInt(123));
|
|
278
|
+
console.log('Eligible:', details.eligible);
|
|
277
279
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
280
|
+
// Agent count per chain
|
|
281
|
+
const ethCount = await scoring.getAgentCount(ChainId.Ethereum);
|
|
282
|
+
const baseCount = await scoring.getAgentCount(ChainId.Base);
|
|
283
|
+
console.log(`Ethereum: ${ethCount.totalAgents}, Base: ${baseCount.totalAgents}`);
|
|
281
284
|
}
|
|
282
285
|
```
|
|
283
286
|
|
|
@@ -479,12 +482,21 @@ agether balance
|
|
|
479
482
|
### Example Flow
|
|
480
483
|
|
|
481
484
|
```bash
|
|
482
|
-
# 1. Initialize
|
|
485
|
+
# 1. Initialize (Ethereum mainnet by default)
|
|
483
486
|
$ agether init 0x5de4...
|
|
484
487
|
✅ Initialized Agether CLI
|
|
485
488
|
Address: 0x3C44C...
|
|
486
|
-
|
|
487
|
-
|
|
489
|
+
Chain: Ethereum (1)
|
|
490
|
+
RPC: https://ethereum-rpc.publicnode.com
|
|
491
|
+
Backend: https://api.agether.ai
|
|
492
|
+
|
|
493
|
+
# 1b. Initialize on Base
|
|
494
|
+
$ agether init 0x5de4... --chain 8453
|
|
495
|
+
✅ Initialized Agether CLI
|
|
496
|
+
Address: 0x3C44C...
|
|
497
|
+
Chain: Base (8453)
|
|
498
|
+
RPC: https://base-rpc.publicnode.com
|
|
499
|
+
Backend: https://api.agether.ai
|
|
488
500
|
|
|
489
501
|
# 2. Register agent
|
|
490
502
|
$ agether register --name "OpenClaw" --code-url "https://github.com/user/openclaw"
|
|
@@ -553,8 +565,8 @@ $ agether draw --amount 1000
|
|
|
553
565
|
### Environment Variables
|
|
554
566
|
|
|
555
567
|
```bash
|
|
556
|
-
export AGETHER_RPC_URL=
|
|
557
|
-
export AGETHER_BACKEND_URL=
|
|
568
|
+
export AGETHER_RPC_URL=https://ethereum-rpc.publicnode.com # or https://base-rpc.publicnode.com
|
|
569
|
+
export AGETHER_BACKEND_URL=https://api.agether.ai
|
|
558
570
|
```
|
|
559
571
|
|
|
560
572
|
---
|
package/dist/cli.js
CHANGED
|
@@ -176,13 +176,13 @@ var init_config = __esm({
|
|
|
176
176
|
safeProxyFactory: SAFE_PROXY_FACTORY,
|
|
177
177
|
safe7579: SAFE7579,
|
|
178
178
|
entryPoint: ENTRYPOINT_V07,
|
|
179
|
-
agether4337Factory:
|
|
180
|
-
agether7579Bootstrap:
|
|
181
|
-
erc8004ValidationModule:
|
|
182
|
-
agetherHookMultiplexer:
|
|
179
|
+
agether4337Factory: "0x94875D0E6c588a73b47b688164AC04AdcC32aA33",
|
|
180
|
+
agether7579Bootstrap: "0xfa1Fe090C6a959455a221d577c2A497307854e34",
|
|
181
|
+
erc8004ValidationModule: "0xD06561888328587e15475681b5936E25694B330B",
|
|
182
|
+
agetherHookMultiplexer: "0x951A010568304a8c54173a63E5Ea74098Ddd8bDB",
|
|
183
183
|
validationRegistry: ZERO,
|
|
184
|
-
agether8004Scorer:
|
|
185
|
-
timelockController:
|
|
184
|
+
agether8004Scorer: "0x09AA6Bb7D4f2b027a3Adb52c2222a0cfDf891201",
|
|
185
|
+
timelockController: "0x8F77bdA1c2E62Cd0F8EE2388C7bc8Fd8Bf6aed6D",
|
|
186
186
|
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
187
187
|
identityRegistry: ERC8004_IDENTITY_REGISTRY,
|
|
188
188
|
morphoBlue: MORPHO_BLUE
|
|
@@ -260,9 +260,9 @@ var init_config = __esm({
|
|
|
260
260
|
[31337 /* Hardhat */]: "http://127.0.0.1:8545"
|
|
261
261
|
};
|
|
262
262
|
SCORING_ENDPOINTS = {
|
|
263
|
-
[1 /* Ethereum */]: "https://
|
|
264
|
-
[8453 /* Base */]: "
|
|
265
|
-
[84532 /* BaseSepolia */]: "
|
|
263
|
+
[1 /* Ethereum */]: "https://api.agether.ai",
|
|
264
|
+
[8453 /* Base */]: "https://api.agether.ai",
|
|
265
|
+
[84532 /* BaseSepolia */]: "https://api.agether.ai",
|
|
266
266
|
[11155111 /* Sepolia */]: "https://scoring-testnet.agether.ai/v1",
|
|
267
267
|
[31337 /* Hardhat */]: "http://127.0.0.1:3001"
|
|
268
268
|
};
|
|
@@ -294,7 +294,7 @@ var init_MorphoClient = __esm({
|
|
|
294
294
|
/** Dynamic token registry: symbol (uppercase) → { address, symbol, decimals } */
|
|
295
295
|
this._tokenCache = /* @__PURE__ */ new Map();
|
|
296
296
|
this._discoveredAt = 0;
|
|
297
|
-
const chainId = config.chainId ??
|
|
297
|
+
const chainId = config.chainId ?? 1 /* Ethereum */;
|
|
298
298
|
const defaultCfg = getDefaultConfig(chainId);
|
|
299
299
|
this.config = defaultCfg;
|
|
300
300
|
this.agentId = config.agentId;
|
|
@@ -2102,9 +2102,7 @@ var init_X402Client = __esm({
|
|
|
2102
2102
|
const paymentAmount = await this._probePaymentAmount(url, fetchOpts);
|
|
2103
2103
|
if (paymentAmount !== null) {
|
|
2104
2104
|
console.log(` [auto-fund] Payment required: ${(Number(paymentAmount) / 1e6).toFixed(6)} USDC`);
|
|
2105
|
-
const
|
|
2106
|
-
const buffer = BigInt(Math.round(parseFloat(bufferStr) * 1e6));
|
|
2107
|
-
const needed = paymentAmount + buffer;
|
|
2105
|
+
const needed = paymentAmount;
|
|
2108
2106
|
if (usdcBalance < needed) {
|
|
2109
2107
|
const totalDeficit = needed - usdcBalance;
|
|
2110
2108
|
console.log(` [auto-fund] Insufficient balance. Deficit: ${(Number(totalDeficit) / 1e6).toFixed(2)} USDC`);
|
|
@@ -2207,12 +2205,14 @@ var init_X402Client = __esm({
|
|
|
2207
2205
|
const data = await response.json();
|
|
2208
2206
|
const paymentResponse = response.headers.get("PAYMENT-RESPONSE");
|
|
2209
2207
|
let txHash;
|
|
2208
|
+
let settlementNetwork;
|
|
2210
2209
|
if (paymentResponse) {
|
|
2211
2210
|
try {
|
|
2212
2211
|
const settlement = JSON.parse(
|
|
2213
2212
|
Buffer.from(paymentResponse, "base64").toString("utf-8")
|
|
2214
2213
|
);
|
|
2215
2214
|
txHash = settlement.transaction;
|
|
2215
|
+
settlementNetwork = settlement.network;
|
|
2216
2216
|
} catch (e) {
|
|
2217
2217
|
console.warn("[agether] x402 payment response parse failed:", e instanceof Error ? e.message : e);
|
|
2218
2218
|
}
|
|
@@ -2224,7 +2224,7 @@ var init_X402Client = __esm({
|
|
|
2224
2224
|
paymentInfo: {
|
|
2225
2225
|
amount: "",
|
|
2226
2226
|
asset: "USDC",
|
|
2227
|
-
network: "eip155
|
|
2227
|
+
network: settlementNetwork || "eip155",
|
|
2228
2228
|
txHash
|
|
2229
2229
|
}
|
|
2230
2230
|
} : {}
|
|
@@ -2330,8 +2330,8 @@ var fs = __toESM(require("fs"));
|
|
|
2330
2330
|
var path = __toESM(require("path"));
|
|
2331
2331
|
var os = __toESM(require("os"));
|
|
2332
2332
|
var CONFIG_PATH = path.join(os.homedir(), ".agether", "config.json");
|
|
2333
|
-
var DEFAULT_RPC = "https://
|
|
2334
|
-
var
|
|
2333
|
+
var DEFAULT_RPC = "https://ethereum-rpc.publicnode.com";
|
|
2334
|
+
var BACKEND_URL = "https://api.agether.ai";
|
|
2335
2335
|
function loadConfig() {
|
|
2336
2336
|
try {
|
|
2337
2337
|
if (fs.existsSync(CONFIG_PATH)) {
|
|
@@ -2372,7 +2372,8 @@ async function getMorphoClient(config) {
|
|
|
2372
2372
|
return new MorphoClient2({
|
|
2373
2373
|
privateKey: config.privateKey,
|
|
2374
2374
|
rpcUrl: config.rpcUrl,
|
|
2375
|
-
agentId: config.agentId !== "0" ? config.agentId : void 0
|
|
2375
|
+
agentId: config.agentId !== "0" ? config.agentId : void 0,
|
|
2376
|
+
chainId: config.chainId
|
|
2376
2377
|
});
|
|
2377
2378
|
}
|
|
2378
2379
|
async function getX402Client(config) {
|
|
@@ -2386,7 +2387,6 @@ async function getX402Client(config) {
|
|
|
2386
2387
|
return new X402Client2({
|
|
2387
2388
|
privateKey: config.privateKey,
|
|
2388
2389
|
rpcUrl: config.rpcUrl,
|
|
2389
|
-
backendUrl: config.backendUrl,
|
|
2390
2390
|
agentId: config.agentId,
|
|
2391
2391
|
accountAddress
|
|
2392
2392
|
});
|
|
@@ -2410,8 +2410,8 @@ var VALIDATION_REGISTRY_ABI = [
|
|
|
2410
2410
|
var MOCK_ERC20_ABI = [
|
|
2411
2411
|
"function mint(address to, uint256 amount) external"
|
|
2412
2412
|
];
|
|
2413
|
-
async function apiGet(
|
|
2414
|
-
const res = await fetch(`${
|
|
2413
|
+
async function apiGet(endpoint) {
|
|
2414
|
+
const res = await fetch(`${BACKEND_URL}${endpoint}`);
|
|
2415
2415
|
return res.json();
|
|
2416
2416
|
}
|
|
2417
2417
|
function decodeError(error) {
|
|
@@ -2426,9 +2426,16 @@ function decodeError(error) {
|
|
|
2426
2426
|
if (msg.length > 200) return msg.slice(0, 200) + "...";
|
|
2427
2427
|
return msg;
|
|
2428
2428
|
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2429
|
+
var CHAIN_RPC = {
|
|
2430
|
+
1: "https://ethereum-rpc.publicnode.com",
|
|
2431
|
+
8453: "https://base-rpc.publicnode.com",
|
|
2432
|
+
84532: "https://sepolia.base.org",
|
|
2433
|
+
11155111: "https://rpc.sepolia.org",
|
|
2434
|
+
31337: "http://127.0.0.1:8545"
|
|
2435
|
+
};
|
|
2436
|
+
async function cmdInit(privateKey, agentId, chain) {
|
|
2437
|
+
const chainId = chain ? Number(chain) : 1;
|
|
2438
|
+
const rpcUrl = process.env.AGETHER_RPC_URL || CHAIN_RPC[chainId] || DEFAULT_RPC;
|
|
2432
2439
|
let wallet;
|
|
2433
2440
|
try {
|
|
2434
2441
|
wallet = new import_ethers2.ethers.Wallet(privateKey);
|
|
@@ -2436,12 +2443,14 @@ async function cmdInit(privateKey, agentId) {
|
|
|
2436
2443
|
console.error("\u274C Invalid private key");
|
|
2437
2444
|
process.exit(1);
|
|
2438
2445
|
}
|
|
2439
|
-
const config = { privateKey, agentId: agentId || "0", rpcUrl,
|
|
2446
|
+
const config = { privateKey, agentId: agentId || "0", rpcUrl, chainId };
|
|
2440
2447
|
saveConfig(config);
|
|
2448
|
+
const chainName = chainId === 1 ? "Ethereum" : chainId === 8453 ? "Base" : `Chain ${chainId}`;
|
|
2441
2449
|
console.log("\u2705 Initialized Agether CLI");
|
|
2442
2450
|
console.log(` Address: ${wallet.address}`);
|
|
2451
|
+
console.log(` Chain: ${chainName} (${chainId})`);
|
|
2443
2452
|
console.log(` RPC: ${rpcUrl}`);
|
|
2444
|
-
console.log(` Backend: ${
|
|
2453
|
+
console.log(` Backend: ${BACKEND_URL}`);
|
|
2445
2454
|
console.log(` Config: ${CONFIG_PATH}`);
|
|
2446
2455
|
}
|
|
2447
2456
|
async function cmdRegister(name) {
|
|
@@ -2455,7 +2464,7 @@ async function cmdRegister(name) {
|
|
|
2455
2464
|
console.log("\n [1/4] Fetching contract addresses...");
|
|
2456
2465
|
let contracts;
|
|
2457
2466
|
try {
|
|
2458
|
-
const statusResp = await apiGet(
|
|
2467
|
+
const statusResp = await apiGet("/status");
|
|
2459
2468
|
contracts = statusResp.contracts || {};
|
|
2460
2469
|
console.log(" \u2713 Backend OK");
|
|
2461
2470
|
} catch (e) {
|
|
@@ -2642,7 +2651,7 @@ async function cmdScore() {
|
|
|
2642
2651
|
\u{1F4C8} Agent #${config.agentId} Score
|
|
2643
2652
|
`);
|
|
2644
2653
|
try {
|
|
2645
|
-
const data = await apiGet(
|
|
2654
|
+
const data = await apiGet(`/score/${config.agentId}/current`);
|
|
2646
2655
|
if (data.score !== void 0) {
|
|
2647
2656
|
console.log(` Onchain Score: ${data.score}`);
|
|
2648
2657
|
console.log(` Timestamp: ${data.timestamp ? new Date(Number(data.timestamp) * 1e3).toISOString() : "N/A"}`);
|
|
@@ -2655,7 +2664,7 @@ async function cmdScore() {
|
|
|
2655
2664
|
console.log(" Could not fetch current score.");
|
|
2656
2665
|
}
|
|
2657
2666
|
console.log("\n To compute a fresh score (x402-gated, costs USDC):");
|
|
2658
|
-
console.log(` agether x402 ${
|
|
2667
|
+
console.log(` agether x402 ${BACKEND_URL}/score/${config.agentId}`);
|
|
2659
2668
|
}
|
|
2660
2669
|
async function cmdMarkets() {
|
|
2661
2670
|
const config = requireConfig();
|
|
@@ -2821,11 +2830,14 @@ function cmdHelp() {
|
|
|
2821
2830
|
console.log(`
|
|
2822
2831
|
\u{1F3E6} Agether CLI \u2014 Direct Morpho Blue Credit for AI Agents (Safe + Safe7579)
|
|
2823
2832
|
|
|
2833
|
+
Supported chains: Ethereum (1, default), Base (8453)
|
|
2834
|
+
|
|
2824
2835
|
USAGE:
|
|
2825
2836
|
agether <command> [options]
|
|
2826
2837
|
|
|
2827
2838
|
SETUP:
|
|
2828
|
-
init <private-key> [--agent-id <id>]
|
|
2839
|
+
init <private-key> [--agent-id <id>] [--chain <chainId>]
|
|
2840
|
+
Initialize (default: Ethereum mainnet)
|
|
2829
2841
|
register [--name <n>] Register ERC-8004 + create Safe account
|
|
2830
2842
|
|
|
2831
2843
|
INFO:
|
|
@@ -2849,16 +2861,20 @@ x402 PAYMENTS:
|
|
|
2849
2861
|
|
|
2850
2862
|
ENVIRONMENT:
|
|
2851
2863
|
AGETHER_RPC_URL RPC endpoint (default: ${DEFAULT_RPC})
|
|
2852
|
-
AGETHER_BACKEND_URL Backend URL (default: ${DEFAULT_BACKEND})
|
|
2853
2864
|
|
|
2854
|
-
EXAMPLE FLOW:
|
|
2855
|
-
agether init 0xYOUR_PRIVATE_KEY
|
|
2865
|
+
EXAMPLE FLOW (Ethereum):
|
|
2866
|
+
agether init 0xYOUR_PRIVATE_KEY # Defaults to Ethereum
|
|
2856
2867
|
agether register --name "MyAgent"
|
|
2857
2868
|
agether deposit --amount 0.05 --token WETH # ~$125 collateral
|
|
2858
2869
|
agether borrow --amount 50 # Borrow $50 USDC
|
|
2859
2870
|
agether status # Check positions
|
|
2860
2871
|
agether repay --amount 50 # Repay when done
|
|
2861
2872
|
agether withdraw --amount all --token WETH # Withdraw collateral
|
|
2873
|
+
|
|
2874
|
+
EXAMPLE FLOW (Base):
|
|
2875
|
+
agether init 0xYOUR_PRIVATE_KEY --chain 8453 # Use Base
|
|
2876
|
+
agether register --name "MyAgent"
|
|
2877
|
+
agether deposit --amount 0.05 --token WETH
|
|
2862
2878
|
`);
|
|
2863
2879
|
}
|
|
2864
2880
|
function parseArgs(args) {
|
|
@@ -2891,7 +2907,7 @@ async function main() {
|
|
|
2891
2907
|
console.error("\u274C Private key required: agether init <private-key>");
|
|
2892
2908
|
process.exit(1);
|
|
2893
2909
|
}
|
|
2894
|
-
await cmdInit(positional[0], options["agent-id"]);
|
|
2910
|
+
await cmdInit(positional[0], options["agent-id"], options["chain"]);
|
|
2895
2911
|
break;
|
|
2896
2912
|
case "register":
|
|
2897
2913
|
await cmdRegister(options.name);
|
package/dist/index.d.mts
CHANGED
|
@@ -750,7 +750,6 @@ type AgetherViemWallet = WalletClient;
|
|
|
750
750
|
/** Base configuration fields shared by both signing modes. */
|
|
751
751
|
interface X402BaseConfig {
|
|
752
752
|
rpcUrl: string;
|
|
753
|
-
backendUrl: string;
|
|
754
753
|
agentId?: string;
|
|
755
754
|
accountAddress?: string;
|
|
756
755
|
/**
|
|
@@ -773,11 +772,6 @@ interface X402BaseConfig {
|
|
|
773
772
|
* Tracks cumulative daily borrows and rejects auto-draw if exceeded.
|
|
774
773
|
*/
|
|
775
774
|
dailySpendLimitUsdc?: string;
|
|
776
|
-
/**
|
|
777
|
-
* Safety margin: borrow this much extra beyond what's needed (in USDC, e.g. '1').
|
|
778
|
-
* Helps avoid rounding issues. Default: '0.5'
|
|
779
|
-
*/
|
|
780
|
-
autoDrawBuffer?: string;
|
|
781
775
|
/**
|
|
782
776
|
* Pre-loaded spending state from a previous session.
|
|
783
777
|
* Pass this to resume the daily spending tracker after a restart.
|
|
@@ -919,17 +913,22 @@ declare class X402Client {
|
|
|
919
913
|
/**
|
|
920
914
|
* ScoringClient — Client for the Agether backend scoring API
|
|
921
915
|
*
|
|
916
|
+
* Supports multi-chain: pass `chainId` to target a specific chain
|
|
917
|
+
* (Base 8453, Ethereum 1). When omitted, the backend uses its default chain.
|
|
918
|
+
*
|
|
922
919
|
* Endpoints:
|
|
923
|
-
* GET /score/:agentId — x402-gated, compute + submit score onchain
|
|
924
|
-
* GET /score/:agentId/current — free, read current onchain score
|
|
925
|
-
* GET /health
|
|
926
|
-
* GET /status
|
|
927
|
-
* GET /agents/:agentId/details — agent details
|
|
920
|
+
* GET /score/:agentId?chain=<chainId> — x402-gated, compute + submit score onchain
|
|
921
|
+
* GET /score/:agentId/current?chain=<chainId> — free, read current onchain score
|
|
922
|
+
* GET /health — service health
|
|
923
|
+
* GET /status — detailed status
|
|
924
|
+
* GET /agents/:agentId/details?chain=<chainId> — agent details
|
|
928
925
|
*/
|
|
929
926
|
|
|
930
927
|
interface ScoringClientConfig {
|
|
931
|
-
/** Backend base URL (e.g.
|
|
928
|
+
/** Backend base URL (e.g. https://api.agether.ai) */
|
|
932
929
|
endpoint: string;
|
|
930
|
+
/** Default chain to use for all calls (optional — backend falls back to its own default) */
|
|
931
|
+
chainId?: ChainId;
|
|
933
932
|
/** x402 config for paid scoring calls (optional — if not set, paid calls will fail) */
|
|
934
933
|
x402?: X402Config;
|
|
935
934
|
}
|
|
@@ -937,7 +936,10 @@ declare class ScoringClient {
|
|
|
937
936
|
private client;
|
|
938
937
|
private x402Client?;
|
|
939
938
|
private endpoint;
|
|
939
|
+
private defaultChainId?;
|
|
940
940
|
constructor(config: ScoringClientConfig);
|
|
941
|
+
/** Build query string with ?chain= if chainId is set */
|
|
942
|
+
private chainQuery;
|
|
941
943
|
/**
|
|
942
944
|
* Request a fresh score computation.
|
|
943
945
|
*
|
|
@@ -946,12 +948,16 @@ declare class ScoringClient {
|
|
|
946
948
|
* the score onchain via AgentReputation.submitScore().
|
|
947
949
|
*
|
|
948
950
|
* Returns the ScoreResult with breakdown and txHash.
|
|
951
|
+
*
|
|
952
|
+
* @param agentId Agent ID
|
|
953
|
+
* @param chainId Target chain (optional — overrides default)
|
|
949
954
|
*/
|
|
950
|
-
requestScore(agentId: string | bigint): Promise<ScoreResult>;
|
|
955
|
+
requestScore(agentId: string | bigint, chainId?: ChainId): Promise<ScoreResult>;
|
|
951
956
|
/**
|
|
952
957
|
* Get the current onchain score (free, no payment required).
|
|
958
|
+
* @param chainId Target chain (optional — overrides default)
|
|
953
959
|
*/
|
|
954
|
-
getCurrentScore(agentId: string | bigint): Promise<{
|
|
960
|
+
getCurrentScore(agentId: string | bigint, chainId?: ChainId): Promise<{
|
|
955
961
|
agentId: string;
|
|
956
962
|
score: number;
|
|
957
963
|
timestamp: number;
|
|
@@ -961,8 +967,9 @@ declare class ScoringClient {
|
|
|
961
967
|
}>;
|
|
962
968
|
/**
|
|
963
969
|
* Get detailed agent info from backend.
|
|
970
|
+
* @param chainId Target chain (optional — overrides default)
|
|
964
971
|
*/
|
|
965
|
-
getAgentDetails(agentId: string | bigint): Promise<{
|
|
972
|
+
getAgentDetails(agentId: string | bigint, chainId?: ChainId): Promise<{
|
|
966
973
|
agentId: string;
|
|
967
974
|
owner: string;
|
|
968
975
|
account: string;
|
|
@@ -997,8 +1004,9 @@ declare class ScoringClient {
|
|
|
997
1004
|
}>;
|
|
998
1005
|
/**
|
|
999
1006
|
* Agent count and list.
|
|
1007
|
+
* @param chainId Target chain (optional — overrides default)
|
|
1000
1008
|
*/
|
|
1001
|
-
getAgentCount(): Promise<{
|
|
1009
|
+
getAgentCount(chainId?: ChainId): Promise<{
|
|
1002
1010
|
totalAgents: number;
|
|
1003
1011
|
totalAccounts: number;
|
|
1004
1012
|
}>;
|
|
@@ -1007,8 +1015,12 @@ declare class ScoringClient {
|
|
|
1007
1015
|
/**
|
|
1008
1016
|
* AgentIdentityClient - Integration with ag0 (ERC-8004)
|
|
1009
1017
|
*
|
|
1010
|
-
* ERC-8004
|
|
1011
|
-
*
|
|
1018
|
+
* ERC-8004 is a per-chain singleton — different chain = different agentId.
|
|
1019
|
+
*
|
|
1020
|
+
* Contract Addresses:
|
|
1021
|
+
* - Ethereum IdentityRegistry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
|
|
1022
|
+
* - Base IdentityRegistry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
|
|
1023
|
+
* - Sepolia IdentityRegistry: 0x8004A818BFB912233c491871b3d84c89A494BD9e
|
|
1012
1024
|
* - Sepolia ReputationRegistry: 0x8004B663056A597Dffe9eCcC1965A193B7388713
|
|
1013
1025
|
*
|
|
1014
1026
|
* SDKs:
|
|
@@ -1283,5 +1295,17 @@ declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
|
|
|
1283
1295
|
* Create custom config (override any defaults)
|
|
1284
1296
|
*/
|
|
1285
1297
|
declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
|
|
1298
|
+
/**
|
|
1299
|
+
* Get USDC address for chain
|
|
1300
|
+
*/
|
|
1301
|
+
declare function getUSDCAddress(chainId: ChainId): string;
|
|
1302
|
+
/**
|
|
1303
|
+
* Get Morpho Blue address for chain
|
|
1304
|
+
*/
|
|
1305
|
+
declare function getMorphoBlueAddress(chainId: ChainId): string;
|
|
1306
|
+
/**
|
|
1307
|
+
* Get all contract addresses for a chain
|
|
1308
|
+
*/
|
|
1309
|
+
declare function getContractAddresses(chainId: ChainId): ContractAddresses;
|
|
1286
1310
|
|
|
1287
|
-
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, type FundResult, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PayFromYieldResult, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type SupplyAssetResult, type SupplyPositionResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawFromAccountResult, type WithdrawResult, type WithdrawSupplyResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, parseUnits, rateToBps };
|
|
1311
|
+
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, type FundResult, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PayFromYieldResult, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type SupplyAssetResult, type SupplyPositionResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawFromAccountResult, type WithdrawResult, type WithdrawSupplyResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getContractAddresses, getDefaultConfig, getMorphoBlueAddress, getUSDCAddress, parseUnits, rateToBps };
|
package/dist/index.d.ts
CHANGED
|
@@ -750,7 +750,6 @@ type AgetherViemWallet = WalletClient;
|
|
|
750
750
|
/** Base configuration fields shared by both signing modes. */
|
|
751
751
|
interface X402BaseConfig {
|
|
752
752
|
rpcUrl: string;
|
|
753
|
-
backendUrl: string;
|
|
754
753
|
agentId?: string;
|
|
755
754
|
accountAddress?: string;
|
|
756
755
|
/**
|
|
@@ -773,11 +772,6 @@ interface X402BaseConfig {
|
|
|
773
772
|
* Tracks cumulative daily borrows and rejects auto-draw if exceeded.
|
|
774
773
|
*/
|
|
775
774
|
dailySpendLimitUsdc?: string;
|
|
776
|
-
/**
|
|
777
|
-
* Safety margin: borrow this much extra beyond what's needed (in USDC, e.g. '1').
|
|
778
|
-
* Helps avoid rounding issues. Default: '0.5'
|
|
779
|
-
*/
|
|
780
|
-
autoDrawBuffer?: string;
|
|
781
775
|
/**
|
|
782
776
|
* Pre-loaded spending state from a previous session.
|
|
783
777
|
* Pass this to resume the daily spending tracker after a restart.
|
|
@@ -919,17 +913,22 @@ declare class X402Client {
|
|
|
919
913
|
/**
|
|
920
914
|
* ScoringClient — Client for the Agether backend scoring API
|
|
921
915
|
*
|
|
916
|
+
* Supports multi-chain: pass `chainId` to target a specific chain
|
|
917
|
+
* (Base 8453, Ethereum 1). When omitted, the backend uses its default chain.
|
|
918
|
+
*
|
|
922
919
|
* Endpoints:
|
|
923
|
-
* GET /score/:agentId — x402-gated, compute + submit score onchain
|
|
924
|
-
* GET /score/:agentId/current — free, read current onchain score
|
|
925
|
-
* GET /health
|
|
926
|
-
* GET /status
|
|
927
|
-
* GET /agents/:agentId/details — agent details
|
|
920
|
+
* GET /score/:agentId?chain=<chainId> — x402-gated, compute + submit score onchain
|
|
921
|
+
* GET /score/:agentId/current?chain=<chainId> — free, read current onchain score
|
|
922
|
+
* GET /health — service health
|
|
923
|
+
* GET /status — detailed status
|
|
924
|
+
* GET /agents/:agentId/details?chain=<chainId> — agent details
|
|
928
925
|
*/
|
|
929
926
|
|
|
930
927
|
interface ScoringClientConfig {
|
|
931
|
-
/** Backend base URL (e.g.
|
|
928
|
+
/** Backend base URL (e.g. https://api.agether.ai) */
|
|
932
929
|
endpoint: string;
|
|
930
|
+
/** Default chain to use for all calls (optional — backend falls back to its own default) */
|
|
931
|
+
chainId?: ChainId;
|
|
933
932
|
/** x402 config for paid scoring calls (optional — if not set, paid calls will fail) */
|
|
934
933
|
x402?: X402Config;
|
|
935
934
|
}
|
|
@@ -937,7 +936,10 @@ declare class ScoringClient {
|
|
|
937
936
|
private client;
|
|
938
937
|
private x402Client?;
|
|
939
938
|
private endpoint;
|
|
939
|
+
private defaultChainId?;
|
|
940
940
|
constructor(config: ScoringClientConfig);
|
|
941
|
+
/** Build query string with ?chain= if chainId is set */
|
|
942
|
+
private chainQuery;
|
|
941
943
|
/**
|
|
942
944
|
* Request a fresh score computation.
|
|
943
945
|
*
|
|
@@ -946,12 +948,16 @@ declare class ScoringClient {
|
|
|
946
948
|
* the score onchain via AgentReputation.submitScore().
|
|
947
949
|
*
|
|
948
950
|
* Returns the ScoreResult with breakdown and txHash.
|
|
951
|
+
*
|
|
952
|
+
* @param agentId Agent ID
|
|
953
|
+
* @param chainId Target chain (optional — overrides default)
|
|
949
954
|
*/
|
|
950
|
-
requestScore(agentId: string | bigint): Promise<ScoreResult>;
|
|
955
|
+
requestScore(agentId: string | bigint, chainId?: ChainId): Promise<ScoreResult>;
|
|
951
956
|
/**
|
|
952
957
|
* Get the current onchain score (free, no payment required).
|
|
958
|
+
* @param chainId Target chain (optional — overrides default)
|
|
953
959
|
*/
|
|
954
|
-
getCurrentScore(agentId: string | bigint): Promise<{
|
|
960
|
+
getCurrentScore(agentId: string | bigint, chainId?: ChainId): Promise<{
|
|
955
961
|
agentId: string;
|
|
956
962
|
score: number;
|
|
957
963
|
timestamp: number;
|
|
@@ -961,8 +967,9 @@ declare class ScoringClient {
|
|
|
961
967
|
}>;
|
|
962
968
|
/**
|
|
963
969
|
* Get detailed agent info from backend.
|
|
970
|
+
* @param chainId Target chain (optional — overrides default)
|
|
964
971
|
*/
|
|
965
|
-
getAgentDetails(agentId: string | bigint): Promise<{
|
|
972
|
+
getAgentDetails(agentId: string | bigint, chainId?: ChainId): Promise<{
|
|
966
973
|
agentId: string;
|
|
967
974
|
owner: string;
|
|
968
975
|
account: string;
|
|
@@ -997,8 +1004,9 @@ declare class ScoringClient {
|
|
|
997
1004
|
}>;
|
|
998
1005
|
/**
|
|
999
1006
|
* Agent count and list.
|
|
1007
|
+
* @param chainId Target chain (optional — overrides default)
|
|
1000
1008
|
*/
|
|
1001
|
-
getAgentCount(): Promise<{
|
|
1009
|
+
getAgentCount(chainId?: ChainId): Promise<{
|
|
1002
1010
|
totalAgents: number;
|
|
1003
1011
|
totalAccounts: number;
|
|
1004
1012
|
}>;
|
|
@@ -1007,8 +1015,12 @@ declare class ScoringClient {
|
|
|
1007
1015
|
/**
|
|
1008
1016
|
* AgentIdentityClient - Integration with ag0 (ERC-8004)
|
|
1009
1017
|
*
|
|
1010
|
-
* ERC-8004
|
|
1011
|
-
*
|
|
1018
|
+
* ERC-8004 is a per-chain singleton — different chain = different agentId.
|
|
1019
|
+
*
|
|
1020
|
+
* Contract Addresses:
|
|
1021
|
+
* - Ethereum IdentityRegistry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
|
|
1022
|
+
* - Base IdentityRegistry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
|
|
1023
|
+
* - Sepolia IdentityRegistry: 0x8004A818BFB912233c491871b3d84c89A494BD9e
|
|
1012
1024
|
* - Sepolia ReputationRegistry: 0x8004B663056A597Dffe9eCcC1965A193B7388713
|
|
1013
1025
|
*
|
|
1014
1026
|
* SDKs:
|
|
@@ -1283,5 +1295,17 @@ declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
|
|
|
1283
1295
|
* Create custom config (override any defaults)
|
|
1284
1296
|
*/
|
|
1285
1297
|
declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
|
|
1298
|
+
/**
|
|
1299
|
+
* Get USDC address for chain
|
|
1300
|
+
*/
|
|
1301
|
+
declare function getUSDCAddress(chainId: ChainId): string;
|
|
1302
|
+
/**
|
|
1303
|
+
* Get Morpho Blue address for chain
|
|
1304
|
+
*/
|
|
1305
|
+
declare function getMorphoBlueAddress(chainId: ChainId): string;
|
|
1306
|
+
/**
|
|
1307
|
+
* Get all contract addresses for a chain
|
|
1308
|
+
*/
|
|
1309
|
+
declare function getContractAddresses(chainId: ChainId): ContractAddresses;
|
|
1286
1310
|
|
|
1287
|
-
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, type FundResult, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PayFromYieldResult, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type SupplyAssetResult, type SupplyPositionResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawFromAccountResult, type WithdrawResult, type WithdrawSupplyResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, parseUnits, rateToBps };
|
|
1311
|
+
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, type FundResult, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PayFromYieldResult, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type SupplyAssetResult, type SupplyPositionResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawFromAccountResult, type WithdrawResult, type WithdrawSupplyResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getContractAddresses, getDefaultConfig, getMorphoBlueAddress, getUSDCAddress, parseUnits, rateToBps };
|