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