@exagent/agent 0.1.13 → 0.1.15
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-W2FU5T46.mjs +3058 -0
- package/dist/chunk-YWPRVCRB.mjs +3009 -0
- package/dist/cli.js +221 -168
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +250 -197
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -834,14 +834,168 @@ function getAllStrategyTemplates() {
|
|
|
834
834
|
return STRATEGY_TEMPLATES;
|
|
835
835
|
}
|
|
836
836
|
|
|
837
|
+
// src/config.ts
|
|
838
|
+
var import_fs2 = require("fs");
|
|
839
|
+
var import_path2 = require("path");
|
|
840
|
+
var import_dotenv = require("dotenv");
|
|
841
|
+
|
|
842
|
+
// src/types.ts
|
|
843
|
+
var import_zod = require("zod");
|
|
844
|
+
var WalletSetupSchema = import_zod.z.enum(["generate", "provide"]);
|
|
845
|
+
var LLMProviderSchema = import_zod.z.enum(["openai", "anthropic", "google", "deepseek", "mistral", "groq", "together", "ollama", "custom"]);
|
|
846
|
+
var LLMConfigSchema = import_zod.z.object({
|
|
847
|
+
provider: LLMProviderSchema,
|
|
848
|
+
model: import_zod.z.string().optional(),
|
|
849
|
+
apiKey: import_zod.z.string().optional(),
|
|
850
|
+
endpoint: import_zod.z.string().url().optional(),
|
|
851
|
+
temperature: import_zod.z.number().min(0).max(2).default(0.7),
|
|
852
|
+
maxTokens: import_zod.z.number().positive().default(4096)
|
|
853
|
+
});
|
|
854
|
+
var RiskUniverseSchema = import_zod.z.enum(["core", "established", "derivatives", "emerging", "frontier"]);
|
|
855
|
+
var TradingConfigSchema = import_zod.z.object({
|
|
856
|
+
timeHorizon: import_zod.z.enum(["intraday", "swing", "position"]).default("swing"),
|
|
857
|
+
maxPositionSizeBps: import_zod.z.number().min(100).max(1e4).default(1e3),
|
|
858
|
+
// 1-100%
|
|
859
|
+
maxDailyLossBps: import_zod.z.number().min(0).max(1e4).default(500),
|
|
860
|
+
// 0-100%
|
|
861
|
+
maxConcurrentPositions: import_zod.z.number().min(1).max(100).default(5),
|
|
862
|
+
tradingIntervalMs: import_zod.z.number().min(1e3).default(6e4),
|
|
863
|
+
// minimum 1 second
|
|
864
|
+
maxSlippageBps: import_zod.z.number().min(10).max(1e3).default(100),
|
|
865
|
+
// 0.1-10%, default 1%
|
|
866
|
+
minTradeValueUSD: import_zod.z.number().min(0).default(1)
|
|
867
|
+
// minimum trade value in USD
|
|
868
|
+
});
|
|
869
|
+
var VaultPolicySchema = import_zod.z.enum([
|
|
870
|
+
"disabled",
|
|
871
|
+
// Never create a vault - trade with agent's own capital only
|
|
872
|
+
"manual"
|
|
873
|
+
// Only create vault when explicitly directed by owner
|
|
874
|
+
]);
|
|
875
|
+
var VaultConfigSchema = import_zod.z.object({
|
|
876
|
+
// Policy for vault creation (asked during deployment)
|
|
877
|
+
policy: VaultPolicySchema.default("manual"),
|
|
878
|
+
// Default vault name (auto-generated from agent name if not set)
|
|
879
|
+
defaultName: import_zod.z.string().optional(),
|
|
880
|
+
// Default vault symbol (auto-generated if not set)
|
|
881
|
+
defaultSymbol: import_zod.z.string().optional(),
|
|
882
|
+
// Fee recipient for vault fees (default: agent wallet)
|
|
883
|
+
feeRecipient: import_zod.z.string().optional(),
|
|
884
|
+
// When vault exists, trade through vault instead of direct trading
|
|
885
|
+
// This pools depositors' capital with the agent's trades
|
|
886
|
+
preferVaultTrading: import_zod.z.boolean().default(true)
|
|
887
|
+
});
|
|
888
|
+
var WalletConfigSchema = import_zod.z.object({
|
|
889
|
+
setup: WalletSetupSchema.default("provide")
|
|
890
|
+
}).optional();
|
|
891
|
+
var RelayConfigSchema = import_zod.z.object({
|
|
892
|
+
enabled: import_zod.z.boolean().default(false),
|
|
893
|
+
apiUrl: import_zod.z.string().url(),
|
|
894
|
+
heartbeatIntervalMs: import_zod.z.number().min(5e3).default(3e4)
|
|
895
|
+
}).optional();
|
|
896
|
+
var AgentConfigSchema = import_zod.z.object({
|
|
897
|
+
// Identity (from on-chain registration)
|
|
898
|
+
agentId: import_zod.z.union([import_zod.z.number().positive(), import_zod.z.string()]),
|
|
899
|
+
name: import_zod.z.string().min(3).max(32),
|
|
900
|
+
// Network
|
|
901
|
+
network: import_zod.z.literal("mainnet").default("mainnet"),
|
|
902
|
+
// Wallet setup preference
|
|
903
|
+
wallet: WalletConfigSchema,
|
|
904
|
+
// LLM
|
|
905
|
+
llm: LLMConfigSchema,
|
|
906
|
+
// Trading parameters
|
|
907
|
+
riskUniverse: RiskUniverseSchema.default("established"),
|
|
908
|
+
trading: TradingConfigSchema.default({}),
|
|
909
|
+
// Vault configuration (copy trading)
|
|
910
|
+
vault: VaultConfigSchema.default({}),
|
|
911
|
+
// Relay configuration (command center)
|
|
912
|
+
relay: RelayConfigSchema,
|
|
913
|
+
// Allowed tokens (addresses)
|
|
914
|
+
allowedTokens: import_zod.z.array(import_zod.z.string()).optional()
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
// src/config.ts
|
|
918
|
+
function loadConfig(configPath) {
|
|
919
|
+
(0, import_dotenv.config)();
|
|
920
|
+
const configFile = configPath || process.env.EXAGENT_CONFIG || "agent-config.json";
|
|
921
|
+
const fullPath = configFile.startsWith("/") ? configFile : (0, import_path2.join)(process.cwd(), configFile);
|
|
922
|
+
if (!(0, import_fs2.existsSync)(fullPath)) {
|
|
923
|
+
throw new Error(`Config file not found: ${fullPath}`);
|
|
924
|
+
}
|
|
925
|
+
const rawConfig = JSON.parse((0, import_fs2.readFileSync)(fullPath, "utf-8"));
|
|
926
|
+
const config = AgentConfigSchema.parse(rawConfig);
|
|
927
|
+
const privateKey = process.env.EXAGENT_PRIVATE_KEY;
|
|
928
|
+
if (privateKey && (!privateKey.startsWith("0x") || privateKey.length !== 66)) {
|
|
929
|
+
throw new Error("EXAGENT_PRIVATE_KEY must be a valid 32-byte hex string starting with 0x");
|
|
930
|
+
}
|
|
931
|
+
const llmConfig = { ...config.llm };
|
|
932
|
+
if (process.env.OPENAI_API_KEY && config.llm.provider === "openai") {
|
|
933
|
+
llmConfig.apiKey = process.env.OPENAI_API_KEY;
|
|
934
|
+
}
|
|
935
|
+
if (process.env.ANTHROPIC_API_KEY && config.llm.provider === "anthropic") {
|
|
936
|
+
llmConfig.apiKey = process.env.ANTHROPIC_API_KEY;
|
|
937
|
+
}
|
|
938
|
+
if (process.env.GOOGLE_AI_API_KEY && config.llm.provider === "google") {
|
|
939
|
+
llmConfig.apiKey = process.env.GOOGLE_AI_API_KEY;
|
|
940
|
+
}
|
|
941
|
+
if (process.env.DEEPSEEK_API_KEY && config.llm.provider === "deepseek") {
|
|
942
|
+
llmConfig.apiKey = process.env.DEEPSEEK_API_KEY;
|
|
943
|
+
}
|
|
944
|
+
if (process.env.MISTRAL_API_KEY && config.llm.provider === "mistral") {
|
|
945
|
+
llmConfig.apiKey = process.env.MISTRAL_API_KEY;
|
|
946
|
+
}
|
|
947
|
+
if (process.env.GROQ_API_KEY && config.llm.provider === "groq") {
|
|
948
|
+
llmConfig.apiKey = process.env.GROQ_API_KEY;
|
|
949
|
+
}
|
|
950
|
+
if (process.env.TOGETHER_API_KEY && config.llm.provider === "together") {
|
|
951
|
+
llmConfig.apiKey = process.env.TOGETHER_API_KEY;
|
|
952
|
+
}
|
|
953
|
+
if (process.env.EXAGENT_LLM_URL) {
|
|
954
|
+
llmConfig.endpoint = process.env.EXAGENT_LLM_URL;
|
|
955
|
+
}
|
|
956
|
+
if (process.env.EXAGENT_LLM_MODEL) {
|
|
957
|
+
llmConfig.model = process.env.EXAGENT_LLM_MODEL;
|
|
958
|
+
}
|
|
959
|
+
const network = process.env.EXAGENT_NETWORK || config.network;
|
|
960
|
+
return {
|
|
961
|
+
...config,
|
|
962
|
+
llm: llmConfig,
|
|
963
|
+
network,
|
|
964
|
+
privateKey: privateKey || ""
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
function validateConfig(config) {
|
|
968
|
+
if (!config.privateKey) {
|
|
969
|
+
throw new Error("Private key is required");
|
|
970
|
+
}
|
|
971
|
+
if (config.llm.provider !== "ollama" && !config.llm.apiKey) {
|
|
972
|
+
throw new Error(`API key required for ${config.llm.provider} provider`);
|
|
973
|
+
}
|
|
974
|
+
if (config.llm.provider === "ollama" && !config.llm.endpoint) {
|
|
975
|
+
config.llm.endpoint = "http://localhost:11434";
|
|
976
|
+
}
|
|
977
|
+
if (config.llm.provider === "custom" && !config.llm.endpoint) {
|
|
978
|
+
throw new Error("Endpoint required for custom LLM provider");
|
|
979
|
+
}
|
|
980
|
+
if (!config.agentId || Number(config.agentId) <= 0) {
|
|
981
|
+
throw new Error("Valid agent ID required");
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
var DEFAULT_RPC_URL = "https://base-rpc.publicnode.com";
|
|
985
|
+
function getRpcUrl() {
|
|
986
|
+
return process.env.BASE_RPC_URL || process.env.EXAGENT_RPC_URL || DEFAULT_RPC_URL;
|
|
987
|
+
}
|
|
988
|
+
|
|
837
989
|
// src/trading/executor.ts
|
|
838
990
|
var TradeExecutor = class {
|
|
839
991
|
client;
|
|
840
992
|
config;
|
|
841
993
|
allowedTokens;
|
|
842
|
-
|
|
994
|
+
configHashFn;
|
|
995
|
+
constructor(client, config, configHashFn) {
|
|
843
996
|
this.client = client;
|
|
844
997
|
this.config = config;
|
|
998
|
+
this.configHashFn = configHashFn;
|
|
845
999
|
this.allowedTokens = new Set(
|
|
846
1000
|
(config.allowedTokens || []).map((t) => t.toLowerCase())
|
|
847
1001
|
);
|
|
@@ -859,11 +1013,13 @@ var TradeExecutor = class {
|
|
|
859
1013
|
if (!this.validateSignal(signal)) {
|
|
860
1014
|
return { success: false, error: "Signal exceeds position limits" };
|
|
861
1015
|
}
|
|
1016
|
+
const configHash = this.configHashFn?.();
|
|
862
1017
|
const result = await this.client.trade({
|
|
863
1018
|
tokenIn: signal.tokenIn,
|
|
864
1019
|
tokenOut: signal.tokenOut,
|
|
865
1020
|
amountIn: signal.amountIn,
|
|
866
|
-
maxSlippageBps: this.config.trading?.maxSlippageBps ?? 100
|
|
1021
|
+
maxSlippageBps: this.config.trading?.maxSlippageBps ?? 100,
|
|
1022
|
+
...configHash && { configHash }
|
|
867
1023
|
});
|
|
868
1024
|
console.log(`Trade executed: ${result.hash}`);
|
|
869
1025
|
return { success: true, txHash: result.hash };
|
|
@@ -1402,7 +1558,7 @@ var VaultManager = class {
|
|
|
1402
1558
|
this.addresses = ADDRESSES[config.network];
|
|
1403
1559
|
this.account = (0, import_accounts.privateKeyToAccount)(config.walletKey);
|
|
1404
1560
|
this.chain = import_chains.base;
|
|
1405
|
-
const rpcUrl =
|
|
1561
|
+
const rpcUrl = getRpcUrl();
|
|
1406
1562
|
this.publicClient = (0, import_viem2.createPublicClient)({
|
|
1407
1563
|
chain: this.chain,
|
|
1408
1564
|
transport: (0, import_viem2.http)(rpcUrl)
|
|
@@ -1925,7 +2081,7 @@ var AgentRuntime = class {
|
|
|
1925
2081
|
console.log(`LLM ready: ${llmMeta.provider} (${llmMeta.model})`);
|
|
1926
2082
|
await this.syncConfigHash();
|
|
1927
2083
|
this.strategy = await loadStrategy();
|
|
1928
|
-
this.executor = new TradeExecutor(this.client, this.config);
|
|
2084
|
+
this.executor = new TradeExecutor(this.client, this.config, () => this.getConfigHash());
|
|
1929
2085
|
this.riskManager = new RiskManager(this.config.trading);
|
|
1930
2086
|
this.marketData = new MarketDataService(this.getRpcUrl());
|
|
1931
2087
|
await this.initializeVaultManager();
|
|
@@ -2530,10 +2686,10 @@ var AgentRuntime = class {
|
|
|
2530
2686
|
}
|
|
2531
2687
|
}
|
|
2532
2688
|
/**
|
|
2533
|
-
* Get RPC URL
|
|
2689
|
+
* Get RPC URL from environment or default
|
|
2534
2690
|
*/
|
|
2535
2691
|
getRpcUrl() {
|
|
2536
|
-
return
|
|
2692
|
+
return getRpcUrl();
|
|
2537
2693
|
}
|
|
2538
2694
|
/**
|
|
2539
2695
|
* Default tokens to track.
|
|
@@ -2542,35 +2698,80 @@ var AgentRuntime = class {
|
|
|
2542
2698
|
*/
|
|
2543
2699
|
getDefaultTokens() {
|
|
2544
2700
|
return [
|
|
2545
|
-
// Core
|
|
2701
|
+
// Core (0)
|
|
2546
2702
|
"0x4200000000000000000000000000000000000006",
|
|
2547
2703
|
// WETH
|
|
2548
2704
|
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
2549
2705
|
// USDC
|
|
2550
2706
|
"0x2Ae3F1Ec7F1F5012CFEab0185bFC7aa3cf0DEC22",
|
|
2551
2707
|
// cbETH
|
|
2552
|
-
"0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
|
|
2553
|
-
// USDbC
|
|
2554
|
-
"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
|
2555
|
-
// DAI
|
|
2556
|
-
// Established
|
|
2557
|
-
"0x940181a94A35A4569E4529A3CDfB74e38FD98631",
|
|
2558
|
-
// AERO
|
|
2559
2708
|
"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
|
|
2560
2709
|
// cbBTC
|
|
2561
2710
|
"0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452",
|
|
2562
2711
|
// wstETH
|
|
2712
|
+
"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
|
2713
|
+
// DAI
|
|
2714
|
+
"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
|
|
2715
|
+
// USDT
|
|
2716
|
+
"0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
|
|
2717
|
+
// USDbC
|
|
2718
|
+
"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",
|
|
2719
|
+
// EURC
|
|
2720
|
+
"0xB6fe221Fe9EeF5aBa221c348bA20A1Bf5e73624c",
|
|
2721
|
+
// rETH
|
|
2722
|
+
"0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
|
|
2723
|
+
// WBTC
|
|
2724
|
+
// Established (1) - filtered by risk universe at init
|
|
2725
|
+
"0x940181a94A35A4569E4529A3CDfB74e38FD98631",
|
|
2726
|
+
// AERO
|
|
2727
|
+
"0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A",
|
|
2728
|
+
// weETH
|
|
2563
2729
|
"0x2416092f143378750bb29b79eD961ab195CcEea5",
|
|
2564
2730
|
// ezETH
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2731
|
+
"0xA88594D404727625A9437C3f886C7643872296AE",
|
|
2732
|
+
// WELL
|
|
2733
|
+
"0xBAa5CC21fd487B8Fcc2F632f3F4E8D37262a0842",
|
|
2734
|
+
// MORPHO
|
|
2735
|
+
"0x88Fb150BDc53A65fe94Dea0c9BA0a6dAf8C6e196",
|
|
2736
|
+
// LINK
|
|
2737
|
+
"0xc3De830EA07524a0761646a6a4e4be0e114a3C83",
|
|
2738
|
+
// UNI
|
|
2739
|
+
"0x63706e401c06ac8513145b7687A14804d17f814b",
|
|
2740
|
+
// AAVE
|
|
2741
|
+
"0x9e1028F5F1D5eDE59748FFceE5532509976840E0",
|
|
2742
|
+
// COMP
|
|
2743
|
+
"0x4158734D47Fc9692176B5085E0F52ee0Da5d47F1",
|
|
2744
|
+
// BAL
|
|
2745
|
+
"0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415",
|
|
2746
|
+
// CRV
|
|
2747
|
+
"0x22e6966B799c4D5B13BE962E1D117b56327FDa66",
|
|
2748
|
+
// SNX
|
|
2749
|
+
// Derivatives (2) - filtered by risk universe at init
|
|
2570
2750
|
"0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
|
|
2571
2751
|
// VIRTUAL
|
|
2572
|
-
"
|
|
2752
|
+
"0x4F9Fd6Be4a90f2620860d680c0d4d5Fb53d1A825",
|
|
2753
|
+
// AIXBT
|
|
2754
|
+
"0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed",
|
|
2755
|
+
// DEGEN
|
|
2756
|
+
"0x0578d8A44db98B23BF096A382e016e29a5Ce0ffe",
|
|
2757
|
+
// HIGHER
|
|
2758
|
+
"0x1bc0c42215582d5A085795f4baDbaC3ff36d1Bcb",
|
|
2759
|
+
// CLANKER
|
|
2760
|
+
// Emerging (3) - filtered by risk universe at init
|
|
2761
|
+
"0x532f27101965dd16442E59d40670FaF5eBB142E4",
|
|
2762
|
+
// BRETT
|
|
2763
|
+
"0xAC1Bd2486aAf3B5C0fc3Fd868558b082a531B2B4",
|
|
2573
2764
|
// TOSHI
|
|
2765
|
+
"0x6921B130D297cc43754afba22e5EAc0FBf8Db75b",
|
|
2766
|
+
// DOGINME
|
|
2767
|
+
"0xB1a03EdA10342529bBF8EB700a06C60441fEf25d",
|
|
2768
|
+
// MIGGLES
|
|
2769
|
+
"0x7F12d13B34F5F4f0a9449c16Bcd42f0da47AF200",
|
|
2770
|
+
// NORMIE
|
|
2771
|
+
"0x27D2DECb4bFC9C76F0309b8E88dec3a601Fe25a8",
|
|
2772
|
+
// BALD
|
|
2773
|
+
"0x768BE13e1680b5ebE0024C42c896E3dB59ec0149"
|
|
2774
|
+
// SKI
|
|
2574
2775
|
];
|
|
2575
2776
|
}
|
|
2576
2777
|
sleep(ms) {
|
|
@@ -2628,154 +2829,6 @@ var AgentRuntime = class {
|
|
|
2628
2829
|
}
|
|
2629
2830
|
};
|
|
2630
2831
|
|
|
2631
|
-
// src/config.ts
|
|
2632
|
-
var import_fs2 = require("fs");
|
|
2633
|
-
var import_path2 = require("path");
|
|
2634
|
-
var import_dotenv = require("dotenv");
|
|
2635
|
-
|
|
2636
|
-
// src/types.ts
|
|
2637
|
-
var import_zod = require("zod");
|
|
2638
|
-
var WalletSetupSchema = import_zod.z.enum(["generate", "provide"]);
|
|
2639
|
-
var LLMProviderSchema = import_zod.z.enum(["openai", "anthropic", "google", "deepseek", "mistral", "groq", "together", "ollama", "custom"]);
|
|
2640
|
-
var LLMConfigSchema = import_zod.z.object({
|
|
2641
|
-
provider: LLMProviderSchema,
|
|
2642
|
-
model: import_zod.z.string().optional(),
|
|
2643
|
-
apiKey: import_zod.z.string().optional(),
|
|
2644
|
-
endpoint: import_zod.z.string().url().optional(),
|
|
2645
|
-
temperature: import_zod.z.number().min(0).max(2).default(0.7),
|
|
2646
|
-
maxTokens: import_zod.z.number().positive().default(4096)
|
|
2647
|
-
});
|
|
2648
|
-
var RiskUniverseSchema = import_zod.z.enum(["core", "established", "derivatives", "emerging", "frontier"]);
|
|
2649
|
-
var TradingConfigSchema = import_zod.z.object({
|
|
2650
|
-
timeHorizon: import_zod.z.enum(["intraday", "swing", "position"]).default("swing"),
|
|
2651
|
-
maxPositionSizeBps: import_zod.z.number().min(100).max(1e4).default(1e3),
|
|
2652
|
-
// 1-100%
|
|
2653
|
-
maxDailyLossBps: import_zod.z.number().min(0).max(1e4).default(500),
|
|
2654
|
-
// 0-100%
|
|
2655
|
-
maxConcurrentPositions: import_zod.z.number().min(1).max(100).default(5),
|
|
2656
|
-
tradingIntervalMs: import_zod.z.number().min(1e3).default(6e4),
|
|
2657
|
-
// minimum 1 second
|
|
2658
|
-
maxSlippageBps: import_zod.z.number().min(10).max(1e3).default(100),
|
|
2659
|
-
// 0.1-10%, default 1%
|
|
2660
|
-
minTradeValueUSD: import_zod.z.number().min(0).default(1)
|
|
2661
|
-
// minimum trade value in USD
|
|
2662
|
-
});
|
|
2663
|
-
var VaultPolicySchema = import_zod.z.enum([
|
|
2664
|
-
"disabled",
|
|
2665
|
-
// Never create a vault - trade with agent's own capital only
|
|
2666
|
-
"manual"
|
|
2667
|
-
// Only create vault when explicitly directed by owner
|
|
2668
|
-
]);
|
|
2669
|
-
var VaultConfigSchema = import_zod.z.object({
|
|
2670
|
-
// Policy for vault creation (asked during deployment)
|
|
2671
|
-
policy: VaultPolicySchema.default("manual"),
|
|
2672
|
-
// Default vault name (auto-generated from agent name if not set)
|
|
2673
|
-
defaultName: import_zod.z.string().optional(),
|
|
2674
|
-
// Default vault symbol (auto-generated if not set)
|
|
2675
|
-
defaultSymbol: import_zod.z.string().optional(),
|
|
2676
|
-
// Fee recipient for vault fees (default: agent wallet)
|
|
2677
|
-
feeRecipient: import_zod.z.string().optional(),
|
|
2678
|
-
// When vault exists, trade through vault instead of direct trading
|
|
2679
|
-
// This pools depositors' capital with the agent's trades
|
|
2680
|
-
preferVaultTrading: import_zod.z.boolean().default(true)
|
|
2681
|
-
});
|
|
2682
|
-
var WalletConfigSchema = import_zod.z.object({
|
|
2683
|
-
setup: WalletSetupSchema.default("provide")
|
|
2684
|
-
}).optional();
|
|
2685
|
-
var RelayConfigSchema = import_zod.z.object({
|
|
2686
|
-
enabled: import_zod.z.boolean().default(false),
|
|
2687
|
-
apiUrl: import_zod.z.string().url(),
|
|
2688
|
-
heartbeatIntervalMs: import_zod.z.number().min(5e3).default(3e4)
|
|
2689
|
-
}).optional();
|
|
2690
|
-
var AgentConfigSchema = import_zod.z.object({
|
|
2691
|
-
// Identity (from on-chain registration)
|
|
2692
|
-
agentId: import_zod.z.union([import_zod.z.number().positive(), import_zod.z.string()]),
|
|
2693
|
-
name: import_zod.z.string().min(3).max(32),
|
|
2694
|
-
// Network
|
|
2695
|
-
network: import_zod.z.literal("mainnet").default("mainnet"),
|
|
2696
|
-
// Wallet setup preference
|
|
2697
|
-
wallet: WalletConfigSchema,
|
|
2698
|
-
// LLM
|
|
2699
|
-
llm: LLMConfigSchema,
|
|
2700
|
-
// Trading parameters
|
|
2701
|
-
riskUniverse: RiskUniverseSchema.default("established"),
|
|
2702
|
-
trading: TradingConfigSchema.default({}),
|
|
2703
|
-
// Vault configuration (copy trading)
|
|
2704
|
-
vault: VaultConfigSchema.default({}),
|
|
2705
|
-
// Relay configuration (command center)
|
|
2706
|
-
relay: RelayConfigSchema,
|
|
2707
|
-
// Allowed tokens (addresses)
|
|
2708
|
-
allowedTokens: import_zod.z.array(import_zod.z.string()).optional()
|
|
2709
|
-
});
|
|
2710
|
-
|
|
2711
|
-
// src/config.ts
|
|
2712
|
-
function loadConfig(configPath) {
|
|
2713
|
-
(0, import_dotenv.config)();
|
|
2714
|
-
const configFile = configPath || process.env.EXAGENT_CONFIG || "agent-config.json";
|
|
2715
|
-
const fullPath = configFile.startsWith("/") ? configFile : (0, import_path2.join)(process.cwd(), configFile);
|
|
2716
|
-
if (!(0, import_fs2.existsSync)(fullPath)) {
|
|
2717
|
-
throw new Error(`Config file not found: ${fullPath}`);
|
|
2718
|
-
}
|
|
2719
|
-
const rawConfig = JSON.parse((0, import_fs2.readFileSync)(fullPath, "utf-8"));
|
|
2720
|
-
const config = AgentConfigSchema.parse(rawConfig);
|
|
2721
|
-
const privateKey = process.env.EXAGENT_PRIVATE_KEY;
|
|
2722
|
-
if (privateKey && (!privateKey.startsWith("0x") || privateKey.length !== 66)) {
|
|
2723
|
-
throw new Error("EXAGENT_PRIVATE_KEY must be a valid 32-byte hex string starting with 0x");
|
|
2724
|
-
}
|
|
2725
|
-
const llmConfig = { ...config.llm };
|
|
2726
|
-
if (process.env.OPENAI_API_KEY && config.llm.provider === "openai") {
|
|
2727
|
-
llmConfig.apiKey = process.env.OPENAI_API_KEY;
|
|
2728
|
-
}
|
|
2729
|
-
if (process.env.ANTHROPIC_API_KEY && config.llm.provider === "anthropic") {
|
|
2730
|
-
llmConfig.apiKey = process.env.ANTHROPIC_API_KEY;
|
|
2731
|
-
}
|
|
2732
|
-
if (process.env.GOOGLE_AI_API_KEY && config.llm.provider === "google") {
|
|
2733
|
-
llmConfig.apiKey = process.env.GOOGLE_AI_API_KEY;
|
|
2734
|
-
}
|
|
2735
|
-
if (process.env.DEEPSEEK_API_KEY && config.llm.provider === "deepseek") {
|
|
2736
|
-
llmConfig.apiKey = process.env.DEEPSEEK_API_KEY;
|
|
2737
|
-
}
|
|
2738
|
-
if (process.env.MISTRAL_API_KEY && config.llm.provider === "mistral") {
|
|
2739
|
-
llmConfig.apiKey = process.env.MISTRAL_API_KEY;
|
|
2740
|
-
}
|
|
2741
|
-
if (process.env.GROQ_API_KEY && config.llm.provider === "groq") {
|
|
2742
|
-
llmConfig.apiKey = process.env.GROQ_API_KEY;
|
|
2743
|
-
}
|
|
2744
|
-
if (process.env.TOGETHER_API_KEY && config.llm.provider === "together") {
|
|
2745
|
-
llmConfig.apiKey = process.env.TOGETHER_API_KEY;
|
|
2746
|
-
}
|
|
2747
|
-
if (process.env.EXAGENT_LLM_URL) {
|
|
2748
|
-
llmConfig.endpoint = process.env.EXAGENT_LLM_URL;
|
|
2749
|
-
}
|
|
2750
|
-
if (process.env.EXAGENT_LLM_MODEL) {
|
|
2751
|
-
llmConfig.model = process.env.EXAGENT_LLM_MODEL;
|
|
2752
|
-
}
|
|
2753
|
-
const network = process.env.EXAGENT_NETWORK || config.network;
|
|
2754
|
-
return {
|
|
2755
|
-
...config,
|
|
2756
|
-
llm: llmConfig,
|
|
2757
|
-
network,
|
|
2758
|
-
privateKey: privateKey || ""
|
|
2759
|
-
};
|
|
2760
|
-
}
|
|
2761
|
-
function validateConfig(config) {
|
|
2762
|
-
if (!config.privateKey) {
|
|
2763
|
-
throw new Error("Private key is required");
|
|
2764
|
-
}
|
|
2765
|
-
if (config.llm.provider !== "ollama" && !config.llm.apiKey) {
|
|
2766
|
-
throw new Error(`API key required for ${config.llm.provider} provider`);
|
|
2767
|
-
}
|
|
2768
|
-
if (config.llm.provider === "ollama" && !config.llm.endpoint) {
|
|
2769
|
-
config.llm.endpoint = "http://localhost:11434";
|
|
2770
|
-
}
|
|
2771
|
-
if (config.llm.provider === "custom" && !config.llm.endpoint) {
|
|
2772
|
-
throw new Error("Endpoint required for custom LLM provider");
|
|
2773
|
-
}
|
|
2774
|
-
if (!config.agentId || Number(config.agentId) <= 0) {
|
|
2775
|
-
throw new Error("Valid agent ID required");
|
|
2776
|
-
}
|
|
2777
|
-
}
|
|
2778
|
-
|
|
2779
2832
|
// src/cli.ts
|
|
2780
2833
|
var import_accounts3 = require("viem/accounts");
|
|
2781
2834
|
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -547,7 +547,7 @@ declare class AgentRuntime {
|
|
|
547
547
|
*/
|
|
548
548
|
stop(): void;
|
|
549
549
|
/**
|
|
550
|
-
* Get RPC URL
|
|
550
|
+
* Get RPC URL from environment or default
|
|
551
551
|
*/
|
|
552
552
|
private getRpcUrl;
|
|
553
553
|
/**
|
|
@@ -769,7 +769,8 @@ declare class TradeExecutor {
|
|
|
769
769
|
private client;
|
|
770
770
|
private config;
|
|
771
771
|
private allowedTokens;
|
|
772
|
-
|
|
772
|
+
private configHashFn?;
|
|
773
|
+
constructor(client: ExagentClient, config: RuntimeConfig, configHashFn?: () => string);
|
|
773
774
|
/**
|
|
774
775
|
* Execute a single trade signal
|
|
775
776
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -547,7 +547,7 @@ declare class AgentRuntime {
|
|
|
547
547
|
*/
|
|
548
548
|
stop(): void;
|
|
549
549
|
/**
|
|
550
|
-
* Get RPC URL
|
|
550
|
+
* Get RPC URL from environment or default
|
|
551
551
|
*/
|
|
552
552
|
private getRpcUrl;
|
|
553
553
|
/**
|
|
@@ -769,7 +769,8 @@ declare class TradeExecutor {
|
|
|
769
769
|
private client;
|
|
770
770
|
private config;
|
|
771
771
|
private allowedTokens;
|
|
772
|
-
|
|
772
|
+
private configHashFn?;
|
|
773
|
+
constructor(client: ExagentClient, config: RuntimeConfig, configHashFn?: () => string);
|
|
773
774
|
/**
|
|
774
775
|
* Execute a single trade signal
|
|
775
776
|
*/
|