@aiaiaichain/agent 0.1.6 → 0.1.7

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.
Files changed (121) hide show
  1. package/dist/api/ExtensionAPI.d.ts +0 -1
  2. package/dist/api/ExtensionAPI.js +3 -7
  3. package/dist/api/Registry.d.ts +0 -1
  4. package/dist/api/Registry.js +54 -57
  5. package/dist/cli.d.ts +0 -1
  6. package/dist/cli.js +683 -686
  7. package/dist/core/AgentDir.d.ts +1 -1
  8. package/dist/core/AgentDir.js +45 -39
  9. package/dist/core/ChainConfig.d.ts +0 -1
  10. package/dist/core/ChainConfig.js +51 -55
  11. package/dist/core/EnvLoader.d.ts +4 -1
  12. package/dist/core/EnvLoader.js +97 -84
  13. package/dist/core/SystemMonitor.d.ts +0 -1
  14. package/dist/core/SystemMonitor.js +72 -85
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.js +19 -26
  17. package/dist/loader.d.ts +0 -1
  18. package/dist/loader.js +64 -67
  19. package/dist/mcp/entry.d.ts +0 -1
  20. package/dist/mcp/entry.js +3 -6
  21. package/dist/mcp/server.d.ts +0 -1
  22. package/dist/mcp/server.js +152 -156
  23. package/dist/models/CostTracker.d.ts +0 -1
  24. package/dist/models/CostTracker.js +58 -61
  25. package/dist/models/ModelRegistry.d.ts +0 -1
  26. package/dist/models/ModelRegistry.js +195 -155
  27. package/dist/providers/ProviderRegistry.d.ts +0 -1
  28. package/dist/providers/ProviderRegistry.js +33 -36
  29. package/dist/runner/AgentRunner.d.ts +0 -1
  30. package/dist/runner/AgentRunner.js +180 -184
  31. package/dist/runner/ModelClient.d.ts +0 -1
  32. package/dist/runner/ModelClient.js +133 -134
  33. package/dist/runner/SwarmRouter.d.ts +0 -1
  34. package/dist/runner/SwarmRouter.js +18 -22
  35. package/dist/runner/ToolDispatcher.d.ts +0 -1
  36. package/dist/runner/ToolDispatcher.js +30 -33
  37. package/dist/scheduler/AgentScheduler.d.ts +0 -1
  38. package/dist/scheduler/AgentScheduler.js +99 -103
  39. package/dist/session/ContextStore.d.ts +1 -1
  40. package/dist/session/ContextStore.js +76 -78
  41. package/dist/session/GoalManager.d.ts +0 -1
  42. package/dist/session/GoalManager.js +96 -100
  43. package/dist/session/MemoryStore.d.ts +2 -1
  44. package/dist/session/MemoryStore.js +108 -87
  45. package/dist/session/SessionManager.d.ts +5 -4
  46. package/dist/session/SessionManager.js +83 -62
  47. package/dist/session/SessionStore.d.ts +0 -1
  48. package/dist/session/SessionStore.js +112 -116
  49. package/dist/setup/SetupWizard.d.ts +0 -1
  50. package/dist/setup/SetupWizard.js +61 -64
  51. package/dist/tools/CrossTools.d.ts +0 -1
  52. package/dist/tools/CrossTools.js +140 -144
  53. package/dist/tools/GmgnIntegration.d.ts +0 -1
  54. package/dist/tools/GmgnIntegration.js +220 -230
  55. package/dist/tools/MarketSentiment.d.ts +0 -1
  56. package/dist/tools/MarketSentiment.js +213 -195
  57. package/dist/tools/NewsSentiment.d.ts +0 -1
  58. package/dist/tools/NewsSentiment.js +126 -130
  59. package/dist/tools/PriceFeed.d.ts +6 -1
  60. package/dist/tools/PriceFeed.js +201 -133
  61. package/dist/tools/TechnicalAnalysis.d.ts +1 -2
  62. package/dist/tools/TechnicalAnalysis.js +248 -216
  63. package/dist/tools/TechnicalAnalysis.worker.d.ts +25 -0
  64. package/dist/tools/TechnicalAnalysis.worker.js +92 -0
  65. package/dist/tools/TokenCalendar.d.ts +0 -1
  66. package/dist/tools/TokenCalendar.js +63 -68
  67. package/dist/tools/TokenSecurityScanner.d.ts +0 -1
  68. package/dist/tools/TokenSecurityScanner.js +93 -96
  69. package/dist/tools/TransactionSim.d.ts +0 -1
  70. package/dist/tools/TransactionSim.js +65 -71
  71. package/dist/tui/App.d.ts +0 -1
  72. package/dist/tui/App.js +895 -824
  73. package/dist/tui/ModelSelector.d.ts +0 -1
  74. package/dist/tui/ModelSelector.js +46 -49
  75. package/dist/tui/REPL.d.ts +0 -1
  76. package/dist/tui/REPL.js +222 -210
  77. package/dist/tui/Sparkline.d.ts +0 -1
  78. package/dist/tui/Sparkline.js +36 -37
  79. package/dist/tui/StatusBar.d.ts +0 -1
  80. package/dist/tui/StatusBar.js +9 -10
  81. package/dist/tui/ThemePresets.d.ts +0 -1
  82. package/dist/tui/ThemePresets.js +99 -103
  83. package/dist/tui/theme.d.ts +0 -1
  84. package/dist/tui/theme.js +50 -31
  85. package/dist/util/clipboard.d.ts +0 -1
  86. package/dist/util/clipboard.js +16 -20
  87. package/dist/util/commandSuggest.d.ts +0 -1
  88. package/dist/util/commandSuggest.js +34 -38
  89. package/dist/util/confirmation.d.ts +0 -1
  90. package/dist/util/confirmation.js +8 -11
  91. package/dist/util/errorHandler.d.ts +0 -1
  92. package/dist/util/errorHandler.js +20 -23
  93. package/dist/util/errors.d.ts +59 -0
  94. package/dist/util/errors.js +93 -0
  95. package/dist/util/logger.d.ts +0 -1
  96. package/dist/util/logger.js +30 -33
  97. package/dist/util/processManager.d.ts +0 -1
  98. package/dist/util/processManager.js +33 -36
  99. package/dist/util/resilientFetch.d.ts +6 -1
  100. package/dist/util/resilientFetch.js +134 -80
  101. package/dist/util/responseCache.d.ts +0 -1
  102. package/dist/util/responseCache.js +36 -45
  103. package/dist/util/rpc.d.ts +16 -0
  104. package/dist/util/rpc.js +69 -0
  105. package/dist/util/safeLog.d.ts +0 -1
  106. package/dist/util/safeLog.js +52 -53
  107. package/dist/util/scheduler.d.ts +0 -1
  108. package/dist/util/scheduler.js +53 -58
  109. package/dist/util/webhooks.d.ts +0 -1
  110. package/dist/util/webhooks.js +54 -58
  111. package/dist/wallet/ActionFeed.d.ts +0 -1
  112. package/dist/wallet/ActionFeed.js +189 -200
  113. package/dist/wallet/AgentWallet.d.ts +7 -8
  114. package/dist/wallet/AgentWallet.js +117 -144
  115. package/dist/wallet/ProfitTracker.d.ts +0 -1
  116. package/dist/wallet/ProfitTracker.js +71 -74
  117. package/package.json +11 -6
  118. package/scripts/build-esbuild.mjs +40 -0
  119. package/scripts/bundle-dts.mjs +58 -0
  120. package/scripts/minify.mjs +44 -0
  121. package/scripts/postinstall.js +27 -0
@@ -1,13 +1,4 @@
1
- /**
2
- * GMGN integration — token research, smart money tracking, market data.
3
- * Auto-manages GMGN_API_KEY. Provides tools for the agent.
4
- *
5
- * Token usage optimization:
6
- * - Cache token info for 60s
7
- * - Cache trending/trenches for 120s
8
- * - Cache kline for 30s
9
- * - Track commands use weight 3, so we batch when possible
10
- */
1
+
11
2
  import { existsSync, readFileSync, writeFileSync, mkdirSync, chmodSync } from "node:fs";
12
3
  import { resolve, join } from "node:path";
13
4
  import { homedir } from "node:os";
@@ -15,250 +6,249 @@ import { execSync } from "node:child_process";
15
6
  import { Type } from "@sinclair/typebox";
16
7
  const GMGN_ENV_DIR = resolve(homedir(), ".config", "gmgn");
17
8
  const GMGN_ENV_PATH = join(GMGN_ENV_DIR, ".env");
18
- // ── Env management ──────────────────────────────────────────────────────────
9
+
19
10
  function ensureGmgnEnv() {
20
- if (!existsSync(GMGN_ENV_DIR))
21
- mkdirSync(GMGN_ENV_DIR, { recursive: true });
11
+ if (!existsSync(GMGN_ENV_DIR))
12
+ mkdirSync(GMGN_ENV_DIR, { recursive: true });
22
13
  }
23
14
  function readGmgnEnv() {
24
- const env = {};
25
- if (existsSync(GMGN_ENV_PATH)) {
26
- const content = readFileSync(GMGN_ENV_PATH, "utf-8");
27
- for (const line of content.split("\n")) {
28
- const trimmed = line.trim();
29
- if (!trimmed || trimmed.startsWith("#"))
30
- continue;
31
- const eqIdx = trimmed.indexOf("=");
32
- if (eqIdx === -1)
33
- continue;
34
- const key = trimmed.slice(0, eqIdx).trim();
35
- const value = trimmed.slice(eqIdx + 1).trim();
36
- if (key)
37
- env[key] = value;
38
- }
39
- }
40
- for (const key of Object.keys(process.env)) {
41
- const val = process.env[key];
42
- if (val)
43
- env[key] = val;
44
- }
45
- return env;
15
+ const env = {};
16
+ if (existsSync(GMGN_ENV_PATH)) {
17
+ const content = readFileSync(GMGN_ENV_PATH, "utf-8");
18
+ for (const line of content.split("\n")) {
19
+ const trimmed = line.trim();
20
+ if (!trimmed || trimmed.startsWith("#"))
21
+ continue;
22
+ const eqIdx = trimmed.indexOf("=");
23
+ if (eqIdx === -1)
24
+ continue;
25
+ const key = trimmed.slice(0, eqIdx).trim();
26
+ const value = trimmed.slice(eqIdx + 1).trim();
27
+ if (key)
28
+ env[key] = value;
29
+ }
30
+ }
31
+ for (const key of Object.keys(process.env)) {
32
+ const val = process.env[key];
33
+ if (val)
34
+ env[key] = val;
35
+ }
36
+ return env;
46
37
  }
47
38
  function writeGmgnKey(key, value) {
48
- ensureGmgnEnv();
49
- const env = readGmgnEnv();
50
- env[key] = value;
51
- const lines = Object.entries(env).map(([k, v]) => `${k}=${v}`);
52
- writeFileSync(GMGN_ENV_PATH, lines.join("\n") + "\n", "utf-8");
53
- try {
54
- chmodSync(GMGN_ENV_PATH, 0o600);
55
- }
56
- catch { /* non-fatal */ }
57
- process.env[key] = value;
39
+ ensureGmgnEnv();
40
+ const env = readGmgnEnv();
41
+ env[key] = value;
42
+ const lines = Object.entries(env).map(([k, v]) => `${k}=${v}`);
43
+ writeFileSync(GMGN_ENV_PATH, lines.join("\n") + "\n", "utf-8");
44
+ try {
45
+ chmodSync(GMGN_ENV_PATH, 0o600);
46
+ }
47
+ catch { }
48
+ process.env[key] = value;
58
49
  }
59
50
  export function getGmgnApiKey() {
60
- return readGmgnEnv().GMGN_API_KEY;
51
+ return readGmgnEnv().GMGN_API_KEY;
61
52
  }
62
53
  export function hasGmgnApiKey() {
63
- const key = getGmgnApiKey();
64
- return !!key && key.trim() !== "";
54
+ const key = getGmgnApiKey();
55
+ return !!key && key.trim() !== "";
65
56
  }
66
57
  export function saveGmgnApiKey(key) {
67
- writeGmgnKey("GMGN_API_KEY", key);
58
+ writeGmgnKey("GMGN_API_KEY", key);
68
59
  }
69
60
  function gmgnEnv() {
70
- return { ...process.env, ...readGmgnEnv() };
61
+ return { ...process.env, ...readGmgnEnv() };
71
62
  }
72
63
  function gmgnAvailable() {
73
- try {
74
- execSync("which gmgn-cli", { stdio: "ignore" });
75
- return true;
76
- }
77
- catch {
78
- return false;
79
- }
80
- }
81
- // ── Sub-command definitions ─────────────────────────────────────────────────
64
+ try {
65
+ execSync("which gmgn-cli", { stdio: "ignore" });
66
+ return true;
67
+ }
68
+ catch {
69
+ return false;
70
+ }
71
+ }
72
+
82
73
  export const GMGN_SUBCOMMANDS = [
83
- { name: "token info", desc: "Token price, market cap, liquidity, holders, socials", usage: "gmgn token info --chain <sol|bsc|base|eth> --address <address>" },
84
- { name: "token security", desc: "Honeypot, taxes, rug ratio, contract risks", usage: "gmgn token security --chain <chain> --address <address>" },
85
- { name: "token pool", desc: "Liquidity pool reserves, DEX, depth", usage: "gmgn token pool --chain <chain> --address <address>" },
86
- { name: "token holders", desc: "Top holders with P&L breakdown", usage: "gmgn token holders --chain <chain> --address <address>" },
87
- { name: "token traders", desc: "Top traders with P&L breakdown", usage: "gmgn token traders --chain <chain> --address <address>" },
88
- { name: "track follow-tokens", desc: "Tokens a wallet follows on GMGN", usage: "gmgn track follow-tokens --chain <chain> --wallet <address>" },
89
- { name: "track follow-wallet", desc: "Trades from wallets you follow", usage: "gmgn track follow-wallet --chain <chain>" },
90
- { name: "track kol", desc: "KOL/influencer trade activity", usage: "gmgn track kol --chain <chain>" },
91
- { name: "track smartmoney", desc: "Smart money/whale trade activity", usage: "gmgn track smartmoney --chain <chain>" },
92
- { name: "market kline", desc: "Token candlestick / OHLCV chart data", usage: "gmgn market kline --chain <chain> --address <address> --resolution <1m|5m|15m|1h|4h|1d>" },
93
- { name: "market trending", desc: "Trending tokens ranked by swaps", usage: "gmgn market trending --chain <chain> --interval <1m|5m|1h|6h|24h>" },
94
- { name: "market trenches", desc: "Newly launched tokens (new/near/completed)", usage: "gmgn market trenches --chain <chain> --type <new_creation|near_completion|completed>" },
95
- { name: "market signal", desc: "Real-time token signals (sol/bsc only)", usage: "gmgn market signal --chain <sol|bsc>" },
74
+ { name: "token info", desc: "Token price, market cap, liquidity, holders, socials", usage: "gmgn token info --chain <sol|bsc|base|eth> --address <address>" },
75
+ { name: "token security", desc: "Honeypot, taxes, rug ratio, contract risks", usage: "gmgn token security --chain <chain> --address <address>" },
76
+ { name: "token pool", desc: "Liquidity pool reserves, DEX, depth", usage: "gmgn token pool --chain <chain> --address <address>" },
77
+ { name: "token holders", desc: "Top holders with P&L breakdown", usage: "gmgn token holders --chain <chain> --address <address>" },
78
+ { name: "token traders", desc: "Top traders with P&L breakdown", usage: "gmgn token traders --chain <chain> --address <address>" },
79
+ { name: "track follow-tokens", desc: "Tokens a wallet follows on GMGN", usage: "gmgn track follow-tokens --chain <chain> --wallet <address>" },
80
+ { name: "track follow-wallet", desc: "Trades from wallets you follow", usage: "gmgn track follow-wallet --chain <chain>" },
81
+ { name: "track kol", desc: "KOL/influencer trade activity", usage: "gmgn track kol --chain <chain>" },
82
+ { name: "track smartmoney", desc: "Smart money/whale trade activity", usage: "gmgn track smartmoney --chain <chain>" },
83
+ { name: "market kline", desc: "Token candlestick / OHLCV chart data", usage: "gmgn market kline --chain <chain> --address <address> --resolution <1m|5m|15m|1h|4h|1d>" },
84
+ { name: "market trending", desc: "Trending tokens ranked by swaps", usage: "gmgn market trending --chain <chain> --interval <1m|5m|1h|6h|24h>" },
85
+ { name: "market trenches", desc: "Newly launched tokens (new/near/completed)", usage: "gmgn market trenches --chain <chain> --type <new_creation|near_completion|completed>" },
86
+ { name: "market signal", desc: "Real-time token signals (sol/bsc only)", usage: "gmgn market signal --chain <sol|bsc>" },
96
87
  ];
97
88
  export const gmgnHelp = () => {
98
- const groups = [
99
- { title: "── Token Research ──────────────────────────────────", filter: (s) => s.startsWith("token") },
100
- { title: "── Smart Money Tracking ───────────────────────────", filter: (s) => s.startsWith("track") },
101
- { title: "── Market Data ────────────────────────────────────", filter: (s) => s.startsWith("market") },
102
- ];
103
- const lines = ["🔍 GMGN — Token Research, Tracking & Market Data", "", "Usage: gmgn <sub-command> [options]", ""];
104
- for (const group of groups) {
105
- lines.push(group.title);
106
- for (const cmd of GMGN_SUBCOMMANDS.filter(c => group.filter(c.name))) {
107
- lines.push(` ${cmd.name.padEnd(20)} ${cmd.desc}`);
108
- lines.push(` ${cmd.usage}`);
109
- }
110
- lines.push("");
111
- }
112
- lines.push("── Setup ─────────────────────────────────────────");
113
- lines.push(" gmgn setup Configure GMGN_API_KEY");
114
- lines.push(" gmgn status Check API key + CLI status");
115
- lines.push("");
116
- if (!gmgnAvailable())
117
- lines.push(" ⚠️ gmgn-cli not installed. Run: npm install -g gmgn-cli");
118
- if (!hasGmgnApiKey())
119
- lines.push(" ⚠️ GMGN_API_KEY not set. Run: gmgn setup");
120
- return lines.join("\n");
89
+ const groups = [
90
+ { title: "── Token Research ──────────────────────────────────", filter: (s) => s.startsWith("token") },
91
+ { title: "── Smart Money Tracking ───────────────────────────", filter: (s) => s.startsWith("track") },
92
+ { title: "── Market Data ────────────────────────────────────", filter: (s) => s.startsWith("market") },
93
+ ];
94
+ const lines = ["🔍 GMGN — Token Research, Tracking & Market Data", "", "Usage: gmgn <sub-command> [options]", ""];
95
+ for (const group of groups) {
96
+ lines.push(group.title);
97
+ for (const cmd of GMGN_SUBCOMMANDS.filter(c => group.filter(c.name))) {
98
+ lines.push(` ${cmd.name.padEnd(20)} ${cmd.desc}`);
99
+ lines.push(` ${cmd.usage}`);
100
+ }
101
+ lines.push("");
102
+ }
103
+ lines.push("── Setup ─────────────────────────────────────────");
104
+ lines.push(" gmgn setup Configure GMGN_API_KEY");
105
+ lines.push(" gmgn status Check API key + CLI status");
106
+ lines.push("");
107
+ if (!gmgnAvailable())
108
+ lines.push(" ⚠️ gmgn-cli not installed. Run: npm install -g gmgn-cli");
109
+ if (!hasGmgnApiKey())
110
+ lines.push(" ⚠️ GMGN_API_KEY not set. Run: gmgn setup");
111
+ return lines.join("\n");
121
112
  };
122
113
  export const gmgnStatus = () => {
123
- return [
124
- "🔍 GMGN Status",
125
- "",
126
- `CLI installed: ${gmgnAvailable() ? "✅ yes" : "❌ no (npm install -g gmgn-cli)"}`,
127
- `API key configured: ${hasGmgnApiKey() ? "✅ yes" : "❌ no (gmgn setup)"}`,
128
- hasGmgnApiKey() ? `Key: ${getGmgnApiKey().slice(0, 6)}••••${getGmgnApiKey().slice(-4)}` : "",
129
- ].filter(Boolean).join("\n");
114
+ return [
115
+ "🔍 GMGN Status",
116
+ "",
117
+ `CLI installed: ${gmgnAvailable() ? "✅ yes" : "❌ no (npm install -g gmgn-cli)"}`,
118
+ `API key configured: ${hasGmgnApiKey() ? "✅ yes" : "❌ no (gmgn setup)"}`,
119
+ hasGmgnApiKey() ? `Key: ${getGmgnApiKey().slice(0, 6)}••••${getGmgnApiKey().slice(-4)}` : "",
120
+ ].filter(Boolean).join("\n");
130
121
  };
131
- // ── Agent Tool ───────────────────────────────────────────────────────────────
122
+
132
123
  export const gmgnToolParams = Type.Object({
133
- subcommand: Type.String({ description: "GMGN sub-command: token info, token security, token holders, token traders, track kol, track smartmoney, track follow-wallet, track follow-tokens, market kline, market trending, market trenches, market signal" }),
134
- chain: Type.Optional(Type.String({ description: "Chain: sol, bsc, base, eth" })),
135
- address: Type.Optional(Type.String({ description: "Token contract address" })),
136
- wallet: Type.Optional(Type.String({ description: "Wallet address for track commands" })),
137
- limit: Type.Optional(Type.Number({ description: "Number of results" })),
138
- resolution: Type.Optional(Type.String({ description: "Kline resolution: 1m, 5m, 15m, 1h, 4h, 1d" })),
139
- interval: Type.Optional(Type.String({ description: "Trending interval: 1m, 5m, 1h, 6h, 24h" })),
140
- type: Type.Optional(Type.String({ description: "Trenches type: new_creation, near_completion, completed" })),
124
+ subcommand: Type.String({ description: "GMGN sub-command: token info, token security, token holders, token traders, track kol, track smartmoney, track follow-wallet, track follow-tokens, market kline, market trending, market trenches, market signal" }),
125
+ chain: Type.Optional(Type.String({ description: "Chain: sol, bsc, base, eth" })),
126
+ address: Type.Optional(Type.String({ description: "Token contract address" })),
127
+ wallet: Type.Optional(Type.String({ description: "Wallet address for track commands" })),
128
+ limit: Type.Optional(Type.Number({ description: "Number of results" })),
129
+ resolution: Type.Optional(Type.String({ description: "Kline resolution: 1m, 5m, 15m, 1h, 4h, 1d" })),
130
+ interval: Type.Optional(Type.String({ description: "Trending interval: 1m, 5m, 1h, 6h, 24h" })),
131
+ type: Type.Optional(Type.String({ description: "Trenches type: new_creation, near_completion, completed" })),
141
132
  });
142
133
  export async function gmgnTool(_id, params) {
143
- if (!gmgnAvailable()) {
144
- return { content: [{ type: "text", text: "gmgn-cli is not installed. Run: npm install -g gmgn-cli" }], isError: true };
145
- }
146
- if (!hasGmgnApiKey()) {
147
- return { content: [{ type: "text", text: "GMGN_API_KEY is not configured. Run 'gmgn setup' or tell the agent to configure it." }], isError: true };
148
- }
149
- const sub = params.subcommand;
150
- const chain = params.chain || "sol";
151
- const address = params.address;
152
- const wallet = params.wallet;
153
- const limit = params.limit;
154
- const resolution = params.resolution;
155
- const interval = params.interval;
156
- const trenchesType = params.type;
157
- const args = ["gmgn-cli", sub];
158
- // Build args based on subcommand type
159
- if (["token info", "token security", "token pool", "token holders", "token traders"].includes(sub)) {
160
- if (!address)
161
- return { content: [{ type: "text", text: `--address is required for '${sub}'` }], isError: true };
162
- args.push("--chain", chain, "--address", address);
163
- if (limit && (sub === "token holders" || sub === "token traders"))
164
- args.push("--limit", String(limit));
165
- }
166
- else if (sub === "market kline") {
167
- if (!address)
168
- return { content: [{ type: "text", text: `--address is required for '${sub}'` }], isError: true };
169
- if (!resolution)
170
- return { content: [{ type: "text", text: `--resolution is required for '${sub}'` }], isError: true };
171
- args.push("--chain", chain, "--address", address, "--resolution", resolution);
172
- }
173
- else if (sub === "market trending") {
174
- args.push("--chain", chain);
175
- if (interval)
176
- args.push("--interval", interval);
177
- if (limit)
178
- args.push("--limit", String(limit));
179
- }
180
- else if (sub === "market trenches") {
181
- args.push("--chain", chain);
182
- if (trenchesType)
183
- args.push("--type", trenchesType);
184
- if (limit)
185
- args.push("--limit", String(limit));
186
- }
187
- else if (sub === "market signal") {
188
- args.push("--chain", chain);
189
- if (limit)
190
- args.push("--limit", String(limit));
191
- }
192
- else if (sub === "track follow-tokens" || sub === "track follow-token-groups") {
193
- if (!wallet)
194
- return { content: [{ type: "text", text: `--wallet is required for '${sub}'` }], isError: true };
195
- args.push("--chain", chain, "--wallet", wallet);
196
- }
197
- else if (sub === "track follow-wallet") {
198
- args.push("--chain", chain);
199
- if (wallet)
200
- args.push("--wallet", wallet);
201
- }
202
- else if (sub === "track kol" || sub === "track smartmoney") {
203
- args.push("--chain", chain);
204
- if (limit)
205
- args.push("--limit", String(limit));
206
- }
207
- try {
208
- const output = execSync(args.join(" "), {
209
- env: gmgnEnv(),
210
- encoding: "utf-8",
211
- timeout: 30_000,
212
- });
213
- return { content: [{ type: "text", text: output.trim() }] };
214
- }
215
- catch (e) {
216
- const msg = e.stderr?.toString() || e.message || "";
217
- if (msg.includes("401") || msg.includes("403")) {
218
- return { content: [{ type: "text", text: "GMGN API key invalid or IPv6 issue. Run 'gmgn status'." }], isError: true };
219
- }
220
- if (msg.includes("429")) {
221
- return { content: [{ type: "text", text: "GMGN rate limit exceeded. Wait and retry." }], isError: true };
222
- }
223
- return { content: [{ type: "text", text: `gmgn-cli error: ${msg.slice(0, 500)}` }], isError: true };
224
- }
225
- }
226
- // ── Market tool (shortcut for agent) ────────────────────────────────────────
134
+ if (!gmgnAvailable()) {
135
+ return { content: [{ type: "text", text: "gmgn-cli is not installed. Run: npm install -g gmgn-cli" }], isError: true };
136
+ }
137
+ if (!hasGmgnApiKey()) {
138
+ return { content: [{ type: "text", text: "GMGN_API_KEY is not configured. Run 'gmgn setup' or tell the agent to configure it." }], isError: true };
139
+ }
140
+ const sub = params.subcommand;
141
+ const chain = params.chain || "sol";
142
+ const address = params.address;
143
+ const wallet = params.wallet;
144
+ const limit = params.limit;
145
+ const resolution = params.resolution;
146
+ const interval = params.interval;
147
+ const trenchesType = params.type;
148
+ const args = ["gmgn-cli", sub];
149
+
150
+ if (["token info", "token security", "token pool", "token holders", "token traders"].includes(sub)) {
151
+ if (!address)
152
+ return { content: [{ type: "text", text: `--address is required for '${sub}'` }], isError: true };
153
+ args.push("--chain", chain, "--address", address);
154
+ if (limit && (sub === "token holders" || sub === "token traders"))
155
+ args.push("--limit", String(limit));
156
+ }
157
+ else if (sub === "market kline") {
158
+ if (!address)
159
+ return { content: [{ type: "text", text: `--address is required for '${sub}'` }], isError: true };
160
+ if (!resolution)
161
+ return { content: [{ type: "text", text: `--resolution is required for '${sub}'` }], isError: true };
162
+ args.push("--chain", chain, "--address", address, "--resolution", resolution);
163
+ }
164
+ else if (sub === "market trending") {
165
+ args.push("--chain", chain);
166
+ if (interval)
167
+ args.push("--interval", interval);
168
+ if (limit)
169
+ args.push("--limit", String(limit));
170
+ }
171
+ else if (sub === "market trenches") {
172
+ args.push("--chain", chain);
173
+ if (trenchesType)
174
+ args.push("--type", trenchesType);
175
+ if (limit)
176
+ args.push("--limit", String(limit));
177
+ }
178
+ else if (sub === "market signal") {
179
+ args.push("--chain", chain);
180
+ if (limit)
181
+ args.push("--limit", String(limit));
182
+ }
183
+ else if (sub === "track follow-tokens" || sub === "track follow-token-groups") {
184
+ if (!wallet)
185
+ return { content: [{ type: "text", text: `--wallet is required for '${sub}'` }], isError: true };
186
+ args.push("--chain", chain, "--wallet", wallet);
187
+ }
188
+ else if (sub === "track follow-wallet") {
189
+ args.push("--chain", chain);
190
+ if (wallet)
191
+ args.push("--wallet", wallet);
192
+ }
193
+ else if (sub === "track kol" || sub === "track smartmoney") {
194
+ args.push("--chain", chain);
195
+ if (limit)
196
+ args.push("--limit", String(limit));
197
+ }
198
+ try {
199
+ const output = execSync(args.join(" "), {
200
+ env: gmgnEnv(),
201
+ encoding: "utf-8",
202
+ timeout: 30_000,
203
+ });
204
+ return { content: [{ type: "text", text: output.trim() }] };
205
+ }
206
+ catch (e) {
207
+ const msg = e.stderr?.toString() || e.message || "";
208
+ if (msg.includes("401") || msg.includes("403")) {
209
+ return { content: [{ type: "text", text: "GMGN API key invalid or IPv6 issue. Run 'gmgn status'." }], isError: true };
210
+ }
211
+ if (msg.includes("429")) {
212
+ return { content: [{ type: "text", text: "GMGN rate limit exceeded. Wait and retry." }], isError: true };
213
+ }
214
+ return { content: [{ type: "text", text: `gmgn-cli error: ${msg.slice(0, 500)}` }], isError: true };
215
+ }
216
+ }
217
+
227
218
  export const gmgnMarketToolParams = Type.Object({
228
- query: Type.String({ description: "What to look up: trending, trenches, kline <address>, holders <address>, traders <address>, signal" }),
229
- chain: Type.Optional(Type.String({ default: "sol" })),
219
+ query: Type.String({ description: "What to look up: trending, trenches, kline <address>, holders <address>, traders <address>, signal" }),
220
+ chain: Type.Optional(Type.String({ default: "sol" })),
230
221
  });
231
222
  export async function gmgnMarketTool(_id, params) {
232
- const query = (params.query || "").toLowerCase().trim();
233
- const chain = params.chain || "sol";
234
- // Parse natural language queries
235
- if (query === "trending" || query === "hot" || query === "pumping") {
236
- return gmgnTool("", { subcommand: "market trending", chain, interval: "1h", limit: 10 });
237
- }
238
- if (query === "trenches" || query === "new tokens" || query === "launches") {
239
- return gmgnTool("", { subcommand: "market trenches", chain, type: "new_creation", limit: 10 });
240
- }
241
- if (query === "signal" || query === "signals" || query === "alerts") {
242
- return gmgnTool("", { subcommand: "market signal", chain: chain === "sol" ? "sol" : "sol", limit: 10 });
243
- }
244
- if (query.startsWith("kline ") || query.startsWith("chart ")) {
245
- const addr = query.split(" ").pop();
246
- if (!addr)
247
- return { content: [{ type: "text", text: "Usage: gmgn market kline <address>" }], isError: true };
248
- return gmgnTool("", { subcommand: "market kline", chain, address: addr, resolution: "1h" });
249
- }
250
- if (query.startsWith("holders ") || query.startsWith("traders ")) {
251
- const parts = query.split(" ");
252
- const sub = parts[0] === "holders" ? "token holders" : "token traders";
253
- const addr = parts[1];
254
- if (!addr)
255
- return { content: [{ type: "text", text: `Usage: gmgn ${sub} <address>` }], isError: true };
256
- return gmgnTool("", { subcommand: sub, chain, address: addr, limit: 10 });
257
- }
258
- // Default: try as address for token info
259
- if (query.length > 20) {
260
- return gmgnTool("", { subcommand: "token info", chain, address: query });
261
- }
262
- return { content: [{ type: "text", text: "Usage: gmgn market <trending|trenches|signal|kline <addr>|holders <addr>|traders <addr>>" }], isError: true };
263
- }
264
- //# sourceMappingURL=GmgnIntegration.js.map
223
+ const query = (params.query || "").toLowerCase().trim();
224
+ const chain = params.chain || "sol";
225
+
226
+ if (query === "trending" || query === "hot" || query === "pumping") {
227
+ return gmgnTool("", { subcommand: "market trending", chain, interval: "1h", limit: 10 });
228
+ }
229
+ if (query === "trenches" || query === "new tokens" || query === "launches") {
230
+ return gmgnTool("", { subcommand: "market trenches", chain, type: "new_creation", limit: 10 });
231
+ }
232
+ if (query === "signal" || query === "signals" || query === "alerts") {
233
+ return gmgnTool("", { subcommand: "market signal", chain: chain === "sol" ? "sol" : "sol", limit: 10 });
234
+ }
235
+ if (query.startsWith("kline ") || query.startsWith("chart ")) {
236
+ const addr = query.split(" ").pop();
237
+ if (!addr)
238
+ return { content: [{ type: "text", text: "Usage: gmgn market kline <address>" }], isError: true };
239
+ return gmgnTool("", { subcommand: "market kline", chain, address: addr, resolution: "1h" });
240
+ }
241
+ if (query.startsWith("holders ") || query.startsWith("traders ")) {
242
+ const parts = query.split(" ");
243
+ const sub = parts[0] === "holders" ? "token holders" : "token traders";
244
+ const addr = parts[1];
245
+ if (!addr)
246
+ return { content: [{ type: "text", text: `Usage: gmgn ${sub} <address>` }], isError: true };
247
+ return gmgnTool("", { subcommand: sub, chain, address: addr, limit: 10 });
248
+ }
249
+
250
+ if (query.length > 20) {
251
+ return gmgnTool("", { subcommand: "token info", chain, address: query });
252
+ }
253
+ return { content: [{ type: "text", text: "Usage: gmgn market <trending|trenches|signal|kline <addr>|holders <addr>|traders <addr>>" }], isError: true };
254
+ }
@@ -17,4 +17,3 @@ export declare const defiTvlParams: import("@sinclair/typebox").TObject<{
17
17
  export declare function getDefiTvlTool(_id: string, params: Record<string, unknown>): Promise<ToolResult>;
18
18
  export declare const solanaStatsParams: import("@sinclair/typebox").TObject<{}>;
19
19
  export declare function getSolanaStatsTool(): Promise<ToolResult>;
20
- //# sourceMappingURL=MarketSentiment.d.ts.map