@exagent/agent 0.1.28 → 0.1.30

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/cli.js CHANGED
@@ -237,7 +237,7 @@ var MarketDataService = class {
237
237
  constructor(rpcUrl) {
238
238
  this.rpcUrl = rpcUrl;
239
239
  this.client = (0, import_viem.createPublicClient)({
240
- transport: (0, import_viem.http)(rpcUrl)
240
+ transport: (0, import_viem.http)(rpcUrl, { timeout: 6e4 })
241
241
  });
242
242
  }
243
243
  /** Cached volume data */
@@ -2198,14 +2198,15 @@ var VaultManager = class {
2198
2198
  this.account = (0, import_accounts.privateKeyToAccount)(config.walletKey);
2199
2199
  this.chain = import_chains.base;
2200
2200
  const rpcUrl = getRpcUrl();
2201
+ const transport = (0, import_viem2.http)(rpcUrl, { timeout: 6e4 });
2201
2202
  this.publicClient = (0, import_viem2.createPublicClient)({
2202
2203
  chain: this.chain,
2203
- transport: (0, import_viem2.http)(rpcUrl)
2204
+ transport
2204
2205
  });
2205
2206
  this.walletClient = (0, import_viem2.createWalletClient)({
2206
2207
  account: this.account,
2207
2208
  chain: this.chain,
2208
- transport: (0, import_viem2.http)(rpcUrl)
2209
+ transport
2209
2210
  });
2210
2211
  if (this.addresses.vaultFactory === "0x0000000000000000000000000000000000000000") {
2211
2212
  console.warn("VaultFactory address is zero \u2014 vault operations will be disabled");
@@ -3307,7 +3308,7 @@ var PerpTradeRecorder = class {
3307
3308
  this.configHash = opts.configHash;
3308
3309
  this.account = (0, import_accounts2.privateKeyToAccount)(opts.privateKey);
3309
3310
  const rpcUrl = opts.rpcUrl || "https://mainnet.base.org";
3310
- const transport = (0, import_viem4.http)(rpcUrl);
3311
+ const transport = (0, import_viem4.http)(rpcUrl, { timeout: 6e4 });
3311
3312
  this.publicClient = (0, import_viem4.createPublicClient)({
3312
3313
  chain: import_chains2.base,
3313
3314
  transport
@@ -3825,7 +3826,7 @@ function loadSecureEnv(basePath, passphrase) {
3825
3826
  }
3826
3827
 
3827
3828
  // src/index.ts
3828
- var AGENT_VERSION = "0.1.28";
3829
+ var AGENT_VERSION = "0.1.30";
3829
3830
 
3830
3831
  // src/relay.ts
3831
3832
  var RelayClient = class {
@@ -4276,7 +4277,7 @@ var AgentRuntime = class {
4276
4277
  const account = (0, import_accounts5.privateKeyToAccount)(perpKey);
4277
4278
  const walletClient = (0, import_viem6.createWalletClient)({
4278
4279
  chain: { id: 42161, name: "Arbitrum", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://arb1.arbitrum.io/rpc"] } } },
4279
- transport: (0, import_viem6.http)("https://arb1.arbitrum.io/rpc"),
4280
+ transport: (0, import_viem6.http)("https://arb1.arbitrum.io/rpc", { timeout: 6e4 }),
4280
4281
  account
4281
4282
  });
4282
4283
  this.perpSigner = new HyperliquidSigner(walletClient);
@@ -4422,6 +4423,10 @@ var AgentRuntime = class {
4422
4423
  this.config.allowedTokens = void 0;
4423
4424
  console.log("Frontier risk universe: all tokens allowed (no restrictions)");
4424
4425
  console.log("Frontier risk universe: vault creation is disabled");
4426
+ const trackedCount = this.positionTracker.getPositions().length;
4427
+ if (trackedCount > 0) {
4428
+ console.log(`Auto-tracking ${trackedCount} token(s) from position history`);
4429
+ }
4425
4430
  return;
4426
4431
  }
4427
4432
  const configTokens = this.config.allowedTokens || this.getDefaultTokens();
@@ -4514,7 +4519,7 @@ var AgentRuntime = class {
4514
4519
  const ccUrl = `https://exagent.io/agents/${encodeURIComponent(this.config.name)}/command-center`;
4515
4520
  const publicClientInstance = (0, import_viem6.createPublicClient)({
4516
4521
  chain: import_chains4.base,
4517
- transport: (0, import_viem6.http)(this.getRpcUrl())
4522
+ transport: (0, import_viem6.http)(this.getRpcUrl(), { timeout: 6e4 })
4518
4523
  });
4519
4524
  console.log("");
4520
4525
  console.log("=== ETH NEEDED FOR GAS ===");
@@ -4981,7 +4986,7 @@ var AgentRuntime = class {
4981
4986
  --- Trading Cycle: ${(/* @__PURE__ */ new Date()).toISOString()} ---`);
4982
4987
  this.cycleCount++;
4983
4988
  this.lastCycleAt = Date.now();
4984
- const tokens = this.config.allowedTokens || this.getDefaultTokens();
4989
+ const tokens = this.getTokensToTrack();
4985
4990
  const marketData = await this.marketData.fetchMarketData(this.client.address, tokens);
4986
4991
  console.log(`Portfolio value: $${marketData.portfolioValue.toFixed(2)}`);
4987
4992
  this.lastPortfolioValue = marketData.portfolioValue;
@@ -5078,7 +5083,7 @@ var AgentRuntime = class {
5078
5083
  success: result.success
5079
5084
  });
5080
5085
  }
5081
- const postTokens = this.config.allowedTokens || this.getDefaultTokens();
5086
+ const postTokens = this.getTokensToTrack();
5082
5087
  const postTradeData = await this.marketData.fetchMarketData(this.client.address, postTokens);
5083
5088
  const marketPnL = postTradeData.portfolioValue - preTradePortfolioValue + totalFeesUSD;
5084
5089
  this.riskManager.updatePnL(marketPnL);
@@ -5221,6 +5226,38 @@ var AgentRuntime = class {
5221
5226
  getRpcUrl() {
5222
5227
  return getRpcUrl();
5223
5228
  }
5229
+ /**
5230
+ * Get the full list of tokens to fetch balances/prices for this cycle.
5231
+ * Starts from allowedTokens (or default whitelist), then merges in any tokens
5232
+ * the position tracker knows about — so previously-traded tokens (especially
5233
+ * for Frontier agents trading outside the whitelist) stay visible.
5234
+ */
5235
+ getTokensToTrack() {
5236
+ const base5 = this.config.allowedTokens || this.getDefaultTokens();
5237
+ const baseSet = new Set(base5.map((t) => t.toLowerCase()));
5238
+ const trackedPositions = this.positionTracker.getPositions();
5239
+ const extras = [];
5240
+ for (const pos of trackedPositions) {
5241
+ if (!baseSet.has(pos.token.toLowerCase())) {
5242
+ extras.push(pos.token);
5243
+ baseSet.add(pos.token.toLowerCase());
5244
+ }
5245
+ }
5246
+ const recentTrades = this.positionTracker.getTradeHistory(20);
5247
+ for (const trade of recentTrades) {
5248
+ for (const addr of [trade.tokenIn, trade.tokenOut]) {
5249
+ const key = addr.toLowerCase();
5250
+ if (key !== NATIVE_ETH.toLowerCase() && !baseSet.has(key)) {
5251
+ extras.push(addr);
5252
+ baseSet.add(key);
5253
+ }
5254
+ }
5255
+ }
5256
+ if (extras.length > 0) {
5257
+ console.log(`Auto-tracking ${extras.length} additional token(s) from position history`);
5258
+ }
5259
+ return [...base5, ...extras];
5260
+ }
5224
5261
  /**
5225
5262
  * Default tokens to track.
5226
5263
  * These are validated against the on-chain registry's isTradeAllowed() during init —
package/dist/cli.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  loadConfig,
7
7
  loadSecureEnv,
8
8
  validateConfig
9
- } from "./chunk-62GBXQNP.mjs";
9
+ } from "./chunk-IMJPVALR.mjs";
10
10
 
11
11
  // src/cli.ts
12
12
  import { Command } from "commander";
package/dist/index.d.mts CHANGED
@@ -892,6 +892,13 @@ declare class AgentRuntime {
892
892
  * Get RPC URL from environment or default
893
893
  */
894
894
  private getRpcUrl;
895
+ /**
896
+ * Get the full list of tokens to fetch balances/prices for this cycle.
897
+ * Starts from allowedTokens (or default whitelist), then merges in any tokens
898
+ * the position tracker knows about — so previously-traded tokens (especially
899
+ * for Frontier agents trading outside the whitelist) stay visible.
900
+ */
901
+ private getTokensToTrack;
895
902
  /**
896
903
  * Default tokens to track.
897
904
  * These are validated against the on-chain registry's isTradeAllowed() during init —
@@ -2107,6 +2114,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
2107
2114
  declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
2108
2115
 
2109
2116
  /** @exagent/agent package version — update alongside package.json */
2110
- declare const AGENT_VERSION = "0.1.28";
2117
+ declare const AGENT_VERSION = "0.1.30";
2111
2118
 
2112
2119
  export { AGENT_VERSION, type AccountSummary, type AgentConfig, AgentConfigSchema, type AgentMode, AgentRuntime, type AgentStatusPayload, AnthropicAdapter, BaseLLMAdapter, type CommandType, DeepSeekAdapter, FileStore, type FillCallback, type FundingCallback, type FundingPayment, GoogleAdapter, GroqAdapter, HYPERLIQUID_DOMAIN, HyperliquidClient, HyperliquidSigner, HyperliquidWebSocket, type LLMAdapter, type LLMConfig, LLMConfigSchema, type LLMMessage, type LLMMetadata, type LLMProvider, LLMProviderSchema, type LLMResponse, type LiquidationCallback, type MarketData, MarketDataService, type MessageLevel, type MessageType, MistralAdapter, OllamaAdapter, type OnboardingStatus, OpenAIAdapter, OrderManager, type OrderResult, type PerpAction, type PerpConfig$1 as PerpConfig, PerpConfigSchema, type PerpFill, type PerpMarketData, PerpOnboarding, type PerpPosition, type PerpStrategyFunction, PerpTradeRecorder, type PerpTradeSignal, type PerpConfig as PerpTradingConfig, PositionManager, type PositionSummary, PositionTracker, type RecordPerpTradeParams, RelayClient, type RelayCommand, type RelayConfig$1 as RelayConfig, RelayConfigSchema, RiskManager, type RiskState, type RiskUniverse, RiskUniverseSchema, type RuntimeConfig, STRATEGY_TEMPLATES, type StrategyContext, type StrategyFunction, type StrategyStore, type StrategyTemplate, TogetherAdapter, type TrackedPosition, TradeExecutor, type TradeRecord, type TradeSignal, type TradingConfig, TradingConfigSchema, type VaultConfig, VaultConfigSchema, VaultManager, type VaultManagerConfig, type VaultPolicy, VaultPolicySchema, type VaultStatus, createLLMAdapter, createSampleConfig, decryptEnvFile, encryptEnvFile, fillHashToBytes32, fillOidToBytes32, getAllStrategyTemplates, getNextNonce, getStrategyTemplate, loadConfig, loadSecureEnv, loadStrategy, validateConfig, validateStrategy };
package/dist/index.d.ts CHANGED
@@ -892,6 +892,13 @@ declare class AgentRuntime {
892
892
  * Get RPC URL from environment or default
893
893
  */
894
894
  private getRpcUrl;
895
+ /**
896
+ * Get the full list of tokens to fetch balances/prices for this cycle.
897
+ * Starts from allowedTokens (or default whitelist), then merges in any tokens
898
+ * the position tracker knows about — so previously-traded tokens (especially
899
+ * for Frontier agents trading outside the whitelist) stay visible.
900
+ */
901
+ private getTokensToTrack;
895
902
  /**
896
903
  * Default tokens to track.
897
904
  * These are validated against the on-chain registry's isTradeAllowed() during init —
@@ -2107,6 +2114,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
2107
2114
  declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
2108
2115
 
2109
2116
  /** @exagent/agent package version — update alongside package.json */
2110
- declare const AGENT_VERSION = "0.1.28";
2117
+ declare const AGENT_VERSION = "0.1.30";
2111
2118
 
2112
2119
  export { AGENT_VERSION, type AccountSummary, type AgentConfig, AgentConfigSchema, type AgentMode, AgentRuntime, type AgentStatusPayload, AnthropicAdapter, BaseLLMAdapter, type CommandType, DeepSeekAdapter, FileStore, type FillCallback, type FundingCallback, type FundingPayment, GoogleAdapter, GroqAdapter, HYPERLIQUID_DOMAIN, HyperliquidClient, HyperliquidSigner, HyperliquidWebSocket, type LLMAdapter, type LLMConfig, LLMConfigSchema, type LLMMessage, type LLMMetadata, type LLMProvider, LLMProviderSchema, type LLMResponse, type LiquidationCallback, type MarketData, MarketDataService, type MessageLevel, type MessageType, MistralAdapter, OllamaAdapter, type OnboardingStatus, OpenAIAdapter, OrderManager, type OrderResult, type PerpAction, type PerpConfig$1 as PerpConfig, PerpConfigSchema, type PerpFill, type PerpMarketData, PerpOnboarding, type PerpPosition, type PerpStrategyFunction, PerpTradeRecorder, type PerpTradeSignal, type PerpConfig as PerpTradingConfig, PositionManager, type PositionSummary, PositionTracker, type RecordPerpTradeParams, RelayClient, type RelayCommand, type RelayConfig$1 as RelayConfig, RelayConfigSchema, RiskManager, type RiskState, type RiskUniverse, RiskUniverseSchema, type RuntimeConfig, STRATEGY_TEMPLATES, type StrategyContext, type StrategyFunction, type StrategyStore, type StrategyTemplate, TogetherAdapter, type TrackedPosition, TradeExecutor, type TradeRecord, type TradeSignal, type TradingConfig, TradingConfigSchema, type VaultConfig, VaultConfigSchema, VaultManager, type VaultManagerConfig, type VaultPolicy, VaultPolicySchema, type VaultStatus, createLLMAdapter, createSampleConfig, decryptEnvFile, encryptEnvFile, fillHashToBytes32, fillOidToBytes32, getAllStrategyTemplates, getNextNonce, getStrategyTemplate, loadConfig, loadSecureEnv, loadStrategy, validateConfig, validateStrategy };
package/dist/index.js CHANGED
@@ -290,7 +290,7 @@ var MarketDataService = class {
290
290
  constructor(rpcUrl) {
291
291
  this.rpcUrl = rpcUrl;
292
292
  this.client = (0, import_viem.createPublicClient)({
293
- transport: (0, import_viem.http)(rpcUrl)
293
+ transport: (0, import_viem.http)(rpcUrl, { timeout: 6e4 })
294
294
  });
295
295
  }
296
296
  /** Cached volume data */
@@ -2286,14 +2286,15 @@ var VaultManager = class {
2286
2286
  this.account = (0, import_accounts.privateKeyToAccount)(config.walletKey);
2287
2287
  this.chain = import_chains.base;
2288
2288
  const rpcUrl = getRpcUrl();
2289
+ const transport = (0, import_viem2.http)(rpcUrl, { timeout: 6e4 });
2289
2290
  this.publicClient = (0, import_viem2.createPublicClient)({
2290
2291
  chain: this.chain,
2291
- transport: (0, import_viem2.http)(rpcUrl)
2292
+ transport
2292
2293
  });
2293
2294
  this.walletClient = (0, import_viem2.createWalletClient)({
2294
2295
  account: this.account,
2295
2296
  chain: this.chain,
2296
- transport: (0, import_viem2.http)(rpcUrl)
2297
+ transport
2297
2298
  });
2298
2299
  if (this.addresses.vaultFactory === "0x0000000000000000000000000000000000000000") {
2299
2300
  console.warn("VaultFactory address is zero \u2014 vault operations will be disabled");
@@ -3660,7 +3661,7 @@ var PerpTradeRecorder = class {
3660
3661
  this.configHash = opts.configHash;
3661
3662
  this.account = (0, import_accounts3.privateKeyToAccount)(opts.privateKey);
3662
3663
  const rpcUrl = opts.rpcUrl || "https://mainnet.base.org";
3663
- const transport = (0, import_viem4.http)(rpcUrl);
3664
+ const transport = (0, import_viem4.http)(rpcUrl, { timeout: 6e4 });
3664
3665
  this.publicClient = (0, import_viem4.createPublicClient)({
3665
3666
  chain: import_chains2.base,
3666
3667
  transport
@@ -4178,7 +4179,7 @@ var AgentRuntime = class {
4178
4179
  const account = (0, import_accounts5.privateKeyToAccount)(perpKey);
4179
4180
  const walletClient = (0, import_viem6.createWalletClient)({
4180
4181
  chain: { id: 42161, name: "Arbitrum", nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://arb1.arbitrum.io/rpc"] } } },
4181
- transport: (0, import_viem6.http)("https://arb1.arbitrum.io/rpc"),
4182
+ transport: (0, import_viem6.http)("https://arb1.arbitrum.io/rpc", { timeout: 6e4 }),
4182
4183
  account
4183
4184
  });
4184
4185
  this.perpSigner = new HyperliquidSigner(walletClient);
@@ -4324,6 +4325,10 @@ var AgentRuntime = class {
4324
4325
  this.config.allowedTokens = void 0;
4325
4326
  console.log("Frontier risk universe: all tokens allowed (no restrictions)");
4326
4327
  console.log("Frontier risk universe: vault creation is disabled");
4328
+ const trackedCount = this.positionTracker.getPositions().length;
4329
+ if (trackedCount > 0) {
4330
+ console.log(`Auto-tracking ${trackedCount} token(s) from position history`);
4331
+ }
4327
4332
  return;
4328
4333
  }
4329
4334
  const configTokens = this.config.allowedTokens || this.getDefaultTokens();
@@ -4416,7 +4421,7 @@ var AgentRuntime = class {
4416
4421
  const ccUrl = `https://exagent.io/agents/${encodeURIComponent(this.config.name)}/command-center`;
4417
4422
  const publicClientInstance = (0, import_viem6.createPublicClient)({
4418
4423
  chain: import_chains4.base,
4419
- transport: (0, import_viem6.http)(this.getRpcUrl())
4424
+ transport: (0, import_viem6.http)(this.getRpcUrl(), { timeout: 6e4 })
4420
4425
  });
4421
4426
  console.log("");
4422
4427
  console.log("=== ETH NEEDED FOR GAS ===");
@@ -4883,7 +4888,7 @@ var AgentRuntime = class {
4883
4888
  --- Trading Cycle: ${(/* @__PURE__ */ new Date()).toISOString()} ---`);
4884
4889
  this.cycleCount++;
4885
4890
  this.lastCycleAt = Date.now();
4886
- const tokens = this.config.allowedTokens || this.getDefaultTokens();
4891
+ const tokens = this.getTokensToTrack();
4887
4892
  const marketData = await this.marketData.fetchMarketData(this.client.address, tokens);
4888
4893
  console.log(`Portfolio value: $${marketData.portfolioValue.toFixed(2)}`);
4889
4894
  this.lastPortfolioValue = marketData.portfolioValue;
@@ -4980,7 +4985,7 @@ var AgentRuntime = class {
4980
4985
  success: result.success
4981
4986
  });
4982
4987
  }
4983
- const postTokens = this.config.allowedTokens || this.getDefaultTokens();
4988
+ const postTokens = this.getTokensToTrack();
4984
4989
  const postTradeData = await this.marketData.fetchMarketData(this.client.address, postTokens);
4985
4990
  const marketPnL = postTradeData.portfolioValue - preTradePortfolioValue + totalFeesUSD;
4986
4991
  this.riskManager.updatePnL(marketPnL);
@@ -5123,6 +5128,38 @@ var AgentRuntime = class {
5123
5128
  getRpcUrl() {
5124
5129
  return getRpcUrl();
5125
5130
  }
5131
+ /**
5132
+ * Get the full list of tokens to fetch balances/prices for this cycle.
5133
+ * Starts from allowedTokens (or default whitelist), then merges in any tokens
5134
+ * the position tracker knows about — so previously-traded tokens (especially
5135
+ * for Frontier agents trading outside the whitelist) stay visible.
5136
+ */
5137
+ getTokensToTrack() {
5138
+ const base5 = this.config.allowedTokens || this.getDefaultTokens();
5139
+ const baseSet = new Set(base5.map((t) => t.toLowerCase()));
5140
+ const trackedPositions = this.positionTracker.getPositions();
5141
+ const extras = [];
5142
+ for (const pos of trackedPositions) {
5143
+ if (!baseSet.has(pos.token.toLowerCase())) {
5144
+ extras.push(pos.token);
5145
+ baseSet.add(pos.token.toLowerCase());
5146
+ }
5147
+ }
5148
+ const recentTrades = this.positionTracker.getTradeHistory(20);
5149
+ for (const trade of recentTrades) {
5150
+ for (const addr of [trade.tokenIn, trade.tokenOut]) {
5151
+ const key = addr.toLowerCase();
5152
+ if (key !== NATIVE_ETH.toLowerCase() && !baseSet.has(key)) {
5153
+ extras.push(addr);
5154
+ baseSet.add(key);
5155
+ }
5156
+ }
5157
+ }
5158
+ if (extras.length > 0) {
5159
+ console.log(`Auto-tracking ${extras.length} additional token(s) from position history`);
5160
+ }
5161
+ return [...base5, ...extras];
5162
+ }
5126
5163
  /**
5127
5164
  * Default tokens to track.
5128
5165
  * These are validated against the on-chain registry's isTradeAllowed() during init —
@@ -5452,7 +5489,7 @@ function loadSecureEnv(basePath, passphrase) {
5452
5489
  }
5453
5490
 
5454
5491
  // src/index.ts
5455
- var AGENT_VERSION = "0.1.28";
5492
+ var AGENT_VERSION = "0.1.30";
5456
5493
  // Annotate the CommonJS export names for ESM import in node:
5457
5494
  0 && (module.exports = {
5458
5495
  AGENT_VERSION,
package/dist/index.mjs CHANGED
@@ -49,7 +49,7 @@ import {
49
49
  loadStrategy,
50
50
  validateConfig,
51
51
  validateStrategy
52
- } from "./chunk-62GBXQNP.mjs";
52
+ } from "./chunk-IMJPVALR.mjs";
53
53
  export {
54
54
  AGENT_VERSION,
55
55
  AgentConfigSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exagent/agent",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "Autonomous trading agent runtime for Exagent",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,7 +29,7 @@
29
29
  "clean": "rm -rf dist"
30
30
  },
31
31
  "dependencies": {
32
- "@exagent/sdk": "^0.1.13",
32
+ "@exagent/sdk": "^0.1.14",
33
33
  "@nktkas/hyperliquid": "^0.31.0",
34
34
  "chalk": "^5.3.0",
35
35
  "commander": "^12.0.0",