@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
package/dist/tools/CrossTools.js
CHANGED
|
@@ -1,190 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
* CrossTools — automation tools that combine multiple data sources.
|
|
3
|
-
* Watch tokens, compare, portfolio tracking, price alerts.
|
|
4
|
-
*/
|
|
1
|
+
|
|
5
2
|
import { Type } from "@sinclair/typebox";
|
|
6
3
|
import { priceFeed } from "../tools/PriceFeed.js";
|
|
7
4
|
import { AIAIAI_TOKEN, agentWallet } from "../wallet/AgentWallet.js";
|
|
8
5
|
import { logger } from "../util/logger.js";
|
|
9
6
|
const alerts = [];
|
|
10
7
|
export function addAlert(token, type, price) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
const alert = {
|
|
9
|
+
id: `alert-${Date.now()}-${Math.random().toString(36).slice(2, 5)}`,
|
|
10
|
+
token,
|
|
11
|
+
type,
|
|
12
|
+
price,
|
|
13
|
+
active: true,
|
|
14
|
+
createdAt: Date.now(),
|
|
15
|
+
};
|
|
16
|
+
alerts.push(alert);
|
|
17
|
+
return alert;
|
|
21
18
|
}
|
|
22
19
|
export function checkAlerts(currentPrice, token) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
const triggered = [];
|
|
21
|
+
for (const alert of alerts) {
|
|
22
|
+
if (!alert.active || alert.token !== token)
|
|
23
|
+
continue;
|
|
24
|
+
if (alert.type === 'above' && currentPrice >= alert.price) {
|
|
25
|
+
alert.active = false;
|
|
26
|
+
alert.triggeredAt = Date.now();
|
|
27
|
+
triggered.push(alert);
|
|
28
|
+
}
|
|
29
|
+
else if (alert.type === 'below' && currentPrice <= alert.price) {
|
|
30
|
+
alert.active = false;
|
|
31
|
+
alert.triggeredAt = Date.now();
|
|
32
|
+
triggered.push(alert);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return triggered;
|
|
39
36
|
}
|
|
40
37
|
export function getActiveAlerts() {
|
|
41
|
-
|
|
38
|
+
return alerts.filter(a => a.active);
|
|
42
39
|
}
|
|
43
|
-
|
|
40
|
+
|
|
44
41
|
const watchList = new Set();
|
|
45
42
|
export function addToWatchList(tokenAddress) {
|
|
46
|
-
|
|
43
|
+
watchList.add(tokenAddress);
|
|
47
44
|
}
|
|
48
45
|
export function removeFromWatchList(tokenAddress) {
|
|
49
|
-
|
|
46
|
+
watchList.delete(tokenAddress);
|
|
50
47
|
}
|
|
51
48
|
export function getWatchList() {
|
|
52
|
-
|
|
49
|
+
return [...watchList];
|
|
53
50
|
}
|
|
54
|
-
|
|
51
|
+
|
|
55
52
|
export const watchTokenParams = Type.Object({
|
|
56
|
-
|
|
53
|
+
address: Type.String({ description: "Token contract address to watch" }),
|
|
57
54
|
});
|
|
58
55
|
export const removeWatchParams = Type.Object({
|
|
59
|
-
|
|
56
|
+
address: Type.String({ description: "Token contract address to remove" }),
|
|
60
57
|
});
|
|
61
58
|
export const listWatchParams = Type.Object({});
|
|
62
59
|
export const addAlertParams = Type.Object({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
token: Type.String({ description: "Token address or 'AIAIAI'" }),
|
|
61
|
+
type: Type.String({ description: "Alert type: above or below" }),
|
|
62
|
+
price: Type.Number({ description: "Price threshold in USD" }),
|
|
66
63
|
});
|
|
67
64
|
export const checkAlertsParams = Type.Object({});
|
|
68
65
|
export const compareTokensParams = Type.Object({
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
address1: Type.String({ description: "First token address" }),
|
|
67
|
+
address2: Type.String({ description: "Second token address" }),
|
|
71
68
|
});
|
|
72
69
|
export async function watchTokenTool(_id, params) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
const addr = params.address;
|
|
71
|
+
addToWatchList(addr);
|
|
72
|
+
return { content: [{ type: "text", text: `👁️ Watching ${addr.slice(0, 8)}…${addr.slice(-6)}. You'll get alerts on significant moves.` }] };
|
|
76
73
|
}
|
|
77
74
|
export async function removeWatchTool(_id, params) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
const addr = params.address;
|
|
76
|
+
removeFromWatchList(addr);
|
|
77
|
+
return { content: [{ type: "text", text: `Removed ${addr.slice(0, 8)}… from watch list.` }] };
|
|
81
78
|
}
|
|
82
79
|
export async function listWatchTool() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
const list = getWatchList();
|
|
81
|
+
if (list.length === 0)
|
|
82
|
+
return { content: [{ type: "text", text: "Watch list is empty." }] };
|
|
83
|
+
const lines = list.map((addr, i) => ` ${i + 1}. ${addr.slice(0, 8)}…${addr.slice(-6)}`);
|
|
84
|
+
return { content: [{ type: "text", text: `Watch List (${list.length}):\n${lines.join("\n")}` }] };
|
|
88
85
|
}
|
|
89
86
|
export async function addAlertTool(_id, params) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
const token = params.token;
|
|
88
|
+
const type = params.type;
|
|
89
|
+
const price = params.price;
|
|
90
|
+
const alert = addAlert(token, type, price);
|
|
91
|
+
return { content: [{ type: "text", text: `🔔 Alert set: ${type} $${price} for ${token.slice(0, 8)}… (${alert.id})` }] };
|
|
95
92
|
}
|
|
96
93
|
export async function checkAlertsTool() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
const active = getActiveAlerts();
|
|
95
|
+
if (active.length === 0)
|
|
96
|
+
return { content: [{ type: "text", text: "No active alerts." }] };
|
|
97
|
+
const lines = active.map(a => ` ${a.id} — ${a.type} $${a.price} (${a.token.slice(0, 8)}…)`);
|
|
98
|
+
return { content: [{ type: "text", text: `Active Alerts (${active.length}):\n${lines.join("\n")}` }] };
|
|
102
99
|
}
|
|
103
100
|
export async function compareTokensTool(_id, params) {
|
|
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
|
-
|
|
101
|
+
const addr1 = params.address1;
|
|
102
|
+
const addr2 = params.address2;
|
|
103
|
+
let price1 = null, price2 = null;
|
|
104
|
+
try {
|
|
105
|
+
if (addr1 === AIAIAI_TOKEN || addr1.toLowerCase() === 'aiaiai') {
|
|
106
|
+
price1 = await priceFeed.getAiaiaiPrice();
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
price1 = await priceFeed.fetchToken(addr1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
logger.warn('CrossTools', 'compareTokens: failed to fetch price1', { address: addr1, error: error.message });
|
|
114
|
+
price1 = null;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
if (addr2 === AIAIAI_TOKEN || addr2.toLowerCase() === 'aiaiai') {
|
|
118
|
+
price2 = await priceFeed.getAiaiaiPrice();
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
price2 = await priceFeed.fetchToken(addr2);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
logger.warn('CrossTools', 'compareTokens: failed to fetch price2', { address: addr2, error: error.message });
|
|
126
|
+
price2 = null;
|
|
127
|
+
}
|
|
128
|
+
const lines = [
|
|
129
|
+
'── Token Comparison ──────────────────────────',
|
|
130
|
+
'',
|
|
131
|
+
`Token 1: ${addr1.slice(0, 8)}…`,
|
|
132
|
+
price1 ? ` Price: $${price1.priceUsd ?? 'N/A'}` : ' Price: N/A',
|
|
133
|
+
price1 ? ` 24h: ${price1.priceChange24h > 0 ? '+' : ''}${price1.priceChange24h.toFixed(2)}%` : ' 24h: N/A',
|
|
134
|
+
price1 ? ` Liq: $${(price1.liquidityUsd / 1000).toFixed(1)}k` : ' Liq: N/A',
|
|
135
|
+
price1 ? ` MCap: $${price1.marketCap ? (price1.marketCap / 1000).toFixed(1) + 'k' : 'N/A'}` : ' MCap: N/A',
|
|
136
|
+
'',
|
|
137
|
+
`Token 2: ${addr2.slice(0, 8)}…`,
|
|
138
|
+
price2 ? ` Price: $${price2.priceUsd ?? 'N/A'}` : ' Price: N/A',
|
|
139
|
+
price2 ? ` 24h: ${price2.priceChange24h > 0 ? '+' : ''}${price2.priceChange24h.toFixed(2)}%` : ' 24h: N/A',
|
|
140
|
+
price2 ? ` Liq: $${(price2.liquidityUsd / 1000).toFixed(1)}k` : ' Liq: N/A',
|
|
141
|
+
price2 ? ` MCap: $${price2.marketCap ? (price2.marketCap / 1000).toFixed(1) + 'k' : 'N/A'}` : ' MCap: N/A',
|
|
142
|
+
];
|
|
143
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
144
|
+
}
|
|
145
|
+
|
|
149
146
|
export const portfolioParams = Type.Object({
|
|
150
|
-
|
|
147
|
+
address: Type.String({ description: "Wallet address to analyze" }),
|
|
151
148
|
});
|
|
152
149
|
export async function portfolioTool(_id, params) {
|
|
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
|
-
|
|
150
|
+
const address = params.address;
|
|
151
|
+
|
|
152
|
+
let result = null;
|
|
153
|
+
try {
|
|
154
|
+
const all = await agentWallet.getAll();
|
|
155
|
+
if (address === COLD_WALLET)
|
|
156
|
+
result = all.cold;
|
|
157
|
+
else if (address === ACTION_WALLET)
|
|
158
|
+
result = all.action;
|
|
159
|
+
else if (address === DEPOSIT_WALLET)
|
|
160
|
+
result = all.deposit;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
logger.warn('CrossTools', 'portfolioTool: wallet lookup failed', { address, error: error.message });
|
|
164
|
+
}
|
|
165
|
+
if (result) {
|
|
166
|
+
let solPrice = await new Promise(res => {
|
|
167
|
+
agentWallet.getSolPrice().then(res).catch(() => res(150));
|
|
168
|
+
});
|
|
169
|
+
const lines = [
|
|
170
|
+
`📊 Portfolio: ${address.slice(0, 8)}…${address.slice(-6)}`,
|
|
171
|
+
'',
|
|
172
|
+
` SOL: ${result.sol.toFixed(4)} ($${(result.sol * solPrice).toFixed(2)} est)`,
|
|
173
|
+
` $AIAIAI: ${result.aiaiai.toLocaleString(undefined, { maximumFractionDigits: 0 })}`,
|
|
174
|
+
` USDC: ${result.usdc.toFixed(2)}`,
|
|
175
|
+
'',
|
|
176
|
+
` Total value (est): $${(result.sol * solPrice + result.usdc).toFixed(2)} + $AIAIAI`,
|
|
177
|
+
];
|
|
178
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
content: [{ type: "text", text: `📊 Analyzed: ${address.slice(0, 8)}…${address.slice(-6)}\nUse /wallet or /deposit for tracked wallet balances.` }],
|
|
182
|
+
};
|
|
186
183
|
}
|
|
187
184
|
export const COLD_WALLET = "A11iZoqEt6hU7HyggqC67ee4AtYmaJjwKCvJLerJRV2J";
|
|
188
185
|
export const ACTION_WALLET = "BygDYM1ZXLQNC1HXLhnd1rHZ7E5XjioqT3vPjJFfjnU2";
|
|
189
186
|
export const DEPOSIT_WALLET = "FBMDYpG9WXKy4SgxuATQdB2sCyzHsJWPrEr45z3TgL2e";
|
|
190
|
-
//# sourceMappingURL=CrossTools.js.map
|
|
@@ -35,4 +35,3 @@ export declare const gmgnMarketToolParams: import("@sinclair/typebox").TObject<{
|
|
|
35
35
|
chain: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
36
36
|
}>;
|
|
37
37
|
export declare function gmgnMarketTool(_id: string, params: Record<string, unknown>): Promise<ToolResult>;
|
|
38
|
-
//# sourceMappingURL=GmgnIntegration.d.ts.map
|