@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,13 +1,19 @@
1
+ "use strict";
1
2
  /**
2
3
  * Lanonasis MCP Server Implementation
3
4
  * Provides MCP protocol access to Lanonasis MaaS functionality
4
5
  */
5
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
- import { CLIConfig } from '../../utils/config.js';
8
- import { APIClient } from '../../utils/api.js';
9
- import chalk from 'chalk';
10
- export class LanonasisMCPServer {
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.LanonasisMCPServer = void 0;
11
+ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
12
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
13
+ const config_js_1 = require("../../utils/config.js");
14
+ const api_js_1 = require("../../utils/api.js");
15
+ const chalk_1 = __importDefault(require("chalk"));
16
+ class LanonasisMCPServer {
11
17
  server;
12
18
  config;
13
19
  apiClient;
@@ -26,7 +32,7 @@ export class LanonasisMCPServer {
26
32
  // Initialize transport settings
27
33
  this.enableFallback = options.enableTransportFallback !== false; // Default to true
28
34
  // Initialize server with metadata
29
- this.server = new Server({
35
+ this.server = new index_js_1.Server({
30
36
  name: options.name || "lanonasis-maas-server",
31
37
  version: options.version || "3.0.1"
32
38
  }, {
@@ -37,8 +43,8 @@ export class LanonasisMCPServer {
37
43
  }
38
44
  });
39
45
  // Initialize config and API client
40
- this.config = new CLIConfig();
41
- this.apiClient = new APIClient();
46
+ this.config = new config_js_1.CLIConfig();
47
+ this.apiClient = new api_js_1.APIClient();
42
48
  // Note: registerTools is now async and called in initialize()
43
49
  // Setup error handling
44
50
  this.setupErrorHandling();
@@ -60,7 +66,7 @@ export class LanonasisMCPServer {
60
66
  const apiUrl = this.config.getApiUrl();
61
67
  const token = this.config.getToken();
62
68
  if (apiUrl) {
63
- this.apiClient = new APIClient();
69
+ this.apiClient = new api_js_1.APIClient();
64
70
  // APIClient will use the config internally
65
71
  }
66
72
  // Register tools, resources, and prompts after config is loaded
@@ -70,10 +76,10 @@ export class LanonasisMCPServer {
70
76
  // Start connection cleanup monitoring
71
77
  this.startConnectionCleanup();
72
78
  if (this.options.verbose) {
73
- console.log(chalk.cyan('🚀 Lanonasis MCP Server initialized'));
74
- console.log(chalk.gray(`API URL: ${apiUrl}`));
75
- console.log(chalk.gray(`Authenticated: ${token ? 'Yes' : 'No'}`));
76
- console.log(chalk.gray(`Max connections: ${this.maxConnections}`));
79
+ console.log(chalk_1.default.cyan('🚀 Lanonasis MCP Server initialized'));
80
+ console.log(chalk_1.default.gray(`API URL: ${apiUrl}`));
81
+ console.log(chalk_1.default.gray(`Authenticated: ${token ? 'Yes' : 'No'}`));
82
+ console.log(chalk_1.default.gray(`Max connections: ${this.maxConnections}`));
77
83
  }
78
84
  }
79
85
  /**
@@ -853,7 +859,7 @@ Please choose an option (1-4):`
853
859
  // Check if we've reached the maximum number of connections
854
860
  if (this.connectionPool.size >= this.maxConnections) {
855
861
  if (this.options.verbose) {
856
- console.log(chalk.yellow(`⚠️ Maximum connections (${this.maxConnections}) reached, rejecting new connection`));
862
+ console.log(chalk_1.default.yellow(`⚠️ Maximum connections (${this.maxConnections}) reached, rejecting new connection`));
857
863
  }
858
864
  return false;
859
865
  }
@@ -867,7 +873,7 @@ Please choose an option (1-4):`
867
873
  };
868
874
  this.connectionPool.set(clientId, connection);
869
875
  if (this.options.verbose) {
870
- console.log(chalk.cyan(`✅ Added connection ${clientId} (${transport}) - Total: ${this.connectionPool.size}`));
876
+ console.log(chalk_1.default.cyan(`✅ Added connection ${clientId} (${transport}) - Total: ${this.connectionPool.size}`));
871
877
  }
872
878
  return true;
873
879
  }
@@ -880,7 +886,7 @@ Please choose an option (1-4):`
880
886
  this.connectionPool.delete(clientId);
881
887
  if (this.options.verbose) {
882
888
  const uptime = Date.now() - connection.connectedAt.getTime();
883
- console.log(chalk.gray(`🔌 Removed connection ${clientId} (uptime: ${Math.round(uptime / 1000)}s) - Total: ${this.connectionPool.size}`));
889
+ console.log(chalk_1.default.gray(`🔌 Removed connection ${clientId} (uptime: ${Math.round(uptime / 1000)}s) - Total: ${this.connectionPool.size}`));
884
890
  }
885
891
  }
886
892
  }
@@ -901,7 +907,7 @@ Please choose an option (1-4):`
901
907
  if (connection) {
902
908
  connection.authenticated = true;
903
909
  if (this.options.verbose) {
904
- console.log(chalk.green(`🔐 Connection ${clientId} authenticated`));
910
+ console.log(chalk_1.default.green(`🔐 Connection ${clientId} authenticated`));
905
911
  }
906
912
  }
907
913
  }
@@ -961,7 +967,7 @@ Please choose an option (1-4):`
961
967
  for (const clientId of staleConnections) {
962
968
  this.removeConnection(clientId);
963
969
  if (this.options.verbose) {
964
- console.log(chalk.yellow(`🧹 Cleaned up stale connection: ${clientId}`));
970
+ console.log(chalk_1.default.yellow(`🧹 Cleaned up stale connection: ${clientId}`));
965
971
  }
966
972
  }
967
973
  }
@@ -1075,7 +1081,7 @@ Please choose an option (1-4):`
1075
1081
  }
1076
1082
  catch (error) {
1077
1083
  if (this.options.verbose) {
1078
- console.log(chalk.yellow(`⚠️ Stored credentials validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
1084
+ console.log(chalk_1.default.yellow(`⚠️ Stored credentials validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
1079
1085
  }
1080
1086
  return false;
1081
1087
  }
@@ -1113,7 +1119,7 @@ Please choose an option (1-4):`
1113
1119
  }
1114
1120
  catch (error) {
1115
1121
  if (this.options.verbose) {
1116
- console.log(chalk.yellow(`⚠️ Credential validation failed: ${error.response?.status || error.message}`));
1122
+ console.log(chalk_1.default.yellow(`⚠️ Credential validation failed: ${error.response?.status || error.message}`));
1117
1123
  }
1118
1124
  return false;
1119
1125
  }
@@ -1216,7 +1222,7 @@ Please choose an option (1-4):`
1216
1222
  };
1217
1223
  this.transportFailures.set(transport, failure);
1218
1224
  if (this.options.verbose) {
1219
- console.log(chalk.yellow(`⚠️ Transport ${transport} failure #${failure.count}: ${error instanceof Error ? error.message : 'Unknown error'}`));
1225
+ console.log(chalk_1.default.yellow(`⚠️ Transport ${transport} failure #${failure.count}: ${error instanceof Error ? error.message : 'Unknown error'}`));
1220
1226
  }
1221
1227
  }
1222
1228
  /**
@@ -1236,7 +1242,7 @@ Please choose an option (1-4):`
1236
1242
  for (const transport of fallbackOrder) {
1237
1243
  if (await this.checkTransportAvailability(transport)) {
1238
1244
  if (this.options.verbose) {
1239
- console.log(chalk.cyan(`🔄 Falling back to ${transport} transport`));
1245
+ console.log(chalk_1.default.cyan(`🔄 Falling back to ${transport} transport`));
1240
1246
  }
1241
1247
  return transport;
1242
1248
  }
@@ -1328,8 +1334,8 @@ Please choose an option (1-4):`
1328
1334
  // Try next available transport
1329
1335
  const nextTransport = await this.getBestAvailableTransport();
1330
1336
  if (nextTransport && nextTransport !== availableTransport) {
1331
- console.log(chalk.yellow(`⚠️ ${transportError.message}`));
1332
- console.log(chalk.cyan(`🔄 Attempting fallback to ${nextTransport} transport...`));
1337
+ console.log(chalk_1.default.yellow(`⚠️ ${transportError.message}`));
1338
+ console.log(chalk_1.default.cyan(`🔄 Attempting fallback to ${nextTransport} transport...`));
1333
1339
  try {
1334
1340
  await this.startTransport(nextTransport);
1335
1341
  return nextTransport;
@@ -1349,7 +1355,7 @@ Please choose an option (1-4):`
1349
1355
  async startTransport(transport) {
1350
1356
  switch (transport) {
1351
1357
  case 'stdio':
1352
- this.transport = new StdioServerTransport();
1358
+ this.transport = new stdio_js_1.StdioServerTransport();
1353
1359
  await this.server.connect(this.transport);
1354
1360
  break;
1355
1361
  case 'websocket':
@@ -1399,16 +1405,16 @@ Please choose an option (1-4):`
1399
1405
  */
1400
1406
  setupErrorHandling() {
1401
1407
  process.on('SIGINT', async () => {
1402
- console.log(chalk.yellow('\n⚠️ Shutting down MCP server...'));
1408
+ console.log(chalk_1.default.yellow('\n⚠️ Shutting down MCP server...'));
1403
1409
  await this.stop();
1404
1410
  process.exit(0);
1405
1411
  });
1406
1412
  process.on('uncaughtException', (error) => {
1407
- console.error(chalk.red('Uncaught exception:'), error);
1413
+ console.error(chalk_1.default.red('Uncaught exception:'), error);
1408
1414
  process.exit(1);
1409
1415
  });
1410
1416
  process.on('unhandledRejection', (reason, promise) => {
1411
- console.error(chalk.red('Unhandled rejection at:'), promise, 'reason:', reason);
1417
+ console.error(chalk_1.default.red('Unhandled rejection at:'), promise, 'reason:', reason);
1412
1418
  });
1413
1419
  }
1414
1420
  /**
@@ -1426,30 +1432,30 @@ Please choose an option (1-4):`
1426
1432
  version: '1.0.0'
1427
1433
  });
1428
1434
  if (this.options.verbose) {
1429
- console.log(chalk.green('✅ Lanonasis MCP Server started'));
1430
- console.log(chalk.gray(`Active transport: ${activeTransport}`));
1431
- console.log(chalk.gray('Waiting for client connections...'));
1435
+ console.log(chalk_1.default.green('✅ Lanonasis MCP Server started'));
1436
+ console.log(chalk_1.default.gray(`Active transport: ${activeTransport}`));
1437
+ console.log(chalk_1.default.gray('Waiting for client connections...'));
1432
1438
  if (this.enableFallback) {
1433
- console.log(chalk.gray('Transport fallback: enabled'));
1439
+ console.log(chalk_1.default.gray('Transport fallback: enabled'));
1434
1440
  }
1435
1441
  }
1436
1442
  // Keep the process alive
1437
1443
  process.stdin.resume();
1438
1444
  }
1439
1445
  catch (error) {
1440
- console.error(chalk.red('❌ Failed to start MCP Server:'));
1441
- console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error'));
1446
+ console.error(chalk_1.default.red('❌ Failed to start MCP Server:'));
1447
+ console.error(chalk_1.default.red(error instanceof Error ? error.message : 'Unknown error'));
1442
1448
  if (this.options.verbose) {
1443
- console.log(chalk.yellow('\n🔧 Troubleshooting tips:'));
1444
- console.log(chalk.cyan('• Check if all required dependencies are installed'));
1445
- console.log(chalk.cyan('• Verify network connectivity and firewall settings'));
1446
- console.log(chalk.cyan('• Try enabling transport fallback: --enable-fallback'));
1447
- console.log(chalk.cyan('• Use --verbose for detailed error information'));
1449
+ console.log(chalk_1.default.yellow('\n🔧 Troubleshooting tips:'));
1450
+ console.log(chalk_1.default.cyan('• Check if all required dependencies are installed'));
1451
+ console.log(chalk_1.default.cyan('• Verify network connectivity and firewall settings'));
1452
+ console.log(chalk_1.default.cyan('• Try enabling transport fallback: --enable-fallback'));
1453
+ console.log(chalk_1.default.cyan('• Use --verbose for detailed error information'));
1448
1454
  const transportStatus = this.getTransportStatus();
1449
1455
  if (Object.keys(transportStatus.transportFailures).length > 0) {
1450
- console.log(chalk.yellow('\n📊 Transport failure history:'));
1456
+ console.log(chalk_1.default.yellow('\n📊 Transport failure history:'));
1451
1457
  for (const [transport, failure] of Object.entries(transportStatus.transportFailures)) {
1452
- console.log(chalk.gray(` ${transport}: ${failure.count} failures (last: ${failure.lastFailure})`));
1458
+ console.log(chalk_1.default.gray(` ${transport}: ${failure.count} failures (last: ${failure.lastFailure})`));
1453
1459
  }
1454
1460
  }
1455
1461
  }
@@ -1469,7 +1475,7 @@ Please choose an option (1-4):`
1469
1475
  this.transport = null;
1470
1476
  }
1471
1477
  if (this.options.verbose) {
1472
- console.log(chalk.gray('MCP Server stopped'));
1478
+ console.log(chalk_1.default.gray('MCP Server stopped'));
1473
1479
  }
1474
1480
  }
1475
1481
  /**
@@ -1485,6 +1491,7 @@ Please choose an option (1-4):`
1485
1491
  return new Map(this.connectionPool);
1486
1492
  }
1487
1493
  }
1494
+ exports.LanonasisMCPServer = LanonasisMCPServer;
1488
1495
  // CLI entry point
1489
1496
  if (import.meta.url === `file://${process.argv[1]}`) {
1490
1497
  const server = new LanonasisMCPServer({
@@ -1493,7 +1500,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
1493
1500
  token: process.env.LANONASIS_TOKEN
1494
1501
  });
1495
1502
  server.start().catch((error) => {
1496
- console.error(chalk.red('Failed to start server:'), error);
1503
+ console.error(chalk_1.default.red('Failed to start server:'), error);
1497
1504
  process.exit(1);
1498
1505
  });
1499
1506
  }
@@ -1,15 +1,21 @@
1
+ "use strict";
1
2
  /**
2
3
  * MCP Transport Manager
3
4
  * Handles multiple transport types for MCP connections
4
5
  */
5
- import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
6
- import { EventEmitter } from 'events';
7
- import WebSocket from 'ws';
8
- import chalk from 'chalk';
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.transportManager = exports.MCPTransportManager = void 0;
11
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/client/stdio.js");
12
+ const events_1 = require("events");
13
+ const ws_1 = __importDefault(require("ws"));
14
+ const chalk_1 = __importDefault(require("chalk"));
9
15
  /**
10
16
  * StdIO Transport wrapper
11
17
  */
12
- class StdioTransport extends EventEmitter {
18
+ class StdioTransport extends events_1.EventEmitter {
13
19
  transport;
14
20
  connected = false;
15
21
  constructor(config) {
@@ -17,7 +23,7 @@ class StdioTransport extends EventEmitter {
17
23
  if (!config.command) {
18
24
  throw new Error('Command required for stdio transport');
19
25
  }
20
- this.transport = new StdioClientTransport({
26
+ this.transport = new stdio_js_1.StdioClientTransport({
21
27
  command: config.command,
22
28
  args: config.args || []
23
29
  });
@@ -44,7 +50,7 @@ class StdioTransport extends EventEmitter {
44
50
  /**
45
51
  * HTTP Transport wrapper
46
52
  */
47
- class HttpTransport extends EventEmitter {
53
+ class HttpTransport extends events_1.EventEmitter {
48
54
  url;
49
55
  headers;
50
56
  connected = false;
@@ -112,7 +118,7 @@ class HttpTransport extends EventEmitter {
112
118
  /**
113
119
  * WebSocket Transport wrapper
114
120
  */
115
- class WebSocketTransport extends EventEmitter {
121
+ class WebSocketTransport extends events_1.EventEmitter {
116
122
  ws = null;
117
123
  url;
118
124
  connected = false;
@@ -147,14 +153,14 @@ class WebSocketTransport extends EventEmitter {
147
153
  async connect() {
148
154
  return new Promise((resolve, reject) => {
149
155
  try {
150
- this.ws = new WebSocket(this.url, {
156
+ this.ws = new ws_1.default(this.url, {
151
157
  headers: this.headers
152
158
  });
153
159
  this.ws.on('open', () => {
154
160
  this.connected = true;
155
161
  this.reconnectAttempts = 0;
156
162
  this.emit('connected');
157
- console.log(chalk.green(`✅ WebSocket connected to ${this.url}`));
163
+ console.log(chalk_1.default.green(`✅ WebSocket connected to ${this.url}`));
158
164
  resolve();
159
165
  });
160
166
  this.ws.on('message', (data) => {
@@ -201,10 +207,10 @@ class WebSocketTransport extends EventEmitter {
201
207
  const delay = this.reconnectConfig?.delay || 5000;
202
208
  const backoff = Math.min(delay * Math.pow(2, this.reconnectAttempts), 30000);
203
209
  this.reconnectAttempts++;
204
- console.log(chalk.yellow(`⏳ Reconnecting WebSocket in ${backoff}ms (attempt ${this.reconnectAttempts})...`));
210
+ console.log(chalk_1.default.yellow(`⏳ Reconnecting WebSocket in ${backoff}ms (attempt ${this.reconnectAttempts})...`));
205
211
  this.reconnectTimer = setTimeout(() => {
206
212
  this.connect().catch(error => {
207
- console.error(chalk.red('Reconnection failed:'), error);
213
+ console.error(chalk_1.default.red('Reconnection failed:'), error);
208
214
  });
209
215
  }, backoff);
210
216
  }
@@ -241,7 +247,7 @@ class WebSocketTransport extends EventEmitter {
241
247
  /**
242
248
  * Server-Sent Events Transport
243
249
  */
244
- class SSETransport extends EventEmitter {
250
+ class SSETransport extends events_1.EventEmitter {
245
251
  eventSource = null;
246
252
  url;
247
253
  connected = false;
@@ -301,7 +307,7 @@ class SSETransport extends EventEmitter {
301
307
  /**
302
308
  * Transport Manager class
303
309
  */
304
- export class MCPTransportManager {
310
+ class MCPTransportManager {
305
311
  transports = new Map();
306
312
  configs = new Map();
307
313
  /**
@@ -339,13 +345,13 @@ export class MCPTransportManager {
339
345
  */
340
346
  setupEventForwarding(name, transport) {
341
347
  transport.on('connected', () => {
342
- console.log(chalk.green(`✅ Transport '${name}' connected`));
348
+ console.log(chalk_1.default.green(`✅ Transport '${name}' connected`));
343
349
  });
344
350
  transport.on('disconnected', (reason) => {
345
- console.log(chalk.yellow(`⚠️ Transport '${name}' disconnected:`, reason));
351
+ console.log(chalk_1.default.yellow(`⚠️ Transport '${name}' disconnected:`, reason));
346
352
  });
347
353
  transport.on('error', (error) => {
348
- console.log(chalk.red(`❌ Transport '${name}' error:`, error.message));
354
+ console.log(chalk_1.default.red(`❌ Transport '${name}' error:`, error.message));
349
355
  });
350
356
  }
351
357
  /**
@@ -430,5 +436,6 @@ export class MCPTransportManager {
430
436
  return this.createTransport(name, config);
431
437
  }
432
438
  }
439
+ exports.MCPTransportManager = MCPTransportManager;
433
440
  // Export singleton instance
434
- export const transportManager = new MCPTransportManager();
441
+ exports.transportManager = new MCPTransportManager();
@@ -1,16 +1,19 @@
1
+ "use strict";
1
2
  /**
2
3
  * Vector Store Integration
3
4
  * Supports multiple vector stores with configurable embedding models
4
5
  */
5
- import { CLIConfig } from '../utils/config.js';
6
- import { logger } from './logger.js';
7
- export class LanonasisVectorStore {
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LanonasisVectorStore = void 0;
8
+ const config_js_1 = require("../utils/config.js");
9
+ const logger_js_1 = require("./logger.js");
10
+ class LanonasisVectorStore {
8
11
  config;
9
12
  storeConfig;
10
13
  isInitialized = false;
11
14
  localEmbeddings = new Map();
12
15
  constructor() {
13
- this.config = new CLIConfig();
16
+ this.config = new config_js_1.CLIConfig();
14
17
  this.storeConfig = {
15
18
  provider: 'local',
16
19
  collection: 'lanonasis_memories',
@@ -19,7 +22,7 @@ export class LanonasisVectorStore {
19
22
  }
20
23
  async initialize() {
21
24
  this.isInitialized = true;
22
- logger.info('Vector store initialized', { provider: this.storeConfig.provider });
25
+ logger_js_1.logger.info('Vector store initialized', { provider: this.storeConfig.provider });
23
26
  }
24
27
  isConfigured() {
25
28
  return this.isInitialized;
@@ -27,7 +30,7 @@ export class LanonasisVectorStore {
27
30
  async addMemory(memoryId, content, metadata) {
28
31
  const embedding = this.generateSimpleEmbedding(content);
29
32
  this.localEmbeddings.set(memoryId, { embedding, metadata, content });
30
- logger.debug('Memory added to vector store', { memoryId });
33
+ logger_js_1.logger.debug('Memory added to vector store', { memoryId });
31
34
  }
32
35
  async searchMemories(query, options = {}) {
33
36
  const queryEmbedding = this.generateSimpleEmbedding(query);
@@ -90,3 +93,4 @@ export class LanonasisVectorStore {
90
93
  return magnitudeA && magnitudeB ? dotProduct / (magnitudeA * magnitudeB) : 0;
91
94
  }
92
95
  }
96
+ exports.LanonasisVectorStore = LanonasisVectorStore;
@@ -1,22 +1,25 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
2
3
  /**
3
4
  * CLI-Embedded MCP Server
4
5
  * Uses the same configuration and authentication as @lanonasis/cli v1.5.2+
5
6
  * Can run standalone or be invoked by CLI commands
6
7
  */
7
- import { fileURLToPath } from 'url';
8
- import { dirname, join } from 'path';
9
- import { existsSync } from 'fs';
10
- import { createRequire } from 'module';
11
- import { spawn } from 'child_process';
12
- import { CLIConfig } from './utils/config.js';
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = dirname(__filename);
15
- const nodeRequire = createRequire(import.meta.url);
16
- export class CLIMCPServer {
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CLIMCPServer = void 0;
10
+ const url_1 = require("url");
11
+ const path_1 = require("path");
12
+ const fs_1 = require("fs");
13
+ const module_1 = require("module");
14
+ const child_process_1 = require("child_process");
15
+ const config_js_1 = require("./utils/config.js");
16
+ const __filename = (0, url_1.fileURLToPath)(import.meta.url);
17
+ const __dirname = (0, path_1.dirname)(__filename);
18
+ const nodeRequire = (0, module_1.createRequire)(import.meta.url);
19
+ class CLIMCPServer {
17
20
  config;
18
21
  constructor() {
19
- this.config = new CLIConfig();
22
+ this.config = new config_js_1.CLIConfig();
20
23
  }
21
24
  /**
22
25
  * Start MCP server using CLI configuration
@@ -49,10 +52,10 @@ export class CLIMCPServer {
49
52
  // Ignore resolution failures and continue through fallbacks
50
53
  }
51
54
  }
52
- candidates.add(join(process.cwd(), 'mcp-server/dist/cli-aligned-mcp-server.js'));
53
- candidates.add(join(__dirname, '../../../mcp-server/dist/cli-aligned-mcp-server.js'));
55
+ candidates.add((0, path_1.join)(process.cwd(), 'mcp-server/dist/cli-aligned-mcp-server.js'));
56
+ candidates.add((0, path_1.join)(__dirname, '../../../mcp-server/dist/cli-aligned-mcp-server.js'));
54
57
  for (const candidate of candidates) {
55
- if (candidate && existsSync(candidate)) {
58
+ if (candidate && (0, fs_1.existsSync)(candidate)) {
56
59
  return candidate;
57
60
  }
58
61
  }
@@ -64,7 +67,7 @@ export class CLIMCPServer {
64
67
  async startLocalMCP(options) {
65
68
  const { mode, port, verbose } = options;
66
69
  // Path to production MCP server (uses CommonJS, no build needed)
67
- const mcpServerPath = join(__dirname, '../../../mcp-server/src/production-mcp-server.cjs');
70
+ const mcpServerPath = (0, path_1.join)(__dirname, '../../../mcp-server/src/production-mcp-server.cjs');
68
71
  const args = mode === 'http' ? ['--http'] : ['--stdio'];
69
72
  if (verbose) {
70
73
  console.error('🚀 Starting CLI-aligned MCP Server...');
@@ -83,7 +86,7 @@ export class CLIMCPServer {
83
86
  MCP_VERBOSE: verbose ? 'true' : 'false',
84
87
  CLI_ALIGNED: 'true'
85
88
  };
86
- const child = spawn('node', [mcpServerPath, ...args], {
89
+ const child = (0, child_process_1.spawn)('node', [mcpServerPath, ...args], {
87
90
  env,
88
91
  stdio: mode === 'stdio' ? ['pipe', 'pipe', 'inherit'] : 'inherit'
89
92
  });
@@ -137,6 +140,7 @@ export class CLIMCPServer {
137
140
  };
138
141
  }
139
142
  }
143
+ exports.CLIMCPServer = CLIMCPServer;
140
144
  // Main execution when run as standalone script
141
145
  async function main() {
142
146
  const args = process.argv.slice(2);
@@ -185,4 +189,4 @@ if (import.meta.url === `file://${process.argv[1]}`) {
185
189
  process.exit(1);
186
190
  });
187
191
  }
188
- export default CLIMCPServer;
192
+ exports.default = CLIMCPServer;
package/dist/utils/api.js CHANGED
@@ -1,23 +1,31 @@
1
- import axios from 'axios';
2
- import chalk from 'chalk';
3
- import { randomUUID } from 'crypto';
4
- import { CLIConfig } from './config.js';
5
- export class APIClient {
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.apiClient = exports.APIClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const crypto_1 = require("crypto");
10
+ const config_js_1 = require("./config.js");
11
+ class APIClient {
6
12
  client;
7
13
  config;
8
14
  constructor() {
9
- this.config = new CLIConfig();
10
- this.client = axios.create();
15
+ this.config = new config_js_1.CLIConfig();
16
+ this.client = axios_1.default.create({
17
+ proxy: false // Bypass proxy to avoid redirect loops in containerized environments
18
+ });
11
19
  // Setup request interceptor to add auth token and headers
12
20
  this.client.interceptors.request.use(async (config) => {
13
21
  await this.config.init();
14
22
  // Service Discovery
15
23
  await this.config.discoverServices();
16
24
  // Use appropriate base URL based on endpoint
17
- const isAuthEndpoint = config.url?.includes('/auth/') || config.url?.includes('/login') || config.url?.includes('/register');
25
+ const isAuthEndpoint = config.url?.includes('/auth/') || config.url?.includes('/login') || config.url?.includes('/register') || config.url?.includes('/oauth/');
18
26
  const discoveredServices = this.config.get('discoveredServices');
19
27
  config.baseURL = isAuthEndpoint ?
20
- (discoveredServices?.auth_base || 'https://api.lanonasis.com') :
28
+ (discoveredServices?.auth_base || 'https://auth.lanonasis.com') :
21
29
  this.config.getApiUrl();
22
30
  // Add project scope header for auth endpoints
23
31
  if (isAuthEndpoint) {
@@ -37,44 +45,44 @@ export class APIClient {
37
45
  config.headers['X-Auth-Method'] = 'jwt';
38
46
  }
39
47
  // Add request ID for correlation
40
- const requestId = randomUUID();
48
+ const requestId = (0, crypto_1.randomUUID)();
41
49
  config.headers['X-Request-ID'] = requestId;
42
50
  // Add project scope for Golden Contract compliance
43
51
  config.headers['X-Project-Scope'] = 'lanonasis-maas';
44
52
  if (process.env.CLI_VERBOSE === 'true') {
45
- console.log(chalk.dim(`→ ${config.method?.toUpperCase()} ${config.url} [${requestId}]`));
53
+ console.log(chalk_1.default.dim(`→ ${config.method?.toUpperCase()} ${config.url} [${requestId}]`));
46
54
  }
47
55
  return config;
48
56
  });
49
57
  // Setup response interceptor for error handling
50
58
  this.client.interceptors.response.use((response) => {
51
59
  if (process.env.CLI_VERBOSE === 'true') {
52
- console.log(chalk.dim(`← ${response.status} ${response.statusText}`));
60
+ console.log(chalk_1.default.dim(`← ${response.status} ${response.statusText}`));
53
61
  }
54
62
  return response;
55
63
  }, (error) => {
56
64
  if (error.response) {
57
65
  const { status, data } = error.response;
58
66
  if (status === 401) {
59
- console.error(chalk.red('✖ Authentication failed'));
60
- console.log(chalk.yellow('Please run:'), chalk.white('memory login'));
67
+ console.error(chalk_1.default.red('✖ Authentication failed'));
68
+ console.log(chalk_1.default.yellow('Please run:'), chalk_1.default.white('memory login'));
61
69
  process.exit(1);
62
70
  }
63
71
  if (status === 403) {
64
- console.error(chalk.red('✖ Permission denied'));
72
+ console.error(chalk_1.default.red('✖ Permission denied'));
65
73
  if (data.message) {
66
- console.error(chalk.gray(data.message));
74
+ console.error(chalk_1.default.gray(data.message));
67
75
  }
68
76
  process.exit(1);
69
77
  }
70
78
  if (status === 429) {
71
- console.error(chalk.red('✖ Rate limit exceeded'));
72
- console.error(chalk.gray('Please wait a moment before trying again'));
79
+ console.error(chalk_1.default.red('✖ Rate limit exceeded'));
80
+ console.error(chalk_1.default.gray('Please wait a moment before trying again'));
73
81
  process.exit(1);
74
82
  }
75
83
  if (process.env.CLI_VERBOSE === 'true') {
76
- console.error(chalk.dim(`← ${status} ${error.response.statusText}`));
77
- console.error(chalk.dim(JSON.stringify(data, null, 2)));
84
+ console.error(chalk_1.default.dim(`← ${status} ${error.response.statusText}`));
85
+ console.error(chalk_1.default.dim(JSON.stringify(data, null, 2)));
78
86
  }
79
87
  }
80
88
  return Promise.reject(error);
@@ -181,4 +189,5 @@ export class APIClient {
181
189
  return response.data;
182
190
  }
183
191
  }
184
- export const apiClient = new APIClient();
192
+ exports.APIClient = APIClient;
193
+ exports.apiClient = new APIClient();