@aiaiaichain/agent 0.1.3 → 0.1.5
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/README.md +2 -2
- package/dist/cli.js +274 -26
- package/dist/core/ChainConfig.js +1 -1
- package/dist/core/SystemMonitor.d.ts +32 -0
- package/dist/core/SystemMonitor.js +89 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +18 -1
- package/dist/models/ModelRegistry.js +12 -4
- package/dist/runner/AgentRunner.d.ts +2 -0
- package/dist/runner/AgentRunner.js +18 -1
- package/dist/runner/ModelClient.js +109 -48
- package/dist/session/SessionManager.d.ts +1 -0
- package/dist/session/SessionManager.js +8 -2
- package/dist/session/SessionStore.d.ts +45 -0
- package/dist/session/SessionStore.js +128 -0
- package/dist/tools/CrossTools.d.ts +52 -0
- package/dist/tools/CrossTools.js +190 -0
- package/dist/tools/MarketSentiment.js +22 -13
- package/dist/tools/NewsSentiment.js +9 -3
- package/dist/tools/PriceFeed.js +11 -4
- package/dist/tools/TechnicalAnalysis.js +2 -1
- package/dist/tools/TokenCalendar.d.ts +24 -0
- package/dist/tools/TokenCalendar.js +81 -0
- package/dist/tools/TokenSecurityScanner.d.ts +22 -0
- package/dist/tools/TokenSecurityScanner.js +102 -0
- package/dist/tools/TransactionSim.d.ts +17 -0
- package/dist/tools/TransactionSim.js +78 -0
- package/dist/tui/App.d.ts +4 -3
- package/dist/tui/App.js +371 -118
- package/dist/tui/REPL.d.ts +2 -1
- package/dist/tui/REPL.js +190 -16
- package/dist/tui/Sparkline.d.ts +21 -0
- package/dist/tui/Sparkline.js +44 -0
- package/dist/tui/StatusBar.d.ts +5 -1
- package/dist/tui/StatusBar.js +6 -4
- package/dist/tui/ThemePresets.d.ts +25 -0
- package/dist/tui/ThemePresets.js +117 -0
- package/dist/util/clipboard.d.ts +9 -0
- package/dist/util/clipboard.js +26 -0
- package/dist/util/commandSuggest.d.ts +7 -0
- package/dist/util/commandSuggest.js +44 -0
- package/dist/util/confirmation.d.ts +6 -0
- package/dist/util/confirmation.js +16 -0
- package/dist/util/errorHandler.d.ts +3 -0
- package/dist/util/errorHandler.js +28 -0
- package/dist/util/logger.d.ts +11 -0
- package/dist/util/logger.js +43 -0
- package/dist/util/processManager.d.ts +5 -0
- package/dist/util/processManager.js +39 -0
- package/dist/util/resilientFetch.d.ts +21 -0
- package/dist/util/resilientFetch.js +94 -0
- package/dist/util/responseCache.d.ts +27 -0
- package/dist/util/responseCache.js +54 -0
- package/dist/util/safeLog.d.ts +4 -5
- package/dist/util/safeLog.js +68 -30
- package/dist/util/scheduler.d.ts +14 -0
- package/dist/util/scheduler.js +75 -0
- package/dist/util/webhooks.d.ts +9 -0
- package/dist/util/webhooks.js +75 -0
- package/dist/wallet/ActionFeed.js +12 -4
- package/dist/wallet/AgentWallet.d.ts +2 -0
- package/dist/wallet/AgentWallet.js +31 -5
- package/dist/wallet/ProfitTracker.d.ts +30 -0
- package/dist/wallet/ProfitTracker.js +93 -0
- package/docs/COMMANDS.md +40 -9
- package/docs/README.md +2 -0
- package/package.json +5 -3
- package/scripts/postinstall.js +34 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/tools/TransactionSim.ts — Simulate Solana transactions before execution.
|
|
3
|
+
* Uses public RPC simulateTransaction for pre-flight checks.
|
|
4
|
+
*/
|
|
5
|
+
import { Type } from "@sinclair/typebox";
|
|
6
|
+
import { resilientFetch } from "../util/resilientFetch.js";
|
|
7
|
+
import { logger } from "../util/logger.js";
|
|
8
|
+
function getRpcUrl() {
|
|
9
|
+
return process.env.SOLANA_RPC_URL || "https://api.mainnet-beta.solana.com";
|
|
10
|
+
}
|
|
11
|
+
export const simulateTxParams = Type.Object({
|
|
12
|
+
transaction: Type.String({ description: "Base64-encoded transaction to simulate" }),
|
|
13
|
+
});
|
|
14
|
+
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
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=TransactionSim.js.map
|
package/dist/tui/App.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* App — root Ink component. Multi-pane TUI with sidebar
|
|
3
|
-
* and
|
|
2
|
+
* App — root Ink component. Multi-pane TUI with sidebar, system monitor,
|
|
3
|
+
* session persistence, and full GMGN command access.
|
|
4
4
|
*/
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { Registry } from "../api/Registry.js";
|
|
7
7
|
import type { CostTracker } from "../models/CostTracker.js";
|
|
8
|
+
import type { ModelRegistry as ModelRegistryType } from "../models/ModelRegistry.js";
|
|
8
9
|
export interface AppProps {
|
|
9
10
|
registry: Registry;
|
|
10
11
|
systemPrompt?: string;
|
|
11
12
|
chain?: string;
|
|
12
|
-
modelReg?:
|
|
13
|
+
modelReg?: ModelRegistryType;
|
|
13
14
|
costTracker?: CostTracker;
|
|
14
15
|
onNotifyReady?: (fn: (msg: string) => void) => void;
|
|
15
16
|
onStatusReady?: (fn: (key: string, val: string) => void) => void;
|