@lanonasis/cli 3.6.4 → 3.6.5

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 (41) hide show
  1. package/dist/commands/api-keys.d.ts +1 -2
  2. package/dist/commands/api-keys.js +78 -73
  3. package/dist/commands/auth.js +167 -160
  4. package/dist/commands/completion.js +39 -31
  5. package/dist/commands/config.js +201 -162
  6. package/dist/commands/enhanced-memory.js +17 -11
  7. package/dist/commands/guide.js +88 -79
  8. package/dist/commands/init.js +20 -14
  9. package/dist/commands/mcp.js +173 -142
  10. package/dist/commands/memory.js +83 -77
  11. package/dist/commands/organization.js +21 -15
  12. package/dist/commands/topics.js +58 -52
  13. package/dist/core/achievements.js +26 -19
  14. package/dist/core/architecture.js +59 -42
  15. package/dist/core/dashboard.js +81 -71
  16. package/dist/core/error-handler.js +39 -30
  17. package/dist/core/power-mode.js +53 -46
  18. package/dist/core/progress.js +44 -35
  19. package/dist/core/welcome.js +64 -56
  20. package/dist/enhanced-cli.js +58 -49
  21. package/dist/index-simple.js +112 -74
  22. package/dist/index.js +68 -63
  23. package/dist/mcp/access-control.js +17 -13
  24. package/dist/mcp/client/enhanced-client.js +23 -16
  25. package/dist/mcp/enhanced-server.js +14 -10
  26. package/dist/mcp/logger.js +6 -2
  27. package/dist/mcp/memory-state.js +17 -13
  28. package/dist/mcp/schemas/tool-schemas.d.ts +28 -28
  29. package/dist/mcp/schemas/tool-schemas.js +126 -122
  30. package/dist/mcp/server/lanonasis-server.js +51 -44
  31. package/dist/mcp/transports/transport-manager.js +25 -18
  32. package/dist/mcp/vector-store.js +10 -6
  33. package/dist/mcp-server.js +21 -17
  34. package/dist/utils/api.js +30 -21
  35. package/dist/utils/config.js +59 -13
  36. package/dist/utils/formatting.js +14 -6
  37. package/dist/utils/mcp-client.js +132 -77
  38. package/package.json +17 -93
  39. package/dist/completions/bash-completion.sh +0 -88
  40. package/dist/completions/fish-completion.fish +0 -132
  41. package/dist/completions/zsh-completion.zsh +0 -196
@@ -1,22 +1,29 @@
1
- import chalk from 'chalk';
2
- import inquirer from 'inquirer';
3
- import ora from 'ora';
4
- import open from 'open';
5
- import crypto from 'crypto';
6
- import http from 'http';
7
- import url from 'url';
8
- import { apiClient } from '../utils/api.js';
9
- import { CLIConfig } from '../utils/config.js';
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.diagnoseCommand = diagnoseCommand;
7
+ exports.loginCommand = loginCommand;
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const inquirer_1 = __importDefault(require("inquirer"));
10
+ const ora_1 = __importDefault(require("ora"));
11
+ const open_1 = __importDefault(require("open"));
12
+ const crypto_1 = __importDefault(require("crypto"));
13
+ const http_1 = __importDefault(require("http"));
14
+ const url_1 = __importDefault(require("url"));
15
+ const api_js_1 = require("../utils/api.js");
16
+ const config_js_1 = require("../utils/config.js");
10
17
  // Color scheme
11
18
  const colors = {
12
- primary: chalk.blue.bold,
13
- success: chalk.green,
14
- warning: chalk.yellow,
15
- error: chalk.red,
16
- info: chalk.cyan,
17
- accent: chalk.magenta,
18
- muted: chalk.gray,
19
- highlight: chalk.white.bold
19
+ primary: chalk_1.default.blue.bold,
20
+ success: chalk_1.default.green,
21
+ warning: chalk_1.default.yellow,
22
+ error: chalk_1.default.red,
23
+ info: chalk_1.default.cyan,
24
+ accent: chalk_1.default.magenta,
25
+ muted: chalk_1.default.gray,
26
+ highlight: chalk_1.default.white.bold
20
27
  };
21
28
  // Helper function to handle authentication delays
22
29
  async function handleAuthDelay(config) {
@@ -25,15 +32,15 @@ async function handleAuthDelay(config) {
25
32
  const failureCount = config.getFailureCount();
26
33
  const lastFailure = config.getLastAuthFailure();
27
34
  console.log();
28
- console.log(chalk.yellow(`⚠️ Multiple authentication failures detected (${failureCount} attempts)`));
35
+ console.log(chalk_1.default.yellow(`⚠️ Multiple authentication failures detected (${failureCount} attempts)`));
29
36
  if (lastFailure) {
30
37
  const lastFailureDate = new Date(lastFailure);
31
- console.log(chalk.gray(`Last failure: ${lastFailureDate.toLocaleString()}`));
38
+ console.log(chalk_1.default.gray(`Last failure: ${lastFailureDate.toLocaleString()}`));
32
39
  }
33
- console.log(chalk.yellow(`Waiting ${Math.round(delayMs / 1000)} seconds before retry...`));
34
- console.log(chalk.gray('This delay helps prevent account lockouts and reduces server load.'));
40
+ console.log(chalk_1.default.yellow(`Waiting ${Math.round(delayMs / 1000)} seconds before retry...`));
41
+ console.log(chalk_1.default.gray('This delay helps prevent account lockouts and reduces server load.'));
35
42
  // Show countdown
36
- const spinner = ora(`Waiting ${Math.round(delayMs / 1000)} seconds...`).start();
43
+ const spinner = (0, ora_1.default)(`Waiting ${Math.round(delayMs / 1000)} seconds...`).start();
37
44
  await new Promise(resolve => setTimeout(resolve, delayMs));
38
45
  spinner.succeed('Ready to retry authentication');
39
46
  console.log();
@@ -47,70 +54,70 @@ async function handleAuthenticationFailure(error, config, authMethod = 'jwt') {
47
54
  // Determine error type and provide specific guidance
48
55
  const errorType = categorizeAuthError(error);
49
56
  console.log();
50
- console.log(chalk.red('✖ Authentication failed'));
57
+ console.log(chalk_1.default.red('✖ Authentication failed'));
51
58
  switch (errorType) {
52
59
  case 'invalid_credentials':
53
- console.log(chalk.red('Invalid credentials provided'));
60
+ console.log(chalk_1.default.red('Invalid credentials provided'));
54
61
  if (authMethod === 'vendor_key') {
55
- console.log(chalk.gray('• Verify the vendor key matches the value shown in your dashboard'));
56
- console.log(chalk.gray('• Confirm the key is active and has not been revoked'));
57
- console.log(chalk.gray('• Ensure you copied the entire key without extra spaces'));
62
+ console.log(chalk_1.default.gray('• Verify the vendor key matches the value shown in your dashboard'));
63
+ console.log(chalk_1.default.gray('• Confirm the key is active and has not been revoked'));
64
+ console.log(chalk_1.default.gray('• Ensure you copied the entire key without extra spaces'));
58
65
  }
59
66
  else {
60
- console.log(chalk.gray('• Double-check your email and password'));
61
- console.log(chalk.gray('• Passwords are case-sensitive'));
62
- console.log(chalk.gray('• Consider resetting your password if needed'));
67
+ console.log(chalk_1.default.gray('• Double-check your email and password'));
68
+ console.log(chalk_1.default.gray('• Passwords are case-sensitive'));
69
+ console.log(chalk_1.default.gray('• Consider resetting your password if needed'));
63
70
  }
64
71
  break;
65
72
  case 'network_error':
66
- console.log(chalk.red('Network connection failed'));
67
- console.log(chalk.gray('• Check your internet connection'));
68
- console.log(chalk.gray('• Verify you can access https://auth.lanonasis.com'));
69
- console.log(chalk.gray('• Try again in a few moments'));
73
+ console.log(chalk_1.default.red('Network connection failed'));
74
+ console.log(chalk_1.default.gray('• Check your internet connection'));
75
+ console.log(chalk_1.default.gray('• Verify you can access https://auth.lanonasis.com'));
76
+ console.log(chalk_1.default.gray('• Try again in a few moments'));
70
77
  if (failureCount >= 2) {
71
- console.log(chalk.gray('• Consider using a different network if issues persist'));
78
+ console.log(chalk_1.default.gray('• Consider using a different network if issues persist'));
72
79
  }
73
80
  break;
74
81
  case 'server_error':
75
- console.log(chalk.red('Server temporarily unavailable'));
76
- console.log(chalk.gray('• The authentication service may be experiencing issues'));
77
- console.log(chalk.gray('• Please try again in a few minutes'));
78
- console.log(chalk.gray('• Check https://status.lanonasis.com for service status'));
82
+ console.log(chalk_1.default.red('Server temporarily unavailable'));
83
+ console.log(chalk_1.default.gray('• The authentication service may be experiencing issues'));
84
+ console.log(chalk_1.default.gray('• Please try again in a few minutes'));
85
+ console.log(chalk_1.default.gray('• Check https://status.lanonasis.com for service status'));
79
86
  break;
80
87
  case 'rate_limited':
81
- console.log(chalk.red('Too many authentication attempts'));
82
- console.log(chalk.gray('• Please wait before trying again'));
83
- console.log(chalk.gray('• Rate limiting helps protect your account'));
84
- console.log(chalk.gray('• Consider using a vendor key for automated access'));
88
+ console.log(chalk_1.default.red('Too many authentication attempts'));
89
+ console.log(chalk_1.default.gray('• Please wait before trying again'));
90
+ console.log(chalk_1.default.gray('• Rate limiting helps protect your account'));
91
+ console.log(chalk_1.default.gray('• Consider using a vendor key for automated access'));
85
92
  break;
86
93
  case 'expired_token':
87
- console.log(chalk.red('Authentication token has expired'));
88
- console.log(chalk.gray('• Please log in again to refresh your session'));
89
- console.log(chalk.gray('• Consider using a vendor key for longer-term access'));
94
+ console.log(chalk_1.default.red('Authentication token has expired'));
95
+ console.log(chalk_1.default.gray('• Please log in again to refresh your session'));
96
+ console.log(chalk_1.default.gray('• Consider using a vendor key for longer-term access'));
90
97
  await config.clearInvalidCredentials();
91
98
  break;
92
99
  default:
93
- console.log(chalk.red(`Unexpected error: ${error.message || 'Unknown error'}`));
94
- console.log(chalk.gray('• Please try again'));
95
- console.log(chalk.gray('• If the problem persists, contact support'));
100
+ console.log(chalk_1.default.red(`Unexpected error: ${error.message || 'Unknown error'}`));
101
+ console.log(chalk_1.default.gray('• Please try again'));
102
+ console.log(chalk_1.default.gray('• If the problem persists, contact support'));
96
103
  }
97
104
  // Progressive guidance for repeated failures
98
105
  if (failureCount >= 3) {
99
106
  console.log();
100
- console.log(chalk.yellow('💡 Multiple failures detected. Recovery options:'));
107
+ console.log(chalk_1.default.yellow('💡 Multiple failures detected. Recovery options:'));
101
108
  if (authMethod === 'vendor_key') {
102
- console.log(chalk.cyan('• Generate a new vendor key from your dashboard'));
103
- console.log(chalk.cyan('• Try: lanonasis auth logout && lanonasis auth login'));
104
- console.log(chalk.cyan('• Switch to browser login: lanonasis auth login (choose Browser Login)'));
109
+ console.log(chalk_1.default.cyan('• Generate a new vendor key from your dashboard'));
110
+ console.log(chalk_1.default.cyan('• Try: lanonasis auth logout && lanonasis auth login'));
111
+ console.log(chalk_1.default.cyan('• Switch to browser login: lanonasis auth login (choose Browser Login)'));
105
112
  }
106
113
  else {
107
- console.log(chalk.cyan('• Reset your password if you\'re unsure'));
108
- console.log(chalk.cyan('• Try vendor key authentication instead'));
109
- console.log(chalk.cyan('• Clear stored config: lanonasis auth logout'));
114
+ console.log(chalk_1.default.cyan('• Reset your password if you\'re unsure'));
115
+ console.log(chalk_1.default.cyan('• Try vendor key authentication instead'));
116
+ console.log(chalk_1.default.cyan('• Clear stored config: lanonasis auth logout'));
110
117
  }
111
118
  if (failureCount >= 5) {
112
- console.log(chalk.yellow('• Consider contacting support if issues persist'));
113
- console.log(chalk.gray('• Include error details and your email address'));
119
+ console.log(chalk_1.default.yellow('• Consider contacting support if issues persist'));
120
+ console.log(chalk_1.default.gray('• Include error details and your email address'));
114
121
  }
115
122
  }
116
123
  }
@@ -174,9 +181,9 @@ function categorizeAuthError(error) {
174
181
  */
175
182
  function generatePKCE() {
176
183
  // Generate random verifier (43-128 chars, base64url)
177
- const verifier = crypto.randomBytes(32).toString('base64url');
184
+ const verifier = crypto_1.default.randomBytes(32).toString('base64url');
178
185
  // Generate challenge: base64url(sha256(verifier))
179
- const challenge = crypto
186
+ const challenge = crypto_1.default
180
187
  .createHash('sha256')
181
188
  .update(verifier)
182
189
  .digest('base64url');
@@ -187,8 +194,8 @@ function generatePKCE() {
187
194
  */
188
195
  function createCallbackServer(port = 8888) {
189
196
  return new Promise((resolve, reject) => {
190
- const server = http.createServer((req, res) => {
191
- const parsedUrl = url.parse(req.url, true);
197
+ const server = http_1.default.createServer((req, res) => {
198
+ const parsedUrl = url_1.default.parse(req.url, true);
192
199
  if (parsedUrl.pathname === '/callback') {
193
200
  const { code, state, error, error_description } = parsedUrl.query;
194
201
  // Send response to browser
@@ -230,7 +237,7 @@ function createCallbackServer(port = 8888) {
230
237
  }
231
238
  });
232
239
  server.listen(port, () => {
233
- console.log(chalk.gray(` Local callback server listening on port ${port}`));
240
+ console.log(chalk_1.default.gray(` Local callback server listening on port ${port}`));
234
241
  });
235
242
  // Timeout after 5 minutes
236
243
  setTimeout(() => {
@@ -244,7 +251,7 @@ function createCallbackServer(port = 8888) {
244
251
  */
245
252
  async function exchangeCodeForTokens(code, verifier, authBase) {
246
253
  const tokenEndpoint = `${authBase}/oauth/token`;
247
- const response = await apiClient.post(tokenEndpoint, {
254
+ const response = await api_js_1.apiClient.post(tokenEndpoint, {
248
255
  grant_type: 'authorization_code',
249
256
  code,
250
257
  code_verifier: verifier,
@@ -263,7 +270,7 @@ async function refreshOAuth2Token(config) {
263
270
  }
264
271
  try {
265
272
  const authBase = config.getDiscoveredApiUrl();
266
- const response = await apiClient.post(`${authBase}/oauth/token`, {
273
+ const response = await api_js_1.apiClient.post(`${authBase}/oauth/token`, {
267
274
  grant_type: 'refresh_token',
268
275
  refresh_token: refreshToken,
269
276
  client_id: 'lanonasis-cli'
@@ -276,14 +283,14 @@ async function refreshOAuth2Token(config) {
276
283
  return true;
277
284
  }
278
285
  catch (error) {
279
- console.error(chalk.yellow('⚠️ Token refresh failed, please re-authenticate'));
286
+ console.error(chalk_1.default.yellow('⚠️ Token refresh failed, please re-authenticate'));
280
287
  return false;
281
288
  }
282
289
  }
283
- export async function diagnoseCommand() {
284
- const config = new CLIConfig();
290
+ async function diagnoseCommand() {
291
+ const config = new config_js_1.CLIConfig();
285
292
  await config.init();
286
- console.log(chalk.blue.bold('🔍 Authentication Diagnostic'));
293
+ console.log(chalk_1.default.blue.bold('🔍 Authentication Diagnostic'));
287
294
  console.log(colors.info('━'.repeat(50)));
288
295
  console.log();
289
296
  const diagnostics = {
@@ -299,146 +306,146 @@ export async function diagnoseCommand() {
299
306
  deviceId: null
300
307
  };
301
308
  // Step 1: Check if config exists
302
- console.log(chalk.cyan('1. Configuration File'));
309
+ console.log(chalk_1.default.cyan('1. Configuration File'));
303
310
  try {
304
311
  const configExists = await config.exists();
305
312
  diagnostics.configExists = configExists;
306
313
  if (configExists) {
307
- console.log(chalk.green(' ✓ Config file exists at'), config.getConfigPath());
314
+ console.log(chalk_1.default.green(' ✓ Config file exists at'), config.getConfigPath());
308
315
  }
309
316
  else {
310
- console.log(chalk.red(' ✖ Config file not found at'), config.getConfigPath());
311
- console.log(chalk.gray(' → Run: lanonasis auth login'));
317
+ console.log(chalk_1.default.red(' ✖ Config file not found at'), config.getConfigPath());
318
+ console.log(chalk_1.default.gray(' → Run: lanonasis auth login'));
312
319
  }
313
320
  }
314
321
  catch (error) {
315
- console.log(chalk.red(' ✖ Error checking config:'), error instanceof Error ? error.message : 'Unknown error');
322
+ console.log(chalk_1.default.red(' ✖ Error checking config:'), error instanceof Error ? error.message : 'Unknown error');
316
323
  }
317
324
  // Step 2: Check stored credentials
318
- console.log(chalk.cyan('\n2. Stored Credentials'));
325
+ console.log(chalk_1.default.cyan('\n2. Stored Credentials'));
319
326
  const token = config.getToken();
320
327
  const vendorKey = config.getVendorKey();
321
328
  const authMethod = config.get('authMethod');
322
329
  if (vendorKey) {
323
330
  diagnostics.hasCredentials = true;
324
331
  diagnostics.credentialType = 'vendor_key';
325
- console.log(chalk.green(' ✓ Vendor key found'));
332
+ console.log(chalk_1.default.green(' ✓ Vendor key found'));
326
333
  // Validate vendor key presence
327
334
  const formatValidation = config.validateVendorKeyFormat(vendorKey);
328
335
  if (formatValidation !== true) {
329
- console.log(chalk.red(` ✖ Vendor key issue: ${formatValidation}`));
336
+ console.log(chalk_1.default.red(` ✖ Vendor key issue: ${formatValidation}`));
330
337
  }
331
338
  }
332
339
  else if (token) {
333
340
  diagnostics.hasCredentials = true;
334
341
  diagnostics.credentialType = authMethod === 'oauth' ? 'oauth' : 'jwt';
335
- console.log(chalk.green(` ✓ ${diagnostics.credentialType.toUpperCase()} token found`));
342
+ console.log(chalk_1.default.green(` ✓ ${diagnostics.credentialType.toUpperCase()} token found`));
336
343
  // Check token expiry
337
344
  try {
338
345
  const isAuth = await config.isAuthenticated();
339
346
  if (!isAuth) {
340
347
  diagnostics.tokenExpired = true;
341
- console.log(chalk.red(' ✖ Token is expired'));
348
+ console.log(chalk_1.default.red(' ✖ Token is expired'));
342
349
  }
343
350
  else {
344
- console.log(chalk.green(' ✓ Token is not expired'));
351
+ console.log(chalk_1.default.green(' ✓ Token is not expired'));
345
352
  }
346
353
  }
347
354
  catch (error) {
348
- console.log(chalk.yellow(' ⚠ Could not validate token expiry'));
355
+ console.log(chalk_1.default.yellow(' ⚠ Could not validate token expiry'));
349
356
  if (process.env.CLI_VERBOSE === 'true' && error instanceof Error) {
350
- console.log(chalk.gray(` ${error.message}`));
357
+ console.log(chalk_1.default.gray(` ${error.message}`));
351
358
  }
352
359
  }
353
360
  }
354
361
  else {
355
- console.log(chalk.red(' ✖ No credentials found'));
356
- console.log(chalk.gray(' → Run: lanonasis auth login'));
362
+ console.log(chalk_1.default.red(' ✖ No credentials found'));
363
+ console.log(chalk_1.default.gray(' → Run: lanonasis auth login'));
357
364
  }
358
365
  // Step 3: Check authentication failures
359
- console.log(chalk.cyan('\n3. Authentication History'));
366
+ console.log(chalk_1.default.cyan('\n3. Authentication History'));
360
367
  diagnostics.authFailures = config.getFailureCount();
361
368
  diagnostics.lastFailure = config.getLastAuthFailure() ?? null;
362
369
  if (diagnostics.authFailures === 0) {
363
- console.log(chalk.green(' ✓ No recent authentication failures'));
370
+ console.log(chalk_1.default.green(' ✓ No recent authentication failures'));
364
371
  }
365
372
  else {
366
- console.log(chalk.yellow(` ⚠ ${diagnostics.authFailures} recent authentication failures`));
373
+ console.log(chalk_1.default.yellow(` ⚠ ${diagnostics.authFailures} recent authentication failures`));
367
374
  if (diagnostics.lastFailure) {
368
375
  const lastFailureDate = new Date(diagnostics.lastFailure);
369
- console.log(chalk.gray(` Last failure: ${lastFailureDate.toLocaleString()}`));
376
+ console.log(chalk_1.default.gray(` Last failure: ${lastFailureDate.toLocaleString()}`));
370
377
  }
371
378
  if (config.shouldDelayAuth()) {
372
379
  const delayMs = config.getAuthDelayMs();
373
- console.log(chalk.yellow(` ⚠ Authentication delay active: ${Math.round(delayMs / 1000)}s`));
380
+ console.log(chalk_1.default.yellow(` ⚠ Authentication delay active: ${Math.round(delayMs / 1000)}s`));
374
381
  }
375
382
  }
376
383
  // Step 4: Test credential validation against server
377
- console.log(chalk.cyan('\n4. Server Validation'));
384
+ console.log(chalk_1.default.cyan('\n4. Server Validation'));
378
385
  if (diagnostics.hasCredentials) {
379
- const spinner = ora('Testing credentials against server...').start();
386
+ const spinner = (0, ora_1.default)('Testing credentials against server...').start();
380
387
  try {
381
388
  const isValid = await config.validateStoredCredentials();
382
389
  diagnostics.credentialsValid = isValid;
383
390
  if (isValid) {
384
391
  spinner.succeed('Credentials are valid');
385
- console.log(chalk.green(' ✓ Server authentication successful'));
392
+ console.log(chalk_1.default.green(' ✓ Server authentication successful'));
386
393
  }
387
394
  else {
388
395
  spinner.fail('Credentials are invalid');
389
- console.log(chalk.red(' ✖ Server rejected credentials'));
390
- console.log(chalk.gray(' → Try: lanonasis auth login'));
396
+ console.log(chalk_1.default.red(' ✖ Server rejected credentials'));
397
+ console.log(chalk_1.default.gray(' → Try: lanonasis auth login'));
391
398
  }
392
399
  }
393
400
  catch (error) {
394
401
  spinner.fail('Server validation failed');
395
- console.log(chalk.red(' ✖ Could not validate with server:'));
396
- console.log(chalk.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
402
+ console.log(chalk_1.default.red(' ✖ Could not validate with server:'));
403
+ console.log(chalk_1.default.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
397
404
  }
398
405
  }
399
406
  else {
400
- console.log(chalk.gray(' - Skipped (no credentials to validate)'));
407
+ console.log(chalk_1.default.gray(' - Skipped (no credentials to validate)'));
401
408
  }
402
409
  // Step 5: Test endpoint connectivity
403
- console.log(chalk.cyan('\n5. Endpoint Connectivity'));
404
- const spinner2 = ora('Testing authentication endpoints...').start();
410
+ console.log(chalk_1.default.cyan('\n5. Endpoint Connectivity'));
411
+ const spinner2 = (0, ora_1.default)('Testing authentication endpoints...').start();
405
412
  try {
406
413
  await config.discoverServices();
407
414
  diagnostics.serviceDiscovery = true;
408
415
  const services = config.get('discoveredServices');
409
416
  if (services) {
410
417
  spinner2.succeed('Authentication endpoints reachable');
411
- console.log(chalk.green(' ✓ Service discovery successful'));
412
- console.log(chalk.gray(` Auth endpoint: ${services.auth_base}`));
418
+ console.log(chalk_1.default.green(' ✓ Service discovery successful'));
419
+ console.log(chalk_1.default.gray(` Auth endpoint: ${services.auth_base}`));
413
420
  diagnostics.endpointsReachable = true;
414
421
  }
415
422
  else {
416
423
  spinner2.warn('Using fallback endpoints');
417
- console.log(chalk.yellow(' ⚠ Service discovery failed, using fallbacks'));
424
+ console.log(chalk_1.default.yellow(' ⚠ Service discovery failed, using fallbacks'));
418
425
  diagnostics.endpointsReachable = true; // Fallbacks still work
419
426
  }
420
427
  }
421
428
  catch (error) {
422
429
  spinner2.fail('Endpoint connectivity failed');
423
- console.log(chalk.red(' ✖ Cannot reach authentication endpoints'));
424
- console.log(chalk.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
425
- console.log(chalk.gray(' → Check internet connection'));
430
+ console.log(chalk_1.default.red(' ✖ Cannot reach authentication endpoints'));
431
+ console.log(chalk_1.default.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
432
+ console.log(chalk_1.default.gray(' → Check internet connection'));
426
433
  }
427
434
  // Step 6: Device identification
428
- console.log(chalk.cyan('\n6. Device Information'));
435
+ console.log(chalk_1.default.cyan('\n6. Device Information'));
429
436
  try {
430
437
  const deviceId = await config.getDeviceId();
431
438
  diagnostics.deviceId = deviceId;
432
- console.log(chalk.green(' ✓ Device ID:'), chalk.gray(deviceId));
439
+ console.log(chalk_1.default.green(' ✓ Device ID:'), chalk_1.default.gray(deviceId));
433
440
  }
434
441
  catch (error) {
435
- console.log(chalk.yellow(' ⚠ Could not get device ID'));
442
+ console.log(chalk_1.default.yellow(' ⚠ Could not get device ID'));
436
443
  if (process.env.CLI_VERBOSE === 'true' && error instanceof Error) {
437
- console.log(chalk.gray(` ${error.message}`));
444
+ console.log(chalk_1.default.gray(` ${error.message}`));
438
445
  }
439
446
  }
440
447
  // Summary and recommendations
441
- console.log(chalk.blue.bold('\n📋 Diagnostic Summary'));
448
+ console.log(chalk_1.default.blue.bold('\n📋 Diagnostic Summary'));
442
449
  console.log(colors.info('━'.repeat(50)));
443
450
  const issues = [];
444
451
  const recommendations = [];
@@ -467,32 +474,32 @@ export async function diagnoseCommand() {
467
474
  recommendations.push('Check internet connection and firewall settings');
468
475
  }
469
476
  if (issues.length === 0) {
470
- console.log(chalk.green('✅ All authentication checks passed!'));
471
- console.log(chalk.cyan(' Your authentication is working correctly.'));
477
+ console.log(chalk_1.default.green('✅ All authentication checks passed!'));
478
+ console.log(chalk_1.default.cyan(' Your authentication is working correctly.'));
472
479
  }
473
480
  else {
474
- console.log(chalk.red(`❌ Found ${issues.length} issue(s):`));
481
+ console.log(chalk_1.default.red(`❌ Found ${issues.length} issue(s):`));
475
482
  issues.forEach(issue => {
476
- console.log(chalk.red(` • ${issue}`));
483
+ console.log(chalk_1.default.red(` • ${issue}`));
477
484
  });
478
- console.log(chalk.yellow('\n💡 Recommended actions:'));
485
+ console.log(chalk_1.default.yellow('\n💡 Recommended actions:'));
479
486
  recommendations.forEach(rec => {
480
- console.log(chalk.cyan(` • ${rec}`));
487
+ console.log(chalk_1.default.cyan(` • ${rec}`));
481
488
  });
482
489
  }
483
490
  // Additional troubleshooting info
484
491
  if (diagnostics.authFailures > 0 || !diagnostics.credentialsValid) {
485
- console.log(chalk.gray('\n🔧 Additional troubleshooting:'));
486
- console.log(chalk.gray(' • Verify the vendor key matches the value shown in your dashboard'));
487
- console.log(chalk.gray(' • Check if your key is active in the dashboard'));
488
- console.log(chalk.gray(' • Try browser authentication: lanonasis auth login (choose Browser Login)'));
489
- console.log(chalk.gray(' • Contact support if issues persist'));
492
+ console.log(chalk_1.default.gray('\n🔧 Additional troubleshooting:'));
493
+ console.log(chalk_1.default.gray(' • Verify the vendor key matches the value shown in your dashboard'));
494
+ console.log(chalk_1.default.gray(' • Check if your key is active in the dashboard'));
495
+ console.log(chalk_1.default.gray(' • Try browser authentication: lanonasis auth login (choose Browser Login)'));
496
+ console.log(chalk_1.default.gray(' • Contact support if issues persist'));
490
497
  }
491
498
  }
492
- export async function loginCommand(options) {
493
- const config = new CLIConfig();
499
+ async function loginCommand(options) {
500
+ const config = new config_js_1.CLIConfig();
494
501
  await config.init();
495
- console.log(chalk.blue.bold('🔐 Onasis-Core Golden Contract Authentication'));
502
+ console.log(chalk_1.default.blue.bold('🔐 Onasis-Core Golden Contract Authentication'));
496
503
  console.log(colors.info('━'.repeat(50)));
497
504
  console.log();
498
505
  // Debug: Check options
@@ -514,7 +521,7 @@ export async function loginCommand(options) {
514
521
  return;
515
522
  }
516
523
  // Show authentication options
517
- const authChoice = await inquirer.prompt([
524
+ const authChoice = await inquirer_1.default.prompt([
518
525
  {
519
526
  type: 'list',
520
527
  name: 'method',
@@ -550,14 +557,14 @@ export async function loginCommand(options) {
550
557
  async function handleVendorKeyAuth(vendorKey, config) {
551
558
  // Check for authentication delay before attempting
552
559
  await handleAuthDelay(config);
553
- const spinner = ora('Validating vendor key...').start();
560
+ const spinner = (0, ora_1.default)('Validating vendor key...').start();
554
561
  try {
555
562
  await config.setVendorKey(vendorKey);
556
563
  // Test the vendor key with a health check
557
- await apiClient.get('/health');
564
+ await api_js_1.apiClient.get('/health');
558
565
  spinner.succeed('Vendor key authentication successful');
559
566
  console.log();
560
- console.log(chalk.green('✓ Authenticated with vendor key'));
567
+ console.log(chalk_1.default.green('✓ Authenticated with vendor key'));
561
568
  console.log(colors.info('Ready to use Onasis-Core services'));
562
569
  }
563
570
  catch (error) {
@@ -569,16 +576,16 @@ async function handleVendorKeyAuth(vendorKey, config) {
569
576
  }
570
577
  async function handleVendorKeyFlow(config) {
571
578
  console.log();
572
- console.log(chalk.yellow('🔑 Vendor Key Authentication'));
573
- console.log(chalk.gray('Vendor keys provide secure API access for automation and integrations.'));
579
+ console.log(chalk_1.default.yellow('🔑 Vendor Key Authentication'));
580
+ console.log(chalk_1.default.gray('Vendor keys provide secure API access for automation and integrations.'));
574
581
  console.log();
575
582
  // Enhanced guidance for obtaining vendor keys
576
- console.log(chalk.cyan('📋 How to get your vendor key:'));
577
- console.log(chalk.gray('1. Visit your Lanonasis dashboard at https://dashboard.lanonasis.com'));
578
- console.log(chalk.gray('2. Navigate to Settings → API Keys'));
579
- console.log(chalk.gray('3. Click "Generate New Key" and copy the full key value'));
583
+ console.log(chalk_1.default.cyan('📋 How to get your vendor key:'));
584
+ console.log(chalk_1.default.gray('1. Visit your Lanonasis dashboard at https://dashboard.lanonasis.com'));
585
+ console.log(chalk_1.default.gray('2. Navigate to Settings → API Keys'));
586
+ console.log(chalk_1.default.gray('3. Click "Generate New Key" and copy the full key value'));
580
587
  console.log();
581
- const { vendorKey } = await inquirer.prompt([
588
+ const { vendorKey } = await inquirer_1.default.prompt([
582
589
  {
583
590
  type: 'password',
584
591
  name: 'vendorKey',
@@ -593,10 +600,10 @@ async function handleVendorKeyFlow(config) {
593
600
  }
594
601
  async function handleOAuthFlow(config) {
595
602
  console.log();
596
- console.log(chalk.yellow('🌐 Browser-Based OAuth2 Authentication'));
597
- console.log(chalk.gray('Secure authentication using OAuth2 with PKCE'));
603
+ console.log(chalk_1.default.yellow('🌐 Browser-Based OAuth2 Authentication'));
604
+ console.log(chalk_1.default.gray('Secure authentication using OAuth2 with PKCE'));
598
605
  console.log();
599
- const { openBrowser } = await inquirer.prompt([
606
+ const { openBrowser } = await inquirer_1.default.prompt([
600
607
  {
601
608
  type: 'confirm',
602
609
  name: 'openBrowser',
@@ -605,17 +612,17 @@ async function handleOAuthFlow(config) {
605
612
  }
606
613
  ]);
607
614
  if (!openBrowser) {
608
- console.log(chalk.yellow('⚠️ Authentication cancelled'));
615
+ console.log(chalk_1.default.yellow('⚠️ Authentication cancelled'));
609
616
  return;
610
617
  }
611
618
  try {
612
619
  // Generate PKCE challenge
613
620
  const pkce = generatePKCE();
614
- console.log(chalk.gray(' ✓ Generated PKCE challenge'));
621
+ console.log(chalk_1.default.gray(' ✓ Generated PKCE challenge'));
615
622
  // Start local callback server
616
623
  const callbackPort = 8888;
617
624
  const callbackPromise = createCallbackServer(callbackPort);
618
- console.log(chalk.gray(` ✓ Started local callback server on port ${callbackPort}`));
625
+ console.log(chalk_1.default.gray(` ✓ Started local callback server on port ${callbackPort}`));
619
626
  // Build OAuth2 authorization URL
620
627
  const authBase = config.getDiscoveredApiUrl();
621
628
  const authUrl = new URL(`${authBase}/oauth/authorize`);
@@ -625,15 +632,15 @@ async function handleOAuthFlow(config) {
625
632
  authUrl.searchParams.set('scope', 'read write offline_access');
626
633
  authUrl.searchParams.set('code_challenge', pkce.challenge);
627
634
  authUrl.searchParams.set('code_challenge_method', 'S256');
628
- authUrl.searchParams.set('state', crypto.randomBytes(16).toString('hex'));
635
+ authUrl.searchParams.set('state', crypto_1.default.randomBytes(16).toString('hex'));
629
636
  console.log();
630
637
  console.log(colors.info('Opening browser for authentication...'));
631
- await open(authUrl.toString());
638
+ await (0, open_1.default)(authUrl.toString());
632
639
  console.log(colors.info('Waiting for authentication in browser...'));
633
640
  console.log(colors.muted(`If browser doesn't open, visit: ${authUrl.toString()}`));
634
641
  console.log();
635
642
  // Wait for callback
636
- const spinner = ora('Waiting for authorization...').start();
643
+ const spinner = (0, ora_1.default)('Waiting for authorization...').start();
637
644
  const { code } = await callbackPromise;
638
645
  spinner.succeed('Authorization code received');
639
646
  // Exchange code for tokens
@@ -647,27 +654,27 @@ async function handleOAuthFlow(config) {
647
654
  await config.set('token_expires_at', Date.now() + (tokens.expires_in * 1000));
648
655
  await config.set('authMethod', 'oauth2');
649
656
  console.log();
650
- console.log(chalk.green('✓ OAuth2 authentication successful'));
657
+ console.log(chalk_1.default.green('✓ OAuth2 authentication successful'));
651
658
  console.log(colors.info('You can now use Lanonasis services'));
652
659
  process.exit(0);
653
660
  }
654
661
  catch (error) {
655
- console.error(chalk.red('✖ OAuth2 authentication failed'));
662
+ console.error(chalk_1.default.red('✖ OAuth2 authentication failed'));
656
663
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
657
- console.error(chalk.gray(` ${errorMessage}`));
664
+ console.error(chalk_1.default.gray(` ${errorMessage}`));
658
665
  process.exit(1);
659
666
  }
660
667
  }
661
668
  async function handleCredentialsFlow(options, config) {
662
669
  console.log();
663
- console.log(chalk.yellow('⚙️ Username/Password Authentication'));
670
+ console.log(chalk_1.default.yellow('⚙️ Username/Password Authentication'));
664
671
  console.log();
665
672
  // Check for authentication delay before attempting
666
673
  await handleAuthDelay(config);
667
674
  let { email, password } = options;
668
675
  // Get credentials if not provided
669
676
  if (!email || !password) {
670
- const answers = await inquirer.prompt([
677
+ const answers = await inquirer_1.default.prompt([
671
678
  {
672
679
  type: 'input',
673
680
  name: 'email',
@@ -689,14 +696,14 @@ async function handleCredentialsFlow(options, config) {
689
696
  email = answers.email;
690
697
  password = answers.password;
691
698
  }
692
- const spinner = ora('Authenticating...').start();
699
+ const spinner = (0, ora_1.default)('Authenticating...').start();
693
700
  try {
694
- const response = await apiClient.login(email, password);
701
+ const response = await api_js_1.apiClient.login(email, password);
695
702
  // Store token and user info
696
703
  await config.setToken(response.token);
697
704
  spinner.succeed('Login successful');
698
705
  console.log();
699
- console.log(chalk.green('✓ Authenticated successfully'));
706
+ console.log(chalk_1.default.green('✓ Authenticated successfully'));
700
707
  console.log(`Welcome, ${response.user.email}!`);
701
708
  if (response.user.organization_id) {
702
709
  console.log(`Organization: ${response.user.organization_id}`);
@@ -711,7 +718,7 @@ async function handleCredentialsFlow(options, config) {
711
718
  const errorResponse = error && typeof error === 'object' && 'response' in error ? error.response : null;
712
719
  if (errorResponse && typeof errorResponse === 'object' && 'status' in errorResponse && errorResponse.status === 401) {
713
720
  console.log();
714
- const answer = await inquirer.prompt([
721
+ const answer = await inquirer_1.default.prompt([
715
722
  {
716
723
  type: 'confirm',
717
724
  name: 'register',
@@ -729,9 +736,9 @@ async function handleCredentialsFlow(options, config) {
729
736
  }
730
737
  async function registerFlow(defaultEmail) {
731
738
  console.log();
732
- console.log(chalk.blue.bold('📝 Create New Account'));
739
+ console.log(chalk_1.default.blue.bold('📝 Create New Account'));
733
740
  console.log();
734
- const answers = await inquirer.prompt([
741
+ const answers = await inquirer_1.default.prompt([
735
742
  {
736
743
  type: 'input',
737
744
  name: 'email',
@@ -765,14 +772,14 @@ async function registerFlow(defaultEmail) {
765
772
  default: ''
766
773
  }
767
774
  ]);
768
- const spinner = ora('Creating account...').start();
775
+ const spinner = (0, ora_1.default)('Creating account...').start();
769
776
  try {
770
- const response = await apiClient.register(answers.email, answers.password, answers.organizationName || undefined);
771
- const config = new CLIConfig();
777
+ const response = await api_js_1.apiClient.register(answers.email, answers.password, answers.organizationName || undefined);
778
+ const config = new config_js_1.CLIConfig();
772
779
  await config.setToken(response.token);
773
780
  spinner.succeed('Account created successfully');
774
781
  console.log();
775
- console.log(chalk.green('✓ Account created and authenticated'));
782
+ console.log(chalk_1.default.green('✓ Account created and authenticated'));
776
783
  console.log(`Welcome to MaaS, ${response.user.email}!`);
777
784
  if (answers.organizationName) {
778
785
  console.log(`Organization: ${answers.organizationName}`);
@@ -782,7 +789,7 @@ async function registerFlow(defaultEmail) {
782
789
  catch (error) {
783
790
  spinner.fail('Registration failed');
784
791
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
785
- console.error(chalk.red('✖ Registration failed:'), errorMessage);
792
+ console.error(chalk_1.default.red('✖ Registration failed:'), errorMessage);
786
793
  process.exit(1);
787
794
  }
788
795
  }