forked from Handit-AI/handit-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-connection.js
More file actions
45 lines (34 loc) · 1.34 KB
/
test-connection.js
File metadata and controls
45 lines (34 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env node
const chalk = require('chalk');
const { HanditApi } = require('./src/api/handitApi');
const { TokenStorage } = require('./src/auth/tokenStorage');
async function testConnection() {
try {
console.log(chalk.blue.bold('🔗 Testing Handit Connection'));
// Load tokens
const tokenStorage = new TokenStorage();
const tokens = await tokenStorage.loadTokens();
if (!tokens || !tokens.authToken) {
console.log(chalk.red('❌ No authentication tokens found'));
console.log(chalk.gray('Please run handit-cli setup first to authenticate'));
return;
}
console.log(chalk.green('✅ Authentication tokens loaded'));
// Initialize API
const handitApi = new HanditApi();
handitApi.authToken = tokens.authToken;
handitApi.apiToken = tokens.apiToken;
// Test connection
const testAgentName = 'test-agent-' + Date.now();
console.log(chalk.gray(`Testing with agent name: ${testAgentName}`));
const result = await handitApi.testConnectionWithAgent(testAgentName);
if (result.connected) {
console.log(chalk.green('✅ Connection test successful!'));
} else {
console.log(chalk.yellow('⚠️ Connection test returned false'));
}
} catch (error) {
console.log(chalk.red(`❌ Connection test failed: ${error.message}`));
}
}
testConnection();