@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.
- 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 +683 -686
- 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 +0 -1
- package/dist/wallet/ActionFeed.js +189 -200
- package/dist/wallet/AgentWallet.d.ts +7 -8
- package/dist/wallet/AgentWallet.js +117 -144
- package/dist/wallet/ProfitTracker.d.ts +0 -1
- package/dist/wallet/ProfitTracker.js +71 -74
- package/package.json +11 -6
- 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
package/dist/index.js
CHANGED
|
@@ -1,64 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Extension files import from here:
|
|
5
|
-
* import { Type } from "aiaiaichain"
|
|
6
|
-
* import type { ExtensionAPI } from "aiaiaichain"
|
|
7
|
-
*/
|
|
8
|
-
// Re-export TypeBox Type builder
|
|
1
|
+
|
|
2
|
+
|
|
9
3
|
export { Type } from "@sinclair/typebox";
|
|
10
4
|
export { text } from "./api/ExtensionAPI.js";
|
|
11
5
|
export { Registry } from "./api/Registry.js";
|
|
12
|
-
|
|
6
|
+
|
|
13
7
|
export { AgentRunner } from "./runner/AgentRunner.js";
|
|
14
8
|
export { ModelClient, resolveModelConfig } from "./runner/ModelClient.js";
|
|
15
9
|
export { ToolDispatcher } from "./runner/ToolDispatcher.js";
|
|
16
10
|
export { SwarmRouter } from "./runner/SwarmRouter.js";
|
|
17
|
-
|
|
11
|
+
|
|
18
12
|
export { loadExtension } from "./loader.js";
|
|
19
|
-
|
|
13
|
+
|
|
20
14
|
export { makeTheme, T, AIAIAI_COLORS } from "./tui/theme.js";
|
|
21
|
-
|
|
15
|
+
|
|
22
16
|
export { ModelRegistry, modelRegistry, classifyModel } from "./models/ModelRegistry.js";
|
|
23
17
|
export { CostTracker } from "./models/CostTracker.js";
|
|
24
|
-
|
|
18
|
+
|
|
25
19
|
export { fullAnalysis, rsi, macd, ema, sma, bollingerBands, atr, getCandlesTool, getCandlesParams } from "./tools/TechnicalAnalysis.js";
|
|
26
20
|
export { PriceFeed, priceFeed } from "./tools/PriceFeed.js";
|
|
27
21
|
export { NewsFeed, newsFeed, getNewsTool, scoreSentiment } from "./tools/NewsSentiment.js";
|
|
28
22
|
export { getFearGreedTool, getFundingRatesTool, getBtcMempoolTool, getDefiTvlTool, getSolanaStatsTool, } from "./tools/MarketSentiment.js";
|
|
29
|
-
|
|
23
|
+
|
|
30
24
|
export { SessionManager } from "./session/SessionManager.js";
|
|
31
25
|
export { MemoryStore, memoryStore } from "./session/MemoryStore.js";
|
|
32
26
|
export { GoalManager, goalManager } from "./session/GoalManager.js";
|
|
33
27
|
export { ContextStore, contextStore } from "./session/ContextStore.js";
|
|
34
|
-
|
|
28
|
+
|
|
35
29
|
export { AgentScheduler, agentScheduler } from "./scheduler/AgentScheduler.js";
|
|
36
|
-
|
|
30
|
+
|
|
37
31
|
export { agentWallet, COLD_WALLET, ACTION_WALLET, DEPOSIT_WALLET, SIGNER, AIAIAI_MINT } from "./wallet/AgentWallet.js";
|
|
38
32
|
export { actionFeed } from "./wallet/ActionFeed.js";
|
|
39
|
-
|
|
33
|
+
|
|
40
34
|
export { gmgnTool, gmgnMarketTool, gmgnHelp, gmgnStatus, hasGmgnApiKey, saveGmgnApiKey, GMGN_SUBCOMMANDS } from "./tools/GmgnIntegration.js";
|
|
41
|
-
|
|
35
|
+
|
|
42
36
|
export { watchTokenTool, removeWatchTool, listWatchTool, addAlertTool, checkAlertsTool, compareTokensTool, portfolioTool, portfolioParams, getWatchList, checkAlerts, addAlert, getActiveAlerts, } from "./tools/CrossTools.js";
|
|
43
|
-
|
|
37
|
+
|
|
44
38
|
export { sessionStore } from "./session/SessionStore.js";
|
|
45
|
-
|
|
39
|
+
|
|
46
40
|
export { systemMonitor } from "./core/SystemMonitor.js";
|
|
47
|
-
|
|
41
|
+
|
|
48
42
|
export { MCPServer } from "./mcp/server.js";
|
|
49
|
-
|
|
43
|
+
|
|
50
44
|
export { AgentDir } from "./core/AgentDir.js";
|
|
51
45
|
export { EnvLoader, env } from "./core/EnvLoader.js";
|
|
52
46
|
export { CHAINS, getPrimaryChain, getEnabledChains, getChain, getSupportedChains } from "./core/ChainConfig.js";
|
|
53
|
-
|
|
47
|
+
|
|
54
48
|
export { resilientFetch, isReachable } from "./util/resilientFetch.js";
|
|
55
49
|
export { logger } from "./util/logger.js";
|
|
56
50
|
export { getCached, setCache, getOrCompute, clearCache, cacheStats } from "./util/responseCache.js";
|
|
57
51
|
export { addTask, removeTask, pauseTask, resumeTask, pauseAll, resumeAll, startScheduler } from "./util/scheduler.js";
|
|
58
52
|
export { requireConfirmation, isNonInteractive } from "./util/confirmation.js";
|
|
59
53
|
export { ProcessManager } from "./util/processManager.js";
|
|
60
|
-
|
|
54
|
+
|
|
61
55
|
export { recordTrade, getPLSummary, getTradeHistory, exportCSV } from "./wallet/ProfitTracker.js";
|
|
62
|
-
|
|
56
|
+
|
|
63
57
|
export { scanTokenSecurityTool } from "./tools/TokenSecurityScanner.js";
|
|
64
|
-
//# sourceMappingURL=index.js.map
|
package/dist/loader.d.ts
CHANGED
package/dist/loader.js
CHANGED
|
@@ -1,73 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
* loader.ts — loads an extension file and wires it to a Registry.
|
|
3
|
-
*/
|
|
1
|
+
|
|
4
2
|
import { pathToFileURL } from "node:url";
|
|
5
3
|
import { resolve, extname } from "node:path";
|
|
6
4
|
import { existsSync } from "node:fs";
|
|
7
5
|
import { makeTheme } from "./tui/theme.js";
|
|
8
6
|
export async function loadExtension(extensionPath, registry, opts = {}) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
7
|
+
const abs = resolve(extensionPath);
|
|
8
|
+
if (!existsSync(abs))
|
|
9
|
+
throw new Error(`Extension file not found: ${abs}`);
|
|
10
|
+
const theme = makeTheme();
|
|
11
|
+
let _notify = opts.onNotify ?? (() => { });
|
|
12
|
+
let _setStatus = opts.onStatusUpdate ?? (() => { });
|
|
13
|
+
let _showModelSelector = opts.onShowModelSelector ?? (() => { });
|
|
14
|
+
const ui = {
|
|
15
|
+
notify(msg) { _notify(msg); },
|
|
16
|
+
setStatus(key, value) { _setStatus(key, value); },
|
|
17
|
+
setTheme(_name) { },
|
|
18
|
+
setHeader(_factory) { },
|
|
19
|
+
showModelSelector(query) { _showModelSelector(query); },
|
|
20
|
+
theme,
|
|
21
|
+
};
|
|
22
|
+
const api = {
|
|
23
|
+
registerCommand(name, def) { registry.addCommand(name, def); },
|
|
24
|
+
registerTool(def) { registry.addTool(def); },
|
|
25
|
+
registerSkill(def) { registry.addSkill(def); },
|
|
26
|
+
on(event, handler) { registry.addHook(event, handler); },
|
|
27
|
+
setSystemPrompt(prompt) { registry.setSystemPrompt(prompt); },
|
|
28
|
+
ui,
|
|
29
|
+
};
|
|
30
|
+
const ext = extname(abs).toLowerCase();
|
|
31
|
+
let mod;
|
|
32
|
+
if (ext === ".ts") {
|
|
33
|
+
const jsPath = abs.replace(/\.ts$/, ".js");
|
|
34
|
+
if (existsSync(jsPath)) {
|
|
35
|
+
mod = await import(pathToFileURL(jsPath).href);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
try {
|
|
39
|
+
const tsxMod = await import("tsx/esm/api");
|
|
40
|
+
mod = await tsxMod.tsImport(pathToFileURL(abs).href, import.meta.url);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new Error(`Cannot import TypeScript extension "${abs}" in packaged mode.\n` +
|
|
44
|
+
`Fix: compile to .js first or install tsx: npm install -g tsx`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
mod = await import(pathToFileURL(abs).href);
|
|
50
|
+
}
|
|
51
|
+
const fn = mod.default ?? mod;
|
|
52
|
+
if (typeof fn !== "function") {
|
|
53
|
+
throw new Error(`Extension must export a default function. Got: ${typeof fn}`);
|
|
54
|
+
}
|
|
55
|
+
const _origLog = console.log;
|
|
56
|
+
const _origError = console.error;
|
|
57
|
+
const _origWarn = console.warn;
|
|
58
|
+
const _extLog = (...args) => { ui.notify(args.map(a => String(a)).join(" ")); };
|
|
59
|
+
console.log = _extLog;
|
|
60
|
+
console.error = _extLog;
|
|
61
|
+
console.warn = _extLog;
|
|
62
|
+
try {
|
|
63
|
+
await fn(api);
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
console.log = _origLog;
|
|
67
|
+
console.error = _origError;
|
|
68
|
+
console.warn = _origWarn;
|
|
69
|
+
}
|
|
72
70
|
}
|
|
73
|
-
//# sourceMappingURL=loader.js.map
|
package/dist/mcp/entry.d.ts
CHANGED
package/dist/mcp/entry.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* MCP entry point — starts the AIAIAI MCP server over stdio.
|
|
3
|
-
*/
|
|
1
|
+
|
|
4
2
|
import { MCPServer } from "./server.js";
|
|
5
3
|
const server = new MCPServer();
|
|
6
4
|
server.start().catch((e) => {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
process.stderr.write(`MCP server error: ${e instanceof Error ? e.message : String(e)}\n`);
|
|
6
|
+
process.exit(1);
|
|
9
7
|
});
|
|
10
|
-
//# sourceMappingURL=entry.js.map
|
package/dist/mcp/server.d.ts
CHANGED
package/dist/mcp/server.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* MCP server — exposes AIAIAI tools via the Model Context Protocol (stdio).
|
|
3
|
-
* Minimal JSON-RPC implementation over stdin/stdout.
|
|
4
|
-
*/
|
|
1
|
+
|
|
5
2
|
import { priceFeed } from "../tools/PriceFeed.js";
|
|
6
3
|
import { getNewsTool } from "../tools/NewsSentiment.js";
|
|
7
4
|
import { getCandlesTool } from "../tools/TechnicalAnalysis.js";
|
|
@@ -9,155 +6,154 @@ import { getFearGreedTool, getFundingRatesTool, getBtcMempoolTool, getDefiTvlToo
|
|
|
9
6
|
import { agentWallet } from "../wallet/AgentWallet.js";
|
|
10
7
|
import { actionFeed } from "../wallet/ActionFeed.js";
|
|
11
8
|
export class MCPServer {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
//# sourceMappingURL=server.js.map
|
|
9
|
+
tools = [];
|
|
10
|
+
constructor() {
|
|
11
|
+
this.registerTools();
|
|
12
|
+
}
|
|
13
|
+
registerTools() {
|
|
14
|
+
this.tools = [
|
|
15
|
+
{
|
|
16
|
+
name: "get_aiaiai_price",
|
|
17
|
+
description: "Get the current $AIAIAI token price, liquidity, market cap, and volume from DexScreener.",
|
|
18
|
+
inputSchema: { type: "object", properties: {} },
|
|
19
|
+
handler: async () => priceFeed.getAiaiaiPriceTool(),
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "get_token_price",
|
|
23
|
+
description: "Get price data for any Solana token by address via DexScreener.",
|
|
24
|
+
inputSchema: { type: "object", properties: { address: { type: "string", description: "Solana token address" } }, required: ["address"] },
|
|
25
|
+
handler: async (args) => priceFeed.getTokenPriceTool("", args),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "get_news",
|
|
29
|
+
description: "Crypto news headlines with sentiment scoring.",
|
|
30
|
+
inputSchema: { type: "object", properties: { limit: { type: "number", description: "Number of items" } } },
|
|
31
|
+
handler: async (args) => getNewsTool("", args),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "get_candles",
|
|
35
|
+
description: "Fetch OHLCV candles from Binance and run technical analysis.",
|
|
36
|
+
inputSchema: { type: "object", properties: { symbol: { type: "string" }, interval: { type: "string" }, limit: { type: "number" } }, required: ["symbol"] },
|
|
37
|
+
handler: async (args) => getCandlesTool("", args),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "get_fear_greed",
|
|
41
|
+
description: "Crypto Fear & Greed Index.",
|
|
42
|
+
inputSchema: { type: "object", properties: {} },
|
|
43
|
+
handler: async () => getFearGreedTool(),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "get_funding_rates",
|
|
47
|
+
description: "Binance perpetual funding rates.",
|
|
48
|
+
inputSchema: { type: "object", properties: { limit: { type: "number" } } },
|
|
49
|
+
handler: async (args) => getFundingRatesTool("", args),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "get_btc_mempool",
|
|
53
|
+
description: "Bitcoin mempool stats and fee rates.",
|
|
54
|
+
inputSchema: { type: "object", properties: {} },
|
|
55
|
+
handler: async () => getBtcMempoolTool(),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "get_defi_tvl",
|
|
59
|
+
description: "DeFiLlama TVL by chain or all chains.",
|
|
60
|
+
inputSchema: { type: "object", properties: { chain: { type: "string" } } },
|
|
61
|
+
handler: async (args) => getDefiTvlTool("", args),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "get_solana_stats",
|
|
65
|
+
description: "Solana network epoch, slot, and SOL price.",
|
|
66
|
+
inputSchema: { type: "object", properties: {} },
|
|
67
|
+
handler: async () => getSolanaStatsTool(),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "get_agent_balance",
|
|
71
|
+
description: "Show agent cold + action wallet balances.",
|
|
72
|
+
inputSchema: { type: "object", properties: {} },
|
|
73
|
+
handler: async () => agentWallet.getAgentBalanceTool(),
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "get_deposit_balance",
|
|
77
|
+
description: "Show deposit wallet balance and instructions.",
|
|
78
|
+
inputSchema: { type: "object", properties: {} },
|
|
79
|
+
handler: async () => agentWallet.getDepositBalanceTool(),
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "get_actions",
|
|
83
|
+
description: "Show recent agent buy/burn actions.",
|
|
84
|
+
inputSchema: { type: "object", properties: { limit: { type: "number" } } },
|
|
85
|
+
handler: async (args) => actionFeed.getActionsTool("", args),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "get_fees",
|
|
89
|
+
description: "Show accumulated fees from agent actions.",
|
|
90
|
+
inputSchema: { type: "object", properties: {} },
|
|
91
|
+
handler: async () => actionFeed.getFeesTool(),
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
async start() {
|
|
96
|
+
let buffer = "";
|
|
97
|
+
process.stdin.setEncoding("utf-8");
|
|
98
|
+
process.stdin.on("data", async (chunk) => {
|
|
99
|
+
buffer += chunk;
|
|
100
|
+
const lines = buffer.split("\n");
|
|
101
|
+
buffer = lines.pop() || "";
|
|
102
|
+
for (const line of lines) {
|
|
103
|
+
if (!line.trim())
|
|
104
|
+
continue;
|
|
105
|
+
await this.handleMessage(line.trim());
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
process.stderr.write("AIAIAI MCP server started (stdio)\n");
|
|
109
|
+
}
|
|
110
|
+
async handleMessage(raw) {
|
|
111
|
+
let msg;
|
|
112
|
+
try {
|
|
113
|
+
msg = JSON.parse(raw);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const { id, method, params } = msg;
|
|
119
|
+
if (method === "initialize") {
|
|
120
|
+
this.respond(id, {
|
|
121
|
+
protocolVersion: "2024-11-05",
|
|
122
|
+
capabilities: { tools: {} },
|
|
123
|
+
serverInfo: { name: "aiaiai-chain", version: "0.1.0" },
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (method === "tools/list") {
|
|
128
|
+
this.respond(id, {
|
|
129
|
+
tools: this.tools.map(t => ({ name: t.name, description: t.description, inputSchema: t.inputSchema })),
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (method === "tools/call") {
|
|
134
|
+
const tool = this.tools.find(t => t.name === params?.name);
|
|
135
|
+
if (!tool) {
|
|
136
|
+
this.respondError(id, -32602, `Unknown tool: ${params?.name}`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
const result = await tool.handler(params.arguments ?? {});
|
|
141
|
+
this.respond(id, { content: result.content });
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
this.respondError(id, -32603, e instanceof Error ? e.message : String(e));
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (method === "ping") {
|
|
149
|
+
this.respond(id, {});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
respond(id, result) {
|
|
154
|
+
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, result }) + "\n");
|
|
155
|
+
}
|
|
156
|
+
respondError(id, code, message) {
|
|
157
|
+
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } }) + "\n");
|
|
158
|
+
}
|
|
159
|
+
}
|