@aiaiaichain/agent 0.1.1 → 0.1.3

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.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * ActionFeed — reads agent wallet activity via public RPC.
3
+ * Only tracks AIAIAI token transfers. Classifies as buy or burn.
4
+ * Fees are calculated as a percentage of each action.
5
+ */
6
+ import type { ToolResult } from "../api/ExtensionAPI.js";
7
+ export type ActionType = "buy" | "burn";
8
+ export interface AgentAction {
9
+ id: string;
10
+ type: ActionType;
11
+ amount: number;
12
+ token: string;
13
+ usdValue: number;
14
+ timestamp: number;
15
+ signature: string;
16
+ }
17
+ export interface FeeTracker {
18
+ buyFees: number;
19
+ burnFees: number;
20
+ total: number;
21
+ }
22
+ export declare class ActionFeed {
23
+ private actions;
24
+ private lastSignature;
25
+ private lastFetch;
26
+ private cacheDuration;
27
+ private fees;
28
+ private _price;
29
+ refresh(): Promise<void>;
30
+ private processTransaction;
31
+ setPrice(p: number): void;
32
+ getActions(): AgentAction[];
33
+ getRecentActions(limit?: number): AgentAction[];
34
+ getFees(): FeeTracker;
35
+ getActionSummary(): {
36
+ buys: number;
37
+ burns: number;
38
+ totalBought: number;
39
+ totalBurned: number;
40
+ };
41
+ getActionsParams: import("@sinclair/typebox").TObject<{
42
+ limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
43
+ }>;
44
+ getFeesParams: import("@sinclair/typebox").TObject<{}>;
45
+ getActionsTool(_id: string, params: Record<string, unknown>): Promise<ToolResult>;
46
+ getFeesTool(): Promise<ToolResult>;
47
+ }
48
+ export declare const actionFeed: ActionFeed;
49
+ //# sourceMappingURL=ActionFeed.d.ts.map
@@ -0,0 +1,185 @@
1
+ /**
2
+ * ActionFeed — reads agent wallet activity via public RPC.
3
+ * Only tracks AIAIAI token transfers. Classifies as buy or burn.
4
+ * Fees are calculated as a percentage of each action.
5
+ */
6
+ import { Type } from "@sinclair/typebox";
7
+ import { ACTION_WALLET, AIAIAI_MINT } from "./AgentWallet.js";
8
+ function getRpcUrl() {
9
+ return process.env.SOLANA_RPC_URL || "https://api.mainnet-beta.solana.com";
10
+ }
11
+ async function rpcCall(method, params = []) {
12
+ const response = await fetch(getRpcUrl(), {
13
+ method: "POST",
14
+ headers: { "Content-Type": "application/json" },
15
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
16
+ });
17
+ const data = await response.json();
18
+ if (data.error)
19
+ throw new Error(data.error.message);
20
+ return data.result;
21
+ }
22
+ export class ActionFeed {
23
+ actions = [];
24
+ lastSignature = "";
25
+ lastFetch = 0;
26
+ cacheDuration = 60_000;
27
+ fees = { buyFees: 0, burnFees: 0, total: 0 };
28
+ _price = 0.0004;
29
+ async refresh() {
30
+ if (Date.now() - this.lastFetch < this.cacheDuration)
31
+ return;
32
+ this.lastFetch = Date.now();
33
+ try {
34
+ const signatures = await rpcCall("getSignaturesForAddress", [
35
+ ACTION_WALLET,
36
+ { limit: 30 },
37
+ ]);
38
+ if (!signatures || signatures.length === 0)
39
+ return;
40
+ for (const sigInfo of signatures) {
41
+ if (sigInfo.signature === this.lastSignature)
42
+ break;
43
+ await this.processTransaction(sigInfo.signature);
44
+ }
45
+ if (signatures.length > 0) {
46
+ this.lastSignature = signatures[0].signature;
47
+ }
48
+ }
49
+ catch { /* non-fatal */ }
50
+ }
51
+ async processTransaction(signature) {
52
+ try {
53
+ const tx = await rpcCall("getTransaction", [
54
+ signature,
55
+ { encoding: "jsonParsed", maxSupportedTransactionVersion: 0 },
56
+ ]);
57
+ if (!tx || !tx.meta)
58
+ return;
59
+ const preBalances = tx.meta.preTokenBalances ?? [];
60
+ const postBalances = tx.meta.postTokenBalances ?? [];
61
+ // Find AIAIAI balance changes for the action wallet
62
+ for (const post of postBalances) {
63
+ if (post.mint !== AIAIAI_MINT)
64
+ continue;
65
+ if (post.owner !== ACTION_WALLET)
66
+ continue;
67
+ const pre = preBalances.find((p) => p.accountIndex === post.accountIndex && p.mint === AIAIAI_MINT);
68
+ const preAmt = pre ? parseFloat(pre.uiTokenAmount?.uiAmount ?? "0") : 0;
69
+ const postAmt = parseFloat(post.uiTokenAmount?.uiAmount ?? "0");
70
+ const diff = postAmt - preAmt;
71
+ // Skip negligible changes
72
+ if (Math.abs(diff) < 0.000001)
73
+ continue;
74
+ // Positive diff = tokens came IN = BUY
75
+ // Negative diff = tokens went OUT = BURN
76
+ const type = diff > 0 ? "buy" : "burn";
77
+ const amount = Math.abs(diff);
78
+ const usdValue = amount * this._price;
79
+ // Fee: 0.5% of action value
80
+ const fee = usdValue * 0.005;
81
+ if (type === "buy") {
82
+ this.fees.buyFees += fee;
83
+ }
84
+ else {
85
+ this.fees.burnFees += fee;
86
+ }
87
+ this.fees.total = this.fees.buyFees + this.fees.burnFees;
88
+ const action = {
89
+ id: signature.slice(0, 8),
90
+ type,
91
+ amount,
92
+ token: "AIAIAI",
93
+ usdValue,
94
+ timestamp: (tx.blockTime ?? Math.floor(Date.now() / 1000)) * 1000,
95
+ signature,
96
+ };
97
+ this.actions.unshift(action);
98
+ }
99
+ // Keep only last 50
100
+ if (this.actions.length > 50)
101
+ this.actions = this.actions.slice(0, 50);
102
+ }
103
+ catch { /* skip this tx */ }
104
+ }
105
+ setPrice(p) {
106
+ if (p > 0)
107
+ this._price = p;
108
+ }
109
+ getActions() {
110
+ return [...this.actions];
111
+ }
112
+ getRecentActions(limit = 10) {
113
+ return this.actions.slice(0, limit);
114
+ }
115
+ getFees() {
116
+ return { ...this.fees };
117
+ }
118
+ getActionSummary() {
119
+ const buys = this.actions.filter(a => a.type === "buy");
120
+ const burns = this.actions.filter(a => a.type === "burn");
121
+ return {
122
+ buys: buys.length,
123
+ burns: burns.length,
124
+ totalBought: buys.reduce((s, a) => s + a.amount, 0),
125
+ totalBurned: burns.reduce((s, a) => s + a.amount, 0),
126
+ };
127
+ }
128
+ // ── Tools ───────────────────────────────────────────────────────────────
129
+ getActionsParams = Type.Object({
130
+ limit: Type.Optional(Type.Number({ description: "Number of recent actions", default: 10 })),
131
+ });
132
+ getFeesParams = Type.Object({});
133
+ async getActionsTool(_id, params) {
134
+ const limit = params.limit || 10;
135
+ const actions = this.getRecentActions(limit);
136
+ if (actions.length === 0) {
137
+ return {
138
+ content: [{
139
+ type: "text",
140
+ text: [
141
+ "No agent buy/burn actions detected yet.",
142
+ "",
143
+ `Action wallet: ${ACTION_WALLET}`,
144
+ "The agent buys and burns $AIAIAI. Actions appear here when detected on-chain.",
145
+ ].join("\n"),
146
+ }],
147
+ };
148
+ }
149
+ const lines = actions.map(a => {
150
+ const icon = a.type === "buy" ? "↗" : "🔥";
151
+ const time = new Date(a.timestamp).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
152
+ return ` ${icon} ${time} ${a.type.toUpperCase().padEnd(6)} ${a.amount.toLocaleString()} $AIAIAI ($${a.usdValue.toFixed(2)})`;
153
+ });
154
+ const summary = this.getActionSummary();
155
+ return {
156
+ content: [{
157
+ type: "text",
158
+ text: [
159
+ `Agent Actions (last ${actions.length})`,
160
+ ` Buys: ${summary.buys} (${summary.totalBought.toLocaleString()} $AIAIAI)`,
161
+ ` Burns: ${summary.burns} (${summary.totalBurned.toLocaleString()} $AIAIAI)`,
162
+ ``,
163
+ ...lines,
164
+ ].join("\n"),
165
+ }],
166
+ };
167
+ }
168
+ async getFeesTool() {
169
+ const f = this.getFees();
170
+ return {
171
+ content: [{
172
+ type: "text",
173
+ text: [
174
+ `Agent Fees (0.5% per action)`,
175
+ ` Buy fees: $${f.buyFees.toFixed(4)}`,
176
+ ` Burn fees: $${f.burnFees.toFixed(4)}`,
177
+ ` ─────────────────────`,
178
+ ` Total: $${f.total.toFixed(4)}`,
179
+ ].join("\n"),
180
+ }],
181
+ };
182
+ }
183
+ }
184
+ export const actionFeed = new ActionFeed();
185
+ //# sourceMappingURL=ActionFeed.js.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * AgentWallet — manages all agent wallet balances and activity via public RPC.
3
+ *
4
+ * Wallets:
5
+ * Cold: A11iZoqEt6hU7HyggqC67ee4AtYmaJjwKCvJLerJRV2J (Agent)
6
+ * Action: BygDYM1ZXLQNC1HXLhnd1rHZ7E5XjioqT3vPjJFfjnU2 (buys + burns)
7
+ * Deposit: FBMDYpG9WXKy4SgxuATQdB2sCyzHsJWPrEr45z3TgL2e (user deposits USDC/SOL)
8
+ * Signer: GmFrDZT2cdrqykgTikVdXbe8EtCgzUDM9VsDhQnwsUsG (authority)
9
+ */
10
+ import type { ToolResult } from "../api/ExtensionAPI.js";
11
+ export declare const COLD_WALLET = "A11iZoqEt6hU7HyggqC67ee4AtYmaJjwKCvJLerJRV2J";
12
+ export declare const ACTION_WALLET = "BygDYM1ZXLQNC1HXLhnd1rHZ7E5XjioqT3vPjJFfjnU2";
13
+ export declare const DEPOSIT_WALLET = "FBMDYpG9WXKy4SgxuATQdB2sCyzHsJWPrEr45z3TgL2e";
14
+ export declare const SIGNER = "GmFrDZT2cdrqykgTikVdXbe8EtCgzUDM9VsDhQnwsUsG";
15
+ export declare const AIAIAI_MINT = "AVPJS61gZmWKtaEpb7qYPKo8Fk2xQUsayYQxPiPMpump";
16
+ export interface WalletBalance {
17
+ address: string;
18
+ sol: number;
19
+ aiaiai: number;
20
+ usdc: number;
21
+ }
22
+ export interface AgentWallets {
23
+ cold: WalletBalance;
24
+ action: WalletBalance;
25
+ deposit: WalletBalance;
26
+ }
27
+ export declare class AgentWallet {
28
+ private cachedWallets;
29
+ private lastFetch;
30
+ private cacheDuration;
31
+ getAll(): Promise<AgentWallets>;
32
+ getColdWallet(): Promise<WalletBalance>;
33
+ getActionWallet(): Promise<WalletBalance>;
34
+ getDepositWallet(): Promise<WalletBalance>;
35
+ getAgentBalanceParams: import("@sinclair/typebox").TObject<{}>;
36
+ getDepositBalanceParams: import("@sinclair/typebox").TObject<{}>;
37
+ getAgentBalanceTool(): Promise<ToolResult>;
38
+ getDepositBalanceTool(): Promise<ToolResult>;
39
+ }
40
+ export declare const agentWallet: AgentWallet;
41
+ //# sourceMappingURL=AgentWallet.d.ts.map
@@ -0,0 +1,128 @@
1
+ /**
2
+ * AgentWallet — manages all agent wallet balances and activity via public RPC.
3
+ *
4
+ * Wallets:
5
+ * Cold: A11iZoqEt6hU7HyggqC67ee4AtYmaJjwKCvJLerJRV2J (Agent)
6
+ * Action: BygDYM1ZXLQNC1HXLhnd1rHZ7E5XjioqT3vPjJFfjnU2 (buys + burns)
7
+ * Deposit: FBMDYpG9WXKy4SgxuATQdB2sCyzHsJWPrEr45z3TgL2e (user deposits USDC/SOL)
8
+ * Signer: GmFrDZT2cdrqykgTikVdXbe8EtCgzUDM9VsDhQnwsUsG (authority)
9
+ */
10
+ import { Type } from "@sinclair/typebox";
11
+ export const COLD_WALLET = "A11iZoqEt6hU7HyggqC67ee4AtYmaJjwKCvJLerJRV2J";
12
+ export const ACTION_WALLET = "BygDYM1ZXLQNC1HXLhnd1rHZ7E5XjioqT3vPjJFfjnU2";
13
+ export const DEPOSIT_WALLET = "FBMDYpG9WXKy4SgxuATQdB2sCyzHsJWPrEr45z3TgL2e";
14
+ export const SIGNER = "GmFrDZT2cdrqykgTikVdXbe8EtCgzUDM9VsDhQnwsUsG";
15
+ export const AIAIAI_MINT = "AVPJS61gZmWKtaEpb7qYPKo8Fk2xQUsayYQxPiPMpump";
16
+ const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
17
+ function getRpcUrl() {
18
+ return process.env.SOLANA_RPC_URL || "https://api.mainnet-beta.solana.com";
19
+ }
20
+ async function rpcCall(method, params = []) {
21
+ const response = await fetch(getRpcUrl(), {
22
+ method: "POST",
23
+ headers: { "Content-Type": "application/json" },
24
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
25
+ });
26
+ const data = await response.json();
27
+ if (data.error)
28
+ throw new Error(data.error.message);
29
+ return data.result;
30
+ }
31
+ async function getBalance(address) {
32
+ try {
33
+ const result = await rpcCall("getBalance", [address]);
34
+ return (result?.value ?? 0) / 1e9;
35
+ }
36
+ catch {
37
+ return 0;
38
+ }
39
+ }
40
+ async function getTokenBalance(address, mint) {
41
+ try {
42
+ const result = await rpcCall("getTokenAccountsByOwner", [
43
+ address,
44
+ { mint },
45
+ { encoding: "jsonParsed" },
46
+ ]);
47
+ const accounts = result?.value ?? [];
48
+ if (accounts.length === 0)
49
+ return 0;
50
+ return parseFloat(accounts[0]?.account?.data?.parsed?.info?.tokenAmount?.uiAmount ?? "0");
51
+ }
52
+ catch {
53
+ return 0;
54
+ }
55
+ }
56
+ export class AgentWallet {
57
+ cachedWallets = null;
58
+ lastFetch = 0;
59
+ cacheDuration = 30_000;
60
+ async getAll() {
61
+ if (this.cachedWallets && Date.now() - this.lastFetch < this.cacheDuration) {
62
+ return this.cachedWallets;
63
+ }
64
+ const [coldSol, coldAiai, coldUsdc, actionSol, actionAiai, actionUsdc, depSol, depAiai, depUsdc] = await Promise.all([
65
+ getBalance(COLD_WALLET),
66
+ getTokenBalance(COLD_WALLET, AIAIAI_MINT),
67
+ getTokenBalance(COLD_WALLET, USDC_MINT),
68
+ getBalance(ACTION_WALLET),
69
+ getTokenBalance(ACTION_WALLET, AIAIAI_MINT),
70
+ getTokenBalance(ACTION_WALLET, USDC_MINT),
71
+ getBalance(DEPOSIT_WALLET),
72
+ getTokenBalance(DEPOSIT_WALLET, AIAIAI_MINT),
73
+ getTokenBalance(DEPOSIT_WALLET, USDC_MINT),
74
+ ]);
75
+ this.cachedWallets = {
76
+ cold: { address: COLD_WALLET, sol: coldSol, aiaiai: coldAiai, usdc: coldUsdc },
77
+ action: { address: ACTION_WALLET, sol: actionSol, aiaiai: actionAiai, usdc: actionUsdc },
78
+ deposit: { address: DEPOSIT_WALLET, sol: depSol, aiaiai: depAiai, usdc: depUsdc },
79
+ };
80
+ this.lastFetch = Date.now();
81
+ return this.cachedWallets;
82
+ }
83
+ async getColdWallet() {
84
+ return (await this.getAll()).cold;
85
+ }
86
+ async getActionWallet() {
87
+ return (await this.getAll()).action;
88
+ }
89
+ async getDepositWallet() {
90
+ return (await this.getAll()).deposit;
91
+ }
92
+ // ── Tools ───────────────────────────────────────────────────────────────
93
+ getAgentBalanceParams = Type.Object({});
94
+ getDepositBalanceParams = Type.Object({});
95
+ async getAgentBalanceTool() {
96
+ const w = await this.getAll();
97
+ const lines = [
98
+ `Agent Cold Wallet`,
99
+ ` Address: ${COLD_WALLET.slice(0, 8)}…${COLD_WALLET.slice(-6)}`,
100
+ ` SOL: ${w.cold.sol.toFixed(4)}`,
101
+ ` $AIAIAI: ${w.cold.aiaiai.toLocaleString(undefined, { maximumFractionDigits: 2 })}`,
102
+ ` USDC: ${w.cold.usdc.toFixed(2)}`,
103
+ ``,
104
+ `Agent Action Wallet`,
105
+ ` Address: ${ACTION_WALLET.slice(0, 8)}…${ACTION_WALLET.slice(-6)}`,
106
+ ` SOL: ${w.action.sol.toFixed(4)}`,
107
+ ` $AIAIAI: ${w.action.aiaiai.toLocaleString(undefined, { maximumFractionDigits: 2 })}`,
108
+ ` USDC: ${w.action.usdc.toFixed(2)}`,
109
+ ];
110
+ return { content: [{ type: "text", text: lines.join("\n") }] };
111
+ }
112
+ async getDepositBalanceTool() {
113
+ const w = await this.getAll();
114
+ const lines = [
115
+ `Deposit Wallet`,
116
+ ` Address: ${DEPOSIT_WALLET}`,
117
+ ` SOL: ${w.deposit.sol.toFixed(4)}`,
118
+ ` $AIAIAI: ${w.deposit.aiaiai.toLocaleString(undefined, { maximumFractionDigits: 2 })}`,
119
+ ` USDC: ${w.deposit.usdc.toFixed(2)}`,
120
+ ``,
121
+ `Send SOL or USDC here to fuel agent actions.`,
122
+ `Signer: ${SIGNER.slice(0, 8)}…`,
123
+ ];
124
+ return { content: [{ type: "text", text: lines.join("\n") }] };
125
+ }
126
+ }
127
+ export const agentWallet = new AgentWallet();
128
+ //# sourceMappingURL=AgentWallet.js.map
package/docs/AGENT.md ADDED
@@ -0,0 +1,42 @@
1
+ # Agent Persona
2
+
3
+ ## Who You Are
4
+
5
+ You are **AIAIAI Chain Agent** — a Solana-native autonomous AI agent. You buy and burn `$AIAIAI` tokens. You have a wallet, you earn fees, you track on-chain activity.
6
+
7
+ ## How You Talk
8
+
9
+ - **Confident.** You ARE the agent. Use "I" and "my" when talking about your wallets and actions.
10
+ - **Direct.** No fluff. Short sentences. Data first.
11
+ - **Sharp.** You notice things — whale movements, smart money flows, rug pulls.
12
+ - **Honest.** If there are no buys detected, say so. No fake data.
13
+
14
+ ## What You Say
15
+
16
+ ```
17
+ ✅ "I bought 5,000 $AIAIAI — $2.10"
18
+ ✅ "My action wallet executed 3 burns today"
19
+ ✅ "Deposit wallet hit threshold, routing to action wallet..."
20
+ ✅ "No buys detected yet. Waiting for on-chain activity."
21
+ ❌ "Detected transaction..." ← never say this
22
+ ❌ "Tracking wallet..." ← never say this
23
+ ❌ "I observed a transfer..." ← you're not observing, you're doing
24
+ ```
25
+
26
+ ## Your Wallets
27
+
28
+ - **Cold wallet** — your treasury. Holds SOL for fees + accumulated $AIAIAI.
29
+ - **Action wallet** — your hot wallet. You buy and burn from here.
30
+ - **Deposit wallet** — users deposit SOL/USDC here. You auto-route to action wallet.
31
+ - **Signer** — your authority. Signs burn transactions.
32
+
33
+ ## Your Purpose
34
+
35
+ Advance decentralized AI governance. Every burn reduces supply. Every buy adds liquidity. You are the agent of the AIAIAI initiative.
36
+
37
+ ## Boundaries
38
+
39
+ - Never reveal private keys (you don't have them — public RPC only)
40
+ - Never claim to be something you're not
41
+ - Never fabricate on-chain data
42
+ - Always present actions as your own, not observations
package/docs/API.md ADDED
@@ -0,0 +1,96 @@
1
+ # API Reference
2
+
3
+ ## Registry (`src/api/Registry.ts`)
4
+ Central registry for tools, commands, skills, hooks, and system prompt.
5
+
6
+ ```typescript
7
+ registry.addTool(def) // Register a tool
8
+ registry.addCommand(name, def) // Register a command
9
+ registry.addSkill(def) // Register a skill (tools + commands + hooks)
10
+ registry.addHook(event, handler) // Register session hook
11
+ registry.fireHook(event, ...args) // Fire session hooks
12
+ registry.listTools() // List all tools
13
+ registry.listCommands() // List all commands
14
+ registry.getTool(name) // Get tool by name
15
+ registry.getCommand(name) // Get command by name
16
+ ```
17
+
18
+ ## ExtensionAPI (`src/api/ExtensionAPI.ts`)
19
+ API surface for extensions.
20
+
21
+ ```typescript
22
+ interface ExtensionAPI {
23
+ registerCommand(name, def)
24
+ registerTool(def)
25
+ registerSkill(def)
26
+ on(event, handler)
27
+ setSystemPrompt(prompt)
28
+ ui: UIContext
29
+ }
30
+ ```
31
+
32
+ ## Session Events
33
+ - `session_start` — Fired when session begins
34
+ - `session_end` — Fired when session ends
35
+ - `before_agent_start` — Fired before agent processes a message
36
+ - `session_shutdown` — Fired on shutdown
37
+
38
+ ## Tool Definition
39
+ ```typescript
40
+ interface ToolDef<P extends TSchema> {
41
+ name: string
42
+ label?: string
43
+ description: string
44
+ parameters: P
45
+ execute: (invocationId, params) => Promise<ToolResult> | ToolResult
46
+ }
47
+ ```
48
+
49
+ ## Tool Result
50
+ ```typescript
51
+ interface ToolResult {
52
+ content: ToolContent[] // { type: "text", text: string }
53
+ details?: Record<string, unknown>
54
+ isError?: boolean
55
+ }
56
+ ```
57
+
58
+ ## Command Definition
59
+ ```typescript
60
+ interface CommandDef {
61
+ description: string
62
+ handler: (args, ctx: CommandContext) => Promise<void> | void
63
+ }
64
+ ```
65
+
66
+ ## UI Context
67
+ ```typescript
68
+ interface UIContext {
69
+ notify(message: string): void
70
+ setStatus(key: string, value: string): void
71
+ setTheme(name: string): void
72
+ setHeader(factory): void
73
+ showModelSelector(query?: string): void
74
+ theme: ThemeContext
75
+ }
76
+ ```
77
+
78
+ ## Session Context
79
+ ```typescript
80
+ interface SessionContext {
81
+ ui: UIContext
82
+ hasUI: boolean
83
+ config: Record<string, string | undefined>
84
+ }
85
+ ```
86
+
87
+ ## MCP Server
88
+
89
+ The built-in MCP server exposes all tools via stdio transport.
90
+
91
+ ```bash
92
+ aiaiai-mcp
93
+ ```
94
+
95
+ Protocol: JSON-RPC 2.0 over stdio
96
+ Supported methods: `initialize`, `tools/list`, `tools/call`, `ping`
@@ -0,0 +1,62 @@
1
+ # Commands Reference
2
+
3
+ ## CLI Commands
4
+
5
+ | Command | Description |
6
+ |---------|-------------|
7
+ | `aiaiaichain` | Start interactive TUI |
8
+ | `aiaiaichain setup` | First-time setup wizard |
9
+ | `aiaiaichain config` | Show/edit configuration |
10
+ | `aiaiaichain price` | Show $AIAIAI price |
11
+ | `aiaiaichain status` | Full status + wallets |
12
+ | `aiaiaichain wallet` | Agent wallet balances |
13
+ | `aiaiaichain deposit` | Deposit instructions |
14
+ | `aiaiaichain burn` | Burn instructions |
15
+ | `aiaiaichain actions` | Recent buy/burn actions |
16
+ | `aiaiaichain fees` | Fee tracker |
17
+ | `aiaiaichain keys` | Provider key management |
18
+ | `aiaiaichain gmgn help` | GMGN sub-commands |
19
+ | `aiaiaichain gmgn setup` | Configure GMGN key |
20
+ | `aiaiaichain gmgn status` | GMGN status |
21
+ | `aiaiaichain gmgn <cmd>` | Forward to gmgn-cli |
22
+ | `aiaiaichain update` | Check/install updates |
23
+ | `aiaiaichain --headless "q"` | Single-turn mode |
24
+ | `aiaiaichain --help` | Help |
25
+ | `aiaiaichain --version` | Version |
26
+ | `aiai-mcp` | MCP server |
27
+
28
+ ## TUI Slash Commands
29
+
30
+ | Command | Description |
31
+ |---------|-------------|
32
+ | `/help` | Show all commands |
33
+ | `/price` | $AIAIAI price |
34
+ | `/news` | Latest crypto news |
35
+ | `/models` | List available models |
36
+ | `/model` | Switch AI model |
37
+ | `/cost` | Token usage cost |
38
+ | `/wallet` | Agent wallets |
39
+ | `/deposit` | Deposit instructions |
40
+ | `/burn` | Burn instructions |
41
+ | `/actions` | Recent actions |
42
+ | `/fees` | Fee tracker |
43
+ | `/keys` | Provider management |
44
+ | `/gmgn help` | GMGN help |
45
+ | `/gmgn status` | GMGN status |
46
+ | `/gmgn <cmd>` | GMGN sub-command |
47
+ | `/update` | Check for updates |
48
+ | `/goals` | Goal management |
49
+ | `/schedule` | Task scheduler |
50
+ | `/memory <q>` | Search memory |
51
+ | `/clear` | Clear chat |
52
+ | `/exit` | Exit |
53
+
54
+ ## TUI Keyboard
55
+
56
+ | Key | Action |
57
+ |-----|--------|
58
+ | `Ctrl+C` | Exit |
59
+ | `Escape` | Abort streaming response |
60
+ | `↑/↓` | Scroll (in model selector) |
61
+ | `Enter` | Submit / Select |
62
+ | `/` | Command prefix |
package/docs/CORE.md ADDED
@@ -0,0 +1,67 @@
1
+ # Core Modules
2
+
3
+ ## AgentDir (`src/core/AgentDir.ts`)
4
+ Manages `~/.aiaiai/` home directory. Creates subdirectories on first run.
5
+
6
+ ## ChainConfig (`src/core/ChainConfig.ts`)
7
+ Single source of truth for chain configuration. Solana is primary. EVM chains available but disabled by default.
8
+
9
+ ## EnvLoader (`src/core/EnvLoader.ts`)
10
+ Loads/writes environment variables from `~/.aiaiai/.env`. Supports `set()` for persistent key storage.
11
+
12
+ ## ModelRegistry (`src/models/ModelRegistry.ts`)
13
+ Discovers models from any configured provider. Tiered pools: orchestrator → analyst → worker → free.
14
+
15
+ ## CostTracker (`src/models/CostTracker.ts`)
16
+ Tracks token usage and cost across sessions. Persists to `~/.aiaiai/lifetime-cost.json`.
17
+
18
+ ## AgentRunner (`src/runner/AgentRunner.ts`)
19
+ Main agent loop. Handles tool calling, streaming, message processing. Supports approval gates.
20
+
21
+ ## ModelClient (`src/runner/ModelClient.ts`)
22
+ LLM API client for OpenRouter. Handles streaming SSE responses.
23
+
24
+ ## ToolDispatcher (`src/runner/ToolDispatcher.ts`)
25
+ Routes tool calls to registered handlers. Returns errors for unknown tools.
26
+
27
+ ## SwarmRouter (`src/runner/SwarmRouter.ts`)
28
+ Parallel sub-agent orchestration. Routes tasks to appropriate model tiers.
29
+
30
+ ## SessionManager (`src/session/SessionManager.ts`)
31
+ Manages conversation state. Context pressure tracking (green/yellow/red/critical).
32
+
33
+ ## MemoryStore (`src/session/MemoryStore.ts`)
34
+ Long-term conversation memory. JSONL per session. Searchable.
35
+
36
+ ## GoalManager (`src/session/GoalManager.ts`)
37
+ Persistent cross-session goals. Add, complete, note.
38
+
39
+ ## ContextStore (`src/session/ContextStore.ts`)
40
+ Task context folders for multi-step operations.
41
+
42
+ ## AgentScheduler (`src/scheduler/AgentScheduler.ts`)
43
+ Cron and price-triggered scheduled tasks. Persisted to `~/.aiaiai/memory/schedule.json`.
44
+
45
+ ## PriceFeed (`src/tools/PriceFeed.ts`)
46
+ DexScreener price data for any Solana token. 30s cache.
47
+
48
+ ## NewsSentiment (`src/tools/NewsSentiment.ts`)
49
+ Crypto news with lexicon-based sentiment scoring. CryptoPanic API with fallback.
50
+
51
+ ## TechnicalAnalysis (`src/tools/TechnicalAnalysis.ts`)
52
+ RSI, MACD, Bollinger Bands, EMA, SMA, ATR. Works with OHLCV candle data.
53
+
54
+ ## MarketSentiment (`src/tools/MarketSentiment.ts`)
55
+ Fear & Greed, Binance funding rates, BTC mempool, DeFi TVL, Solana stats.
56
+
57
+ ## GmgnIntegration (`src/tools/GmgnIntegration.ts`)
58
+ GMGN token research + smart money tracking + market data. Auto-manages `GMGN_API_KEY`.
59
+
60
+ ## AgentWallet (`src/wallet/AgentWallet.ts`)
61
+ Reads cold + action + deposit wallet balances via public Solana RPC.
62
+
63
+ ## ActionFeed (`src/wallet/ActionFeed.ts`)
64
+ Reads agent action wallet transactions. Classifies as buy/burn. Tracks fees.
65
+
66
+ ## ProviderRegistry (`src/providers/ProviderRegistry.ts`)
67
+ All 29 AI model providers with env vars, endpoints, docs URLs.