@lanonasis/cli 3.6.5 → 3.6.7

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.
Files changed (40) hide show
  1. package/dist/commands/api-keys.d.ts +2 -1
  2. package/dist/commands/api-keys.js +73 -78
  3. package/dist/commands/auth.js +160 -167
  4. package/dist/commands/completion.js +31 -39
  5. package/dist/commands/config.js +162 -201
  6. package/dist/commands/enhanced-memory.js +11 -17
  7. package/dist/commands/guide.js +79 -88
  8. package/dist/commands/init.js +14 -20
  9. package/dist/commands/mcp.d.ts +10 -0
  10. package/dist/commands/mcp.js +167 -156
  11. package/dist/commands/memory.js +77 -83
  12. package/dist/commands/organization.js +15 -21
  13. package/dist/commands/topics.js +52 -58
  14. package/dist/core/achievements.js +19 -26
  15. package/dist/core/architecture.js +42 -59
  16. package/dist/core/dashboard.js +71 -81
  17. package/dist/core/error-handler.js +30 -39
  18. package/dist/core/power-mode.js +46 -53
  19. package/dist/core/progress.js +35 -44
  20. package/dist/core/welcome.js +56 -64
  21. package/dist/enhanced-cli.js +49 -58
  22. package/dist/index-simple.js +75 -113
  23. package/dist/index.js +64 -69
  24. package/dist/mcp/access-control.js +13 -17
  25. package/dist/mcp/client/enhanced-client.js +16 -23
  26. package/dist/mcp/enhanced-server.js +10 -14
  27. package/dist/mcp/logger.js +3 -7
  28. package/dist/mcp/memory-state.js +13 -17
  29. package/dist/mcp/schemas/tool-schemas.d.ts +16 -16
  30. package/dist/mcp/schemas/tool-schemas.js +122 -126
  31. package/dist/mcp/server/lanonasis-server.js +66 -57
  32. package/dist/mcp/transports/transport-manager.js +18 -25
  33. package/dist/mcp/vector-store.js +6 -10
  34. package/dist/mcp-server.js +23 -27
  35. package/dist/utils/api.js +19 -26
  36. package/dist/utils/config.d.ts +2 -1
  37. package/dist/utils/config.js +65 -78
  38. package/dist/utils/formatting.js +6 -14
  39. package/dist/utils/mcp-client.js +76 -117
  40. package/package.json +36 -5
@@ -1,17 +1,21 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.mcpCommands = mcpCommands;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const ora_1 = __importDefault(require("ora"));
9
- const table_1 = require("table");
10
- const mcp_client_js_1 = require("../utils/mcp-client.js");
11
- const enhanced_client_js_1 = require("../mcp/client/enhanced-client.js");
12
- const config_js_1 = require("../utils/config.js");
13
- const ws_1 = __importDefault(require("ws"));
14
- function mcpCommands(program) {
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import { table } from 'table';
4
+ import { getMCPClient } from '../utils/mcp-client.js';
5
+ import { EnhancedMCPClient } from '../mcp/client/enhanced-client.js';
6
+ import { CLIConfig } from '../utils/config.js';
7
+ import WebSocket from 'ws';
8
+ /**
9
+ * Register MCP-related CLI commands (mcp and mcp-server) on a Commander program.
10
+ *
11
+ * Adds commands and subcommands for MCP server initialization, connection management,
12
+ * status reporting, tool listing and invocation, memory create/search operations,
13
+ * preference configuration, and diagnostic routines, wiring each command to its
14
+ * corresponding action handlers.
15
+ *
16
+ * @param program - Commander program instance to extend with MCP commands
17
+ */
18
+ export function mcpCommands(program) {
15
19
  const mcp = program
16
20
  .command('mcp')
17
21
  .description('MCP (Model Context Protocol) server operations');
@@ -22,35 +26,35 @@ function mcpCommands(program) {
22
26
  mcpServer.command('init')
23
27
  .description('Initialize MCP server configuration')
24
28
  .action(async () => {
25
- console.log(chalk_1.default.cyan('šŸš€ Initializing MCP Server Configuration'));
29
+ console.log(chalk.cyan('šŸš€ Initializing MCP Server Configuration'));
26
30
  console.log('');
27
- const config = new config_js_1.CLIConfig();
31
+ const config = new CLIConfig();
28
32
  const isAuthenticated = !!config.get('token');
29
33
  if (isAuthenticated) {
30
- console.log(chalk_1.default.green('āœ“ Authenticated - Using remote MCP mode'));
34
+ console.log(chalk.green('āœ“ Authenticated - Using remote MCP mode'));
31
35
  console.log(' Your memory operations will use mcp.lanonasis.com');
32
36
  console.log(' with real-time SSE updates enabled');
33
37
  }
34
38
  else {
35
- console.log(chalk_1.default.yellow('āš ļø Not authenticated - Using local MCP mode'));
39
+ console.log(chalk.yellow('āš ļø Not authenticated - Using local MCP mode'));
36
40
  console.log(' Run "lanonasis auth login" to enable remote mode');
37
41
  }
38
42
  console.log('');
39
- console.log(chalk_1.default.cyan('Available MCP Commands:'));
43
+ console.log(chalk.cyan('Available MCP Commands:'));
40
44
  console.log(' lanonasis mcp connect # Auto-connect to best mode');
41
45
  console.log(' lanonasis mcp connect -r # Force remote mode');
42
46
  console.log(' lanonasis mcp connect -l # Force local mode');
43
47
  console.log(' lanonasis mcp status # Check connection status');
44
48
  console.log(' lanonasis mcp tools # List available tools');
45
49
  console.log('');
46
- console.log(chalk_1.default.cyan('Memory operations are MCP-powered by default!'));
50
+ console.log(chalk.cyan('Memory operations are MCP-powered by default!'));
47
51
  // Auto-connect to MCP
48
- const spinner = (0, ora_1.default)('Auto-connecting to MCP...').start();
52
+ const spinner = ora('Auto-connecting to MCP...').start();
49
53
  try {
50
- const client = (0, mcp_client_js_1.getMCPClient)();
54
+ const client = getMCPClient();
51
55
  const connected = await client.connect({ useRemote: isAuthenticated });
52
56
  if (connected) {
53
- spinner.succeed(chalk_1.default.green(`Connected to ${isAuthenticated ? 'remote' : 'local'} MCP server`));
57
+ spinner.succeed(chalk.green(`Connected to ${isAuthenticated ? 'remote' : 'local'} MCP server`));
54
58
  process.exit(0);
55
59
  }
56
60
  else {
@@ -73,8 +77,8 @@ function mcpCommands(program) {
73
77
  .option('-u, --url <url>', 'Remote/WebSocket server URL')
74
78
  .option('--local-args <args>', 'Extra args for local server (e.g., "--stdio --port 3001")')
75
79
  .action(async (options) => {
76
- const spinner = (0, ora_1.default)('Connecting to MCP server...').start();
77
- const config = new config_js_1.CLIConfig();
80
+ const spinner = ora('Connecting to MCP server...').start();
81
+ const config = new CLIConfig();
78
82
  try {
79
83
  let connectionMode;
80
84
  // Determine connection mode - WebSocket takes precedence over remote and local
@@ -88,8 +92,9 @@ function mcpCommands(program) {
88
92
  connectionMode = 'local';
89
93
  }
90
94
  else {
91
- // Default to remote if authenticated, otherwise local
92
- connectionMode = config.get('token') ? 'remote' : 'local';
95
+ // Default to websocket (production mode) for all users
96
+ // Local mode should only be used explicitly for development
97
+ connectionMode = 'websocket';
93
98
  }
94
99
  // Save preferences
95
100
  config.set('mcpConnectionMode', connectionMode);
@@ -106,7 +111,7 @@ function mcpCommands(program) {
106
111
  }
107
112
  let connected = false;
108
113
  // Use Enhanced MCP Client for better connection handling
109
- const enhancedClient = new enhanced_client_js_1.EnhancedMCPClient();
114
+ const enhancedClient = new EnhancedMCPClient();
110
115
  if (options.url) {
111
116
  // Connect to specific URL (WebSocket or remote)
112
117
  const serverConfig = {
@@ -117,14 +122,14 @@ function mcpCommands(program) {
117
122
  };
118
123
  connected = await enhancedClient.connectSingle(serverConfig);
119
124
  if (connected) {
120
- spinner.succeed(chalk_1.default.green(`Connected to MCP server at ${options.url}`));
125
+ spinner.succeed(chalk.green(`Connected to MCP server at ${options.url}`));
121
126
  process.exit(0);
122
127
  return;
123
128
  }
124
129
  }
125
130
  else {
126
131
  // Fall back to old client for local connections
127
- const client = (0, mcp_client_js_1.getMCPClient)();
132
+ const client = getMCPClient();
128
133
  const localArgs = typeof options.localArgs === 'string' && options.localArgs.trim().length > 0
129
134
  ? options.localArgs.split(' ').map((s) => s.trim()).filter(Boolean)
130
135
  : undefined;
@@ -136,15 +141,15 @@ function mcpCommands(program) {
136
141
  });
137
142
  }
138
143
  if (connected) {
139
- spinner.succeed(chalk_1.default.green(`Connected to MCP server in ${connectionMode} mode`));
144
+ spinner.succeed(chalk.green(`Connected to MCP server in ${connectionMode} mode`));
140
145
  process.exit(0);
141
146
  if (connectionMode === 'remote') {
142
- console.log(chalk_1.default.cyan('ā„¹ļø Using remote MCP via mcp.lanonasis.com'));
143
- console.log(chalk_1.default.cyan('šŸ“” SSE endpoint active for real-time updates'));
147
+ console.log(chalk.cyan('ā„¹ļø Using remote MCP via mcp.lanonasis.com'));
148
+ console.log(chalk.cyan('šŸ“” SSE endpoint active for real-time updates'));
144
149
  }
145
150
  else if (connectionMode === 'websocket') {
146
- console.log(chalk_1.default.cyan('ā„¹ļø Using enterprise WebSocket MCP server'));
147
- console.log(chalk_1.default.cyan('šŸ“” WebSocket connection active with auto-reconnect'));
151
+ console.log(chalk.cyan('ā„¹ļø Using enterprise WebSocket MCP server'));
152
+ console.log(chalk.cyan('šŸ“” WebSocket connection active with auto-reconnect'));
148
153
  }
149
154
  }
150
155
  else {
@@ -161,47 +166,47 @@ function mcpCommands(program) {
161
166
  mcp.command('disconnect')
162
167
  .description('Disconnect from MCP server')
163
168
  .action(async () => {
164
- const client = (0, mcp_client_js_1.getMCPClient)();
169
+ const client = getMCPClient();
165
170
  await client.disconnect();
166
- console.log(chalk_1.default.green('āœ“ Disconnected from MCP server'));
171
+ console.log(chalk.green('āœ“ Disconnected from MCP server'));
167
172
  });
168
173
  // Status command
169
174
  mcp.command('status')
170
175
  .description('Show MCP connection status')
171
176
  .action(async () => {
172
- const client = (0, mcp_client_js_1.getMCPClient)();
177
+ const client = getMCPClient();
173
178
  // Reload config from disk to get latest preference
174
179
  await client.init();
175
180
  const status = client.getConnectionStatus();
176
- console.log(chalk_1.default.cyan('\nšŸ“Š MCP Connection Status'));
177
- console.log(chalk_1.default.cyan('========================'));
178
- console.log(`Status: ${status.connected ? chalk_1.default.green('Connected') : chalk_1.default.red('Disconnected')}`);
181
+ console.log(chalk.cyan('\nšŸ“Š MCP Connection Status'));
182
+ console.log(chalk.cyan('========================'));
183
+ console.log(`Status: ${status.connected ? chalk.green('Connected') : chalk.red('Disconnected')}`);
179
184
  // Display mode with proper labels
180
185
  let modeDisplay;
181
186
  switch (status.mode) {
182
187
  case 'websocket':
183
- modeDisplay = chalk_1.default.blue('WebSocket');
188
+ modeDisplay = chalk.blue('WebSocket');
184
189
  break;
185
190
  case 'remote':
186
- modeDisplay = chalk_1.default.blue('Remote (HTTP/SSE)');
191
+ modeDisplay = chalk.blue('Remote (HTTP/SSE)');
187
192
  break;
188
193
  case 'local':
189
- modeDisplay = chalk_1.default.yellow('Local (stdio)');
194
+ modeDisplay = chalk.yellow('Local (stdio)');
190
195
  break;
191
196
  default:
192
- modeDisplay = chalk_1.default.gray(status.mode);
197
+ modeDisplay = chalk.gray(status.mode);
193
198
  }
194
199
  console.log(`Mode: ${modeDisplay}`);
195
200
  console.log(`Server: ${status.server}`);
196
201
  if (status.connected) {
197
202
  if (status.mode === 'remote') {
198
- console.log(`\n${chalk_1.default.cyan('Features:')}`);
203
+ console.log(`\n${chalk.cyan('Features:')}`);
199
204
  console.log('• Real-time updates via SSE');
200
205
  console.log('• Authenticated API access');
201
206
  console.log('• MCP-compatible tool interface');
202
207
  }
203
208
  else if (status.mode === 'websocket') {
204
- console.log(`\n${chalk_1.default.cyan('Features:')}`);
209
+ console.log(`\n${chalk.cyan('Features:')}`);
205
210
  console.log('• Bi-directional real-time communication');
206
211
  console.log('• Authenticated WebSocket connection');
207
212
  console.log('• Production-ready MCP server');
@@ -212,29 +217,29 @@ function mcpCommands(program) {
212
217
  mcp.command('tools')
213
218
  .description('List available MCP tools')
214
219
  .action(async () => {
215
- const spinner = (0, ora_1.default)('Fetching available tools...').start();
220
+ const spinner = ora('Fetching available tools...').start();
216
221
  try {
217
- const client = (0, mcp_client_js_1.getMCPClient)();
222
+ const client = getMCPClient();
218
223
  if (!client.isConnectedToServer()) {
219
224
  spinner.info('Not connected. Attempting auto-connect...');
220
- const config = new config_js_1.CLIConfig();
225
+ const config = new CLIConfig();
221
226
  const useRemote = !!config.get('token');
222
227
  await client.connect({ useRemote });
223
228
  }
224
229
  const tools = await client.listTools();
225
230
  spinner.succeed('Tools fetched successfully');
226
- console.log(chalk_1.default.cyan('\nšŸ”§ Available MCP Tools'));
227
- console.log(chalk_1.default.cyan('====================='));
231
+ console.log(chalk.cyan('\nšŸ”§ Available MCP Tools'));
232
+ console.log(chalk.cyan('====================='));
228
233
  const tableData = [
229
- [chalk_1.default.bold('Tool Name'), chalk_1.default.bold('Description')]
234
+ [chalk.bold('Tool Name'), chalk.bold('Description')]
230
235
  ];
231
236
  tools.forEach(tool => {
232
237
  tableData.push([
233
- chalk_1.default.green(tool.name),
238
+ chalk.green(tool.name),
234
239
  tool.description
235
240
  ]);
236
241
  });
237
- console.log((0, table_1.table)(tableData, {
242
+ console.log(table(tableData, {
238
243
  border: {
239
244
  topBody: '─',
240
245
  topJoin: '┬',
@@ -265,12 +270,12 @@ function mcpCommands(program) {
265
270
  .argument('<tool>', 'Tool name to call')
266
271
  .option('-a, --args <json>', 'Tool arguments as JSON')
267
272
  .action(async (toolName, options) => {
268
- const spinner = (0, ora_1.default)(`Calling tool: ${toolName}...`).start();
273
+ const spinner = ora(`Calling tool: ${toolName}...`).start();
269
274
  try {
270
- const client = (0, mcp_client_js_1.getMCPClient)();
275
+ const client = getMCPClient();
271
276
  if (!client.isConnectedToServer()) {
272
277
  spinner.info('Not connected. Attempting auto-connect...');
273
- const config = new config_js_1.CLIConfig();
278
+ const config = new CLIConfig();
274
279
  const useRemote = !!config.get('token');
275
280
  await client.connect({ useRemote });
276
281
  }
@@ -286,7 +291,7 @@ function mcpCommands(program) {
286
291
  }
287
292
  const result = await client.callTool(toolName, args);
288
293
  spinner.succeed(`Tool ${toolName} executed successfully`);
289
- console.log(chalk_1.default.cyan('\nšŸ“¤ Tool Result:'));
294
+ console.log(chalk.cyan('\nšŸ“¤ Tool Result:'));
290
295
  console.log(JSON.stringify(result, null, 2));
291
296
  }
292
297
  catch (error) {
@@ -304,12 +309,12 @@ function mcpCommands(program) {
304
309
  .option('-T, --type <type>', 'Memory type', 'context')
305
310
  .option('--tags <tags>', 'Comma-separated tags')
306
311
  .action(async (options) => {
307
- const spinner = (0, ora_1.default)('Creating memory via MCP...').start();
312
+ const spinner = ora('Creating memory via MCP...').start();
308
313
  try {
309
- const client = (0, mcp_client_js_1.getMCPClient)();
314
+ const client = getMCPClient();
310
315
  if (!client.isConnectedToServer()) {
311
316
  spinner.info('Not connected. Attempting auto-connect...');
312
- const config = new config_js_1.CLIConfig();
317
+ const config = new CLIConfig();
313
318
  const useRemote = !!config.get('token');
314
319
  await client.connect({ useRemote });
315
320
  }
@@ -320,8 +325,8 @@ function mcpCommands(program) {
320
325
  tags: options.tags ? options.tags.split(',').map((t) => t.trim()) : []
321
326
  });
322
327
  spinner.succeed('Memory created successfully');
323
- console.log(chalk_1.default.green('\nāœ“ Memory created'));
324
- console.log(`ID: ${chalk_1.default.cyan(result.id)}`);
328
+ console.log(chalk.green('\nāœ“ Memory created'));
329
+ console.log(`ID: ${chalk.cyan(result.id)}`);
325
330
  console.log(`Title: ${result.title}`);
326
331
  console.log(`Type: ${result.memory_type}`);
327
332
  }
@@ -336,12 +341,12 @@ function mcpCommands(program) {
336
341
  .option('-l, --limit <number>', 'Maximum results', '10')
337
342
  .option('-t, --threshold <number>', 'Similarity threshold (0-1)', '0.7')
338
343
  .action(async (query, options) => {
339
- const spinner = (0, ora_1.default)('Searching memories via MCP...').start();
344
+ const spinner = ora('Searching memories via MCP...').start();
340
345
  try {
341
- const client = (0, mcp_client_js_1.getMCPClient)();
346
+ const client = getMCPClient();
342
347
  if (!client.isConnectedToServer()) {
343
348
  spinner.info('Not connected. Attempting auto-connect...');
344
- const config = new config_js_1.CLIConfig();
349
+ const config = new CLIConfig();
345
350
  const useRemote = !!config.get('token');
346
351
  await client.connect({ useRemote });
347
352
  }
@@ -352,15 +357,15 @@ function mcpCommands(program) {
352
357
  });
353
358
  spinner.succeed(`Found ${results.length} memories`);
354
359
  if (results.length === 0) {
355
- console.log(chalk_1.default.yellow('\nNo memories found matching your query'));
360
+ console.log(chalk.yellow('\nNo memories found matching your query'));
356
361
  return;
357
362
  }
358
- console.log(chalk_1.default.cyan('\nšŸ” Search Results:'));
363
+ console.log(chalk.cyan('\nšŸ” Search Results:'));
359
364
  results.forEach((memory, index) => {
360
- console.log(`\n${chalk_1.default.bold(`${index + 1}. ${memory.title}`)}`);
361
- console.log(` ID: ${chalk_1.default.gray(memory.id)}`);
362
- console.log(` Type: ${chalk_1.default.blue(memory.memory_type)}`);
363
- console.log(` Score: ${chalk_1.default.green((memory.relevance_score * 100).toFixed(1) + '%')}`);
365
+ console.log(`\n${chalk.bold(`${index + 1}. ${memory.title}`)}`);
366
+ console.log(` ID: ${chalk.gray(memory.id)}`);
367
+ console.log(` Type: ${chalk.blue(memory.memory_type)}`);
368
+ console.log(` Score: ${chalk.green((memory.relevance_score * 100).toFixed(1) + '%')}`);
364
369
  console.log(` Content: ${memory.content.substring(0, 100)}...`);
365
370
  });
366
371
  }
@@ -372,30 +377,36 @@ function mcpCommands(program) {
372
377
  // Configure MCP preferences
373
378
  mcp.command('config')
374
379
  .description('Configure MCP preferences')
375
- .option('--prefer-remote', 'Prefer remote MCP server when available')
376
- .option('--prefer-local', 'Prefer local MCP server')
380
+ .option('--prefer-websocket', 'Prefer WebSocket MCP connection (recommended for production)')
381
+ .option('--prefer-remote', 'Prefer remote MCP server (REST/SSE mode)')
382
+ .option('--prefer-local', 'Prefer local MCP server (development only)')
377
383
  .option('--auto', 'Auto-detect best connection mode')
378
384
  .action(async (options) => {
379
- const config = new config_js_1.CLIConfig();
380
- if (options.preferRemote) {
385
+ const config = new CLIConfig();
386
+ if (options.preferWebsocket) {
387
+ await config.setAndSave('mcpPreference', 'websocket');
388
+ console.log(chalk.green('āœ“ Set MCP preference to WebSocket (production mode)'));
389
+ }
390
+ else if (options.preferRemote) {
381
391
  await config.setAndSave('mcpPreference', 'remote');
382
- console.log(chalk_1.default.green('āœ“ Set MCP preference to remote'));
392
+ console.log(chalk.green('āœ“ Set MCP preference to remote (REST/SSE mode)'));
383
393
  }
384
394
  else if (options.preferLocal) {
385
395
  await config.setAndSave('mcpPreference', 'local');
386
- console.log(chalk_1.default.green('āœ“ Set MCP preference to local'));
396
+ console.log(chalk.green('āœ“ Set MCP preference to local (development only)'));
387
397
  }
388
398
  else if (options.auto) {
389
399
  await config.setAndSave('mcpPreference', 'auto');
390
- console.log(chalk_1.default.green('āœ“ Set MCP preference to auto-detect'));
400
+ console.log(chalk.green('āœ“ Set MCP preference to auto-detect'));
391
401
  }
392
402
  else {
393
403
  const current = config.get('mcpPreference') || 'auto';
394
- console.log(`Current MCP preference: ${chalk_1.default.cyan(current)}`);
404
+ console.log(`Current MCP preference: ${chalk.cyan(current)}`);
395
405
  console.log('\nOptions:');
396
- console.log(' --prefer-remote : Use remote MCP server (mcp.lanonasis.com)');
397
- console.log(' --prefer-local : Use local MCP server');
398
- console.log(' --auto : Auto-detect based on authentication');
406
+ console.log(' --prefer-websocket : Use WebSocket mode (recommended for production)');
407
+ console.log(' --prefer-remote : Use remote REST/SSE mode (alternative)');
408
+ console.log(' --prefer-local : Use local stdio mode (development only)');
409
+ console.log(' --auto : Auto-detect based on configuration (default)');
399
410
  }
400
411
  });
401
412
  // Diagnose MCP connection issues
@@ -403,10 +414,10 @@ function mcpCommands(program) {
403
414
  .description('Diagnose MCP connection issues')
404
415
  .option('-v, --verbose', 'show detailed diagnostic information')
405
416
  .action(async (options) => {
406
- const config = new config_js_1.CLIConfig();
417
+ const config = new CLIConfig();
407
418
  await config.init();
408
- console.log(chalk_1.default.blue.bold('šŸ” MCP Connection Diagnostic'));
409
- console.log(chalk_1.default.cyan('━'.repeat(50)));
419
+ console.log(chalk.blue.bold('šŸ” MCP Connection Diagnostic'));
420
+ console.log(chalk.cyan('━'.repeat(50)));
410
421
  console.log();
411
422
  const diagnostics = {
412
423
  authenticationValid: false,
@@ -422,64 +433,64 @@ function mcpCommands(program) {
422
433
  healthCheckPassing: false
423
434
  };
424
435
  // Step 1: Check authentication status
425
- console.log(chalk_1.default.cyan('1. Authentication Status'));
436
+ console.log(chalk.cyan('1. Authentication Status'));
426
437
  const token = config.getToken();
427
438
  const vendorKey = config.getVendorKey();
428
439
  if (!token && !vendorKey) {
429
- console.log(chalk_1.default.red(' āœ– No authentication credentials found'));
430
- console.log(chalk_1.default.gray(' → Run: lanonasis auth login'));
431
- console.log(chalk_1.default.gray(' → MCP requires authentication for remote access'));
440
+ console.log(chalk.red(' āœ– No authentication credentials found'));
441
+ console.log(chalk.gray(' → Run: lanonasis auth login'));
442
+ console.log(chalk.gray(' → MCP requires authentication for remote access'));
432
443
  }
433
444
  else {
434
445
  try {
435
446
  const isValid = await config.validateStoredCredentials();
436
447
  diagnostics.authenticationValid = isValid;
437
448
  if (isValid) {
438
- console.log(chalk_1.default.green(' āœ“ Authentication credentials are valid'));
449
+ console.log(chalk.green(' āœ“ Authentication credentials are valid'));
439
450
  }
440
451
  else {
441
- console.log(chalk_1.default.red(' āœ– Authentication credentials are invalid'));
442
- console.log(chalk_1.default.gray(' → Run: lanonasis auth login'));
452
+ console.log(chalk.red(' āœ– Authentication credentials are invalid'));
453
+ console.log(chalk.gray(' → Run: lanonasis auth login'));
443
454
  }
444
455
  }
445
456
  catch (error) {
446
- console.log(chalk_1.default.yellow(' ⚠ Could not validate authentication'));
447
- console.log(chalk_1.default.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
457
+ console.log(chalk.yellow(' ⚠ Could not validate authentication'));
458
+ console.log(chalk.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
448
459
  }
449
460
  }
450
461
  // Step 2: Test endpoint availability
451
- console.log(chalk_1.default.cyan('\n2. Endpoint Availability'));
452
- const spinner1 = (0, ora_1.default)('Testing MCP endpoints...').start();
462
+ console.log(chalk.cyan('\n2. Endpoint Availability'));
463
+ const spinner1 = ora('Testing MCP endpoints...').start();
453
464
  try {
454
465
  await config.discoverServices(options.verbose);
455
466
  const services = config.get('discoveredServices');
456
467
  if (services) {
457
468
  spinner1.succeed('MCP endpoints discovered');
458
469
  diagnostics.endpointsReachable = true;
459
- console.log(chalk_1.default.green(' āœ“ Service discovery successful'));
470
+ console.log(chalk.green(' āœ“ Service discovery successful'));
460
471
  if (options.verbose) {
461
472
  const svc = services;
462
- console.log(chalk_1.default.gray(` HTTP: ${svc.mcp_base}`));
463
- console.log(chalk_1.default.gray(` WebSocket: ${svc.mcp_ws_base}`));
464
- console.log(chalk_1.default.gray(` SSE: ${svc.mcp_sse_base}`));
473
+ console.log(chalk.gray(` HTTP: ${svc.mcp_base}`));
474
+ console.log(chalk.gray(` WebSocket: ${svc.mcp_ws_base}`));
475
+ console.log(chalk.gray(` SSE: ${svc.mcp_sse_base}`));
465
476
  }
466
477
  }
467
478
  else {
468
479
  spinner1.warn('Using fallback endpoints');
469
- console.log(chalk_1.default.yellow(' ⚠ Service discovery failed, using fallbacks'));
480
+ console.log(chalk.yellow(' ⚠ Service discovery failed, using fallbacks'));
470
481
  diagnostics.endpointsReachable = true; // Fallbacks still work
471
482
  }
472
483
  }
473
484
  catch (error) {
474
485
  spinner1.fail('Endpoint discovery failed');
475
- console.log(chalk_1.default.red(' āœ– Cannot discover MCP endpoints'));
476
- console.log(chalk_1.default.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
486
+ console.log(chalk.red(' āœ– Cannot discover MCP endpoints'));
487
+ console.log(chalk.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
477
488
  }
478
489
  // Step 3: Test transport protocols
479
- console.log(chalk_1.default.cyan('\n3. Transport Protocol Tests'));
490
+ console.log(chalk.cyan('\n3. Transport Protocol Tests'));
480
491
  // Test HTTP/REST endpoint
481
492
  if (diagnostics.authenticationValid) {
482
- const httpSpinner = (0, ora_1.default)('Testing HTTP transport...').start();
493
+ const httpSpinner = ora('Testing HTTP transport...').start();
483
494
  try {
484
495
  const startTime = Date.now();
485
496
  const axios = (await import('axios')).default;
@@ -495,22 +506,22 @@ function mcpCommands(program) {
495
506
  diagnostics.connectionLatency.http = latency;
496
507
  diagnostics.transportTests.http = true;
497
508
  httpSpinner.succeed(`HTTP transport working (${latency}ms)`);
498
- console.log(chalk_1.default.green(` āœ“ HTTP/REST endpoint reachable`));
509
+ console.log(chalk.green(` āœ“ HTTP/REST endpoint reachable`));
499
510
  }
500
511
  catch (error) {
501
512
  httpSpinner.fail('HTTP transport failed');
502
- console.log(chalk_1.default.red(' āœ– HTTP/REST endpoint failed'));
513
+ console.log(chalk.red(' āœ– HTTP/REST endpoint failed'));
503
514
  if (options.verbose) {
504
- console.log(chalk_1.default.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
515
+ console.log(chalk.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
505
516
  }
506
517
  }
507
518
  // Test WebSocket endpoint
508
- const wsSpinner = (0, ora_1.default)('Testing WebSocket transport...').start();
519
+ const wsSpinner = ora('Testing WebSocket transport...').start();
509
520
  try {
510
521
  const startTime = Date.now();
511
522
  const wsUrl = config.getMCPServerUrl();
512
523
  // Create a test WebSocket connection
513
- const ws = new ws_1.default(wsUrl, [], {
524
+ const ws = new WebSocket(wsUrl, [], {
514
525
  headers: {
515
526
  'Authorization': `Bearer ${token}`,
516
527
  'X-API-Key': String(token || vendorKey)
@@ -535,17 +546,17 @@ function mcpCommands(program) {
535
546
  });
536
547
  });
537
548
  wsSpinner.succeed(`WebSocket transport working (${diagnostics.connectionLatency.websocket}ms)`);
538
- console.log(chalk_1.default.green(' āœ“ WebSocket endpoint reachable'));
549
+ console.log(chalk.green(' āœ“ WebSocket endpoint reachable'));
539
550
  }
540
551
  catch (error) {
541
552
  wsSpinner.fail('WebSocket transport failed');
542
- console.log(chalk_1.default.red(' āœ– WebSocket endpoint failed'));
553
+ console.log(chalk.red(' āœ– WebSocket endpoint failed'));
543
554
  if (options.verbose) {
544
- console.log(chalk_1.default.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
555
+ console.log(chalk.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
545
556
  }
546
557
  }
547
558
  // Test SSE endpoint
548
- const sseSpinner = (0, ora_1.default)('Testing SSE transport...').start();
559
+ const sseSpinner = ora('Testing SSE transport...').start();
549
560
  try {
550
561
  const startTime = Date.now();
551
562
  const sseUrl = config.getMCPSSEUrl();
@@ -562,86 +573,86 @@ function mcpCommands(program) {
562
573
  diagnostics.connectionLatency.sse = latency;
563
574
  diagnostics.transportTests.sse = true;
564
575
  sseSpinner.succeed(`SSE transport working (${latency}ms)`);
565
- console.log(chalk_1.default.green(' āœ“ SSE endpoint reachable'));
576
+ console.log(chalk.green(' āœ“ SSE endpoint reachable'));
566
577
  }
567
578
  catch (error) {
568
579
  sseSpinner.fail('SSE transport failed');
569
- console.log(chalk_1.default.red(' āœ– SSE endpoint failed'));
580
+ console.log(chalk.red(' āœ– SSE endpoint failed'));
570
581
  if (options.verbose) {
571
- console.log(chalk_1.default.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
582
+ console.log(chalk.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
572
583
  }
573
584
  }
574
585
  }
575
586
  else {
576
- console.log(chalk_1.default.gray(' - Skipped transport tests (authentication required)'));
587
+ console.log(chalk.gray(' - Skipped transport tests (authentication required)'));
577
588
  }
578
589
  // Step 4: Test current MCP connection
579
- console.log(chalk_1.default.cyan('\n4. Current MCP Connection'));
580
- const client = (0, mcp_client_js_1.getMCPClient)();
590
+ console.log(chalk.cyan('\n4. Current MCP Connection'));
591
+ const client = getMCPClient();
581
592
  diagnostics.currentConnection = client.getConnectionStatus();
582
593
  if (diagnostics.currentConnection.connected) {
583
- console.log(chalk_1.default.green(' āœ“ MCP client is connected'));
584
- console.log(chalk_1.default.gray(` Mode: ${diagnostics.currentConnection.mode}`));
585
- console.log(chalk_1.default.gray(` Server: ${diagnostics.currentConnection.server}`));
594
+ console.log(chalk.green(' āœ“ MCP client is connected'));
595
+ console.log(chalk.gray(` Mode: ${diagnostics.currentConnection.mode}`));
596
+ console.log(chalk.gray(` Server: ${diagnostics.currentConnection.server}`));
586
597
  if (diagnostics.currentConnection.connectionUptime) {
587
598
  const uptimeSeconds = Math.floor(diagnostics.currentConnection.connectionUptime / 1000);
588
- console.log(chalk_1.default.gray(` Uptime: ${uptimeSeconds}s`));
599
+ console.log(chalk.gray(` Uptime: ${uptimeSeconds}s`));
589
600
  }
590
601
  if (diagnostics.currentConnection.lastHealthCheck) {
591
602
  const healthCheckAge = Date.now() - diagnostics.currentConnection.lastHealthCheck.getTime();
592
- console.log(chalk_1.default.gray(` Last health check: ${Math.floor(healthCheckAge / 1000)}s ago`));
603
+ console.log(chalk.gray(` Last health check: ${Math.floor(healthCheckAge / 1000)}s ago`));
593
604
  }
594
605
  }
595
606
  else {
596
- console.log(chalk_1.default.red(' āœ– MCP client is not connected'));
597
- console.log(chalk_1.default.gray(' → Try: lanonasis mcp connect'));
607
+ console.log(chalk.red(' āœ– MCP client is not connected'));
608
+ console.log(chalk.gray(' → Try: lanonasis mcp connect'));
598
609
  }
599
610
  // Step 5: Test tool availability
600
- console.log(chalk_1.default.cyan('\n5. Tool Availability'));
611
+ console.log(chalk.cyan('\n5. Tool Availability'));
601
612
  if (diagnostics.currentConnection.connected) {
602
- const toolSpinner = (0, ora_1.default)('Testing MCP tools...').start();
613
+ const toolSpinner = ora('Testing MCP tools...').start();
603
614
  try {
604
615
  const tools = await client.listTools();
605
616
  diagnostics.toolsAvailable = tools.length > 0;
606
617
  toolSpinner.succeed(`Found ${tools.length} available tools`);
607
- console.log(chalk_1.default.green(` āœ“ ${tools.length} MCP tools available`));
618
+ console.log(chalk.green(` āœ“ ${tools.length} MCP tools available`));
608
619
  if (options.verbose && tools.length > 0) {
609
- console.log(chalk_1.default.gray(' Available tools:'));
620
+ console.log(chalk.gray(' Available tools:'));
610
621
  tools.slice(0, 5).forEach(tool => {
611
- console.log(chalk_1.default.gray(` • ${tool.name}`));
622
+ console.log(chalk.gray(` • ${tool.name}`));
612
623
  });
613
624
  if (tools.length > 5) {
614
- console.log(chalk_1.default.gray(` ... and ${tools.length - 5} more`));
625
+ console.log(chalk.gray(` ... and ${tools.length - 5} more`));
615
626
  }
616
627
  }
617
628
  }
618
629
  catch (error) {
619
630
  toolSpinner.fail('Tool listing failed');
620
- console.log(chalk_1.default.red(' āœ– Cannot list MCP tools'));
631
+ console.log(chalk.red(' āœ– Cannot list MCP tools'));
621
632
  if (options.verbose) {
622
- console.log(chalk_1.default.gray(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
633
+ console.log(chalk.gray(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
623
634
  }
624
635
  }
625
636
  }
626
637
  else {
627
- console.log(chalk_1.default.gray(' - Skipped (not connected to MCP server)'));
638
+ console.log(chalk.gray(' - Skipped (not connected to MCP server)'));
628
639
  }
629
640
  // Step 6: Connection quality measurement
630
- console.log(chalk_1.default.cyan('\n6. Connection Quality'));
641
+ console.log(chalk.cyan('\n6. Connection Quality'));
631
642
  if (Object.keys(diagnostics.connectionLatency).length > 0) {
632
- console.log(chalk_1.default.green(' āœ“ Latency measurements:'));
643
+ console.log(chalk.green(' āœ“ Latency measurements:'));
633
644
  Object.entries(diagnostics.connectionLatency).forEach(([transport, latency]) => {
634
645
  const quality = latency < 100 ? 'Excellent' : latency < 300 ? 'Good' : latency < 1000 ? 'Fair' : 'Poor';
635
- const color = latency < 100 ? chalk_1.default.green : latency < 300 ? chalk_1.default.yellow : chalk_1.default.red;
646
+ const color = latency < 100 ? chalk.green : latency < 300 ? chalk.yellow : chalk.red;
636
647
  console.log(color(` ${transport.toUpperCase()}: ${latency}ms (${quality})`));
637
648
  });
638
649
  }
639
650
  else {
640
- console.log(chalk_1.default.gray(' - No latency measurements available'));
651
+ console.log(chalk.gray(' - No latency measurements available'));
641
652
  }
642
653
  // Summary and recommendations
643
- console.log(chalk_1.default.blue.bold('\nšŸ“‹ MCP Diagnostic Summary'));
644
- console.log(chalk_1.default.cyan('━'.repeat(50)));
654
+ console.log(chalk.blue.bold('\nšŸ“‹ MCP Diagnostic Summary'));
655
+ console.log(chalk.cyan('━'.repeat(50)));
645
656
  const issues = [];
646
657
  const recommendations = [];
647
658
  if (!diagnostics.authenticationValid) {
@@ -671,30 +682,30 @@ function mcpCommands(program) {
671
682
  }
672
683
  // Show results
673
684
  if (issues.length === 0) {
674
- console.log(chalk_1.default.green('āœ… All MCP connection checks passed!'));
675
- console.log(chalk_1.default.cyan(' Your MCP connection is working correctly.'));
685
+ console.log(chalk.green('āœ… All MCP connection checks passed!'));
686
+ console.log(chalk.cyan(' Your MCP connection is working correctly.'));
676
687
  if (Object.keys(diagnostics.connectionLatency).length > 0) {
677
688
  const avgLatency = Object.values(diagnostics.connectionLatency).reduce((a, b) => a + b, 0) / Object.values(diagnostics.connectionLatency).length;
678
- console.log(chalk_1.default.cyan(` Average latency: ${Math.round(avgLatency)}ms`));
689
+ console.log(chalk.cyan(` Average latency: ${Math.round(avgLatency)}ms`));
679
690
  }
680
691
  }
681
692
  else {
682
- console.log(chalk_1.default.red(`āŒ Found ${issues.length} issue(s):`));
693
+ console.log(chalk.red(`āŒ Found ${issues.length} issue(s):`));
683
694
  issues.forEach(issue => {
684
- console.log(chalk_1.default.red(` • ${issue}`));
695
+ console.log(chalk.red(` • ${issue}`));
685
696
  });
686
- console.log(chalk_1.default.yellow('\nšŸ’” Recommended actions:'));
697
+ console.log(chalk.yellow('\nšŸ’” Recommended actions:'));
687
698
  recommendations.forEach(rec => {
688
- console.log(chalk_1.default.cyan(` • ${rec}`));
699
+ console.log(chalk.cyan(` • ${rec}`));
689
700
  });
690
701
  }
691
702
  // Additional troubleshooting info
692
703
  if (issues.length > 0) {
693
- console.log(chalk_1.default.gray('\nšŸ”§ Additional troubleshooting:'));
694
- console.log(chalk_1.default.gray(' • Try different connection modes: --mode websocket|remote|local'));
695
- console.log(chalk_1.default.gray(' • Check firewall settings for ports 80, 443, and WebSocket'));
696
- console.log(chalk_1.default.gray(' • Verify your network allows outbound HTTPS connections'));
697
- console.log(chalk_1.default.gray(' • Contact support if issues persist'));
704
+ console.log(chalk.gray('\nšŸ”§ Additional troubleshooting:'));
705
+ console.log(chalk.gray(' • Try different connection modes: --mode websocket|remote|local'));
706
+ console.log(chalk.gray(' • Check firewall settings for ports 80, 443, and WebSocket'));
707
+ console.log(chalk.gray(' • Verify your network allows outbound HTTPS connections'));
708
+ console.log(chalk.gray(' • Contact support if issues persist'));
698
709
  }
699
710
  });
700
711
  }