@exagent/agent 0.1.12 → 0.1.14
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-BSNYL2DK.mjs +3005 -0
- package/dist/chunk-YWPRVCRB.mjs +3009 -0
- package/dist/cli.js +189 -203
- package/dist/cli.mjs +3 -3
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +216 -230
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/templates/.env.template +3 -4
- package/templates/docker-compose.yml +1 -1
- package/templates/strategy.template.ts +1 -1
package/dist/cli.js
CHANGED
|
@@ -779,7 +779,7 @@ export const generateSignals: StrategyFunction = async (marketData, llm, config)
|
|
|
779
779
|
riskWarnings: [
|
|
780
780
|
"Custom strategies have no guardrails - you are fully responsible",
|
|
781
781
|
"LLMs can hallucinate or make errors - always validate outputs",
|
|
782
|
-
"
|
|
782
|
+
"Start with small amounts before scaling up",
|
|
783
783
|
"Consider edge cases: what happens if the LLM returns invalid JSON?",
|
|
784
784
|
"Your prompts and strategy logic are your competitive advantage - protect them",
|
|
785
785
|
"Agents may not behave exactly as expected based on your prompts"
|
|
@@ -834,6 +834,158 @@ 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;
|
|
@@ -947,11 +1099,8 @@ var TOKEN_DECIMALS = {
|
|
|
947
1099
|
// cbBTC
|
|
948
1100
|
"0x2416092f143378750bb29b79ed961ab195cceea5": 18,
|
|
949
1101
|
// ezETH (Renzo)
|
|
950
|
-
"0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452": 18
|
|
1102
|
+
"0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452": 18
|
|
951
1103
|
// wstETH (Lido)
|
|
952
|
-
// Base Sepolia
|
|
953
|
-
"0x036cbd53842c5426634e7929541ec2318f3dcf7e": 6
|
|
954
|
-
// USDC testnet
|
|
955
1104
|
};
|
|
956
1105
|
function getTokenDecimals(address) {
|
|
957
1106
|
const decimals = TOKEN_DECIMALS[address.toLowerCase()];
|
|
@@ -1319,16 +1468,10 @@ var import_viem2 = require("viem");
|
|
|
1319
1468
|
var import_accounts = require("viem/accounts");
|
|
1320
1469
|
var import_chains = require("viem/chains");
|
|
1321
1470
|
var ADDRESSES = {
|
|
1322
|
-
testnet: {
|
|
1323
|
-
vaultFactory: "0x5c099daaE33801a907Bb57011c6749655b55dc75",
|
|
1324
|
-
registry: "0xCF48C341e3FebeCA5ECB7eb2535f61A2Ba855d9C",
|
|
1325
|
-
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
|
|
1326
|
-
},
|
|
1327
1471
|
mainnet: {
|
|
1328
1472
|
vaultFactory: process.env.EXAGENT_VAULT_FACTORY_ADDRESS || "0x0000000000000000000000000000000000000000",
|
|
1329
1473
|
registry: process.env.EXAGENT_REGISTRY_ADDRESS || "0x0000000000000000000000000000000000000000",
|
|
1330
1474
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
1331
|
-
// Base mainnet USDC
|
|
1332
1475
|
}
|
|
1333
1476
|
};
|
|
1334
1477
|
var VAULT_FACTORY_ABI = [
|
|
@@ -1410,8 +1553,8 @@ var VaultManager = class {
|
|
|
1410
1553
|
this.config = config;
|
|
1411
1554
|
this.addresses = ADDRESSES[config.network];
|
|
1412
1555
|
this.account = (0, import_accounts.privateKeyToAccount)(config.walletKey);
|
|
1413
|
-
this.chain =
|
|
1414
|
-
const rpcUrl =
|
|
1556
|
+
this.chain = import_chains.base;
|
|
1557
|
+
const rpcUrl = getRpcUrl();
|
|
1415
1558
|
this.publicClient = (0, import_viem2.createPublicClient)({
|
|
1416
1559
|
chain: this.chain,
|
|
1417
1560
|
transport: (0, import_viem2.http)(rpcUrl)
|
|
@@ -2119,7 +2262,7 @@ var AgentRuntime = class {
|
|
|
2119
2262
|
const message = error instanceof Error ? error.message : String(error);
|
|
2120
2263
|
if (message.includes("insufficient funds") || message.includes("gas") || message.includes("intrinsic gas too low") || message.includes("exceeds the balance")) {
|
|
2121
2264
|
const ccUrl = `https://exagent.io/agents/${encodeURIComponent(this.config.name)}/command-center`;
|
|
2122
|
-
const chain =
|
|
2265
|
+
const chain = import_chains2.base;
|
|
2123
2266
|
const publicClientInstance = (0, import_viem3.createPublicClient)({
|
|
2124
2267
|
chain,
|
|
2125
2268
|
transport: (0, import_viem3.http)(this.getRpcUrl())
|
|
@@ -2539,13 +2682,10 @@ var AgentRuntime = class {
|
|
|
2539
2682
|
}
|
|
2540
2683
|
}
|
|
2541
2684
|
/**
|
|
2542
|
-
* Get RPC URL
|
|
2685
|
+
* Get RPC URL from environment or default
|
|
2543
2686
|
*/
|
|
2544
2687
|
getRpcUrl() {
|
|
2545
|
-
|
|
2546
|
-
return "https://mainnet.base.org";
|
|
2547
|
-
}
|
|
2548
|
-
return "https://sepolia.base.org";
|
|
2688
|
+
return getRpcUrl();
|
|
2549
2689
|
}
|
|
2550
2690
|
/**
|
|
2551
2691
|
* Default tokens to track.
|
|
@@ -2553,42 +2693,36 @@ var AgentRuntime = class {
|
|
|
2553
2693
|
* agents in restricted risk universes will have ineligible tokens filtered out.
|
|
2554
2694
|
*/
|
|
2555
2695
|
getDefaultTokens() {
|
|
2556
|
-
if (this.config.network === "mainnet") {
|
|
2557
|
-
return [
|
|
2558
|
-
// Core
|
|
2559
|
-
"0x4200000000000000000000000000000000000006",
|
|
2560
|
-
// WETH
|
|
2561
|
-
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
2562
|
-
// USDC
|
|
2563
|
-
"0x2Ae3F1Ec7F1F5012CFEab0185bFC7aa3cf0DEC22",
|
|
2564
|
-
// cbETH
|
|
2565
|
-
"0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
|
|
2566
|
-
// USDbC
|
|
2567
|
-
"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
|
2568
|
-
// DAI
|
|
2569
|
-
// Established
|
|
2570
|
-
"0x940181a94A35A4569E4529A3CDfB74e38FD98631",
|
|
2571
|
-
// AERO
|
|
2572
|
-
"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
|
|
2573
|
-
// cbBTC
|
|
2574
|
-
"0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452",
|
|
2575
|
-
// wstETH
|
|
2576
|
-
"0x2416092f143378750bb29b79eD961ab195CcEea5",
|
|
2577
|
-
// ezETH
|
|
2578
|
-
// Emerging (filtered by risk universe at init)
|
|
2579
|
-
"0x532f27101965dd16442E59d40670FaF5eBB142E4",
|
|
2580
|
-
// BRETT
|
|
2581
|
-
"0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed",
|
|
2582
|
-
// DEGEN
|
|
2583
|
-
"0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
|
|
2584
|
-
// VIRTUAL
|
|
2585
|
-
"0xAC1Bd2486Aaf3B5C0fc3Fd868558b082a531B2B4"
|
|
2586
|
-
// TOSHI
|
|
2587
|
-
];
|
|
2588
|
-
}
|
|
2589
2696
|
return [
|
|
2590
|
-
|
|
2697
|
+
// Core
|
|
2698
|
+
"0x4200000000000000000000000000000000000006",
|
|
2591
2699
|
// WETH
|
|
2700
|
+
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
2701
|
+
// USDC
|
|
2702
|
+
"0x2Ae3F1Ec7F1F5012CFEab0185bFC7aa3cf0DEC22",
|
|
2703
|
+
// cbETH
|
|
2704
|
+
"0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
|
|
2705
|
+
// USDbC
|
|
2706
|
+
"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
|
2707
|
+
// DAI
|
|
2708
|
+
// Established
|
|
2709
|
+
"0x940181a94A35A4569E4529A3CDfB74e38FD98631",
|
|
2710
|
+
// AERO
|
|
2711
|
+
"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
|
|
2712
|
+
// cbBTC
|
|
2713
|
+
"0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452",
|
|
2714
|
+
// wstETH
|
|
2715
|
+
"0x2416092f143378750bb29b79eD961ab195CcEea5",
|
|
2716
|
+
// ezETH
|
|
2717
|
+
// Emerging (filtered by risk universe at init)
|
|
2718
|
+
"0x532f27101965dd16442E59d40670FaF5eBB142E4",
|
|
2719
|
+
// BRETT
|
|
2720
|
+
"0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed",
|
|
2721
|
+
// DEGEN
|
|
2722
|
+
"0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
|
|
2723
|
+
// VIRTUAL
|
|
2724
|
+
"0xAC1Bd2486Aaf3B5C0fc3Fd868558b082a531B2B4"
|
|
2725
|
+
// TOSHI
|
|
2592
2726
|
];
|
|
2593
2727
|
}
|
|
2594
2728
|
sleep(ms) {
|
|
@@ -2646,154 +2780,6 @@ var AgentRuntime = class {
|
|
|
2646
2780
|
}
|
|
2647
2781
|
};
|
|
2648
2782
|
|
|
2649
|
-
// src/config.ts
|
|
2650
|
-
var import_fs2 = require("fs");
|
|
2651
|
-
var import_path2 = require("path");
|
|
2652
|
-
var import_dotenv = require("dotenv");
|
|
2653
|
-
|
|
2654
|
-
// src/types.ts
|
|
2655
|
-
var import_zod = require("zod");
|
|
2656
|
-
var WalletSetupSchema = import_zod.z.enum(["generate", "provide"]);
|
|
2657
|
-
var LLMProviderSchema = import_zod.z.enum(["openai", "anthropic", "google", "deepseek", "mistral", "groq", "together", "ollama", "custom"]);
|
|
2658
|
-
var LLMConfigSchema = import_zod.z.object({
|
|
2659
|
-
provider: LLMProviderSchema,
|
|
2660
|
-
model: import_zod.z.string().optional(),
|
|
2661
|
-
apiKey: import_zod.z.string().optional(),
|
|
2662
|
-
endpoint: import_zod.z.string().url().optional(),
|
|
2663
|
-
temperature: import_zod.z.number().min(0).max(2).default(0.7),
|
|
2664
|
-
maxTokens: import_zod.z.number().positive().default(4096)
|
|
2665
|
-
});
|
|
2666
|
-
var RiskUniverseSchema = import_zod.z.enum(["core", "established", "derivatives", "emerging", "frontier"]);
|
|
2667
|
-
var TradingConfigSchema = import_zod.z.object({
|
|
2668
|
-
timeHorizon: import_zod.z.enum(["intraday", "swing", "position"]).default("swing"),
|
|
2669
|
-
maxPositionSizeBps: import_zod.z.number().min(100).max(1e4).default(1e3),
|
|
2670
|
-
// 1-100%
|
|
2671
|
-
maxDailyLossBps: import_zod.z.number().min(0).max(1e4).default(500),
|
|
2672
|
-
// 0-100%
|
|
2673
|
-
maxConcurrentPositions: import_zod.z.number().min(1).max(100).default(5),
|
|
2674
|
-
tradingIntervalMs: import_zod.z.number().min(1e3).default(6e4),
|
|
2675
|
-
// minimum 1 second
|
|
2676
|
-
maxSlippageBps: import_zod.z.number().min(10).max(1e3).default(100),
|
|
2677
|
-
// 0.1-10%, default 1%
|
|
2678
|
-
minTradeValueUSD: import_zod.z.number().min(0).default(1)
|
|
2679
|
-
// minimum trade value in USD
|
|
2680
|
-
});
|
|
2681
|
-
var VaultPolicySchema = import_zod.z.enum([
|
|
2682
|
-
"disabled",
|
|
2683
|
-
// Never create a vault - trade with agent's own capital only
|
|
2684
|
-
"manual"
|
|
2685
|
-
// Only create vault when explicitly directed by owner
|
|
2686
|
-
]);
|
|
2687
|
-
var VaultConfigSchema = import_zod.z.object({
|
|
2688
|
-
// Policy for vault creation (asked during deployment)
|
|
2689
|
-
policy: VaultPolicySchema.default("manual"),
|
|
2690
|
-
// Default vault name (auto-generated from agent name if not set)
|
|
2691
|
-
defaultName: import_zod.z.string().optional(),
|
|
2692
|
-
// Default vault symbol (auto-generated if not set)
|
|
2693
|
-
defaultSymbol: import_zod.z.string().optional(),
|
|
2694
|
-
// Fee recipient for vault fees (default: agent wallet)
|
|
2695
|
-
feeRecipient: import_zod.z.string().optional(),
|
|
2696
|
-
// When vault exists, trade through vault instead of direct trading
|
|
2697
|
-
// This pools depositors' capital with the agent's trades
|
|
2698
|
-
preferVaultTrading: import_zod.z.boolean().default(true)
|
|
2699
|
-
});
|
|
2700
|
-
var WalletConfigSchema = import_zod.z.object({
|
|
2701
|
-
setup: WalletSetupSchema.default("provide")
|
|
2702
|
-
}).optional();
|
|
2703
|
-
var RelayConfigSchema = import_zod.z.object({
|
|
2704
|
-
enabled: import_zod.z.boolean().default(false),
|
|
2705
|
-
apiUrl: import_zod.z.string().url(),
|
|
2706
|
-
heartbeatIntervalMs: import_zod.z.number().min(5e3).default(3e4)
|
|
2707
|
-
}).optional();
|
|
2708
|
-
var AgentConfigSchema = import_zod.z.object({
|
|
2709
|
-
// Identity (from on-chain registration)
|
|
2710
|
-
agentId: import_zod.z.union([import_zod.z.number().positive(), import_zod.z.string()]),
|
|
2711
|
-
name: import_zod.z.string().min(3).max(32),
|
|
2712
|
-
// Network
|
|
2713
|
-
network: import_zod.z.enum(["mainnet", "testnet"]).default("testnet"),
|
|
2714
|
-
// Wallet setup preference
|
|
2715
|
-
wallet: WalletConfigSchema,
|
|
2716
|
-
// LLM
|
|
2717
|
-
llm: LLMConfigSchema,
|
|
2718
|
-
// Trading parameters
|
|
2719
|
-
riskUniverse: RiskUniverseSchema.default("established"),
|
|
2720
|
-
trading: TradingConfigSchema.default({}),
|
|
2721
|
-
// Vault configuration (copy trading)
|
|
2722
|
-
vault: VaultConfigSchema.default({}),
|
|
2723
|
-
// Relay configuration (command center)
|
|
2724
|
-
relay: RelayConfigSchema,
|
|
2725
|
-
// Allowed tokens (addresses)
|
|
2726
|
-
allowedTokens: import_zod.z.array(import_zod.z.string()).optional()
|
|
2727
|
-
});
|
|
2728
|
-
|
|
2729
|
-
// src/config.ts
|
|
2730
|
-
function loadConfig(configPath) {
|
|
2731
|
-
(0, import_dotenv.config)();
|
|
2732
|
-
const configFile = configPath || process.env.EXAGENT_CONFIG || "agent-config.json";
|
|
2733
|
-
const fullPath = configFile.startsWith("/") ? configFile : (0, import_path2.join)(process.cwd(), configFile);
|
|
2734
|
-
if (!(0, import_fs2.existsSync)(fullPath)) {
|
|
2735
|
-
throw new Error(`Config file not found: ${fullPath}`);
|
|
2736
|
-
}
|
|
2737
|
-
const rawConfig = JSON.parse((0, import_fs2.readFileSync)(fullPath, "utf-8"));
|
|
2738
|
-
const config = AgentConfigSchema.parse(rawConfig);
|
|
2739
|
-
const privateKey = process.env.EXAGENT_PRIVATE_KEY;
|
|
2740
|
-
if (privateKey && (!privateKey.startsWith("0x") || privateKey.length !== 66)) {
|
|
2741
|
-
throw new Error("EXAGENT_PRIVATE_KEY must be a valid 32-byte hex string starting with 0x");
|
|
2742
|
-
}
|
|
2743
|
-
const llmConfig = { ...config.llm };
|
|
2744
|
-
if (process.env.OPENAI_API_KEY && config.llm.provider === "openai") {
|
|
2745
|
-
llmConfig.apiKey = process.env.OPENAI_API_KEY;
|
|
2746
|
-
}
|
|
2747
|
-
if (process.env.ANTHROPIC_API_KEY && config.llm.provider === "anthropic") {
|
|
2748
|
-
llmConfig.apiKey = process.env.ANTHROPIC_API_KEY;
|
|
2749
|
-
}
|
|
2750
|
-
if (process.env.GOOGLE_AI_API_KEY && config.llm.provider === "google") {
|
|
2751
|
-
llmConfig.apiKey = process.env.GOOGLE_AI_API_KEY;
|
|
2752
|
-
}
|
|
2753
|
-
if (process.env.DEEPSEEK_API_KEY && config.llm.provider === "deepseek") {
|
|
2754
|
-
llmConfig.apiKey = process.env.DEEPSEEK_API_KEY;
|
|
2755
|
-
}
|
|
2756
|
-
if (process.env.MISTRAL_API_KEY && config.llm.provider === "mistral") {
|
|
2757
|
-
llmConfig.apiKey = process.env.MISTRAL_API_KEY;
|
|
2758
|
-
}
|
|
2759
|
-
if (process.env.GROQ_API_KEY && config.llm.provider === "groq") {
|
|
2760
|
-
llmConfig.apiKey = process.env.GROQ_API_KEY;
|
|
2761
|
-
}
|
|
2762
|
-
if (process.env.TOGETHER_API_KEY && config.llm.provider === "together") {
|
|
2763
|
-
llmConfig.apiKey = process.env.TOGETHER_API_KEY;
|
|
2764
|
-
}
|
|
2765
|
-
if (process.env.EXAGENT_LLM_URL) {
|
|
2766
|
-
llmConfig.endpoint = process.env.EXAGENT_LLM_URL;
|
|
2767
|
-
}
|
|
2768
|
-
if (process.env.EXAGENT_LLM_MODEL) {
|
|
2769
|
-
llmConfig.model = process.env.EXAGENT_LLM_MODEL;
|
|
2770
|
-
}
|
|
2771
|
-
const network = process.env.EXAGENT_NETWORK || config.network;
|
|
2772
|
-
return {
|
|
2773
|
-
...config,
|
|
2774
|
-
llm: llmConfig,
|
|
2775
|
-
network,
|
|
2776
|
-
privateKey: privateKey || ""
|
|
2777
|
-
};
|
|
2778
|
-
}
|
|
2779
|
-
function validateConfig(config) {
|
|
2780
|
-
if (!config.privateKey) {
|
|
2781
|
-
throw new Error("Private key is required");
|
|
2782
|
-
}
|
|
2783
|
-
if (config.llm.provider !== "ollama" && !config.llm.apiKey) {
|
|
2784
|
-
throw new Error(`API key required for ${config.llm.provider} provider`);
|
|
2785
|
-
}
|
|
2786
|
-
if (config.llm.provider === "ollama" && !config.llm.endpoint) {
|
|
2787
|
-
config.llm.endpoint = "http://localhost:11434";
|
|
2788
|
-
}
|
|
2789
|
-
if (config.llm.provider === "custom" && !config.llm.endpoint) {
|
|
2790
|
-
throw new Error("Endpoint required for custom LLM provider");
|
|
2791
|
-
}
|
|
2792
|
-
if (!config.agentId || Number(config.agentId) <= 0) {
|
|
2793
|
-
throw new Error("Valid agent ID required");
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
|
|
2797
2783
|
// src/cli.ts
|
|
2798
2784
|
var import_accounts3 = require("viem/accounts");
|
|
2799
2785
|
|
|
@@ -3151,7 +3137,7 @@ async function checkFirstRunSetup(configPath) {
|
|
|
3151
3137
|
EXAGENT_PRIVATE_KEY=${privateKey}
|
|
3152
3138
|
|
|
3153
3139
|
# Network
|
|
3154
|
-
EXAGENT_NETWORK=${config.network || "
|
|
3140
|
+
EXAGENT_NETWORK=${config.network || "mainnet"}
|
|
3155
3141
|
|
|
3156
3142
|
# LLM (${llmProvider})
|
|
3157
3143
|
${llmEnvVar}EXAGENT_LLM_MODEL=${config.llm?.model || ""}
|
|
@@ -3202,7 +3188,7 @@ ${llmEnvVar}EXAGENT_LLM_MODEL=${config.llm?.model || ""}
|
|
|
3202
3188
|
console.log("");
|
|
3203
3189
|
if (walletSetup === "generate") {
|
|
3204
3190
|
console.log(" NEXT: Fund your wallet before starting to trade.");
|
|
3205
|
-
console.log(` Send
|
|
3191
|
+
console.log(` Send ETH to: ${walletAddress}`);
|
|
3206
3192
|
}
|
|
3207
3193
|
console.log("");
|
|
3208
3194
|
console.log(" The agent will now start...");
|
package/dist/cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
loadConfig,
|
|
7
7
|
loadSecureEnv,
|
|
8
8
|
validateConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YWPRVCRB.mjs";
|
|
10
10
|
|
|
11
11
|
// src/cli.ts
|
|
12
12
|
import { Command } from "commander";
|
|
@@ -184,7 +184,7 @@ async function checkFirstRunSetup(configPath) {
|
|
|
184
184
|
EXAGENT_PRIVATE_KEY=${privateKey}
|
|
185
185
|
|
|
186
186
|
# Network
|
|
187
|
-
EXAGENT_NETWORK=${config.network || "
|
|
187
|
+
EXAGENT_NETWORK=${config.network || "mainnet"}
|
|
188
188
|
|
|
189
189
|
# LLM (${llmProvider})
|
|
190
190
|
${llmEnvVar}EXAGENT_LLM_MODEL=${config.llm?.model || ""}
|
|
@@ -235,7 +235,7 @@ ${llmEnvVar}EXAGENT_LLM_MODEL=${config.llm?.model || ""}
|
|
|
235
235
|
console.log("");
|
|
236
236
|
if (walletSetup === "generate") {
|
|
237
237
|
console.log(" NEXT: Fund your wallet before starting to trade.");
|
|
238
|
-
console.log(` Send
|
|
238
|
+
console.log(` Send ETH to: ${walletAddress}`);
|
|
239
239
|
}
|
|
240
240
|
console.log("");
|
|
241
241
|
console.log(" The agent will now start...");
|
package/dist/index.d.mts
CHANGED
|
@@ -94,7 +94,7 @@ type RelayConfig$1 = z.infer<typeof RelayConfigSchema>;
|
|
|
94
94
|
declare const AgentConfigSchema: z.ZodObject<{
|
|
95
95
|
agentId: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
96
96
|
name: z.ZodString;
|
|
97
|
-
network: z.ZodDefault<z.
|
|
97
|
+
network: z.ZodDefault<z.ZodLiteral<"mainnet">>;
|
|
98
98
|
wallet: z.ZodOptional<z.ZodObject<{
|
|
99
99
|
setup: z.ZodDefault<z.ZodEnum<["generate", "provide"]>>;
|
|
100
100
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -186,7 +186,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
186
186
|
}, "strip", z.ZodTypeAny, {
|
|
187
187
|
agentId: string | number;
|
|
188
188
|
name: string;
|
|
189
|
-
network: "mainnet"
|
|
189
|
+
network: "mainnet";
|
|
190
190
|
llm: {
|
|
191
191
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
192
192
|
temperature: number;
|
|
@@ -232,7 +232,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
232
232
|
temperature?: number | undefined;
|
|
233
233
|
maxTokens?: number | undefined;
|
|
234
234
|
};
|
|
235
|
-
network?: "mainnet" |
|
|
235
|
+
network?: "mainnet" | undefined;
|
|
236
236
|
wallet?: {
|
|
237
237
|
setup?: "generate" | "provide" | undefined;
|
|
238
238
|
} | undefined;
|
|
@@ -334,7 +334,7 @@ interface VaultStatus {
|
|
|
334
334
|
interface VaultManagerConfig {
|
|
335
335
|
agentId: bigint;
|
|
336
336
|
agentName: string;
|
|
337
|
-
network: 'mainnet'
|
|
337
|
+
network: 'mainnet';
|
|
338
338
|
walletKey: `0x${string}`;
|
|
339
339
|
vaultConfig: VaultConfig;
|
|
340
340
|
}
|
|
@@ -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
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ type RelayConfig$1 = z.infer<typeof RelayConfigSchema>;
|
|
|
94
94
|
declare const AgentConfigSchema: z.ZodObject<{
|
|
95
95
|
agentId: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
96
96
|
name: z.ZodString;
|
|
97
|
-
network: z.ZodDefault<z.
|
|
97
|
+
network: z.ZodDefault<z.ZodLiteral<"mainnet">>;
|
|
98
98
|
wallet: z.ZodOptional<z.ZodObject<{
|
|
99
99
|
setup: z.ZodDefault<z.ZodEnum<["generate", "provide"]>>;
|
|
100
100
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -186,7 +186,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
186
186
|
}, "strip", z.ZodTypeAny, {
|
|
187
187
|
agentId: string | number;
|
|
188
188
|
name: string;
|
|
189
|
-
network: "mainnet"
|
|
189
|
+
network: "mainnet";
|
|
190
190
|
llm: {
|
|
191
191
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
192
192
|
temperature: number;
|
|
@@ -232,7 +232,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
232
232
|
temperature?: number | undefined;
|
|
233
233
|
maxTokens?: number | undefined;
|
|
234
234
|
};
|
|
235
|
-
network?: "mainnet" |
|
|
235
|
+
network?: "mainnet" | undefined;
|
|
236
236
|
wallet?: {
|
|
237
237
|
setup?: "generate" | "provide" | undefined;
|
|
238
238
|
} | undefined;
|
|
@@ -334,7 +334,7 @@ interface VaultStatus {
|
|
|
334
334
|
interface VaultManagerConfig {
|
|
335
335
|
agentId: bigint;
|
|
336
336
|
agentName: string;
|
|
337
|
-
network: 'mainnet'
|
|
337
|
+
network: 'mainnet';
|
|
338
338
|
walletKey: `0x${string}`;
|
|
339
339
|
vaultConfig: VaultConfig;
|
|
340
340
|
}
|
|
@@ -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
|
/**
|