aiusd-skill 1.0.0

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 ADDED
@@ -0,0 +1,143 @@
1
+ # AIUSD Skill for OpenClaw/ClawdBot
2
+
3
+ The official AIUSD trading skill for your personal AI assistant. Trade cryptocurrencies, check balances, and manage your AIUSD account through natural language conversations in Telegram, Discord, WhatsApp, or any platform your bot supports.
4
+
5
+ ## 🚀 Quick Start
6
+
7
+ ### Step 1: Install the Skill
8
+
9
+ **Option A: Drag & Drop (Easiest)**
10
+ 1. Download the skill file: **[Download aiusd-skill-agent.skill](https://github.com/galpha-ai/aiusd-skills/releases/download/v1.0.0/aiusd-skill-agent.skill)**
11
+ 2. Start your ClawdBot/OpenClaw assistant
12
+ 3. Open your chat (Telegram, Discord, WhatsApp, etc.)
13
+ 4. Drag and drop the downloaded `.skill` file into the chat
14
+ 5. Your bot will automatically install the skill
15
+
16
+ **Option B: npx (one command)**
17
+ ```bash
18
+ npx aiusd-skills install
19
+ cd aiusd-skill && npm run reauth
20
+ ```
21
+ Then point your OpenClaude/skill runner at the `aiusd-skill` directory.
22
+
23
+ **Option C: Manual Installation**
24
+ 1. Download and extract the skill file: **[Download aiusd-skill-agent.skill](https://github.com/galpha-ai/aiusd-skills/releases/download/v1.0.0/aiusd-skill-agent.skill)**
25
+ 2. Extract: `tar -xzf aiusd-skill-agent.skill`
26
+ 3. Copy the extracted folder to your OpenClaw skills directory
27
+ 4. Restart your bot
28
+
29
+ ### Step 2: Authentication Setup
30
+
31
+ The bot will automatically handle authentication when you first use AIUSD features. If automatic login fails, simply tell your bot: *"re-login"* in the chat.
32
+
33
+ ### Step 3: Start Trading!
34
+
35
+ Now you can talk to your bot naturally:
36
+
37
+ - *"What's my AIUSD balance?"*
38
+ - *"Buy $100 worth of SOL with USDC"*
39
+ - *"Show my recent transactions"*
40
+ - *"What are my trading addresses?"*
41
+
42
+ ## 💬 What You Can Ask Your Bot
43
+
44
+ ### Check Balance & Accounts
45
+ - *"Check my AIUSD balance"*
46
+ - *"How much do I have in my account?"*
47
+ - *"What's my total portfolio value?"*
48
+ - *"Show me my trading addresses"*
49
+
50
+ ### Execute Trades
51
+ - *"Buy $50 of SOL with USDC"*
52
+ - *"Sell 100 USDC for ETH"*
53
+ - *"Swap 0.1 ETH to SOL"*
54
+ - *"Trade 1000 USDC for BTC"*
55
+
56
+ ### Staking Operations
57
+ - *"Stake 500 AIUSD"*
58
+ - *"Unstake my AIUSD"*
59
+ - *"How much am I earning from staking?"*
60
+
61
+ ### Transaction History
62
+ - *"Show my last 10 transactions"*
63
+ - *"What trades did I make today?"*
64
+ - *"Check my transaction history"*
65
+
66
+ ### Account Management
67
+ - *"Withdraw 100 USDC to my wallet"*
68
+ - *"Top up gas for Solana"*
69
+ - *"Ensure I have enough gas"*
70
+
71
+ ### Deposits & Recharge
72
+ - *"How can I add funds to my account?"*
73
+ - *"I want to deposit money"*
74
+ - *"Where can I recharge?"*
75
+
76
+ ## 💰 Adding Funds to Your Account
77
+
78
+ Your bot will guide you through two deposit options:
79
+
80
+ ### Option 1: Direct USDC Deposit
81
+ - **USDC only** - other coins not supported for direct deposit
82
+ - Ask your bot: *"What are my deposit addresses?"*
83
+ - Send USDC to your Solana or EVM trading address
84
+
85
+ ### Option 2: All Coins via Website
86
+ - Visit **https://aiusd.ai**
87
+ - Login with the same wallet you use for trading
88
+ - Supports all stablecoins (USDT, DAI, BUSD, etc.)
89
+
90
+ **Important**: For coins other than USDC, you must use the website - direct deposits only accept USDC.
91
+
92
+ ## ⚙️ Supported Platforms
93
+
94
+ This skill works with OpenClaw/ClawdBot on:
95
+ - **Telegram** - Private chats and groups
96
+ - **Discord** - Direct messages and server channels
97
+ - **WhatsApp** - Personal and business accounts
98
+ - **Slack** - Workspaces and direct messages
99
+ - **SMS** - Text message interface
100
+ - **CLI** - Command line interface
101
+
102
+ ## 🔒 Privacy & Security
103
+
104
+ - **Local First**: Your bot runs locally, your data stays private
105
+ - **Secure Storage**: Authentication tokens stored locally on your device
106
+ - **No Data Sharing**: AIUSD skill only communicates with official AIUSD servers
107
+ - **Open Source**: Skill code is transparent and auditable
108
+
109
+ ## 📱 Example Conversation
110
+
111
+ ```
112
+ You: Hey bot, what's my AIUSD balance?
113
+
114
+ Bot: 🔍 Checking your AIUSD account...
115
+
116
+ ✅ Your AIUSD Balance:
117
+ • Custody Account: 1,250.75 AIUSD
118
+ • Staking Account: 2,500.00 sAIUSD
119
+ • Total Value: $3,750.75 USD
120
+
121
+ You: Buy $100 worth of SOL with USDC
122
+
123
+ Bot: 🔄 Executing trade: Buy SOL with $100 USDC...
124
+
125
+ ✅ Trade completed successfully!
126
+ • Bought: 0.234 SOL
127
+ • Spent: $100.00 USDC
128
+ • Transaction ID: abc123...
129
+ ```
130
+
131
+ ## 🌟 Why Use This Skill?
132
+
133
+ - **Natural Language**: No complex commands - just talk normally
134
+ - **Real-time**: Instant balance checks and trade execution
135
+ - **Multi-platform**: Works wherever your bot is available
136
+ - **Secure**: OAuth authentication with official AIUSD servers
137
+ - **Comprehensive**: Full trading, staking, and account management
138
+
139
+ ---
140
+
141
+ **Get Started**: **[Download the skill file](https://github.com/galpha-ai/aiusd-skills/releases/download/v1.0.0/aiusd-skill-agent.skill)** and drop it into your bot's chat to start trading!
142
+
143
+ **Version**: 1.0.0 | **License**: MIT | **Support**: https://aiusd.ai
package/SKILL.md ADDED
@@ -0,0 +1,397 @@
1
+ ---
2
+ name: aiusd-skill
3
+ description: "AIUSD trading and account management skill for cryptocurrency trading and account management."
4
+ license: MIT
5
+ ---
6
+
7
+ # AIUSD Skill (Agent Reference)
8
+
9
+ This skill calls the AIUSD backend via MCP. Auth is resolved in order: env `MCP_HUB_TOKEN`, mcporter OAuth, or local `~/.mcp-hub/token.json`. Ensure a valid Bearer token is available before calling. **Before invoking the CLI**, read **Common Pitfalls and Solutions** to avoid parameter, escaping, and intent mistakes.
10
+
11
+ ## ⚠️ Agent Output Guidelines
12
+
13
+ **CRITICAL - ABSOLUTELY FORBIDDEN PHRASES**:
14
+ Agents must NEVER use these words or phrases when responding to users:
15
+
16
+ **TEMPLATE-RELATED (COMPLETELY BANNED)**:
17
+ - "template" (any form: template, templates)
18
+ - "example" (when referring to trading examples: Example 1, Example 12, etc.)
19
+ - "pattern" (when referring to trading patterns)
20
+ - "using template", "get template", "trading template", "buy template"
21
+ - "use Example [number]", "based on template", "following template"
22
+
23
+ **VERIFICATION-RELATED (COMPLETELY BANNED)**:
24
+ - "skill verification", "verification"
25
+
26
+ **WHAT TO SAY INSTEAD**:
27
+ - Instead of "using template": say "executing the trade" or "placing the order"
28
+ - Instead of "get template": say "preparing the trade" or "setting up the order"
29
+ - Instead of "Example 12 template": say "the trade configuration" or simply describe the action
30
+
31
+ **ZERO TOLERANCE**: Any use of the word "template" in trading contexts is STRICTLY PROHIBITED.
32
+
33
+ **Authentication Response Guidelines**:
34
+ **CRITICAL**: When users request re-authentication, respond ONLY with:
35
+ - "The browser window should have opened for you"
36
+ - "If it didn't open automatically, please tell the agent to re-login again (or type 'reauth' again)"
37
+ - "After completing authentication, you can check your account balance or wallet status in chat"
38
+
39
+ **NEVER return the login URL to the user**: Do NOT ever show or tell the user `https://mcp.alpha.dev/oauth/login`. If the browser did not open, do NOT give them the URL—only tell them to ask the agent to re-login / type 'reauth' again.
40
+
41
+ **STRICTLY FORBIDDEN**:
42
+ - Do NOT include or mention the login URL (e.g. mcp.alpha.dev/oauth/login) in your response to the user
43
+ - Do NOT include numbered steps like "1. Open page: [URL]", "2. Connect wallet", etc.
44
+ - Do NOT mention any specific auth/login URLs in the response
45
+ - Do NOT say "waiting for authentication completion" or similar waiting phrases
46
+ - Do NOT provide detailed step-by-step browser instructions
47
+ - Do NOT create bulleted lists of authentication steps
48
+ - Do NOT say phrases like "browser has been opened for you", "please complete the following steps in browser"
49
+ - Simply guide them to the browser and, if it didn't open, only say to re-login / type reauth again
50
+
51
+ Use natural, direct language to describe trading operations and system status. Simply describe what the trade will do without referencing templates or examples.
52
+
53
+ ## Important URLs
54
+
55
+ - **Login/Auth**: `https://mcp.alpha.dev/oauth/login` - Only for getting authentication token
56
+ - **Official Website**: `https://aiusd.ai` - For trading operations, recharge, troubleshooting, and all user interactions
57
+
58
+ ## Common Pitfalls and Solutions
59
+
60
+ **Read this before invoking the skill CLI** (e.g. when using the installed skill via `aiusd-skill` or `node dist/index.js`). These prevent the most frequent failures.
61
+
62
+ ### 1. CLI parameter passing
63
+
64
+ - **Wrong**: `node dist/index.js call genalpha_execute_intent '{"intent": "..."}'` (positional JSON)
65
+ - **Right**: `node dist/index.js call genalpha_execute_intent --params '{"intent": "..."}'`
66
+ - The CLI expects JSON via the **`--params`** flag, not as a positional argument.
67
+
68
+ ### 2. Passing JSON from code (shell escaping)
69
+
70
+ - **Problem**: Complex XML inside JSON is hard to escape correctly in shell.
71
+ - **Solution**: When invoking the CLI from code, use **spawn** (not `execSync`) and pass params as a single string to avoid shell interpretation:
72
+ - `args = ['dist/index.js', 'call', toolName, '--params', JSON.stringify(params)]`
73
+ - `spawn('node', args, { stdio: 'pipe' })`
74
+
75
+ ### 3. Intent XML semantics (`genalpha_execute_intent`)
76
+
77
+ - **`<buy>`**: `amount` = amount of **QUOTE** token to spend.
78
+ - **`<sell>`**: `amount` = amount of **BASE** token to sell.
79
+ - **AIUSD constraint**: AIUSD can only be converted to stablecoins (USDC/USDT/USD1). To buy a non-stable (e.g. SOL): first convert AIUSD→USDC, then USDC→target token.
80
+ - **Selling AIUSD**: use `<buy>` with `<quote>AIUSD</quote>` and `<base>USDC_ADDRESS</base>` (you are “buying” USDC with AIUSD).
81
+ - **Buying a token**: use `<buy>` with `<quote>USDC_ADDRESS</quote>` and `<base>TOKEN_SYMBOL</base>`; `amount` is the USDC amount to spend.
82
+
83
+ ### 4. Code references (if extending or debugging the skill)
84
+
85
+ - **MCP client**: Import **`MCPClient`** (capital C), not `McpClient`.
86
+ - **TokenManager**: Use **`TokenManager.getToken()`** (static method), not `new TokenManager(); tokenManager.getToken()`.
87
+
88
+ ### 5. Error handling
89
+
90
+ - On tool failure, **check parameters against the latest `tools --detailed` output** before retrying. Do not retry with the same payload blindly.
91
+ - Always obtain and use the live schema from `tools --detailed`; do not rely on static examples in docs.
92
+
93
+ ### 6. Debugging commands
94
+
95
+ ```bash
96
+ # Current tool schemas and examples
97
+ node dist/index.js tools --detailed
98
+ # Or after install: aiusd-skill tools --detailed
99
+
100
+ # Test connection
101
+ node dist/index.js test
102
+
103
+ # Quick balance check
104
+ node dist/index.js balances
105
+
106
+ # Transaction history
107
+ node dist/index.js call genalpha_get_transactions --params '{}'
108
+ ```
109
+
110
+ ### 7. Common error messages
111
+
112
+ | Message | Meaning / action |
113
+ |--------|-------------------|
114
+ | `Missing or invalid 'intent' parameter` | Check JSON structure and that `intent` is present and valid; compare with `tools --detailed`. |
115
+ | `insufficient liquidity` | Token may have no/low liquidity on that chain; try another chain or token. |
116
+ | `Jwt is missing` / 401 | Auth issue; run reauth (e.g. `npm run reauth` or installer’s reauth command). |
117
+
118
+ ## Installation Pitfalls and Solutions
119
+
120
+ **For installers and users setting up the skill.** Auth setup is the most error-prone step; prefer a one-click reauth script when available.
121
+
122
+ ### 1. CLI / hub install not finding the skill
123
+
124
+ - **Problem**: `clawdbot install aiusd-skill-agent` or install by repo path reports "Skill not found".
125
+ - **Workaround**: Manual download, then unzip:
126
+ ```bash
127
+ curl -L "https://auth.clawdhub.com/api/v1/download?slug=aiusd-skill-agent" -o aiusd-skill.zip
128
+ unzip aiusd-skill.zip
129
+ ```
130
+
131
+ ### 2. Security scan warnings
132
+
133
+ - **Possible**: VirusTotal / OpenClaw may flag "Suspicious" (e.g. undeclared auth dependencies or installer code).
134
+ - **Recommendation**: Review the code and use an official or trusted source before continuing.
135
+
136
+ ### 3. Dependency install timeout or failure
137
+
138
+ - **Problem**: `npm install` times out or fails (network, conflicts).
139
+ - **Solution**:
140
+ ```bash
141
+ rm -rf node_modules package-lock.json
142
+ npm cache clean --force
143
+ npm install
144
+ ```
145
+
146
+ ### 4. TypeScript / build failures
147
+
148
+ - **Problem**: Build errors such as "Cannot find module 'commander'" or "Cannot find name 'process'".
149
+ - **Solution**: Install full dev dependencies and Node types:
150
+ ```bash
151
+ npm install --include=dev
152
+ # or
153
+ npm install @types/node --save-dev
154
+ ```
155
+
156
+ ### 5. Auth setup (mcporter, OAuth, ports)
157
+
158
+ - **Problems**: mcporter config, OAuth timeout, or port conflicts.
159
+ - **Recommended flow**: Install → build → ensure mcporter → run reauth once:
160
+ ```bash
161
+ cd aiusd-skill
162
+ npm install && npm run build
163
+ which mcporter || npm install -g mcporter
164
+ npm run reauth
165
+ ```
166
+ Or: `npx mcporter auth https://mcp.alpha.dev/api/mcp-hub/mcp`. Prefer the project’s **one-click reauth script** when provided.
167
+
168
+ ### 6. OAuth callback / browser not opening
169
+
170
+ - **Problems**: Default callback port in use, browser does not open.
171
+ - **Solutions**: Check port usage (e.g. `lsof -i :59589`), or run reauth again; if the environment supports it, use a different port via `PORT=59589 npm run reauth`. Do **not** give users the login URL; tell them to run reauth again or use the one-click auth script.
172
+
173
+ ### 7. Auth file locations and full reset
174
+
175
+ - **Auth state** may live in: `~/.mcporter/credentials.json`, `~/.mcp-hub/token.json`, or env `MCP_HUB_TOKEN`.
176
+ - **Full auth reset**:
177
+ ```bash
178
+ rm -rf ~/.mcporter ~/.mcp-hub
179
+ unset MCP_HUB_TOKEN
180
+ npm run reauth
181
+ ```
182
+
183
+ ### 8. Module export name (when extending the skill)
184
+
185
+ - **Problem**: `import { McpClient } from '...'` fails (no export named `McpClient`).
186
+ - **Fix**: Use **`MCPClient`** (capital C). See Common Pitfalls §4.
187
+
188
+ ### 9. Post-install verification
189
+
190
+ - **Problem**: `npm test` or first tool call fails with "Jwt is missing" or auth errors.
191
+ - **Checklist**:
192
+ 1. Download/unzip (or install via supported method).
193
+ 2. `npm install` (postinstall runs if configured).
194
+ 3. `npm run build`; confirm `dist/` exists.
195
+ 4. `npm run reauth` and complete OAuth in the browser.
196
+ 5. `node dist/index.js balances` (or `aiusd-skill balances`).
197
+ 6. `node dist/index.js tools --detailed` to confirm tool list.
198
+
199
+ ### 10. Debug and network checks
200
+
201
+ ```bash
202
+ # Verbose reauth
203
+ DEBUG=* npm run reauth
204
+
205
+ # Reachability
206
+ curl -I https://mcp.alpha.dev/api/mcp-hub/mcp
207
+
208
+ # Check mcporter credential file exists
209
+ node -e "console.log(require('fs').existsSync(require('os').homedir() + '/.mcporter/credentials.json'))"
210
+ ```
211
+
212
+ ### 11. Common error codes (install/runtime)
213
+
214
+ | Code | Meaning / action |
215
+ |------|-------------------|
216
+ | ENOTFOUND | Network/DNS; check connectivity. |
217
+ | ECONNREFUSED | Service unreachable; retry or check URL. |
218
+ | ETIMEDOUT | OAuth or network timeout; retry `npm run reauth`. |
219
+ | Permission denied | Check file/dir permissions (e.g. `~/.mcporter`, `~/.mcp-hub`). |
220
+
221
+ ## Tool Overview
222
+
223
+ **CRITICAL**: Always run `aiusd-skill tools --detailed` FIRST to get the current live schema and available tools before making any calls. Tool parameters and available tools may change.
224
+
225
+ | Tool | Purpose | Typical user intents |
226
+ |------|---------|----------------------|
227
+ | genalpha_get_balances | Query account balances | balance, how much, account balance |
228
+ | genalpha_get_trading_accounts | Get trading accounts / addresses | my account, trading account, wallet address |
229
+ | genalpha_execute_intent | Execute trade intent (buy/sell/swap) | buy, sell, buy SOL with USDC, swap |
230
+ | genalpha_stake_aiusd | Stake AIUSD | stake, stake AIUSD |
231
+ | genalpha_unstake_aiusd | Unstake | unstake |
232
+ | genalpha_withdraw_to_wallet | Withdraw to external wallet | withdraw, transfer out |
233
+ | genalpha_ensure_gas | Top up Gas for on-chain account | top up gas, ensure gas |
234
+ | genalpha_get_transactions | Query transaction history | history, recent transactions |
235
+ | recharge / top up | Guide user to recharge account | recharge, top up, deposit, add funds |
236
+ | reauth / login | Re-authenticate / login | login, re-login, auth expired, 401 |
237
+
238
+ **NOTE**: This list shows commonly available tools. NEW TOOLS may be added. Always check `tools --detailed` to discover any additional tools that may better serve the user's specific intent.
239
+
240
+ ## Tool Reference and Call Usage
241
+
242
+ **MANDATORY**: Before calling ANY tool, run `aiusd-skill tools --detailed` to get current parameters, examples, and any new tools.
243
+
244
+ ### genalpha_get_balances
245
+
246
+ - **Purpose**: Return user AIUSD custody and staking account balances.
247
+ - **When to use**: User asks for balance, how much, account assets.
248
+ - **Parameters**: Check `tools --detailed` for current schema.
249
+
250
+ ### genalpha_get_trading_accounts
251
+
252
+ - **Purpose**: Return user trading accounts (addresses, etc.) per chain.
253
+ - **When to use**: User asks "my account", "trading account", "wallet address".
254
+ - **Parameters**: Check `tools --detailed` for current schema.
255
+
256
+ ### genalpha_execute_intent
257
+
258
+ - **Purpose**: Execute buy/sell/swap (e.g. buy SOL with USDC, sell ETH).
259
+ - **When to use**: User clearly wants to place order, buy, sell, swap.
260
+ - **Parameters**: Check `tools --detailed` for current schema and XML examples.
261
+ - **IMPORTANT**: Intent format may change. Always use examples from live schema.
262
+
263
+ ### genalpha_stake_aiusd
264
+
265
+ - **Purpose**: Stake AIUSD for yield (e.g. sAIUSD).
266
+ - **When to use**: User says stake, stake AIUSD.
267
+ - **Parameters**: Check `tools --detailed` for current schema.
268
+
269
+ ### genalpha_unstake_aiusd
270
+
271
+ - **Purpose**: Unstake AIUSD (e.g. redeem sAIUSD).
272
+ - **When to use**: User says unstake, redeem.
273
+ - **Parameters**: Check `tools --detailed` for current schema.
274
+
275
+ ### genalpha_withdraw_to_wallet
276
+
277
+ - **Purpose**: Withdraw stablecoin (e.g. USDC) to user-specified external wallet address.
278
+ - **When to use**: User says withdraw, transfer out.
279
+ - **Parameters**: Check `tools --detailed` for current schema.
280
+
281
+ ### genalpha_ensure_gas
282
+
283
+ - **Purpose**: Top up native Gas for user trading account on a given chain.
284
+ - **When to use**: User says top up gas, ensure gas, or chain has low gas.
285
+ - **Parameters**: Check `tools --detailed` for current schema.
286
+
287
+ ### genalpha_get_transactions
288
+
289
+ - **Purpose**: Return user transaction history (list, may include status).
290
+ - **When to use**: User asks history, recent transactions, order status.
291
+ - **Parameters**: Check `tools --detailed` for current schema and filtering options.
292
+
293
+ ### recharge / top up
294
+
295
+ - **Purpose**: Guide user to recharge their AIUSD account with funds.
296
+ - **When to use**: User asks to recharge, top up, deposit, or add funds to their account.
297
+ - **Response Options**:
298
+ - **Option 1 - Direct deposit**: Only USDC stablecoins accepted. Other stablecoins must use official website.
299
+ - **Option 2 - Official website**: https://aiusd.ai (supports all tokens, login with same wallet)
300
+ - **Important**: For direct deposits, only send USDC to the provided addresses. For other stablecoins (USDT, DAI, etc.), user must use the official website.
301
+ - **Example response**: "For recharge, you have two options: 1) Direct USDC deposit to your trading addresses, or 2) Visit https://aiusd.ai for all token types (login with same wallet). Direct deposits only accept USDC - other stablecoins must use the website."
302
+
303
+ ### reauth / login (Re-authenticate)
304
+
305
+ - **Purpose**: Clear all cached auth and run OAuth login again.
306
+ - **When to use**: User has 401 Unauthorized, "Session ID is required", token expired, auth failure, user asks to re-login, or switch account.
307
+ - **Params**: None. Pass `{}`.
308
+ - **Example**:
309
+ - `npm run reauth`
310
+ - `npm run login`
311
+ - `node scripts/reauth.js`
312
+ - **Steps**:
313
+ 1. Clear mcporter cache (`~/.mcporter/`)
314
+ 2. Clear local token file (`~/.mcp-hub/`)
315
+ 3. Clear other auth cache files
316
+ 4. Start browser OAuth login
317
+ 5. Verify new auth works
318
+ - **Sample dialogue**:
319
+ ```
320
+ User: "I'm getting 401"
321
+ Claude: Looks like an auth issue; re-authenticating...
322
+ [Run: npm run reauth]
323
+ Claude: Re-auth done; you can use the skill again.
324
+
325
+ User: "Re-login"
326
+ Claude: Clearing cache and re-logging in...
327
+ [Run: npm run login]
328
+ ```
329
+
330
+ ## Usage Flow (for Agent Reasoning)
331
+
332
+ 1. **Get current tools**: ALWAYS run `aiusd-skill tools --detailed` first to discover all available tools and their current schemas.
333
+ 2. **Parse intent**: Map natural language to the most appropriate tool. Check if newer tools better match the user's intent.
334
+ 3. **Prepare params**: Build JSON parameters strictly from the live schema obtained in step 1.
335
+ 4. **Call**: Invoke the skill's call interface with tool name and params.
336
+ 5. **Handle result**: Format tool JSON/text for the user; on error, retry or prompt (e.g. auth expired → prompt re-login).
337
+
338
+ **CRITICAL**: Never use parameter examples from this documentation. Always use the live schema from `tools --detailed`.
339
+
340
+ ## Auth and Error Handling
341
+
342
+ ### Auth error auto-fix
343
+
344
+ On auth-related errors, Claude should run re-auth:
345
+
346
+ - **401 Unauthorized** → run `npm run reauth`
347
+ - **Session ID is required** → run `npm run reauth`
348
+ - **Token invalid or expired** → run `npm run reauth`
349
+ - **Auth failed** → run `npm run reauth`
350
+
351
+ ### Error handling flow
352
+
353
+ 1. **Detect auth error** → run `npm run reauth`
354
+ 2. **Business error** → relay server error to user; do not invent causes
355
+ 3. **Network/timeout** → retry once; then ask user to check network or try later
356
+ 4. **Trading issues/failures** → direct user to official website https://aiusd.ai for manual operations and support
357
+
358
+ ### Sample error dialogues
359
+
360
+ #### Auth Error
361
+ ```
362
+ User: "Check balance"
363
+ [Tool returns 401]
364
+ Claude: Auth expired; re-authenticating...
365
+ [Run: npm run reauth]
366
+ Claude: Re-auth done. Fetching balance...
367
+ [Call: genalpha_get_balances]
368
+ ```
369
+
370
+ #### Trading Error
371
+ ```
372
+ User: "Buy 100 USDC worth of SOL"
373
+ [Tool returns trading error]
374
+ Claude: I encountered an issue with the trade execution. For manual trading operations, please visit https://aiusd.ai and use the same wallet you use for authentication.
375
+ ```
376
+
377
+ ## Getting Current Tools and Schema
378
+
379
+ **MANDATORY FIRST STEP**: Before performing any user task, run:
380
+
381
+ ```bash
382
+ aiusd-skill tools --detailed
383
+ ```
384
+
385
+ This command returns:
386
+ 1. **Complete list of available tools** (may include new tools not listed in this document)
387
+ 2. **Current parameter schemas** for all tools
388
+ 3. **Working examples** and proper formatting
389
+ 4. **Any tool-specific instructions** or constraints
390
+
391
+ **Why this is critical**:
392
+ - Tools may be added, modified, or deprecated
393
+ - Parameter formats can change
394
+ - New tools may better serve specific user intents
395
+ - Examples in this document may become outdated
396
+
397
+ Always base your tool calls on the live output from `tools --detailed`, not on static examples in this documentation.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * CLI Interface - Command line interface for AIUSD Skills
3
+ *
4
+ * Provides user-friendly commands that combine:
5
+ * - Token management (TokenManager)
6
+ * - MCP client operations (MCPClient)
7
+ */
8
+ import { Command } from 'commander';
9
+ export declare class CLI {
10
+ private program;
11
+ private defaultServerUrl;
12
+ constructor();
13
+ private setupCommands;
14
+ private createClient;
15
+ private handleTest;
16
+ private handleListTools;
17
+ private handleCallTool;
18
+ run(argv: string[]): Promise<void>;
19
+ getProgram(): Command;
20
+ }