@lanonasis/cli 3.6.5 → 3.7.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.
Files changed (43) hide show
  1. package/README.md +19 -2
  2. package/dist/commands/api-keys.d.ts +2 -1
  3. package/dist/commands/api-keys.js +73 -78
  4. package/dist/commands/auth.js +244 -177
  5. package/dist/commands/completion.js +31 -39
  6. package/dist/commands/config.js +162 -201
  7. package/dist/commands/enhanced-memory.js +11 -17
  8. package/dist/commands/guide.js +79 -88
  9. package/dist/commands/init.js +14 -20
  10. package/dist/commands/mcp.d.ts +10 -0
  11. package/dist/commands/mcp.js +215 -156
  12. package/dist/commands/memory.js +77 -83
  13. package/dist/commands/organization.js +15 -21
  14. package/dist/commands/topics.js +52 -58
  15. package/dist/core/achievements.js +19 -26
  16. package/dist/core/architecture.js +42 -59
  17. package/dist/core/dashboard.js +71 -81
  18. package/dist/core/error-handler.js +30 -39
  19. package/dist/core/power-mode.js +46 -53
  20. package/dist/core/progress.js +35 -44
  21. package/dist/core/welcome.js +56 -64
  22. package/dist/enhanced-cli.js +49 -58
  23. package/dist/index-simple.js +75 -113
  24. package/dist/index.js +64 -69
  25. package/dist/mcp/access-control.js +13 -17
  26. package/dist/mcp/client/enhanced-client.js +17 -28
  27. package/dist/mcp/enhanced-server.js +10 -14
  28. package/dist/mcp/logger.js +3 -7
  29. package/dist/mcp/memory-state.js +13 -17
  30. package/dist/mcp/schemas/tool-schemas.d.ts +16 -16
  31. package/dist/mcp/schemas/tool-schemas.js +122 -126
  32. package/dist/mcp/server/lanonasis-server.js +66 -57
  33. package/dist/mcp/transports/transport-manager.js +18 -25
  34. package/dist/mcp/vector-store.js +6 -10
  35. package/dist/mcp-server.js +23 -27
  36. package/dist/utils/api.js +21 -27
  37. package/dist/utils/config.d.ts +2 -1
  38. package/dist/utils/config.js +65 -78
  39. package/dist/utils/formatting.js +6 -14
  40. package/dist/utils/hash-utils.d.ts +23 -0
  41. package/dist/utils/hash-utils.js +37 -0
  42. package/dist/utils/mcp-client.js +76 -117
  43. package/package.json +36 -5
@@ -1,83 +1,45 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- const commander_1 = require("commander");
41
- const chalk_1 = __importDefault(require("chalk"));
42
- const dotenv_1 = require("dotenv");
2
+ import { Command } from 'commander';
3
+ import chalk from 'chalk';
4
+ import { config } from 'dotenv';
43
5
  // Load environment variables silently
44
- (0, dotenv_1.config)({ quiet: true });
45
- const init_js_1 = require("./commands/init.js");
46
- const auth_js_1 = require("./commands/auth.js");
47
- const memory_js_1 = require("./commands/memory.js");
48
- const topics_js_1 = require("./commands/topics.js");
49
- const config_js_1 = require("./commands/config.js");
50
- const organization_js_1 = require("./commands/organization.js");
51
- const mcp_js_1 = require("./commands/mcp.js");
52
- const api_keys_js_1 = __importDefault(require("./commands/api-keys.js"));
53
- const completion_js_1 = require("./commands/completion.js");
54
- const guide_js_1 = require("./commands/guide.js");
55
- const config_js_2 = require("./utils/config.js");
56
- const mcp_client_js_1 = require("./utils/mcp-client.js");
57
- const fs = __importStar(require("fs"));
58
- const path = __importStar(require("path"));
59
- const url_1 = require("url");
60
- const __filename = (0, url_1.fileURLToPath)(import.meta.url);
6
+ config({ quiet: true });
7
+ import { initCommand } from './commands/init.js';
8
+ import { loginCommand } from './commands/auth.js';
9
+ import { memoryCommands } from './commands/memory.js';
10
+ import { topicCommands } from './commands/topics.js';
11
+ import { configCommands } from './commands/config.js';
12
+ import { orgCommands } from './commands/organization.js';
13
+ import { mcpCommands } from './commands/mcp.js';
14
+ import apiKeysCommand from './commands/api-keys.js';
15
+ import { completionCommand, installCompletionsCommand } from './commands/completion.js';
16
+ import { guideCommand, quickStartCommand } from './commands/guide.js';
17
+ import { CLIConfig } from './utils/config.js';
18
+ import { getMCPClient } from './utils/mcp-client.js';
19
+ import * as fs from 'fs';
20
+ import * as path from 'path';
21
+ import { fileURLToPath } from 'url';
22
+ const __filename = fileURLToPath(import.meta.url);
61
23
  const __dirname = path.dirname(__filename);
62
24
  // Load environment variables
63
- (0, dotenv_1.config)();
64
- const module_1 = require("module");
65
- const require = (0, module_1.createRequire)(import.meta.url);
25
+ config();
26
+ import { createRequire } from 'module';
27
+ const require = createRequire(import.meta.url);
66
28
  const packageJson = require('../package.json');
67
29
  // Enhanced color scheme (VPS-style)
68
30
  const colors = {
69
- primary: chalk_1.default.blue.bold,
70
- success: chalk_1.default.green,
71
- warning: chalk_1.default.yellow,
72
- error: chalk_1.default.red,
73
- info: chalk_1.default.cyan,
74
- accent: chalk_1.default.magenta,
75
- muted: chalk_1.default.gray,
76
- highlight: chalk_1.default.white.bold
31
+ primary: chalk.blue.bold,
32
+ success: chalk.green,
33
+ warning: chalk.yellow,
34
+ error: chalk.red,
35
+ info: chalk.cyan,
36
+ accent: chalk.magenta,
37
+ muted: chalk.gray,
38
+ highlight: chalk.white.bold
77
39
  };
78
- const program = new commander_1.Command();
40
+ const program = new Command();
79
41
  // CLI Configuration
80
- const cliConfig = new config_js_2.CLIConfig();
42
+ const cliConfig = new CLIConfig();
81
43
  // Detect which command was used to invoke the CLI
82
44
  const invocationName = process.argv[1] ? path.basename(process.argv[1]) : 'lanonasis';
83
45
  const isOnasisInvocation = invocationName === 'onasis';
@@ -109,7 +71,7 @@ program
109
71
  actionCommand.parent?.name?.() === 'mcp-server';
110
72
  if (opts.mcp !== false && !isMcpFlow && !['init', 'auth', 'login', 'health', 'status'].includes(actionCommand.name())) {
111
73
  try {
112
- const client = (0, mcp_client_js_1.getMCPClient)();
74
+ const client = getMCPClient();
113
75
  if (!client.isConnectedToServer()) {
114
76
  const useRemote = await cliConfig.isAuthenticated();
115
77
  await client.connect({ useRemote });
@@ -212,7 +174,7 @@ const healthCheck = async () => {
212
174
  console.log();
213
175
  process.stdout.write('MCP Server status: ');
214
176
  try {
215
- const client = (0, mcp_client_js_1.getMCPClient)();
177
+ const client = getMCPClient();
216
178
  const status = client.getConnectionStatus();
217
179
  const mcpPreference = await cliConfig.get('mcpPreference') || 'auto';
218
180
  if (client.isConnectedToServer()) {
@@ -258,8 +220,8 @@ const requireAuth = (command) => {
258
220
  await cliConfig.init();
259
221
  const isAuthenticated = await cliConfig.isAuthenticated();
260
222
  if (!isAuthenticated) {
261
- console.error(chalk_1.default.red('✖ Authentication required'));
262
- console.log(chalk_1.default.yellow('Please run:'), chalk_1.default.white('lanonasis auth login'));
223
+ console.error(chalk.red('✖ Authentication required'));
224
+ console.log(chalk.yellow('Please run:'), chalk.white('lanonasis auth login'));
263
225
  process.exit(1);
264
226
  }
265
227
  });
@@ -269,7 +231,7 @@ program
269
231
  .command('init')
270
232
  .description('Initialize CLI configuration')
271
233
  .option('-f, --force', 'overwrite existing configuration')
272
- .action(init_js_1.initCommand);
234
+ .action(initCommand);
273
235
  // Authentication commands (no auth required)
274
236
  const authCmd = program
275
237
  .command('auth')
@@ -287,14 +249,14 @@ authCmd
287
249
  if (options.oauth) {
288
250
  options.useWebAuth = true;
289
251
  }
290
- await (0, auth_js_1.loginCommand)(options);
252
+ await loginCommand(options);
291
253
  });
292
254
  authCmd
293
255
  .command('logout')
294
256
  .description('Logout from your account')
295
257
  .action(async () => {
296
258
  await cliConfig.logout();
297
- console.log(chalk_1.default.green('✓ Logged out successfully'));
259
+ console.log(chalk.green('✓ Logged out successfully'));
298
260
  });
299
261
  authCmd
300
262
  .command('status')
@@ -308,10 +270,10 @@ authCmd
308
270
  const lastFailure = cliConfig.getLastAuthFailure();
309
271
  const authMethod = cliConfig.get('authMethod');
310
272
  const lastValidated = cliConfig.get('lastValidated');
311
- console.log(chalk_1.default.blue.bold('🔐 Authentication Status'));
273
+ console.log(chalk.blue.bold('🔐 Authentication Status'));
312
274
  console.log('━'.repeat(40));
313
275
  if (isAuth && user) {
314
- console.log(chalk_1.default.green('✓ Authenticated'));
276
+ console.log(chalk.green('✓ Authenticated'));
315
277
  console.log(`Email: ${user.email}`);
316
278
  console.log(`Organization: ${user.organization_id}`);
317
279
  console.log(`Plan: ${user.plan}`);
@@ -324,13 +286,13 @@ authCmd
324
286
  }
325
287
  }
326
288
  else {
327
- console.log(chalk_1.default.red('✖ Not authenticated'));
328
- console.log(chalk_1.default.yellow('Run:'), chalk_1.default.white('memory login'));
289
+ console.log(chalk.red('✖ Not authenticated'));
290
+ console.log(chalk.yellow('Run:'), chalk.white('memory login'));
329
291
  }
330
292
  // Show failure tracking information
331
293
  if (failureCount > 0) {
332
294
  console.log();
333
- console.log(chalk_1.default.yellow('⚠️ Authentication Issues:'));
295
+ console.log(chalk.yellow('⚠️ Authentication Issues:'));
334
296
  console.log(`Failed attempts: ${failureCount}`);
335
297
  if (lastFailure) {
336
298
  const failureDate = new Date(lastFailure);
@@ -338,22 +300,22 @@ authCmd
338
300
  }
339
301
  if (cliConfig.shouldDelayAuth()) {
340
302
  const delayMs = cliConfig.getAuthDelayMs();
341
- console.log(chalk_1.default.yellow(`Next retry delay: ${Math.round(delayMs / 1000)} seconds`));
303
+ console.log(chalk.yellow(`Next retry delay: ${Math.round(delayMs / 1000)} seconds`));
342
304
  }
343
305
  console.log();
344
- console.log(chalk_1.default.cyan('💡 To reset failure count:'));
345
- console.log(chalk_1.default.white(' lanonasis auth logout && lanonasis auth login'));
306
+ console.log(chalk.cyan('💡 To reset failure count:'));
307
+ console.log(chalk.white(' lanonasis auth logout && lanonasis auth login'));
346
308
  }
347
309
  });
348
310
  // MCP Commands (primary interface)
349
- (0, mcp_js_1.mcpCommands)(program);
311
+ mcpCommands(program);
350
312
  // Memory commands (require auth) - now MCP-powered by default
351
313
  const memoryCmd = program
352
314
  .command('memory')
353
315
  .alias('mem')
354
316
  .description('Memory management commands');
355
317
  requireAuth(memoryCmd);
356
- (0, memory_js_1.memoryCommands)(memoryCmd);
318
+ memoryCommands(memoryCmd);
357
319
  // Note: Memory commands are now MCP-powered when available
358
320
  // Topic commands (require auth)
359
321
  const topicCmd = program
@@ -361,23 +323,23 @@ const topicCmd = program
361
323
  .alias('topics')
362
324
  .description('Topic management commands');
363
325
  requireAuth(topicCmd);
364
- (0, topics_js_1.topicCommands)(topicCmd);
326
+ topicCommands(topicCmd);
365
327
  // Configuration commands (require auth)
366
328
  const configCmd = program
367
329
  .command('config')
368
330
  .description('Configuration management');
369
331
  requireAuth(configCmd);
370
- (0, config_js_1.configCommands)(configCmd);
332
+ configCommands(configCmd);
371
333
  // Organization commands (require auth)
372
334
  const orgCmd = program
373
335
  .command('org')
374
336
  .alias('organization')
375
337
  .description('Organization management');
376
338
  requireAuth(orgCmd);
377
- (0, organization_js_1.orgCommands)(orgCmd);
339
+ orgCommands(orgCmd);
378
340
  // API Key management commands (require auth)
379
- requireAuth(api_keys_js_1.default);
380
- program.addCommand(api_keys_js_1.default);
341
+ requireAuth(apiKeysCommand);
342
+ program.addCommand(apiKeysCommand);
381
343
  // Dashboard management commands (require auth)
382
344
  const dashboardCmd = program
383
345
  .command('dashboard')
@@ -531,7 +493,7 @@ deployCmd
531
493
  { name: 'Documentation', url: 'https://docs.lanonasis.com/memory-services', status: 'healthy' },
532
494
  { name: 'Memory API', url: 'https://api.lanonasis.com/memories', status: 'healthy' },
533
495
  { name: 'MCP Server', url: 'https://mcp.lanonasis.com/api/v1/events', status: 'healthy' },
534
- { name: 'Authentication', url: 'https://api.lanonasis.com/auth', status: 'healthy' }
496
+ { name: 'Authentication', url: 'https://auth.lanonasis.com', status: 'healthy' }
535
497
  ];
536
498
  for (const service of services) {
537
499
  process.stdout.write(`${service.name.padEnd(20)}: `);
@@ -580,9 +542,9 @@ program
580
542
  await cliConfig.init();
581
543
  const isAuth = await cliConfig.isAuthenticated();
582
544
  const apiUrl = cliConfig.getApiUrl();
583
- console.log(chalk_1.default.blue.bold('MaaS CLI Status'));
545
+ console.log(chalk.blue.bold('MaaS CLI Status'));
584
546
  console.log(`API URL: ${apiUrl}`);
585
- console.log(`Authenticated: ${isAuth ? chalk_1.default.green('Yes') : chalk_1.default.red('No')}`);
547
+ console.log(`Authenticated: ${isAuth ? chalk.green('Yes') : chalk.red('No')}`);
586
548
  if (isAuth) {
587
549
  const user = await cliConfig.getCurrentUser();
588
550
  if (user) {
@@ -614,15 +576,15 @@ program
614
576
  .description('Open documentation in browser')
615
577
  .action(() => {
616
578
  const url = 'https://api.lanonasis.com/docs';
617
- console.log(chalk_1.default.blue(`Opening documentation: ${url}`));
579
+ console.log(chalk.blue(`Opening documentation: ${url}`));
618
580
  // Try to open in browser
619
581
  import('open').then(open => {
620
582
  open.default(url).catch(() => {
621
- console.log(chalk_1.default.yellow('Could not open browser automatically.'));
622
- console.log(chalk_1.default.white(`Please visit: ${url}`));
583
+ console.log(chalk.yellow('Could not open browser automatically.'));
584
+ console.log(chalk.white(`Please visit: ${url}`));
623
585
  });
624
586
  }).catch(() => {
625
- console.log(chalk_1.default.white(`Please visit: ${url}`));
587
+ console.log(chalk.white(`Please visit: ${url}`));
626
588
  });
627
589
  });
628
590
  // Completion commands
@@ -632,7 +594,7 @@ program
632
594
  .argument('[shell]', 'shell type (bash, zsh, fish)')
633
595
  .action(async (shell) => {
634
596
  if (!shell) {
635
- await (0, completion_js_1.installCompletionsCommand)();
597
+ await installCompletionsCommand();
636
598
  return;
637
599
  }
638
600
  const completionsDir = path.join(__dirname, 'completions');
@@ -666,44 +628,44 @@ program
666
628
  .command('guide')
667
629
  .alias('setup')
668
630
  .description('Interactive setup guide for new users')
669
- .action(guide_js_1.guideCommand);
631
+ .action(guideCommand);
670
632
  program
671
633
  .command('quickstart')
672
634
  .alias('quick')
673
635
  .description('Show essential commands for quick start')
674
- .action(guide_js_1.quickStartCommand);
636
+ .action(quickStartCommand);
675
637
  // Help customization
676
638
  program.configureHelp({
677
639
  formatHelp: (cmd, helper) => {
678
- let help = chalk_1.default.blue.bold('🧠 Memory as a Service CLI\n\n');
640
+ let help = chalk.blue.bold('🧠 Memory as a Service CLI\n\n');
679
641
  help += helper.commandUsage(cmd) + '\n\n';
680
642
  if (cmd.description()) {
681
- help += chalk_1.default.yellow('Description:\n');
643
+ help += chalk.yellow('Description:\n');
682
644
  help += ` ${cmd.description()}\n\n`;
683
645
  }
684
646
  const commands = helper.visibleCommands(cmd);
685
647
  if (commands.length > 0) {
686
- help += chalk_1.default.yellow('Commands:\n');
648
+ help += chalk.yellow('Commands:\n');
687
649
  const maxNameLength = Math.max(...commands.map(c => c.name().length));
688
650
  commands.forEach(c => {
689
651
  const name = c.name().padEnd(maxNameLength);
690
- help += ` ${chalk_1.default.white(name)} ${c.description()}\n`;
652
+ help += ` ${chalk.white(name)} ${c.description()}\n`;
691
653
  });
692
654
  help += '\n';
693
655
  }
694
656
  const options = helper.visibleOptions(cmd);
695
657
  if (options.length > 0) {
696
- help += chalk_1.default.yellow('Options:\n');
658
+ help += chalk.yellow('Options:\n');
697
659
  options.forEach(option => {
698
660
  help += ` ${option.flags.padEnd(20)} ${option.description}\n`;
699
661
  });
700
662
  help += '\n';
701
663
  }
702
664
  const cmdName = isOnasisInvocation ? 'onasis' : program.name();
703
- help += chalk_1.default.gray(`For more help on a specific command, run: ${cmdName} <command> --help\n`);
704
- help += chalk_1.default.gray('Documentation: https://api.lanonasis.com/docs\n');
665
+ help += chalk.gray(`For more help on a specific command, run: ${cmdName} <command> --help\n`);
666
+ help += chalk.gray('Documentation: https://api.lanonasis.com/docs\n');
705
667
  if (isOnasisInvocation) {
706
- help += chalk_1.default.gray('Golden Contract: Onasis-Core v0.1 Compliant\n');
668
+ help += chalk.gray('Golden Contract: Onasis-Core v0.1 Compliant\n');
707
669
  }
708
670
  return help;
709
671
  }
@@ -712,7 +674,7 @@ program.configureHelp({
712
674
  async function main() {
713
675
  // Check for special flags first
714
676
  if (process.argv.includes('--completion-data')) {
715
- await (0, completion_js_1.completionCommand)();
677
+ await completionCommand();
716
678
  return;
717
679
  }
718
680
  if (process.argv.includes('--completion')) {
@@ -757,7 +719,7 @@ async function main() {
757
719
  }
758
720
  catch (error) {
759
721
  if (error instanceof Error) {
760
- console.error(chalk_1.default.red('✖ Error:'), error.message);
722
+ console.error(chalk.red('✖ Error:'), error.message);
761
723
  if (process.env.CLI_VERBOSE === 'true') {
762
724
  console.error(error.stack);
763
725
  }