@aiaiaichain/agent 0.1.5 → 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.
- package/dist/api/ExtensionAPI.d.ts +0 -1
- package/dist/api/ExtensionAPI.js +3 -7
- package/dist/api/Registry.d.ts +0 -1
- package/dist/api/Registry.js +54 -57
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +684 -685
- package/dist/core/AgentDir.d.ts +1 -1
- package/dist/core/AgentDir.js +45 -39
- package/dist/core/ChainConfig.d.ts +0 -1
- package/dist/core/ChainConfig.js +51 -55
- package/dist/core/EnvLoader.d.ts +4 -1
- package/dist/core/EnvLoader.js +97 -84
- package/dist/core/SystemMonitor.d.ts +0 -1
- package/dist/core/SystemMonitor.js +72 -85
- package/dist/index.d.ts +0 -1
- package/dist/index.js +19 -26
- package/dist/loader.d.ts +0 -1
- package/dist/loader.js +64 -67
- package/dist/mcp/entry.d.ts +0 -1
- package/dist/mcp/entry.js +3 -6
- package/dist/mcp/server.d.ts +0 -1
- package/dist/mcp/server.js +152 -156
- package/dist/models/CostTracker.d.ts +0 -1
- package/dist/models/CostTracker.js +58 -61
- package/dist/models/ModelRegistry.d.ts +0 -1
- package/dist/models/ModelRegistry.js +195 -155
- package/dist/providers/ProviderRegistry.d.ts +0 -1
- package/dist/providers/ProviderRegistry.js +33 -36
- package/dist/runner/AgentRunner.d.ts +0 -1
- package/dist/runner/AgentRunner.js +180 -184
- package/dist/runner/ModelClient.d.ts +0 -1
- package/dist/runner/ModelClient.js +133 -134
- package/dist/runner/SwarmRouter.d.ts +0 -1
- package/dist/runner/SwarmRouter.js +18 -22
- package/dist/runner/ToolDispatcher.d.ts +0 -1
- package/dist/runner/ToolDispatcher.js +30 -33
- package/dist/scheduler/AgentScheduler.d.ts +0 -1
- package/dist/scheduler/AgentScheduler.js +99 -103
- package/dist/session/ContextStore.d.ts +1 -1
- package/dist/session/ContextStore.js +76 -78
- package/dist/session/GoalManager.d.ts +0 -1
- package/dist/session/GoalManager.js +96 -100
- package/dist/session/MemoryStore.d.ts +2 -1
- package/dist/session/MemoryStore.js +108 -87
- package/dist/session/SessionManager.d.ts +5 -4
- package/dist/session/SessionManager.js +83 -62
- package/dist/session/SessionStore.d.ts +0 -1
- package/dist/session/SessionStore.js +112 -116
- package/dist/setup/SetupWizard.d.ts +0 -1
- package/dist/setup/SetupWizard.js +61 -64
- package/dist/tools/CrossTools.d.ts +0 -1
- package/dist/tools/CrossTools.js +140 -144
- package/dist/tools/GmgnIntegration.d.ts +0 -1
- package/dist/tools/GmgnIntegration.js +220 -230
- package/dist/tools/MarketSentiment.d.ts +0 -1
- package/dist/tools/MarketSentiment.js +213 -195
- package/dist/tools/NewsSentiment.d.ts +0 -1
- package/dist/tools/NewsSentiment.js +126 -130
- package/dist/tools/PriceFeed.d.ts +6 -1
- package/dist/tools/PriceFeed.js +201 -133
- package/dist/tools/TechnicalAnalysis.d.ts +1 -2
- package/dist/tools/TechnicalAnalysis.js +248 -216
- package/dist/tools/TechnicalAnalysis.worker.d.ts +25 -0
- package/dist/tools/TechnicalAnalysis.worker.js +92 -0
- package/dist/tools/TokenCalendar.d.ts +0 -1
- package/dist/tools/TokenCalendar.js +63 -68
- package/dist/tools/TokenSecurityScanner.d.ts +0 -1
- package/dist/tools/TokenSecurityScanner.js +93 -96
- package/dist/tools/TransactionSim.d.ts +0 -1
- package/dist/tools/TransactionSim.js +65 -71
- package/dist/tui/App.d.ts +0 -1
- package/dist/tui/App.js +895 -824
- package/dist/tui/ModelSelector.d.ts +0 -1
- package/dist/tui/ModelSelector.js +46 -49
- package/dist/tui/REPL.d.ts +0 -1
- package/dist/tui/REPL.js +222 -210
- package/dist/tui/Sparkline.d.ts +0 -1
- package/dist/tui/Sparkline.js +36 -37
- package/dist/tui/StatusBar.d.ts +0 -1
- package/dist/tui/StatusBar.js +9 -10
- package/dist/tui/ThemePresets.d.ts +0 -1
- package/dist/tui/ThemePresets.js +99 -103
- package/dist/tui/theme.d.ts +0 -1
- package/dist/tui/theme.js +50 -31
- package/dist/util/clipboard.d.ts +0 -1
- package/dist/util/clipboard.js +16 -20
- package/dist/util/commandSuggest.d.ts +0 -1
- package/dist/util/commandSuggest.js +34 -38
- package/dist/util/confirmation.d.ts +0 -1
- package/dist/util/confirmation.js +8 -11
- package/dist/util/errorHandler.d.ts +0 -1
- package/dist/util/errorHandler.js +20 -23
- package/dist/util/errors.d.ts +59 -0
- package/dist/util/errors.js +93 -0
- package/dist/util/logger.d.ts +0 -1
- package/dist/util/logger.js +30 -33
- package/dist/util/processManager.d.ts +0 -1
- package/dist/util/processManager.js +33 -36
- package/dist/util/resilientFetch.d.ts +6 -1
- package/dist/util/resilientFetch.js +134 -80
- package/dist/util/responseCache.d.ts +0 -1
- package/dist/util/responseCache.js +36 -45
- package/dist/util/rpc.d.ts +16 -0
- package/dist/util/rpc.js +69 -0
- package/dist/util/safeLog.d.ts +0 -1
- package/dist/util/safeLog.js +52 -53
- package/dist/util/scheduler.d.ts +0 -1
- package/dist/util/scheduler.js +53 -58
- package/dist/util/webhooks.d.ts +0 -1
- package/dist/util/webhooks.js +54 -58
- package/dist/wallet/ActionFeed.d.ts +3 -3
- package/dist/wallet/ActionFeed.js +189 -187
- package/dist/wallet/AgentWallet.d.ts +9 -7
- package/dist/wallet/AgentWallet.js +121 -141
- package/dist/wallet/ProfitTracker.d.ts +0 -1
- package/dist/wallet/ProfitTracker.js +71 -74
- package/package.json +12 -7
- package/scripts/build-esbuild.mjs +40 -0
- package/scripts/bundle-dts.mjs +58 -0
- package/scripts/minify.mjs +44 -0
- 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
|
-
|
|
9
|
+
|
|
19
10
|
function ensureGmgnEnv() {
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
if (!existsSync(GMGN_ENV_DIR))
|
|
12
|
+
mkdirSync(GMGN_ENV_DIR, { recursive: true });
|
|
22
13
|
}
|
|
23
14
|
function readGmgnEnv() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
51
|
+
return readGmgnEnv().GMGN_API_KEY;
|
|
61
52
|
}
|
|
62
53
|
export function hasGmgnApiKey() {
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
const key = getGmgnApiKey();
|
|
55
|
+
return !!key && key.trim() !== "";
|
|
65
56
|
}
|
|
66
57
|
export function saveGmgnApiKey(key) {
|
|
67
|
-
|
|
58
|
+
writeGmgnKey("GMGN_API_KEY", key);
|
|
68
59
|
}
|
|
69
60
|
function gmgnEnv() {
|
|
70
|
-
|
|
61
|
+
return { ...process.env, ...readGmgnEnv() };
|
|
71
62
|
}
|
|
72
63
|
function gmgnAvailable() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
122
|
+
|
|
132
123
|
export const gmgnToolParams = Type.Object({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
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
|
-
|
|
229
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|