@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.
- package/dist/commands/api-keys.d.ts +2 -1
- package/dist/commands/api-keys.js +73 -78
- package/dist/commands/auth.js +160 -167
- package/dist/commands/completion.js +31 -39
- package/dist/commands/config.js +162 -201
- package/dist/commands/enhanced-memory.js +11 -17
- package/dist/commands/guide.js +79 -88
- package/dist/commands/init.js +14 -20
- package/dist/commands/mcp.d.ts +10 -0
- package/dist/commands/mcp.js +167 -156
- package/dist/commands/memory.js +77 -83
- package/dist/commands/organization.js +15 -21
- package/dist/commands/topics.js +52 -58
- package/dist/core/achievements.js +19 -26
- package/dist/core/architecture.js +42 -59
- package/dist/core/dashboard.js +71 -81
- package/dist/core/error-handler.js +30 -39
- package/dist/core/power-mode.js +46 -53
- package/dist/core/progress.js +35 -44
- package/dist/core/welcome.js +56 -64
- package/dist/enhanced-cli.js +49 -58
- package/dist/index-simple.js +75 -113
- package/dist/index.js +64 -69
- package/dist/mcp/access-control.js +13 -17
- package/dist/mcp/client/enhanced-client.js +16 -23
- package/dist/mcp/enhanced-server.js +10 -14
- package/dist/mcp/logger.js +3 -7
- package/dist/mcp/memory-state.js +13 -17
- package/dist/mcp/schemas/tool-schemas.d.ts +16 -16
- package/dist/mcp/schemas/tool-schemas.js +122 -126
- package/dist/mcp/server/lanonasis-server.js +66 -57
- package/dist/mcp/transports/transport-manager.js +18 -25
- package/dist/mcp/vector-store.js +6 -10
- package/dist/mcp-server.js +23 -27
- package/dist/utils/api.js +19 -26
- package/dist/utils/config.d.ts +2 -1
- package/dist/utils/config.js +65 -78
- package/dist/utils/formatting.js +6 -14
- package/dist/utils/mcp-client.js +76 -117
- package/package.json +36 -5
package/dist/index-simple.js
CHANGED
|
@@ -1,83 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const __filename =
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
const require =
|
|
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:
|
|
70
|
-
success:
|
|
71
|
-
warning:
|
|
72
|
-
error:
|
|
73
|
-
info:
|
|
74
|
-
accent:
|
|
75
|
-
muted:
|
|
76
|
-
highlight:
|
|
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
|
|
40
|
+
const program = new Command();
|
|
79
41
|
// CLI Configuration
|
|
80
|
-
const cliConfig = new
|
|
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 =
|
|
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 =
|
|
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(
|
|
262
|
-
console.log(
|
|
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(
|
|
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
|
|
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(
|
|
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(
|
|
273
|
+
console.log(chalk.blue.bold('🔐 Authentication Status'));
|
|
312
274
|
console.log('━'.repeat(40));
|
|
313
275
|
if (isAuth && user) {
|
|
314
|
-
console.log(
|
|
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(
|
|
328
|
-
console.log(
|
|
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(
|
|
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(
|
|
303
|
+
console.log(chalk.yellow(`Next retry delay: ${Math.round(delayMs / 1000)} seconds`));
|
|
342
304
|
}
|
|
343
305
|
console.log();
|
|
344
|
-
console.log(
|
|
345
|
-
console.log(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
339
|
+
orgCommands(orgCmd);
|
|
378
340
|
// API Key management commands (require auth)
|
|
379
|
-
requireAuth(
|
|
380
|
-
program.addCommand(
|
|
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://
|
|
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(
|
|
545
|
+
console.log(chalk.blue.bold('MaaS CLI Status'));
|
|
584
546
|
console.log(`API URL: ${apiUrl}`);
|
|
585
|
-
console.log(`Authenticated: ${isAuth ?
|
|
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(
|
|
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(
|
|
622
|
-
console.log(
|
|
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(
|
|
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
|
|
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(
|
|
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(
|
|
636
|
+
.action(quickStartCommand);
|
|
675
637
|
// Help customization
|
|
676
638
|
program.configureHelp({
|
|
677
639
|
formatHelp: (cmd, helper) => {
|
|
678
|
-
let help =
|
|
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 +=
|
|
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 +=
|
|
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 += ` ${
|
|
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 +=
|
|
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 +=
|
|
704
|
-
help +=
|
|
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 +=
|
|
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
|
|
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(
|
|
722
|
+
console.error(chalk.red('✖ Error:'), error.message);
|
|
761
723
|
if (process.env.CLI_VERBOSE === 'true') {
|
|
762
724
|
console.error(error.stack);
|
|
763
725
|
}
|