|
1 | 1 | import chalk from 'chalk'; |
2 | 2 | import { getConnection } from '../config.js'; |
| 3 | +import { callTool } from '../call-tool.js'; |
3 | 4 |
|
4 | 5 | const DEFAULT_ACCOUNTS_URL = 'https://accounts.atxp.ai'; |
5 | 6 |
|
@@ -42,12 +43,19 @@ export async function whoamiCommand(): Promise<void> { |
42 | 43 |
|
43 | 44 | try { |
44 | 45 | const credentials = Buffer.from(`${token}:`).toString('base64'); |
45 | | - const response = await fetch(`${baseUrl}/me`, { |
46 | | - headers: { |
47 | | - 'Authorization': `Basic ${credentials}`, |
48 | | - 'Content-Type': 'application/json', |
49 | | - }, |
50 | | - }); |
| 46 | + |
| 47 | + // Fetch account info and phone number in parallel |
| 48 | + const [response, phoneNumber] = await Promise.all([ |
| 49 | + fetch(`${baseUrl}/me`, { |
| 50 | + headers: { |
| 51 | + 'Authorization': `Basic ${credentials}`, |
| 52 | + 'Content-Type': 'application/json', |
| 53 | + }, |
| 54 | + }), |
| 55 | + callTool('phone.mcp.atxp.ai', 'phone_check_sms', {}) |
| 56 | + .then((r) => { try { return JSON.parse(r).phoneNumber || null; } catch { return null; } }) |
| 57 | + .catch(() => null), |
| 58 | + ]); |
51 | 59 |
|
52 | 60 | if (!response.ok) { |
53 | 61 | if (response.status === 401) { |
@@ -79,6 +87,9 @@ export async function whoamiCommand(): Promise<void> { |
79 | 87 | if (data.email) { |
80 | 88 | console.log(' ' + chalk.bold('Email:') + ' ' + chalk.cyan(data.email)); |
81 | 89 | } |
| 90 | + if (phoneNumber) { |
| 91 | + console.log(' ' + chalk.bold('Phone:') + ' ' + chalk.cyan(phoneNumber)); |
| 92 | + } |
82 | 93 | if (data.displayName) { |
83 | 94 | console.log(' ' + chalk.bold('Display Name:') + ' ' + data.displayName); |
84 | 95 | } |
|
0 commit comments