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