@exagent/agent 0.1.7 → 0.1.9
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/dist/chunk-CKSCA3O7.mjs +2686 -0
- package/dist/chunk-ONWRXGJG.mjs +2678 -0
- package/dist/cli.js +15 -2
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +15 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1388,6 +1388,7 @@ var RelayClient = class {
|
|
|
1388
1388
|
config;
|
|
1389
1389
|
ws = null;
|
|
1390
1390
|
authenticated = false;
|
|
1391
|
+
authRejected = false;
|
|
1391
1392
|
reconnectAttempts = 0;
|
|
1392
1393
|
maxReconnectAttempts = 50;
|
|
1393
1394
|
reconnectTimer = null;
|
|
@@ -1420,8 +1421,8 @@ var RelayClient = class {
|
|
|
1420
1421
|
}
|
|
1421
1422
|
}, 15e3);
|
|
1422
1423
|
this.ws.on("open", async () => {
|
|
1424
|
+
this.authRejected = false;
|
|
1423
1425
|
console.log("Relay: Connected, authenticating...");
|
|
1424
|
-
this.reconnectAttempts = 0;
|
|
1425
1426
|
try {
|
|
1426
1427
|
await this.authenticate();
|
|
1427
1428
|
} catch (error) {
|
|
@@ -1438,11 +1439,13 @@ var RelayClient = class {
|
|
|
1438
1439
|
if (data.type === "auth_success") {
|
|
1439
1440
|
clearTimeout(connectTimeout);
|
|
1440
1441
|
this.authenticated = true;
|
|
1442
|
+
this.reconnectAttempts = 0;
|
|
1441
1443
|
this.startHeartbeat();
|
|
1442
1444
|
console.log("Relay: Authenticated successfully");
|
|
1443
1445
|
resolve();
|
|
1444
1446
|
} else if (data.type === "auth_error") {
|
|
1445
1447
|
clearTimeout(connectTimeout);
|
|
1448
|
+
this.authRejected = true;
|
|
1446
1449
|
console.error(`Relay: Auth rejected: ${data.message}`);
|
|
1447
1450
|
reject(new Error(data.message));
|
|
1448
1451
|
}
|
|
@@ -1454,7 +1457,9 @@ var RelayClient = class {
|
|
|
1454
1457
|
this.authenticated = false;
|
|
1455
1458
|
this.stopHeartbeat();
|
|
1456
1459
|
if (!this.stopped) {
|
|
1457
|
-
|
|
1460
|
+
if (!this.authRejected) {
|
|
1461
|
+
console.log(`Relay: Disconnected (${code}: ${reason.toString() || "unknown"})`);
|
|
1462
|
+
}
|
|
1458
1463
|
this.scheduleReconnect();
|
|
1459
1464
|
}
|
|
1460
1465
|
});
|
|
@@ -1659,6 +1664,8 @@ var AgentRuntime = class {
|
|
|
1659
1664
|
lastVaultCheck = 0;
|
|
1660
1665
|
cycleCount = 0;
|
|
1661
1666
|
lastCycleAt = 0;
|
|
1667
|
+
lastPortfolioValue = 0;
|
|
1668
|
+
lastEthBalance = "0";
|
|
1662
1669
|
processAlive = true;
|
|
1663
1670
|
VAULT_CHECK_INTERVAL = 3e5;
|
|
1664
1671
|
// Check vault status every 5 minutes
|
|
@@ -2069,6 +2076,8 @@ var AgentRuntime = class {
|
|
|
2069
2076
|
cycleCount: this.cycleCount,
|
|
2070
2077
|
lastCycleAt: this.lastCycleAt,
|
|
2071
2078
|
tradingIntervalMs: this.config.trading.tradingIntervalMs,
|
|
2079
|
+
portfolioValue: this.lastPortfolioValue,
|
|
2080
|
+
ethBalance: this.lastEthBalance,
|
|
2072
2081
|
llm: {
|
|
2073
2082
|
provider: this.config.llm.provider,
|
|
2074
2083
|
model: this.config.llm.model || "default"
|
|
@@ -2098,6 +2107,10 @@ var AgentRuntime = class {
|
|
|
2098
2107
|
const tokens = this.config.allowedTokens || this.getDefaultTokens();
|
|
2099
2108
|
const marketData = await this.marketData.fetchMarketData(this.client.address, tokens);
|
|
2100
2109
|
console.log(`Portfolio value: $${marketData.portfolioValue.toFixed(2)}`);
|
|
2110
|
+
this.lastPortfolioValue = marketData.portfolioValue;
|
|
2111
|
+
const wethAddr = "0x4200000000000000000000000000000000000006";
|
|
2112
|
+
const ethBal = marketData.balances[wethAddr] || BigInt(0);
|
|
2113
|
+
this.lastEthBalance = (Number(ethBal) / 1e18).toFixed(6);
|
|
2101
2114
|
this.checkFundsLow(marketData);
|
|
2102
2115
|
let signals;
|
|
2103
2116
|
try {
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -467,6 +467,8 @@ declare class AgentRuntime {
|
|
|
467
467
|
private lastVaultCheck;
|
|
468
468
|
private cycleCount;
|
|
469
469
|
private lastCycleAt;
|
|
470
|
+
private lastPortfolioValue;
|
|
471
|
+
private lastEthBalance;
|
|
470
472
|
private processAlive;
|
|
471
473
|
private readonly VAULT_CHECK_INTERVAL;
|
|
472
474
|
constructor(config: RuntimeConfig);
|
|
@@ -862,6 +864,7 @@ declare class RelayClient {
|
|
|
862
864
|
private config;
|
|
863
865
|
private ws;
|
|
864
866
|
private authenticated;
|
|
867
|
+
private authRejected;
|
|
865
868
|
private reconnectAttempts;
|
|
866
869
|
private maxReconnectAttempts;
|
|
867
870
|
private reconnectTimer;
|
package/dist/index.d.ts
CHANGED
|
@@ -467,6 +467,8 @@ declare class AgentRuntime {
|
|
|
467
467
|
private lastVaultCheck;
|
|
468
468
|
private cycleCount;
|
|
469
469
|
private lastCycleAt;
|
|
470
|
+
private lastPortfolioValue;
|
|
471
|
+
private lastEthBalance;
|
|
470
472
|
private processAlive;
|
|
471
473
|
private readonly VAULT_CHECK_INTERVAL;
|
|
472
474
|
constructor(config: RuntimeConfig);
|
|
@@ -862,6 +864,7 @@ declare class RelayClient {
|
|
|
862
864
|
private config;
|
|
863
865
|
private ws;
|
|
864
866
|
private authenticated;
|
|
867
|
+
private authRejected;
|
|
865
868
|
private reconnectAttempts;
|
|
866
869
|
private maxReconnectAttempts;
|
|
867
870
|
private reconnectTimer;
|
package/dist/index.js
CHANGED
|
@@ -1432,6 +1432,7 @@ var RelayClient = class {
|
|
|
1432
1432
|
config;
|
|
1433
1433
|
ws = null;
|
|
1434
1434
|
authenticated = false;
|
|
1435
|
+
authRejected = false;
|
|
1435
1436
|
reconnectAttempts = 0;
|
|
1436
1437
|
maxReconnectAttempts = 50;
|
|
1437
1438
|
reconnectTimer = null;
|
|
@@ -1464,8 +1465,8 @@ var RelayClient = class {
|
|
|
1464
1465
|
}
|
|
1465
1466
|
}, 15e3);
|
|
1466
1467
|
this.ws.on("open", async () => {
|
|
1468
|
+
this.authRejected = false;
|
|
1467
1469
|
console.log("Relay: Connected, authenticating...");
|
|
1468
|
-
this.reconnectAttempts = 0;
|
|
1469
1470
|
try {
|
|
1470
1471
|
await this.authenticate();
|
|
1471
1472
|
} catch (error) {
|
|
@@ -1482,11 +1483,13 @@ var RelayClient = class {
|
|
|
1482
1483
|
if (data.type === "auth_success") {
|
|
1483
1484
|
clearTimeout(connectTimeout);
|
|
1484
1485
|
this.authenticated = true;
|
|
1486
|
+
this.reconnectAttempts = 0;
|
|
1485
1487
|
this.startHeartbeat();
|
|
1486
1488
|
console.log("Relay: Authenticated successfully");
|
|
1487
1489
|
resolve();
|
|
1488
1490
|
} else if (data.type === "auth_error") {
|
|
1489
1491
|
clearTimeout(connectTimeout);
|
|
1492
|
+
this.authRejected = true;
|
|
1490
1493
|
console.error(`Relay: Auth rejected: ${data.message}`);
|
|
1491
1494
|
reject(new Error(data.message));
|
|
1492
1495
|
}
|
|
@@ -1498,7 +1501,9 @@ var RelayClient = class {
|
|
|
1498
1501
|
this.authenticated = false;
|
|
1499
1502
|
this.stopHeartbeat();
|
|
1500
1503
|
if (!this.stopped) {
|
|
1501
|
-
|
|
1504
|
+
if (!this.authRejected) {
|
|
1505
|
+
console.log(`Relay: Disconnected (${code}: ${reason.toString() || "unknown"})`);
|
|
1506
|
+
}
|
|
1502
1507
|
this.scheduleReconnect();
|
|
1503
1508
|
}
|
|
1504
1509
|
});
|
|
@@ -1703,6 +1708,8 @@ var AgentRuntime = class {
|
|
|
1703
1708
|
lastVaultCheck = 0;
|
|
1704
1709
|
cycleCount = 0;
|
|
1705
1710
|
lastCycleAt = 0;
|
|
1711
|
+
lastPortfolioValue = 0;
|
|
1712
|
+
lastEthBalance = "0";
|
|
1706
1713
|
processAlive = true;
|
|
1707
1714
|
VAULT_CHECK_INTERVAL = 3e5;
|
|
1708
1715
|
// Check vault status every 5 minutes
|
|
@@ -2113,6 +2120,8 @@ var AgentRuntime = class {
|
|
|
2113
2120
|
cycleCount: this.cycleCount,
|
|
2114
2121
|
lastCycleAt: this.lastCycleAt,
|
|
2115
2122
|
tradingIntervalMs: this.config.trading.tradingIntervalMs,
|
|
2123
|
+
portfolioValue: this.lastPortfolioValue,
|
|
2124
|
+
ethBalance: this.lastEthBalance,
|
|
2116
2125
|
llm: {
|
|
2117
2126
|
provider: this.config.llm.provider,
|
|
2118
2127
|
model: this.config.llm.model || "default"
|
|
@@ -2142,6 +2151,10 @@ var AgentRuntime = class {
|
|
|
2142
2151
|
const tokens = this.config.allowedTokens || this.getDefaultTokens();
|
|
2143
2152
|
const marketData = await this.marketData.fetchMarketData(this.client.address, tokens);
|
|
2144
2153
|
console.log(`Portfolio value: $${marketData.portfolioValue.toFixed(2)}`);
|
|
2154
|
+
this.lastPortfolioValue = marketData.portfolioValue;
|
|
2155
|
+
const wethAddr = "0x4200000000000000000000000000000000000006";
|
|
2156
|
+
const ethBal = marketData.balances[wethAddr] || BigInt(0);
|
|
2157
|
+
this.lastEthBalance = (Number(ethBal) / 1e18).toFixed(6);
|
|
2145
2158
|
this.checkFundsLow(marketData);
|
|
2146
2159
|
let signals;
|
|
2147
2160
|
try {
|
package/dist/index.mjs
CHANGED