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 +143 -0
- package/SKILL.md +397 -0
- package/dist/cli.d.ts +20 -0
- package/dist/cli.js +224 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-client.d.ts +62 -0
- package/dist/mcp-client.js +183 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/token-manager.d.ts +49 -0
- package/dist/token-manager.js +191 -0
- package/dist/token-manager.js.map +1 -0
- package/package.json +72 -0
- package/patches/mcporter+0.7.3.patch +165 -0
- package/scripts/build-js-installer.js +249 -0
- package/scripts/build-sh-installer.js +269 -0
- package/scripts/build-skill.js +171 -0
- package/scripts/build.sh +99 -0
- package/scripts/reauth.js +324 -0
- package/scripts/reauth.sh +44 -0
- package/scripts/skill-init.js +233 -0
- package/scripts/test-client.sh +91 -0
- package/scripts/test-reauth.js +116 -0
- package/src/cli.ts +256 -0
- package/src/index.ts +41 -0
- package/src/mcp-client.ts +211 -0
- package/src/token-manager.ts +217 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AIUSD Skill - Re-authentication Script
|
|
5
|
+
*
|
|
6
|
+
* This script clears cached authentication data and performs fresh OAuth login:
|
|
7
|
+
* 1. Clears mcporter credentials
|
|
8
|
+
* 2. Clears local token files
|
|
9
|
+
* 3. Performs fresh OAuth authentication
|
|
10
|
+
* 4. Verifies new authentication
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { execSync } from 'child_process';
|
|
14
|
+
import { existsSync, rmSync, mkdirSync } from 'fs';
|
|
15
|
+
import { join, dirname } from 'path';
|
|
16
|
+
import { fileURLToPath } from 'url';
|
|
17
|
+
import { homedir } from 'os';
|
|
18
|
+
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
const __dirname = dirname(__filename);
|
|
21
|
+
const projectRoot = join(__dirname, '..');
|
|
22
|
+
|
|
23
|
+
const colors = {
|
|
24
|
+
red: '\x1b[31m',
|
|
25
|
+
green: '\x1b[32m',
|
|
26
|
+
yellow: '\x1b[33m',
|
|
27
|
+
blue: '\x1b[34m',
|
|
28
|
+
magenta: '\x1b[35m',
|
|
29
|
+
cyan: '\x1b[36m',
|
|
30
|
+
reset: '\x1b[0m'
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function log(message, color = 'reset') {
|
|
34
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function logStep(step, message) {
|
|
38
|
+
log(`\n๐ Step ${step}: ${message}`, 'blue');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function logSuccess(message) {
|
|
42
|
+
log(`โ
${message}`, 'green');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function logError(message) {
|
|
46
|
+
log(`โ ${message}`, 'red');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function logWarning(message) {
|
|
50
|
+
log(`โ ๏ธ ${message}`, 'yellow');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class ReAuthenticator {
|
|
54
|
+
constructor() {
|
|
55
|
+
this.mcporterDir = join(homedir(), '.mcporter');
|
|
56
|
+
this.mcpHubDir = join(homedir(), '.mcp-hub');
|
|
57
|
+
this.serverUrl = 'https://mcp.alpha.dev/api/mcp-hub/mcp';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async run() {
|
|
61
|
+
try {
|
|
62
|
+
log('\n๐ AIUSD Skill - Re-authentication', 'magenta');
|
|
63
|
+
log('====================================', 'magenta');
|
|
64
|
+
log('This will clear all cached authentication and login fresh', 'cyan');
|
|
65
|
+
|
|
66
|
+
// Step 1: Clear cached credentials
|
|
67
|
+
await this.clearCachedAuth();
|
|
68
|
+
|
|
69
|
+
// Step 2: Clear environment variables (inform user)
|
|
70
|
+
this.clearEnvironmentVars();
|
|
71
|
+
|
|
72
|
+
// Step 3: Perform fresh OAuth login
|
|
73
|
+
await this.performFreshLogin();
|
|
74
|
+
|
|
75
|
+
// Step 4: Verify new authentication
|
|
76
|
+
await this.verifyAuthentication();
|
|
77
|
+
|
|
78
|
+
log('\n๐ Re-authentication completed successfully!', 'green');
|
|
79
|
+
log('๐ก You can now use the skill with fresh credentials', 'cyan');
|
|
80
|
+
|
|
81
|
+
} catch (error) {
|
|
82
|
+
logError(`Re-authentication failed: ${error.message}`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async clearCachedAuth() {
|
|
88
|
+
logStep(1, 'Clearing cached authentication data');
|
|
89
|
+
|
|
90
|
+
let cleared = false;
|
|
91
|
+
|
|
92
|
+
// Clear mcporter credentials
|
|
93
|
+
if (existsSync(this.mcporterDir)) {
|
|
94
|
+
log('๐๏ธ Removing mcporter credentials...', 'yellow');
|
|
95
|
+
try {
|
|
96
|
+
rmSync(this.mcporterDir, { recursive: true });
|
|
97
|
+
logSuccess('mcporter credentials cleared');
|
|
98
|
+
cleared = true;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
logWarning(`Failed to clear mcporter credentials: ${error.message}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Clear local token files
|
|
105
|
+
if (existsSync(this.mcpHubDir)) {
|
|
106
|
+
log('๐๏ธ Removing local token files...', 'yellow');
|
|
107
|
+
try {
|
|
108
|
+
rmSync(this.mcpHubDir, { recursive: true });
|
|
109
|
+
logSuccess('Local token files cleared');
|
|
110
|
+
cleared = true;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
logWarning(`Failed to clear local token files: ${error.message}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Clear any other common auth files
|
|
117
|
+
const otherAuthFiles = [
|
|
118
|
+
join(homedir(), 'auth.json'),
|
|
119
|
+
join(homedir(), 'token.json'),
|
|
120
|
+
join(homedir(), 'credentials.json')
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
for (const authFile of otherAuthFiles) {
|
|
124
|
+
if (existsSync(authFile)) {
|
|
125
|
+
try {
|
|
126
|
+
rmSync(authFile);
|
|
127
|
+
log(`๐๏ธ Removed ${authFile}`, 'yellow');
|
|
128
|
+
cleared = true;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
logWarning(`Failed to remove ${authFile}: ${error.message}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!cleared) {
|
|
136
|
+
log('๐ No cached authentication data found', 'cyan');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
clearEnvironmentVars() {
|
|
141
|
+
logStep(2, 'Checking environment variables');
|
|
142
|
+
|
|
143
|
+
const envVars = ['MCP_HUB_TOKEN', 'AIUSD_TOKEN'];
|
|
144
|
+
let hasEnvVars = false;
|
|
145
|
+
|
|
146
|
+
for (const envVar of envVars) {
|
|
147
|
+
if (process.env[envVar]) {
|
|
148
|
+
hasEnvVars = true;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (hasEnvVars) {
|
|
154
|
+
logWarning('Environment variables detected:');
|
|
155
|
+
for (const envVar of envVars) {
|
|
156
|
+
if (process.env[envVar]) {
|
|
157
|
+
log(` ${envVar}=${process.env[envVar].slice(0, 20)}...`, 'yellow');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
log('');
|
|
161
|
+
log('๐ To clear environment variables, run:', 'cyan');
|
|
162
|
+
for (const envVar of envVars) {
|
|
163
|
+
if (process.env[envVar]) {
|
|
164
|
+
log(` unset ${envVar}`, 'blue');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
log('');
|
|
168
|
+
} else {
|
|
169
|
+
logSuccess('No environment authentication variables found');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async performFreshLogin() {
|
|
174
|
+
logStep(3, 'Performing fresh OAuth login');
|
|
175
|
+
|
|
176
|
+
// Check if mcporter is available
|
|
177
|
+
try {
|
|
178
|
+
execSync('which mcporter', { stdio: 'pipe' });
|
|
179
|
+
log('๐ฑ mcporter found, attempting OAuth login...', 'blue');
|
|
180
|
+
} catch (error) {
|
|
181
|
+
log('๐ฅ Installing mcporter...', 'blue');
|
|
182
|
+
try {
|
|
183
|
+
execSync('npm install -g mcporter', { stdio: 'inherit' });
|
|
184
|
+
log('โ
mcporter installed', 'green');
|
|
185
|
+
} catch (installError) {
|
|
186
|
+
logError('Failed to install mcporter. Please install manually: npm install -g mcporter');
|
|
187
|
+
throw installError;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Create fresh mcporter directory
|
|
192
|
+
mkdirSync(this.mcporterDir, { recursive: true });
|
|
193
|
+
|
|
194
|
+
log('๐ Starting OAuth authentication flow...', 'blue');
|
|
195
|
+
log('Please complete authentication in your browser', 'cyan');
|
|
196
|
+
log('After completing authentication, you can check your account balance or wallet status in chat', 'yellow');
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
const result = execSync(
|
|
200
|
+
`npx mcporter list --http-url ${this.serverUrl} --name aiusd`,
|
|
201
|
+
{
|
|
202
|
+
cwd: projectRoot,
|
|
203
|
+
encoding: 'utf8',
|
|
204
|
+
stdio: 'pipe',
|
|
205
|
+
timeout: 60000 // 1 minutes timeout
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
logSuccess('OAuth authentication completed');
|
|
210
|
+
} catch (error) {
|
|
211
|
+
// Check if OAuth actually succeeded despite the error
|
|
212
|
+
log('๐ Checking if OAuth succeeded despite error...', 'blue');
|
|
213
|
+
|
|
214
|
+
const credentialsPath = join(this.mcporterDir, 'credentials.json');
|
|
215
|
+
if (existsSync(credentialsPath)) {
|
|
216
|
+
try {
|
|
217
|
+
const fs = await import('fs');
|
|
218
|
+
const credentials = JSON.parse(fs.readFileSync(credentialsPath, 'utf8'));
|
|
219
|
+
|
|
220
|
+
// Look for any entry with access_token
|
|
221
|
+
const hasValidToken = Object.values(credentials.entries || {}).some(
|
|
222
|
+
entry => entry.tokens && entry.tokens.access_token
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
if (hasValidToken) {
|
|
226
|
+
logSuccess('OAuth tokens found! Authentication actually succeeded');
|
|
227
|
+
log('๐ก The timeout/error was a mcporter display issue, not a real failure', 'cyan');
|
|
228
|
+
return; // Continue with success
|
|
229
|
+
}
|
|
230
|
+
} catch (parseError) {
|
|
231
|
+
// Credentials file exists but couldn't parse it
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// If we get here, OAuth really did fail
|
|
236
|
+
if (error.code === 'TIMEOUT') {
|
|
237
|
+
logError('Authentication timed out. Please try again.');
|
|
238
|
+
} else if (error.stderr && error.stderr.includes('User denied')) {
|
|
239
|
+
logError('Authentication was cancelled by user');
|
|
240
|
+
} else {
|
|
241
|
+
logError(`Authentication failed: ${error.message}`);
|
|
242
|
+
}
|
|
243
|
+
throw error;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async verifyAuthentication() {
|
|
248
|
+
logStep(4, 'Verifying new authentication');
|
|
249
|
+
|
|
250
|
+
// Wait a moment for credentials to be saved
|
|
251
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
252
|
+
|
|
253
|
+
try {
|
|
254
|
+
log('๐ Testing MCP connection...', 'blue');
|
|
255
|
+
const result = execSync('node dist/index.js test', {
|
|
256
|
+
cwd: projectRoot,
|
|
257
|
+
encoding: 'utf8',
|
|
258
|
+
timeout: 15000
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
if (result.includes('successful')) {
|
|
262
|
+
logSuccess('Authentication verification passed');
|
|
263
|
+
|
|
264
|
+
// Also test tool listing
|
|
265
|
+
try {
|
|
266
|
+
log('๐ Testing tool access...', 'blue');
|
|
267
|
+
const toolsResult = execSync('node dist/index.js tools', {
|
|
268
|
+
cwd: projectRoot,
|
|
269
|
+
encoding: 'utf8',
|
|
270
|
+
timeout: 15000
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const toolCount = (toolsResult.match(/โข/g) || []).length;
|
|
274
|
+
if (toolCount > 0) {
|
|
275
|
+
logSuccess(`Found ${toolCount} available tools`);
|
|
276
|
+
} else {
|
|
277
|
+
logWarning('Tools listed but count unclear');
|
|
278
|
+
}
|
|
279
|
+
} catch (error) {
|
|
280
|
+
logWarning('Tool listing test failed, but basic auth works');
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
} else {
|
|
284
|
+
logWarning('Authentication verification completed with warnings');
|
|
285
|
+
}
|
|
286
|
+
} catch (error) {
|
|
287
|
+
logError('Authentication verification failed');
|
|
288
|
+
logError('Please check your credentials and try again');
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Show usage if help requested
|
|
295
|
+
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
296
|
+
console.log(`
|
|
297
|
+
๐ AIUSD Skill Re-authentication
|
|
298
|
+
|
|
299
|
+
This script clears all cached authentication data and performs fresh OAuth login.
|
|
300
|
+
|
|
301
|
+
Usage:
|
|
302
|
+
node scripts/reauth.js
|
|
303
|
+
npm run reauth
|
|
304
|
+
|
|
305
|
+
What it does:
|
|
306
|
+
1. Clears mcporter credentials (~/.mcporter/)
|
|
307
|
+
2. Clears local token files (~/.mcp-hub/)
|
|
308
|
+
3. Clears other cached auth files
|
|
309
|
+
4. Performs fresh OAuth browser login
|
|
310
|
+
5. Verifies new authentication works
|
|
311
|
+
|
|
312
|
+
Options:
|
|
313
|
+
--help, -h Show this help message
|
|
314
|
+
`);
|
|
315
|
+
process.exit(0);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Main execution
|
|
319
|
+
async function main() {
|
|
320
|
+
const reauth = new ReAuthenticator();
|
|
321
|
+
await reauth.run();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# AIUSD Skill Re-authentication Script
|
|
4
|
+
# Quick shell wrapper for the Node.js re-authentication script
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
# Colors
|
|
10
|
+
RED='\033[0;31m'
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
BLUE='\033[0;34m'
|
|
14
|
+
MAGENTA='\033[0;35m'
|
|
15
|
+
NC='\033[0m' # No Color
|
|
16
|
+
|
|
17
|
+
log_info() { echo -e "${BLUE}โน๏ธ${NC} $1"; }
|
|
18
|
+
log_success() { echo -e "${GREEN}โ
${NC} $1"; }
|
|
19
|
+
log_warning() { echo -e "${YELLOW}โ ๏ธ${NC} $1"; }
|
|
20
|
+
log_error() { echo -e "${RED}โ${NC} $1"; }
|
|
21
|
+
|
|
22
|
+
# Project directory - go up one level from scripts/
|
|
23
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
24
|
+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
25
|
+
cd "$PROJECT_ROOT"
|
|
26
|
+
|
|
27
|
+
echo -e "${MAGENTA}๐ AIUSD Skill Re-authentication${NC}"
|
|
28
|
+
echo "================================="
|
|
29
|
+
|
|
30
|
+
# Check if Node.js is available
|
|
31
|
+
if ! command -v node >/dev/null 2>&1; then
|
|
32
|
+
log_error "Node.js not found. Please install Node.js 18+ from https://nodejs.org"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Check if the JavaScript version exists
|
|
37
|
+
if [[ ! -f "scripts/reauth.js" ]]; then
|
|
38
|
+
log_error "Re-authentication script not found: scripts/reauth.js"
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
# Execute the Node.js re-authentication script
|
|
43
|
+
log_info "Executing re-authentication script..."
|
|
44
|
+
exec node scripts/reauth.js "$@"
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AIUSD Skill Auto-Setup
|
|
5
|
+
*
|
|
6
|
+
* This script automatically handles:
|
|
7
|
+
* 1. Dependency installation
|
|
8
|
+
* 2. Project building
|
|
9
|
+
* 3. Authentication setup
|
|
10
|
+
* 4. Connection testing
|
|
11
|
+
* 5. Tool availability
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { spawn, execSync } from 'child_process';
|
|
15
|
+
import { existsSync, readFileSync } from 'fs';
|
|
16
|
+
import { fileURLToPath } from 'url';
|
|
17
|
+
import { dirname, join } from 'path';
|
|
18
|
+
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
const __dirname = dirname(__filename);
|
|
21
|
+
const projectRoot = join(__dirname, '..');
|
|
22
|
+
|
|
23
|
+
// Colors for console output
|
|
24
|
+
const colors = {
|
|
25
|
+
red: '\x1b[31m',
|
|
26
|
+
green: '\x1b[32m',
|
|
27
|
+
yellow: '\x1b[33m',
|
|
28
|
+
blue: '\x1b[34m',
|
|
29
|
+
magenta: '\x1b[35m',
|
|
30
|
+
cyan: '\x1b[36m',
|
|
31
|
+
reset: '\x1b[0m'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function log(message, color = 'reset') {
|
|
35
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function logStep(step, message) {
|
|
39
|
+
log(`\n๐ Step ${step}: ${message}`, 'blue');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function logSuccess(message) {
|
|
43
|
+
log(`โ
${message}`, 'green');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function logError(message) {
|
|
47
|
+
log(`โ ${message}`, 'red');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function logWarning(message) {
|
|
51
|
+
log(`โ ๏ธ ${message}`, 'yellow');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class SkillSetup {
|
|
55
|
+
constructor() {
|
|
56
|
+
this.projectRoot = projectRoot;
|
|
57
|
+
this.isFirstRun = !existsSync(join(this.projectRoot, 'dist'));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async run() {
|
|
61
|
+
try {
|
|
62
|
+
log('\n๐ AIUSD Skill Auto-Setup', 'magenta');
|
|
63
|
+
log('================================', 'magenta');
|
|
64
|
+
|
|
65
|
+
if (this.isFirstRun) {
|
|
66
|
+
log('๐ฏ First-time setup detected', 'cyan');
|
|
67
|
+
} else {
|
|
68
|
+
log('๐ Re-running setup', 'cyan');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Step 1: Check dependencies
|
|
72
|
+
await this.installDependencies();
|
|
73
|
+
|
|
74
|
+
// Step 2: Build project
|
|
75
|
+
await this.buildProject();
|
|
76
|
+
|
|
77
|
+
// Step 3: Setup authentication
|
|
78
|
+
await this.setupAuthentication();
|
|
79
|
+
|
|
80
|
+
// Step 4: Test connection
|
|
81
|
+
await this.testConnection();
|
|
82
|
+
|
|
83
|
+
// Step 5: Show available tools
|
|
84
|
+
await this.showTools();
|
|
85
|
+
|
|
86
|
+
log('\n๐ Setup completed successfully!', 'green');
|
|
87
|
+
log('๐ก You can now use the skill for AIUSD operations', 'cyan');
|
|
88
|
+
|
|
89
|
+
} catch (error) {
|
|
90
|
+
logError(`Setup failed: ${error.message}`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async installDependencies() {
|
|
96
|
+
logStep(1, 'Installing dependencies');
|
|
97
|
+
|
|
98
|
+
if (!existsSync(join(this.projectRoot, 'node_modules'))) {
|
|
99
|
+
log('๐ฆ Installing npm packages...', 'blue');
|
|
100
|
+
execSync('npm install', {
|
|
101
|
+
cwd: this.projectRoot,
|
|
102
|
+
stdio: 'inherit'
|
|
103
|
+
});
|
|
104
|
+
logSuccess('Dependencies installed');
|
|
105
|
+
} else {
|
|
106
|
+
logSuccess('Dependencies already installed');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async buildProject() {
|
|
111
|
+
logStep(2, 'Building TypeScript project');
|
|
112
|
+
|
|
113
|
+
if (!existsSync(join(this.projectRoot, 'dist')) || this.needsRebuild()) {
|
|
114
|
+
log('๐จ Compiling TypeScript...', 'blue');
|
|
115
|
+
execSync('npm run build', {
|
|
116
|
+
cwd: this.projectRoot,
|
|
117
|
+
stdio: 'inherit'
|
|
118
|
+
});
|
|
119
|
+
logSuccess('Project built successfully');
|
|
120
|
+
} else {
|
|
121
|
+
logSuccess('Project already built');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
needsRebuild() {
|
|
126
|
+
try {
|
|
127
|
+
const srcStat = execSync('find src -name "*.ts" -newer dist 2>/dev/null | wc -l', {
|
|
128
|
+
cwd: this.projectRoot,
|
|
129
|
+
encoding: 'utf8'
|
|
130
|
+
});
|
|
131
|
+
return parseInt(srcStat.trim()) > 0;
|
|
132
|
+
} catch {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async setupAuthentication() {
|
|
138
|
+
logStep(3, 'Setting up authentication');
|
|
139
|
+
|
|
140
|
+
// Check for existing authentication
|
|
141
|
+
if (process.env.MCP_HUB_TOKEN || process.env.AIUSD_TOKEN) {
|
|
142
|
+
logSuccess('Environment token found');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Check for mcporter
|
|
147
|
+
try {
|
|
148
|
+
execSync('which mcporter', { stdio: 'pipe' });
|
|
149
|
+
log('๐ Checking mcporter authentication...', 'blue');
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
const result = execSync(
|
|
153
|
+
'npx mcporter list --http-url https://mcp.alpha.dev/api/mcp-hub/mcp --name aiusd',
|
|
154
|
+
{ cwd: this.projectRoot, encoding: 'utf8', timeout: 10000 }
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
if (result.includes('tools')) {
|
|
158
|
+
logSuccess('mcporter authentication verified');
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
} catch (error) {
|
|
162
|
+
logWarning('mcporter authentication needed');
|
|
163
|
+
}
|
|
164
|
+
} catch {
|
|
165
|
+
logWarning('mcporter not available');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Show setup instructions
|
|
169
|
+
log('\n๐ Authentication Setup Required:', 'yellow');
|
|
170
|
+
log('Choose one of these methods:', 'cyan');
|
|
171
|
+
log('');
|
|
172
|
+
log('1. Environment Variable:', 'blue');
|
|
173
|
+
log(' export MCP_HUB_TOKEN="Bearer your_token_here"', 'cyan');
|
|
174
|
+
log('');
|
|
175
|
+
log('2. Use mcporter (Recommended):', 'blue');
|
|
176
|
+
log(' npx mcporter list --http-url https://mcp.alpha.dev/api/mcp-hub/mcp --name aiusd', 'cyan');
|
|
177
|
+
log('');
|
|
178
|
+
log('3. Get token from: https://mcp.alpha.dev/oauth/login', 'blue');
|
|
179
|
+
log('');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async testConnection() {
|
|
183
|
+
logStep(4, 'Testing MCP connection');
|
|
184
|
+
|
|
185
|
+
try {
|
|
186
|
+
const result = execSync('node dist/index.js test', {
|
|
187
|
+
cwd: this.projectRoot,
|
|
188
|
+
encoding: 'utf8',
|
|
189
|
+
timeout: 15000
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
if (result.includes('successful')) {
|
|
193
|
+
logSuccess('MCP connection test passed');
|
|
194
|
+
} else {
|
|
195
|
+
logWarning('Connection test completed with warnings');
|
|
196
|
+
log(result, 'yellow');
|
|
197
|
+
}
|
|
198
|
+
} catch (error) {
|
|
199
|
+
logWarning('Connection test skipped (authentication required)');
|
|
200
|
+
log(' Set up authentication and run: npm test', 'cyan');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async showTools() {
|
|
205
|
+
logStep(5, 'Available tools');
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
const result = execSync('node dist/index.js tools', {
|
|
209
|
+
cwd: this.projectRoot,
|
|
210
|
+
encoding: 'utf8',
|
|
211
|
+
timeout: 15000
|
|
212
|
+
});
|
|
213
|
+
log(result, 'cyan');
|
|
214
|
+
} catch (error) {
|
|
215
|
+
log('๐ Core AIUSD Tools Available:', 'cyan');
|
|
216
|
+
log('โข genalpha_get_balances - Check account balances', 'blue');
|
|
217
|
+
log('โข genalpha_execute_intent - Execute trading orders', 'blue');
|
|
218
|
+
log('โข genalpha_stake_aiusd - Stake AIUSD tokens', 'blue');
|
|
219
|
+
log('โข genalpha_withdraw_to_wallet - Withdraw to external wallet', 'blue');
|
|
220
|
+
log('โข genalpha_get_transactions - View transaction history', 'blue');
|
|
221
|
+
log('');
|
|
222
|
+
log('๐ก Authenticate to see full tool details', 'yellow');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Main execution
|
|
228
|
+
async function main() {
|
|
229
|
+
const setup = new SkillSetup();
|
|
230
|
+
await setup.run();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Test script for AIUSD Skills MCP Client
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# Colors
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
NC='\033[0m' # No Color
|
|
14
|
+
|
|
15
|
+
log_info() { echo -e "${BLUE}โน๏ธ${NC} $1"; }
|
|
16
|
+
log_success() { echo -e "${GREEN}โ
${NC} $1"; }
|
|
17
|
+
log_warning() { echo -e "${YELLOW}โ ๏ธ${NC} $1"; }
|
|
18
|
+
log_error() { echo -e "${RED}โ${NC} $1"; }
|
|
19
|
+
|
|
20
|
+
# Project directory - go up one level from scripts/
|
|
21
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
22
|
+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
23
|
+
cd "$PROJECT_ROOT"
|
|
24
|
+
|
|
25
|
+
echo "๐งช Testing AIUSD Skills MCP Client"
|
|
26
|
+
echo "================================="
|
|
27
|
+
|
|
28
|
+
# Check if built
|
|
29
|
+
if [[ ! -f "dist/index.js" ]]; then
|
|
30
|
+
log_error "Project not built. Run 'npm run build' first"
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# Test 1: Version check
|
|
35
|
+
log_info "Testing version command..."
|
|
36
|
+
if node dist/index.js --version >/dev/null 2>&1; then
|
|
37
|
+
log_success "Version command works"
|
|
38
|
+
else
|
|
39
|
+
log_error "Version command failed"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Test 2: Help command
|
|
44
|
+
log_info "Testing help command..."
|
|
45
|
+
if node dist/index.js --help >/dev/null 2>&1; then
|
|
46
|
+
log_success "Help command works"
|
|
47
|
+
else
|
|
48
|
+
log_error "Help command failed"
|
|
49
|
+
exit 1
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# Test 3: Connection test (may require auth)
|
|
53
|
+
log_info "Testing MCP connection..."
|
|
54
|
+
if node dist/index.js test >/dev/null 2>&1; then
|
|
55
|
+
log_success "Connection test passed"
|
|
56
|
+
else
|
|
57
|
+
log_warning "Connection test failed (may need authentication)"
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
# Test 4: Tools listing (may require auth)
|
|
61
|
+
log_info "Testing tools listing..."
|
|
62
|
+
if node dist/index.js tools >/dev/null 2>&1; then
|
|
63
|
+
log_success "Tools listing works"
|
|
64
|
+
else
|
|
65
|
+
log_warning "Tools listing failed (may need authentication)"
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Test 5: Balance check (requires auth)
|
|
69
|
+
log_info "Testing balance check..."
|
|
70
|
+
if node dist/index.js balances >/dev/null 2>&1; then
|
|
71
|
+
log_success "Balance check works"
|
|
72
|
+
echo ""
|
|
73
|
+
echo "๐ Current balances:"
|
|
74
|
+
node dist/index.js balances --pretty
|
|
75
|
+
else
|
|
76
|
+
log_warning "Balance check failed (authentication required)"
|
|
77
|
+
echo ""
|
|
78
|
+
echo "๐ To enable full testing, set up authentication:"
|
|
79
|
+
echo " export MCP_HUB_TOKEN=\"Bearer your_token\""
|
|
80
|
+
echo " OR use: npm run setup"
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
echo ""
|
|
84
|
+
log_success "Basic functionality tests completed!"
|
|
85
|
+
|
|
86
|
+
echo ""
|
|
87
|
+
echo "๐ Manual testing commands:"
|
|
88
|
+
echo " npm test # This test script"
|
|
89
|
+
echo " node dist/index.js test # Connection test"
|
|
90
|
+
echo " node dist/index.js tools # List available tools"
|
|
91
|
+
echo " node dist/index.js balances # Check balances"
|