@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.
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 +364 -768
  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 +70 -85
  15. package/dist/index.d.ts +4 -61
  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 +17 -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 +1 -7
  72. package/dist/tui/App.js +896 -825
  73. package/dist/tui/ModelSelector.d.ts +1 -3
  74. package/dist/tui/ModelSelector.js +47 -50
  75. package/dist/tui/REPL.d.ts +1 -3
  76. package/dist/tui/REPL.js +222 -210
  77. package/dist/tui/Sparkline.d.ts +1 -3
  78. package/dist/tui/Sparkline.js +38 -37
  79. package/dist/tui/StatusBar.d.ts +1 -3
  80. package/dist/tui/StatusBar.js +11 -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 +0 -1
  112. package/dist/wallet/ActionFeed.js +189 -200
  113. package/dist/wallet/AgentWallet.d.ts +7 -8
  114. package/dist/wallet/AgentWallet.js +117 -144
  115. package/dist/wallet/ProfitTracker.d.ts +0 -1
  116. package/dist/wallet/ProfitTracker.js +71 -74
  117. package/package.json +14 -8
  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 +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
- chain: Type.Optional(Type.String({ description: "Chain: solana, ethereum, bsc, base", default: "solana" })),
11
- limit: Type.Optional(Type.Number({ description: "Max entries", default: 10 })),
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; // 5 min
11
+ const CACHE_DURATION = 300_000;
16
12
  export async function launchCalendarTool(_id, params) {
17
- const chain = params.chain || "solana";
18
- const limit = params.limit || 10;
19
- if (Date.now() - lastFetch < CACHE_DURATION && cachedLaunches.length > 0) {
20
- const filtered = cachedLaunches.filter(l => l.chain === chain).slice(0, limit);
21
- return formatResult(filtered, chain);
22
- }
23
- try {
24
- // DexScreener "latest" endpoint per chain
25
- const url = `https://api.dexscreener.com/latest/dex/tokens/${chain}`;
26
- const response = await resilientFetch(url, { timeout: 10_000, retries: 1 });
27
- if (!response.ok) {
28
- return { content: [{ type: "text", text: `Token launch calendar unavailable for ${chain}.` }] };
29
- }
30
- const data = await response.json();
31
- const pairs = data?.pairs ?? [];
32
- cachedLaunches = pairs.map((p) => {
33
- const createdAt = p.pairCreatedAt ? new Date(p.pairCreatedAt) : null;
34
- const now = Date.now();
35
- const diffMs = createdAt ? now - createdAt.getTime() : Infinity;
36
- const age = createdAt
37
- ? diffMs < 3600000 ? `${Math.floor(diffMs / 60000)}m ago`
38
- : diffMs < 86400000 ? `${Math.floor(diffMs / 3600000)}h ago`
39
- : `${Math.floor(diffMs / 86400000)}d ago`
40
- : "unknown";
41
- return {
42
- address: p.baseToken?.address ?? "",
43
- symbol: p.baseToken?.symbol ?? "???",
44
- name: p.baseToken?.name ?? "Unknown",
45
- priceUsd: p.priceUsd ?? null,
46
- volume24h: p.volume?.h24 ?? 0,
47
- liquidityUsd: p.liquidity?.usd ?? 0,
48
- age,
49
- chain,
50
- };
51
- });
52
- lastFetch = Date.now();
53
- const filtered = cachedLaunches.slice(0, limit);
54
- return formatResult(filtered, chain);
55
- }
56
- catch (error) {
57
- logger.warn("TokenCalendar", "Failed to fetch launches", { chain, error: error.message });
58
- return { content: [{ type: "text", text: `Token launch calendar: Data temporarily unavailable.` }] };
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
- if (launches.length === 0) {
63
- return { content: [{ type: "text", text: `No recent launches found on ${chain}.` }] };
64
- }
65
- const lines = [`🚀 Recent Token Launches — ${chain.toUpperCase()}`, ""];
66
- for (const l of launches.slice(0, 10)) {
67
- const price = l.priceUsd ? `$${parseFloat(l.priceUsd).toFixed(8)}` : "N/A";
68
- const vol = l.volume24h > 0 ? `$${(l.volume24h / 1000).toFixed(1)}k` : "no vol";
69
- const liq = l.liquidityUsd > 0 ? `$${(l.liquidityUsd / 1000).toFixed(1)}k` : "no liq";
70
- lines.push(` ${l.symbol.padEnd(10)} ${price.padEnd(16)} ${vol.padEnd(10)} ${l.age.padEnd(10)} ${l.address.slice(0, 6)}…`);
71
- }
72
- return { content: [{ type: "text", text: lines.join("\n") }], details: { launches } };
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
- /** Get sidebar-ready summary */
70
+
75
71
  export function getLaunchSummary() {
76
- if (cachedLaunches.length === 0)
77
- return "Loading…";
78
- const recent = cachedLaunches.slice(0, 3);
79
- return recent.map(l => l.symbol).join(" · ");
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
- address: Type.String({ description: "Token mint address on Solana" }),
6
+ address: Type.String({ description: "Token mint address on Solana" }),
9
7
  });
10
8
  export async function scanTokenSecurityTool(_id, params) {
11
- const address = params.address;
12
- if (!address || address.length < 32 || address.length > 44) {
13
- return {
14
- content: [{ type: "text", text: "Invalid token address format." }],
15
- isError: true,
16
- };
17
- }
18
- const warnings = [];
19
- let score = 100;
20
- let isHoneypot = false;
21
- let isRugRisk = false;
22
- let dexData = null;
23
- try {
24
- const resp = await resilientFetch(`https://api.dexscreener.com/tokens/v1/solana/${address}`, {
25
- timeout: 10_000,
26
- retries: 1,
27
- });
28
- if (resp.ok) {
29
- const data = await resp.json();
30
- if (data && data.length > 0)
31
- dexData = data[0];
32
- }
33
- }
34
- catch (error) {
35
- logger.warn("TokenSecurity", "DexScreener lookup failed", { address, error: error.message });
36
- }
37
- if (!dexData) {
38
- warnings.push("No DEX liquidity found - token may be dead or not traded");
39
- score -= 50;
40
- isRugRisk = true;
41
- }
42
- else {
43
- const liquidity = dexData.liquidity?.usd ?? 0;
44
- if (liquidity < 1000) {
45
- warnings.push(`Low liquidity: $${liquidity.toFixed(0)}`);
46
- score -= 30;
47
- isRugRisk = true;
48
- }
49
- else if (liquidity < 10000) {
50
- warnings.push(`Moderate liquidity: $${liquidity.toFixed(0)}`);
51
- score -= 10;
52
- }
53
- const volume = dexData.volume?.h24 ?? 0;
54
- if (volume < 100) {
55
- warnings.push(`Very low 24h volume: $${volume.toFixed(0)}`);
56
- score -= 20;
57
- }
58
- }
59
- try {
60
- const rugResp = await resilientFetch(`https://api.rugcheck.xyz/v1/tokens/${address}/report`, {
61
- timeout: 8_000,
62
- retries: 0,
63
- });
64
- if (rugResp.ok) {
65
- const report = await rugResp.json();
66
- if (report.status === "WARNING" || report.status === "BLOCKED") {
67
- warnings.push(`RugCheck status: ${report.status}`);
68
- score -= 40;
69
- isRugRisk = true;
70
- }
71
- }
72
- }
73
- catch (error) {
74
- logger.warn('TokenSecurity', 'RugCheck lookup failed (optional)', { address, error: error.message });
75
- }
76
- const symbol = dexData?.baseToken?.symbol ?? "???";
77
- const name = dexData?.baseToken?.name ?? "Unknown";
78
- const scoreLabel = score >= 70 ? "SAFE" : score >= 40 ? "CAUTION" : "DANGEROUS";
79
- const lines = [
80
- "Token Security Scan",
81
- "",
82
- `Token: ${name} ($${symbol})`,
83
- `Address: ${address.slice(0, 8)}...${address.slice(-6)}`,
84
- `Score: ${scoreLabel} (${score}/100)`,
85
- "",
86
- ];
87
- if (warnings.length > 0) {
88
- lines.push("Warnings:");
89
- for (const w of warnings)
90
- lines.push(" - " + w);
91
- }
92
- else {
93
- lines.push("No immediate risks detected.");
94
- }
95
- lines.push("");
96
- lines.push("This is not financial advice. Always verify before trading.");
97
- return {
98
- content: [{ type: "text", text: lines.join("\n") }],
99
- details: { address, symbol, name, score, isHoneypot, isRugRisk, warnings },
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
- transaction: Type.String({ description: "Base64-encoded transaction to simulate" }),
7
+ transaction: Type.String({ description: "Base64-encoded transaction to simulate" }),
13
8
  });
14
9
  export async function simulateTxTool(_id, params) {
15
- const tx = params.transaction || "";
16
- if (!tx || tx.length < 10) {
17
- return {
18
- content: [{ type: "text", text: "Invalid transaction: must be base64-encoded Solana transaction." }],
19
- isError: true,
20
- };
21
- }
22
- try {
23
- const body = JSON.stringify({
24
- jsonrpc: "2.0", id: 1,
25
- method: "simulateTransaction",
26
- params: [
27
- tx,
28
- { sigVerify: false, commitment: "processed", encoding: "base64" },
29
- ],
30
- });
31
- const response = await resilientFetch(getRpcUrl(), {
32
- timeout: 15_000, retries: 1,
33
- method: "POST",
34
- headers: { "Content-Type": "application/json" },
35
- body,
36
- });
37
- const data = await response.json();
38
- const result = data?.result?.value ?? data?.result;
39
- if (!result) {
40
- const errMsg = data?.error?.message ?? "Unknown simulation error";
41
- return {
42
- content: [{ type: "text", text: `❌ Simulation failed: ${errMsg}` }],
43
- isError: true,
44
- details: { ok: false, error: errMsg, logs: [], unitsConsumed: 0, fee: 0 },
45
- };
46
- }
47
- const ok = !result.err;
48
- const unitsConsumed = result.unitsConsumed ?? 0;
49
- const logs = (result.logs ?? []);
50
- const fee = (result.fee ?? 0) / 1e9 * 0.000005; // rough estimate
51
- const error = result.err ? JSON.stringify(result.err) : undefined;
52
- const lines = [
53
- ok ? "✅ Transaction simulation: SUCCESS" : "❌ Transaction simulation: FAILED",
54
- "",
55
- `Units: ${unitsConsumed.toLocaleString()}`,
56
- `Est. Fee: ${fee.toFixed(6)} SOL`,
57
- "",
58
- ];
59
- if (logs.length > 0) {
60
- lines.push("Logs:");
61
- logs.slice(-8).forEach(l => lines.push(` ${l}`));
62
- }
63
- if (error)
64
- lines.push(`Error: ${error}`);
65
- return {
66
- content: [{ type: "text", text: lines.join("\n") }],
67
- details: { ok, error: error, logs, unitsConsumed, fee },
68
- };
69
- }
70
- catch (error) {
71
- logger.warn("TransactionSim", "Simulation failed", { error: error.message });
72
- return {
73
- content: [{ type: "text", text: "⚠️ Transaction simulation unavailable (RPC may be rate-limited)." }],
74
- isError: true,
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): React.JSX.Element;
20
- //# sourceMappingURL=App.d.ts.map
14
+ export declare function App({ registry, systemPrompt, chain: initialChain, modelReg, costTracker, onNotifyReady, onStatusReady, onModelSelectorReady, }: AppProps): any;