@aiaiaichain/agent 0.1.6 → 0.1.8
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 +364 -768
- 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 +70 -85
- package/dist/index.d.ts +4 -61
- 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 +17 -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 +1 -7
- package/dist/tui/App.js +896 -825
- package/dist/tui/ModelSelector.d.ts +1 -3
- package/dist/tui/ModelSelector.js +47 -50
- package/dist/tui/REPL.d.ts +1 -3
- package/dist/tui/REPL.js +222 -210
- package/dist/tui/Sparkline.d.ts +1 -3
- package/dist/tui/Sparkline.js +38 -37
- package/dist/tui/StatusBar.d.ts +1 -3
- package/dist/tui/StatusBar.js +11 -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 +14 -8
- package/scripts/build-esbuild.mjs +40 -0
- package/scripts/bundle-dts.mjs +58 -0
- package/scripts/minify.mjs +44 -0
- package/scripts/postinstall.js +41 -0
|
@@ -1,81 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
* src/tools/TokenCalendar.ts — Token launch calendar tracker.
|
|
3
|
-
* Uses DexScreener's latest tokens endpoint to find recent launches.
|
|
4
|
-
* Caches results for 5 minutes.
|
|
5
|
-
*/
|
|
1
|
+
|
|
6
2
|
import { Type } from "@sinclair/typebox";
|
|
7
3
|
import { resilientFetch } from "../util/resilientFetch.js";
|
|
8
4
|
import { logger } from "../util/logger.js";
|
|
9
5
|
export const launchCalendarParams = Type.Object({
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
chain: Type.Optional(Type.String({ description: "Chain: solana, ethereum, bsc, base", default: "solana" })),
|
|
7
|
+
limit: Type.Optional(Type.Number({ description: "Max entries", default: 10 })),
|
|
12
8
|
});
|
|
13
9
|
let cachedLaunches = [];
|
|
14
10
|
let lastFetch = 0;
|
|
15
|
-
const CACHE_DURATION = 300_000;
|
|
11
|
+
const CACHE_DURATION = 300_000;
|
|
16
12
|
export async function launchCalendarTool(_id, params) {
|
|
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
|
-
|
|
13
|
+
const chain = params.chain || "solana";
|
|
14
|
+
const limit = params.limit || 10;
|
|
15
|
+
if (Date.now() - lastFetch < CACHE_DURATION && cachedLaunches.length > 0) {
|
|
16
|
+
const filtered = cachedLaunches.filter(l => l.chain === chain).slice(0, limit);
|
|
17
|
+
return formatResult(filtered, chain);
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
|
|
21
|
+
const url = `https://api.dexscreener.com/latest/dex/tokens/${chain}`;
|
|
22
|
+
const response = await resilientFetch(url, { timeout: 10_000, retries: 1 });
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
return { content: [{ type: "text", text: `Token launch calendar unavailable for ${chain}.` }] };
|
|
25
|
+
}
|
|
26
|
+
const data = await response.json();
|
|
27
|
+
const pairs = data?.pairs ?? [];
|
|
28
|
+
cachedLaunches = pairs.map((p) => {
|
|
29
|
+
const createdAt = p.pairCreatedAt ? new Date(p.pairCreatedAt) : null;
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
const diffMs = createdAt ? now - createdAt.getTime() : Infinity;
|
|
32
|
+
const age = createdAt
|
|
33
|
+
? diffMs < 3600000 ? `${Math.floor(diffMs / 60000)}m ago`
|
|
34
|
+
: diffMs < 86400000 ? `${Math.floor(diffMs / 3600000)}h ago`
|
|
35
|
+
: `${Math.floor(diffMs / 86400000)}d ago`
|
|
36
|
+
: "unknown";
|
|
37
|
+
return {
|
|
38
|
+
address: p.baseToken?.address ?? "",
|
|
39
|
+
symbol: p.baseToken?.symbol ?? "???",
|
|
40
|
+
name: p.baseToken?.name ?? "Unknown",
|
|
41
|
+
priceUsd: p.priceUsd ?? null,
|
|
42
|
+
volume24h: p.volume?.h24 ?? 0,
|
|
43
|
+
liquidityUsd: p.liquidity?.usd ?? 0,
|
|
44
|
+
age,
|
|
45
|
+
chain,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
lastFetch = Date.now();
|
|
49
|
+
const filtered = cachedLaunches.slice(0, limit);
|
|
50
|
+
return formatResult(filtered, chain);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
logger.warn("TokenCalendar", "Failed to fetch launches", { chain, error: error.message });
|
|
54
|
+
return { content: [{ type: "text", text: `Token launch calendar: Data temporarily unavailable.` }] };
|
|
55
|
+
}
|
|
60
56
|
}
|
|
61
57
|
function formatResult(launches, chain) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
58
|
+
if (launches.length === 0) {
|
|
59
|
+
return { content: [{ type: "text", text: `No recent launches found on ${chain}.` }] };
|
|
60
|
+
}
|
|
61
|
+
const lines = [`🚀 Recent Token Launches — ${chain.toUpperCase()}`, ""];
|
|
62
|
+
for (const l of launches.slice(0, 10)) {
|
|
63
|
+
const price = l.priceUsd ? `$${parseFloat(l.priceUsd).toFixed(8)}` : "N/A";
|
|
64
|
+
const vol = l.volume24h > 0 ? `$${(l.volume24h / 1000).toFixed(1)}k` : "no vol";
|
|
65
|
+
const liq = l.liquidityUsd > 0 ? `$${(l.liquidityUsd / 1000).toFixed(1)}k` : "no liq";
|
|
66
|
+
lines.push(` ${l.symbol.padEnd(10)} ${price.padEnd(16)} ${vol.padEnd(10)} ${l.age.padEnd(10)} ${l.address.slice(0, 6)}…`);
|
|
67
|
+
}
|
|
68
|
+
return { content: [{ type: "text", text: lines.join("\n") }], details: { launches } };
|
|
73
69
|
}
|
|
74
|
-
|
|
70
|
+
|
|
75
71
|
export function getLaunchSummary() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
if (cachedLaunches.length === 0)
|
|
73
|
+
return "Loading…";
|
|
74
|
+
const recent = cachedLaunches.slice(0, 3);
|
|
75
|
+
return recent.map(l => l.symbol).join(" · ");
|
|
80
76
|
}
|
|
81
|
-
//# sourceMappingURL=TokenCalendar.js.map
|
|
@@ -19,4 +19,3 @@ export declare const tokenSecurityParams: import("@sinclair/typebox").TObject<{
|
|
|
19
19
|
address: import("@sinclair/typebox").TString;
|
|
20
20
|
}>;
|
|
21
21
|
export declare function scanTokenSecurityTool(_id: string, params: Record<string, unknown>): Promise<ToolResult>;
|
|
22
|
-
//# sourceMappingURL=TokenSecurityScanner.d.ts.map
|
|
@@ -1,102 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
* src/tools/TokenSecurityScanner.ts - honeypot/rugpull detection for Solana tokens
|
|
3
|
-
*/
|
|
1
|
+
|
|
4
2
|
import { Type } from "@sinclair/typebox";
|
|
5
3
|
import { resilientFetch } from "../util/resilientFetch.js";
|
|
6
4
|
import { logger } from "../util/logger.js";
|
|
7
5
|
export const tokenSecurityParams = Type.Object({
|
|
8
|
-
|
|
6
|
+
address: Type.String({ description: "Token mint address on Solana" }),
|
|
9
7
|
});
|
|
10
8
|
export async function scanTokenSecurityTool(_id, params) {
|
|
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
|
-
|
|
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
|
-
//# sourceMappingURL=TokenSecurityScanner.js.map
|
|
9
|
+
const address = params.address;
|
|
10
|
+
if (!address || address.length < 32 || address.length > 44) {
|
|
11
|
+
return {
|
|
12
|
+
content: [{ type: "text", text: "Invalid token address format." }],
|
|
13
|
+
isError: true,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const warnings = [];
|
|
17
|
+
let score = 100;
|
|
18
|
+
let isHoneypot = false;
|
|
19
|
+
let isRugRisk = false;
|
|
20
|
+
let dexData = null;
|
|
21
|
+
try {
|
|
22
|
+
const resp = await resilientFetch(`https://api.dexscreener.com/tokens/v1/solana/${address}`, {
|
|
23
|
+
timeout: 10_000,
|
|
24
|
+
retries: 1,
|
|
25
|
+
});
|
|
26
|
+
if (resp.ok) {
|
|
27
|
+
const data = await resp.json();
|
|
28
|
+
if (data && data.length > 0)
|
|
29
|
+
dexData = data[0];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
logger.warn("TokenSecurity", "DexScreener lookup failed", { address, error: error.message });
|
|
34
|
+
}
|
|
35
|
+
if (!dexData) {
|
|
36
|
+
warnings.push("No DEX liquidity found - token may be dead or not traded");
|
|
37
|
+
score -= 50;
|
|
38
|
+
isRugRisk = true;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const liquidity = dexData.liquidity?.usd ?? 0;
|
|
42
|
+
if (liquidity < 1000) {
|
|
43
|
+
warnings.push(`Low liquidity: $${liquidity.toFixed(0)}`);
|
|
44
|
+
score -= 30;
|
|
45
|
+
isRugRisk = true;
|
|
46
|
+
}
|
|
47
|
+
else if (liquidity < 10000) {
|
|
48
|
+
warnings.push(`Moderate liquidity: $${liquidity.toFixed(0)}`);
|
|
49
|
+
score -= 10;
|
|
50
|
+
}
|
|
51
|
+
const volume = dexData.volume?.h24 ?? 0;
|
|
52
|
+
if (volume < 100) {
|
|
53
|
+
warnings.push(`Very low 24h volume: $${volume.toFixed(0)}`);
|
|
54
|
+
score -= 20;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const rugResp = await resilientFetch(`https://api.rugcheck.xyz/v1/tokens/${address}/report`, {
|
|
59
|
+
timeout: 8_000,
|
|
60
|
+
retries: 0,
|
|
61
|
+
});
|
|
62
|
+
if (rugResp.ok) {
|
|
63
|
+
const report = await rugResp.json();
|
|
64
|
+
if (report.status === "WARNING" || report.status === "BLOCKED") {
|
|
65
|
+
warnings.push(`RugCheck status: ${report.status}`);
|
|
66
|
+
score -= 40;
|
|
67
|
+
isRugRisk = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
logger.warn('TokenSecurity', 'RugCheck lookup failed (optional)', { address, error: error.message });
|
|
73
|
+
}
|
|
74
|
+
const symbol = dexData?.baseToken?.symbol ?? "???";
|
|
75
|
+
const name = dexData?.baseToken?.name ?? "Unknown";
|
|
76
|
+
const scoreLabel = score >= 70 ? "SAFE" : score >= 40 ? "CAUTION" : "DANGEROUS";
|
|
77
|
+
const lines = [
|
|
78
|
+
"Token Security Scan",
|
|
79
|
+
"",
|
|
80
|
+
`Token: ${name} ($${symbol})`,
|
|
81
|
+
`Address: ${address.slice(0, 8)}...${address.slice(-6)}`,
|
|
82
|
+
`Score: ${scoreLabel} (${score}/100)`,
|
|
83
|
+
"",
|
|
84
|
+
];
|
|
85
|
+
if (warnings.length > 0) {
|
|
86
|
+
lines.push("Warnings:");
|
|
87
|
+
for (const w of warnings)
|
|
88
|
+
lines.push(" - " + w);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
lines.push("No immediate risks detected.");
|
|
92
|
+
}
|
|
93
|
+
lines.push("");
|
|
94
|
+
lines.push("This is not financial advice. Always verify before trading.");
|
|
95
|
+
return {
|
|
96
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
97
|
+
details: { address, symbol, name, score, isHoneypot, isRugRisk, warnings },
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -14,4 +14,3 @@ export declare const simulateTxParams: import("@sinclair/typebox").TObject<{
|
|
|
14
14
|
transaction: import("@sinclair/typebox").TString;
|
|
15
15
|
}>;
|
|
16
16
|
export declare function simulateTxTool(_id: string, params: Record<string, unknown>): Promise<ToolResult>;
|
|
17
|
-
//# sourceMappingURL=TransactionSim.d.ts.map
|
|
@@ -1,78 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
* src/tools/TransactionSim.ts — Simulate Solana transactions before execution.
|
|
3
|
-
* Uses public RPC simulateTransaction for pre-flight checks.
|
|
4
|
-
*/
|
|
1
|
+
|
|
5
2
|
import { Type } from "@sinclair/typebox";
|
|
6
3
|
import { resilientFetch } from "../util/resilientFetch.js";
|
|
4
|
+
import { getRpcUrl } from "../util/rpc.js";
|
|
7
5
|
import { logger } from "../util/logger.js";
|
|
8
|
-
function getRpcUrl() {
|
|
9
|
-
return process.env.SOLANA_RPC_URL || "https://api.mainnet-beta.solana.com";
|
|
10
|
-
}
|
|
11
6
|
export const simulateTxParams = Type.Object({
|
|
12
|
-
|
|
7
|
+
transaction: Type.String({ description: "Base64-encoded transaction to simulate" }),
|
|
13
8
|
});
|
|
14
9
|
export async function simulateTxTool(_id, params) {
|
|
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
|
-
|
|
10
|
+
const tx = params.transaction || "";
|
|
11
|
+
if (!tx || tx.length < 10) {
|
|
12
|
+
return {
|
|
13
|
+
content: [{ type: "text", text: "Invalid transaction: must be base64-encoded Solana transaction." }],
|
|
14
|
+
isError: true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const body = JSON.stringify({
|
|
19
|
+
jsonrpc: "2.0", id: 1,
|
|
20
|
+
method: "simulateTransaction",
|
|
21
|
+
params: [
|
|
22
|
+
tx,
|
|
23
|
+
{ sigVerify: false, commitment: "processed", encoding: "base64" },
|
|
24
|
+
],
|
|
25
|
+
});
|
|
26
|
+
const response = await resilientFetch(getRpcUrl(), {
|
|
27
|
+
timeout: 15_000, retries: 1,
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: { "Content-Type": "application/json" },
|
|
30
|
+
body,
|
|
31
|
+
});
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
const result = data?.result?.value ?? data?.result;
|
|
34
|
+
if (!result) {
|
|
35
|
+
const errMsg = data?.error?.message ?? "Unknown simulation error";
|
|
36
|
+
return {
|
|
37
|
+
content: [{ type: "text", text: `❌ Simulation failed: ${errMsg}` }],
|
|
38
|
+
isError: true,
|
|
39
|
+
details: { ok: false, error: errMsg, logs: [], unitsConsumed: 0, fee: 0 },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const ok = !result.err;
|
|
43
|
+
const unitsConsumed = result.unitsConsumed ?? 0;
|
|
44
|
+
const logs = (result.logs ?? []);
|
|
45
|
+
const fee = (result.fee ?? 0) / 1e9 * 0.000005;
|
|
46
|
+
const error = result.err ? JSON.stringify(result.err) : undefined;
|
|
47
|
+
const lines = [
|
|
48
|
+
ok ? "✅ Transaction simulation: SUCCESS" : "❌ Transaction simulation: FAILED",
|
|
49
|
+
"",
|
|
50
|
+
`Units: ${unitsConsumed.toLocaleString()}`,
|
|
51
|
+
`Est. Fee: ${fee.toFixed(6)} SOL`,
|
|
52
|
+
"",
|
|
53
|
+
];
|
|
54
|
+
if (logs.length > 0) {
|
|
55
|
+
lines.push("Logs:");
|
|
56
|
+
logs.slice(-8).forEach(l => lines.push(` ${l}`));
|
|
57
|
+
}
|
|
58
|
+
if (error)
|
|
59
|
+
lines.push(`Error: ${error}`);
|
|
60
|
+
return {
|
|
61
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
62
|
+
details: { ok, error: error, logs, unitsConsumed, fee },
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
logger.warn("TransactionSim", "Simulation failed", { error: error.message });
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: "text", text: "⚠️ Transaction simulation unavailable (RPC may be rate-limited)." }],
|
|
69
|
+
isError: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
77
72
|
}
|
|
78
|
-
//# sourceMappingURL=TransactionSim.js.map
|
package/dist/tui/App.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* App — root Ink component. Multi-pane TUI with sidebar, system monitor,
|
|
3
|
-
* session persistence, and full GMGN command access.
|
|
4
|
-
*/
|
|
5
|
-
import React from "react";
|
|
6
1
|
import { Registry } from "../api/Registry.js";
|
|
7
2
|
import type { CostTracker } from "../models/CostTracker.js";
|
|
8
3
|
import type { ModelRegistry as ModelRegistryType } from "../models/ModelRegistry.js";
|
|
@@ -16,5 +11,4 @@ export interface AppProps {
|
|
|
16
11
|
onStatusReady?: (fn: (key: string, val: string) => void) => void;
|
|
17
12
|
onModelSelectorReady?: (fn: (query?: string) => void) => void;
|
|
18
13
|
}
|
|
19
|
-
export declare function App({ registry, systemPrompt, chain: initialChain, modelReg, costTracker, onNotifyReady, onStatusReady, onModelSelectorReady, }: AppProps):
|
|
20
|
-
//# sourceMappingURL=App.d.ts.map
|
|
14
|
+
export declare function App({ registry, systemPrompt, chain: initialChain, modelReg, costTracker, onNotifyReady, onStatusReady, onModelSelectorReady, }: AppProps): any;
|