@lanonasis/cli 3.6.4 → 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.
@@ -1,2 +1,12 @@
1
1
  import { Command } from 'commander';
2
+ /**
3
+ * Register MCP-related CLI commands (mcp and mcp-server) on a Commander program.
4
+ *
5
+ * Adds commands and subcommands for MCP server initialization, connection management,
6
+ * status reporting, tool listing and invocation, memory create/search operations,
7
+ * preference configuration, and diagnostic routines, wiring each command to its
8
+ * corresponding action handlers.
9
+ *
10
+ * @param program - Commander program instance to extend with MCP commands
11
+ */
2
12
  export declare function mcpCommands(program: Command): void;
@@ -5,6 +5,16 @@ import { getMCPClient } from '../utils/mcp-client.js';
5
5
  import { EnhancedMCPClient } from '../mcp/client/enhanced-client.js';
6
6
  import { CLIConfig } from '../utils/config.js';
7
7
  import WebSocket from 'ws';
8
+ /**
9
+ * Register MCP-related CLI commands (mcp and mcp-server) on a Commander program.
10
+ *
11
+ * Adds commands and subcommands for MCP server initialization, connection management,
12
+ * status reporting, tool listing and invocation, memory create/search operations,
13
+ * preference configuration, and diagnostic routines, wiring each command to its
14
+ * corresponding action handlers.
15
+ *
16
+ * @param program - Commander program instance to extend with MCP commands
17
+ */
8
18
  export function mcpCommands(program) {
9
19
  const mcp = program
10
20
  .command('mcp')
@@ -82,8 +92,9 @@ export function mcpCommands(program) {
82
92
  connectionMode = 'local';
83
93
  }
84
94
  else {
85
- // Default to remote if authenticated, otherwise local
86
- connectionMode = config.get('token') ? 'remote' : 'local';
95
+ // Default to websocket (production mode) for all users
96
+ // Local mode should only be used explicitly for development
97
+ connectionMode = 'websocket';
87
98
  }
88
99
  // Save preferences
89
100
  config.set('mcpConnectionMode', connectionMode);
@@ -164,17 +175,42 @@ export function mcpCommands(program) {
164
175
  .description('Show MCP connection status')
165
176
  .action(async () => {
166
177
  const client = getMCPClient();
178
+ // Reload config from disk to get latest preference
179
+ await client.init();
167
180
  const status = client.getConnectionStatus();
168
181
  console.log(chalk.cyan('\nšŸ“Š MCP Connection Status'));
169
182
  console.log(chalk.cyan('========================'));
170
183
  console.log(`Status: ${status.connected ? chalk.green('Connected') : chalk.red('Disconnected')}`);
171
- console.log(`Mode: ${status.mode === 'remote' ? chalk.blue('Remote (API)') : chalk.yellow('Local')}`);
184
+ // Display mode with proper labels
185
+ let modeDisplay;
186
+ switch (status.mode) {
187
+ case 'websocket':
188
+ modeDisplay = chalk.blue('WebSocket');
189
+ break;
190
+ case 'remote':
191
+ modeDisplay = chalk.blue('Remote (HTTP/SSE)');
192
+ break;
193
+ case 'local':
194
+ modeDisplay = chalk.yellow('Local (stdio)');
195
+ break;
196
+ default:
197
+ modeDisplay = chalk.gray(status.mode);
198
+ }
199
+ console.log(`Mode: ${modeDisplay}`);
172
200
  console.log(`Server: ${status.server}`);
173
- if (status.connected && status.mode === 'remote') {
174
- console.log(`\n${chalk.cyan('Features:')}`);
175
- console.log('• Real-time updates via SSE');
176
- console.log('• Authenticated API access');
177
- console.log('• MCP-compatible tool interface');
201
+ if (status.connected) {
202
+ if (status.mode === 'remote') {
203
+ console.log(`\n${chalk.cyan('Features:')}`);
204
+ console.log('• Real-time updates via SSE');
205
+ console.log('• Authenticated API access');
206
+ console.log('• MCP-compatible tool interface');
207
+ }
208
+ else if (status.mode === 'websocket') {
209
+ console.log(`\n${chalk.cyan('Features:')}`);
210
+ console.log('• Bi-directional real-time communication');
211
+ console.log('• Authenticated WebSocket connection');
212
+ console.log('• Production-ready MCP server');
213
+ }
178
214
  }
179
215
  });
180
216
  // List tools command
@@ -341,18 +377,23 @@ export function mcpCommands(program) {
341
377
  // Configure MCP preferences
342
378
  mcp.command('config')
343
379
  .description('Configure MCP preferences')
344
- .option('--prefer-remote', 'Prefer remote MCP server when available')
345
- .option('--prefer-local', 'Prefer local MCP server')
380
+ .option('--prefer-websocket', 'Prefer WebSocket MCP connection (recommended for production)')
381
+ .option('--prefer-remote', 'Prefer remote MCP server (REST/SSE mode)')
382
+ .option('--prefer-local', 'Prefer local MCP server (development only)')
346
383
  .option('--auto', 'Auto-detect best connection mode')
347
384
  .action(async (options) => {
348
385
  const config = new CLIConfig();
349
- if (options.preferRemote) {
386
+ if (options.preferWebsocket) {
387
+ await config.setAndSave('mcpPreference', 'websocket');
388
+ console.log(chalk.green('āœ“ Set MCP preference to WebSocket (production mode)'));
389
+ }
390
+ else if (options.preferRemote) {
350
391
  await config.setAndSave('mcpPreference', 'remote');
351
- console.log(chalk.green('āœ“ Set MCP preference to remote'));
392
+ console.log(chalk.green('āœ“ Set MCP preference to remote (REST/SSE mode)'));
352
393
  }
353
394
  else if (options.preferLocal) {
354
395
  await config.setAndSave('mcpPreference', 'local');
355
- console.log(chalk.green('āœ“ Set MCP preference to local'));
396
+ console.log(chalk.green('āœ“ Set MCP preference to local (development only)'));
356
397
  }
357
398
  else if (options.auto) {
358
399
  await config.setAndSave('mcpPreference', 'auto');
@@ -362,9 +403,10 @@ export function mcpCommands(program) {
362
403
  const current = config.get('mcpPreference') || 'auto';
363
404
  console.log(`Current MCP preference: ${chalk.cyan(current)}`);
364
405
  console.log('\nOptions:');
365
- console.log(' --prefer-remote : Use remote MCP server (mcp.lanonasis.com)');
366
- console.log(' --prefer-local : Use local MCP server');
367
- console.log(' --auto : Auto-detect based on authentication');
406
+ console.log(' --prefer-websocket : Use WebSocket mode (recommended for production)');
407
+ console.log(' --prefer-remote : Use remote REST/SSE mode (alternative)');
408
+ console.log(' --prefer-local : Use local stdio mode (development only)');
409
+ console.log(' --auto : Auto-detect based on configuration (default)');
368
410
  }
369
411
  });
370
412
  // Diagnose MCP connection issues
@@ -493,7 +493,7 @@ deployCmd
493
493
  { name: 'Documentation', url: 'https://docs.lanonasis.com/memory-services', status: 'healthy' },
494
494
  { name: 'Memory API', url: 'https://api.lanonasis.com/memories', status: 'healthy' },
495
495
  { name: 'MCP Server', url: 'https://mcp.lanonasis.com/api/v1/events', status: 'healthy' },
496
- { name: 'Authentication', url: 'https://api.lanonasis.com/auth', status: 'healthy' }
496
+ { name: 'Authentication', url: 'https://auth.lanonasis.com', status: 'healthy' }
497
497
  ];
498
498
  for (const service of services) {
499
499
  process.stdout.write(`${service.name.padEnd(20)}: `);
package/dist/index.js CHANGED
@@ -488,7 +488,7 @@ deployCmd
488
488
  { name: 'Documentation', url: 'https://api.lanonasis.com/docs', status: 'healthy' },
489
489
  { name: 'Memory API', url: 'https://api.lanonasis.com/memories', status: 'healthy' },
490
490
  { name: 'MCP Server', url: 'https://mcp.lanonasis.com/api/v1/events', status: 'healthy' },
491
- { name: 'Authentication', url: 'https://api.lanonasis.com/auth', status: 'healthy' }
491
+ { name: 'Authentication', url: 'https://auth.lanonasis.com', status: 'healthy' }
492
492
  ];
493
493
  for (const service of services) {
494
494
  process.stdout.write(`${service.name.padEnd(20)}: `);
@@ -42,6 +42,6 @@ export class Logger {
42
42
  }
43
43
  }
44
44
  export const logger = new Logger({
45
- service: 'lanonasis-mcp-server',
45
+ service: 'mcp-core',
46
46
  version: '1.0.0'
47
47
  });
@@ -111,16 +111,16 @@ export declare const TopicCreateSchema: z.ZodObject<{
111
111
  color: z.ZodOptional<z.ZodString>;
112
112
  icon: z.ZodOptional<z.ZodString>;
113
113
  }, "strip", z.ZodTypeAny, {
114
- description?: string;
115
- icon?: string;
116
114
  name?: string;
117
115
  color?: string;
118
- parent_id?: string;
119
- }, {
120
116
  description?: string;
121
117
  icon?: string;
118
+ parent_id?: string;
119
+ }, {
122
120
  name?: string;
123
121
  color?: string;
122
+ description?: string;
123
+ icon?: string;
124
124
  parent_id?: string;
125
125
  }>;
126
126
  export declare const TopicUpdateSchema: z.ZodObject<{
@@ -131,18 +131,18 @@ export declare const TopicUpdateSchema: z.ZodObject<{
131
131
  color: z.ZodOptional<z.ZodString>;
132
132
  icon: z.ZodOptional<z.ZodString>;
133
133
  }, "strip", z.ZodTypeAny, {
134
- description?: string;
135
- icon?: string;
136
134
  name?: string;
137
135
  color?: string;
138
136
  topic_id?: string;
139
- parent_id?: string;
140
- }, {
141
137
  description?: string;
142
138
  icon?: string;
139
+ parent_id?: string;
140
+ }, {
143
141
  name?: string;
144
142
  color?: string;
145
143
  topic_id?: string;
144
+ description?: string;
145
+ icon?: string;
146
146
  parent_id?: string;
147
147
  }>;
148
148
  export declare const TopicListSchema: z.ZodObject<{
@@ -485,16 +485,16 @@ export declare const MCPSchemas: {
485
485
  color: z.ZodOptional<z.ZodString>;
486
486
  icon: z.ZodOptional<z.ZodString>;
487
487
  }, "strip", z.ZodTypeAny, {
488
- description?: string;
489
- icon?: string;
490
488
  name?: string;
491
489
  color?: string;
492
- parent_id?: string;
493
- }, {
494
490
  description?: string;
495
491
  icon?: string;
492
+ parent_id?: string;
493
+ }, {
496
494
  name?: string;
497
495
  color?: string;
496
+ description?: string;
497
+ icon?: string;
498
498
  parent_id?: string;
499
499
  }>;
500
500
  update: z.ZodObject<{
@@ -505,18 +505,18 @@ export declare const MCPSchemas: {
505
505
  color: z.ZodOptional<z.ZodString>;
506
506
  icon: z.ZodOptional<z.ZodString>;
507
507
  }, "strip", z.ZodTypeAny, {
508
- description?: string;
509
- icon?: string;
510
508
  name?: string;
511
509
  color?: string;
512
510
  topic_id?: string;
513
- parent_id?: string;
514
- }, {
515
511
  description?: string;
516
512
  icon?: string;
513
+ parent_id?: string;
514
+ }, {
517
515
  name?: string;
518
516
  color?: string;
519
517
  topic_id?: string;
518
+ description?: string;
519
+ icon?: string;
520
520
  parent_id?: string;
521
521
  }>;
522
522
  list: z.ZodObject<{
@@ -1104,12 +1104,28 @@ Please choose an option (1-4):`
1104
1104
  headers['Authorization'] = `Bearer ${token}`;
1105
1105
  headers['X-Auth-Method'] = 'jwt';
1106
1106
  }
1107
- // Validate against server with health endpoint
1108
- await axios.get(`${authBase}/api/v1/health`, {
1109
- headers,
1110
- timeout: 10000
1111
- });
1112
- return true;
1107
+ const normalizedBase = authBase.replace(/\/$/, '');
1108
+ const endpoints = [
1109
+ `${normalizedBase}/health`,
1110
+ `${normalizedBase}/api/v1/health`
1111
+ ];
1112
+ let lastError;
1113
+ for (const endpoint of endpoints) {
1114
+ try {
1115
+ await axios.get(endpoint, {
1116
+ headers,
1117
+ timeout: 10000
1118
+ });
1119
+ return true;
1120
+ }
1121
+ catch (error) {
1122
+ lastError = error;
1123
+ }
1124
+ }
1125
+ if (lastError instanceof Error) {
1126
+ throw lastError;
1127
+ }
1128
+ throw new Error('Auth health endpoints unreachable');
1113
1129
  }
1114
1130
  catch (error) {
1115
1131
  if (this.options.verbose) {
@@ -37,8 +37,8 @@ export class CLIMCPServer {
37
37
  candidates.add(process.env.MCP_SERVER_PATH);
38
38
  }
39
39
  const packageRequests = [
40
- '@lanonasis/mcp-server/dist/cli-aligned-mcp-server.js',
41
- 'lanonasis-mcp-server/dist/cli-aligned-mcp-server.js'
40
+ 'mcp-core/dist/cli-aligned-mcp-server.js',
41
+ 'mcp-core/dist/cli-aligned-mcp-server.js'
42
42
  ];
43
43
  for (const request of packageRequests) {
44
44
  try {
@@ -158,7 +158,7 @@ async function main() {
158
158
  CLI MCP Server - CLI-aligned Model Context Protocol server
159
159
 
160
160
  Usage:
161
- lanonasis-mcp-server [options]
161
+ mcp-core [options]
162
162
 
163
163
  Options:
164
164
  --stdio Use stdio transport (default)
@@ -170,9 +170,9 @@ Options:
170
170
  --help Show this help
171
171
 
172
172
  Examples:
173
- lanonasis-mcp-server # Start stdio server
174
- lanonasis-mcp-server --http --port=3002 # Start HTTP server
175
- lanonasis-mcp-server --status # Check status
173
+ mcp-core # Start stdio server
174
+ mcp-core --http --port=3002 # Start HTTP server
175
+ mcp-core --status # Check status
176
176
  `);
177
177
  return;
178
178
  }
package/dist/utils/api.js CHANGED
@@ -7,17 +7,19 @@ export class APIClient {
7
7
  config;
8
8
  constructor() {
9
9
  this.config = new CLIConfig();
10
- this.client = axios.create();
10
+ this.client = axios.create({
11
+ proxy: false // Bypass proxy to avoid redirect loops in containerized environments
12
+ });
11
13
  // Setup request interceptor to add auth token and headers
12
14
  this.client.interceptors.request.use(async (config) => {
13
15
  await this.config.init();
14
16
  // Service Discovery
15
17
  await this.config.discoverServices();
16
18
  // Use appropriate base URL based on endpoint
17
- const isAuthEndpoint = config.url?.includes('/auth/') || config.url?.includes('/login') || config.url?.includes('/register');
19
+ const isAuthEndpoint = config.url?.includes('/auth/') || config.url?.includes('/login') || config.url?.includes('/register') || config.url?.includes('/oauth/');
18
20
  const discoveredServices = this.config.get('discoveredServices');
19
21
  config.baseURL = isAuthEndpoint ?
20
- (discoveredServices?.auth_base || 'https://api.lanonasis.com') :
22
+ (discoveredServices?.auth_base || 'https://auth.lanonasis.com') :
21
23
  this.config.getApiUrl();
22
24
  // Add project scope header for auth endpoints
23
25
  if (isAuthEndpoint) {
@@ -13,7 +13,7 @@ interface CLIConfigData {
13
13
  mcpServerPath?: string;
14
14
  mcpServerUrl?: string;
15
15
  mcpUseRemote?: boolean;
16
- mcpPreference?: 'local' | 'remote' | 'auto';
16
+ mcpPreference?: 'local' | 'remote' | 'websocket' | 'auto';
17
17
  discoveredServices?: {
18
18
  auth_base: string;
19
19
  memory_base: string;
@@ -65,6 +65,7 @@ export declare class CLIConfig {
65
65
  private categorizeServiceDiscoveryError;
66
66
  private resolveFallbackEndpoints;
67
67
  private logFallbackUsage;
68
+ private pingAuthHealth;
68
69
  setManualEndpoints(endpoints: Partial<CLIConfigData['discoveredServices']>): Promise<void>;
69
70
  hasManualEndpointOverrides(): boolean;
70
71
  clearManualEndpointOverrides(): Promise<void>;
@@ -165,7 +165,7 @@ export class CLIConfig {
165
165
  getApiUrl() {
166
166
  return process.env.MEMORY_API_URL ||
167
167
  this.config.apiUrl ||
168
- 'https://api.lanonasis.com/api/v1';
168
+ 'https://mcp.lanonasis.com/api/v1';
169
169
  }
170
170
  // Enhanced Service Discovery Integration
171
171
  async discoverServices(verbose = false) {
@@ -178,20 +178,30 @@ export class CLIConfig {
178
178
  }
179
179
  const response = await axios.get(discoveryUrl, {
180
180
  timeout: 10000,
181
+ maxRedirects: 5,
182
+ proxy: false, // Bypass proxy to avoid redirect loops
181
183
  headers: {
182
184
  'User-Agent': 'Lanonasis-CLI/3.0.13'
183
185
  }
184
186
  });
185
187
  // Map discovery response to our config format
186
188
  const discovered = response.data;
189
+ // Extract auth base, but filter out localhost URLs
190
+ let authBase = discovered.auth?.base || discovered.auth?.login?.replace('/auth/login', '') || '';
191
+ // Override localhost with production auth endpoint
192
+ if (authBase.includes('localhost') || authBase.includes('127.0.0.1')) {
193
+ authBase = 'https://auth.lanonasis.com';
194
+ }
195
+ const memoryBase = discovered.endpoints?.http || 'https://mcp.lanonasis.com/api/v1';
187
196
  this.config.discoveredServices = {
188
- auth_base: discovered.auth?.login?.replace('/auth/login', '') || 'https://api.lanonasis.com',
189
- memory_base: 'https://api.lanonasis.com/api/v1',
190
- mcp_base: discovered.endpoints?.http || 'https://mcp.lanonasis.com/api/v1',
197
+ auth_base: authBase || 'https://auth.lanonasis.com',
198
+ memory_base: memoryBase,
199
+ mcp_base: memoryBase,
191
200
  mcp_ws_base: discovered.endpoints?.websocket || 'wss://mcp.lanonasis.com/ws',
192
201
  mcp_sse_base: discovered.endpoints?.sse || 'https://mcp.lanonasis.com/api/v1/events',
193
202
  project_scope: 'lanonasis-maas'
194
203
  };
204
+ this.config.apiUrl = memoryBase;
195
205
  // Mark discovery as successful
196
206
  this.config.lastServiceDiscovery = new Date().toISOString();
197
207
  await this.save();
@@ -248,6 +258,7 @@ export class CLIConfig {
248
258
  ...fallback.endpoints,
249
259
  project_scope: 'lanonasis-maas'
250
260
  };
261
+ this.config.apiUrl = fallback.endpoints.memory_base;
251
262
  // Mark as fallback (don't set lastServiceDiscovery)
252
263
  await this.save();
253
264
  this.logFallbackUsage(fallback.source, this.config.discoveredServices);
@@ -293,7 +304,7 @@ export class CLIConfig {
293
304
  const nodeEnv = (process.env.NODE_ENV ?? '').toLowerCase();
294
305
  const isDevEnvironment = nodeEnv === 'development' || nodeEnv === 'test';
295
306
  const defaultAuthBase = isDevEnvironment ? 'http://localhost:4000' : 'https://auth.lanonasis.com';
296
- const defaultMemoryBase = isDevEnvironment ? 'http://localhost:4000/api/v1' : 'https://api.lanonasis.com/api/v1';
307
+ const defaultMemoryBase = isDevEnvironment ? 'http://localhost:4000/api/v1' : 'https://mcp.lanonasis.com/api/v1';
297
308
  const defaultMcpBase = isDevEnvironment ? 'http://localhost:4100/api/v1' : 'https://mcp.lanonasis.com/api/v1';
298
309
  const defaultMcpWsBase = isDevEnvironment ? 'ws://localhost:4100/ws' : 'wss://mcp.lanonasis.com/ws';
299
310
  const defaultMcpSseBase = isDevEnvironment ? 'http://localhost:4100/api/v1/events' : 'https://mcp.lanonasis.com/api/v1/events';
@@ -324,6 +335,34 @@ export class CLIConfig {
324
335
  process.emitWarning(message, 'ServiceDiscoveryFallback');
325
336
  }
326
337
  }
338
+ async pingAuthHealth(axiosInstance, authBase, headers, options = {}) {
339
+ const normalizedBase = authBase.replace(/\/$/, '');
340
+ const endpoints = [
341
+ `${normalizedBase}/health`,
342
+ `${normalizedBase}/api/v1/health`
343
+ ];
344
+ let lastError;
345
+ for (const endpoint of endpoints) {
346
+ try {
347
+ const requestConfig = {
348
+ headers,
349
+ timeout: options.timeout ?? 10000
350
+ };
351
+ if (options.proxy === false) {
352
+ requestConfig.proxy = false;
353
+ }
354
+ await axiosInstance.get(endpoint, requestConfig);
355
+ return;
356
+ }
357
+ catch (error) {
358
+ lastError = error;
359
+ }
360
+ }
361
+ if (lastError instanceof Error) {
362
+ throw lastError;
363
+ }
364
+ throw new Error('Auth health endpoints unreachable');
365
+ }
327
366
  // Manual endpoint override functionality
328
367
  async setManualEndpoints(endpoints) {
329
368
  if (!this.config.discoveredServices) {
@@ -344,13 +383,15 @@ export class CLIConfig {
344
383
  return !!this.config.manualEndpointOverrides;
345
384
  }
346
385
  async clearManualEndpointOverrides() {
347
- this.config.manualEndpointOverrides = undefined;
348
- this.config.lastManualEndpointUpdate = undefined;
386
+ delete this.config.manualEndpointOverrides;
387
+ delete this.config.lastManualEndpointUpdate;
349
388
  // Rediscover services
350
389
  await this.discoverServices();
351
390
  }
352
391
  getDiscoveredApiUrl() {
353
- return this.config.discoveredServices?.auth_base || this.getApiUrl();
392
+ return process.env.AUTH_BASE ||
393
+ this.config.discoveredServices?.auth_base ||
394
+ 'https://auth.lanonasis.com';
354
395
  }
355
396
  // Enhanced authentication support
356
397
  async setVendorKey(vendorKey) {
@@ -382,15 +423,11 @@ export class CLIConfig {
382
423
  // Ensure service discovery is done
383
424
  await this.discoverServices();
384
425
  const authBase = this.config.discoveredServices?.auth_base || 'https://auth.lanonasis.com';
385
- // Test vendor key with health endpoint
386
- await axios.get(`${authBase}/health`, {
387
- headers: {
388
- 'X-API-Key': vendorKey,
389
- 'X-Auth-Method': 'vendor_key',
390
- 'X-Project-Scope': 'lanonasis-maas'
391
- },
392
- timeout: 10000
393
- });
426
+ await this.pingAuthHealth(axios, authBase, {
427
+ 'X-API-Key': vendorKey,
428
+ 'X-Auth-Method': 'vendor_key',
429
+ 'X-Project-Scope': 'lanonasis-maas'
430
+ }, { timeout: 10000, proxy: false });
394
431
  }
395
432
  catch (error) {
396
433
  // Provide specific error messages based on response
@@ -523,8 +560,7 @@ export class CLIConfig {
523
560
  const axios = (await import('axios')).default;
524
561
  const endpoints = [
525
562
  'http://localhost:4000/v1/auth/verify-token',
526
- 'https://auth.lanonasis.com/v1/auth/verify-token',
527
- 'https://api.lanonasis.com/auth/verify'
563
+ 'https://auth.lanonasis.com/v1/auth/verify-token'
528
564
  ];
529
565
  for (const endpoint of endpoints) {
530
566
  try {
@@ -562,8 +598,7 @@ export class CLIConfig {
562
598
  // Try auth-gateway first (port 4000), then fall back to Netlify function
563
599
  const endpoints = [
564
600
  'http://localhost:4000/v1/auth/verify-token',
565
- 'https://auth.lanonasis.com/v1/auth/verify-token',
566
- 'https://api.lanonasis.com/auth/verify'
601
+ 'https://auth.lanonasis.com/v1/auth/verify-token'
567
602
  ];
568
603
  let response = null;
569
604
  for (const endpoint of endpoints) {
@@ -636,7 +671,7 @@ export class CLIConfig {
636
671
  const axios = (await import('axios')).default;
637
672
  // Ensure service discovery is done
638
673
  await this.discoverServices();
639
- const authBase = this.config.discoveredServices?.auth_base || 'https://api.lanonasis.com';
674
+ const authBase = this.config.discoveredServices?.auth_base || 'https://auth.lanonasis.com';
640
675
  const headers = {
641
676
  'X-Project-Scope': 'lanonasis-maas'
642
677
  };
@@ -648,11 +683,7 @@ export class CLIConfig {
648
683
  headers['Authorization'] = `Bearer ${token}`;
649
684
  headers['X-Auth-Method'] = 'jwt';
650
685
  }
651
- // Validate against server with health endpoint
652
- await axios.get(`${authBase}/api/v1/health`, {
653
- headers,
654
- timeout: 10000
655
- });
686
+ await this.pingAuthHealth(axios, authBase, headers);
656
687
  // Update last validated timestamp
657
688
  this.config.lastValidated = new Date().toISOString();
658
689
  await this.resetFailureCount();
@@ -684,7 +715,7 @@ export class CLIConfig {
684
715
  // Import axios dynamically
685
716
  const axios = (await import('axios')).default;
686
717
  await this.discoverServices();
687
- const authBase = this.config.discoveredServices?.auth_base || 'https://api.lanonasis.com';
718
+ const authBase = this.config.discoveredServices?.auth_base || 'https://auth.lanonasis.com';
688
719
  // Attempt token refresh
689
720
  const response = await axios.post(`${authBase}/v1/auth/refresh`, {}, {
690
721
  headers: {
@@ -788,14 +819,16 @@ export class CLIConfig {
788
819
  shouldUseRemoteMCP() {
789
820
  const preference = this.config.mcpPreference || 'auto';
790
821
  switch (preference) {
822
+ case 'websocket':
791
823
  case 'remote':
792
824
  return true;
793
825
  case 'local':
794
826
  return false;
795
827
  case 'auto':
796
828
  default:
797
- // Use remote if authenticated, otherwise local
798
- return !!this.config.token;
829
+ // Default to remote/websocket (production mode)
830
+ // Local mode should only be used when explicitly configured
831
+ return true;
799
832
  }
800
833
  }
801
834
  }
@@ -823,7 +823,21 @@ export class MCPClient {
823
823
  * Get connection status details with health information
824
824
  */
825
825
  getConnectionStatus() {
826
- const connectionMode = this.activeConnectionMode;
826
+ // When disconnected, show the configured preference instead of the stale activeConnectionMode
827
+ let connectionMode = this.activeConnectionMode;
828
+ if (!this.isConnected) {
829
+ // Check configured preference
830
+ const mcpPreference = this.config.get('mcpPreference');
831
+ const mcpConnectionMode = this.config.get('mcpConnectionMode');
832
+ const preferRemote = this.config.get('mcpUseRemote');
833
+ connectionMode = mcpConnectionMode
834
+ ?? mcpPreference
835
+ ?? (preferRemote ? 'remote' : 'websocket');
836
+ // If preference is 'auto', resolve to default (websocket)
837
+ if (connectionMode === 'auto') {
838
+ connectionMode = 'websocket';
839
+ }
840
+ }
827
841
  let server;
828
842
  switch (connectionMode) {
829
843
  case 'websocket':
package/package.json CHANGED
@@ -1,105 +1,60 @@
1
1
  {
2
2
  "name": "@lanonasis/cli",
3
- "version": "3.6.4",
4
- "description": "LanOnasis Enterprise CLI - Memory as a Service, API Key Management, and Infrastructure Orchestration",
5
- "main": "dist/index-simple.js",
3
+ "version": "3.6.7",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
6
7
  "bin": {
7
- "lanonasis": "dist/index-simple.js",
8
- "onasis": "dist/index-simple.js",
9
- "lanonasis-mcp-server": "dist/mcp-server.js",
10
- "lanonasis-mcp-cli-aligned": "dist/mcp-server.js",
11
- "memory": "dist/index-simple.js",
12
- "maas": "dist/index-simple.js"
8
+ "onasis": "dist/index.js",
9
+ "lanonasis": "dist/index.js"
13
10
  },
14
- "type": "module",
15
- "scripts": {
16
- "dev": "tsx src/index.ts",
17
- "dev:mcp": "tsx src/mcp/server/lanonasis-server.ts --verbose",
18
- "build": "tsc && chmod +x dist/index-simple.js && chmod +x dist/mcp-server.js && cp -r src/completions dist/",
19
- "build:mcp": "tsc && npm run build:mcp-server && npm run build:mcp-client",
20
- "build:mcp-server": "tsc src/mcp/server/lanonasis-server.ts --outDir dist/mcp/server && chmod +x dist/mcp/server/lanonasis-server.js",
21
- "build:mcp-client": "tsc src/mcp/client/enhanced-client.ts --outDir dist/mcp/client",
22
- "start": "node dist/index.js",
23
- "start:mcp-server": "node dist/mcp/server/lanonasis-server.js",
24
- "test": "NODE_OPTIONS=--experimental-vm-modules jest",
25
- "test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\"integration|reliability|persistence\"",
26
- "test:mcp": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=mcp",
27
- "test:integration": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\"integration|reliability|persistence\"",
28
- "test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
29
- "lint": "eslint .",
30
- "type-check": "tsc --noEmit",
31
- "prepare": "npm run build",
32
- "publish:with-mcp": "npm run build:mcp && npm publish"
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ }
33
17
  },
34
- "keywords": [
35
- "lanonasis",
36
- "cli",
37
- "memory",
38
- "ai",
39
- "maas",
40
- "enterprise",
41
- "infrastructure",
42
- "orchestrator",
43
- "api-keys",
44
- "secrets",
45
- "mcp",
46
- "security"
47
- ],
48
- "author": "Lanonasis (Seye Derick)",
49
- "license": "MIT",
50
18
  "files": [
51
19
  "dist",
52
- "README.md"
20
+ "README.md",
21
+ "LICENSE"
53
22
  ],
54
- "publishConfig": {
55
- "access": "public",
56
- "registry": "https://registry.npmjs.org/"
57
- },
58
- "repository": {
59
- "type": "git",
60
- "url": "git+https://github.com/lanonasis/lanonasis-maas.git",
61
- "directory": "cli"
62
- },
63
- "bugs": {
64
- "url": "https://github.com/lanonasis/lanonasis-maas/issues"
65
- },
66
- "homepage": "https://github.com/lanonasis/lanonasis-maas#readme",
67
23
  "dependencies": {
68
- "@lanonasis/cli": "^3.6.3",
69
- "@modelcontextprotocol/sdk": "^1.17.4",
70
- "@types/eventsource": "^1.1.15",
71
- "@types/ws": "^8.18.1",
72
- "axios": "^1.12.0",
73
- "boxen": "^7.1.1",
74
- "chalk": "^5.5.0",
24
+ "@modelcontextprotocol/sdk": "^1.1.1",
25
+ "axios": "^1.7.7",
26
+ "chalk": "^5.3.0",
75
27
  "cli-progress": "^3.12.0",
76
- "cli-table3": "^0.6.5",
28
+ "cli-table3": "^0.6.3",
77
29
  "commander": "^12.1.0",
78
30
  "date-fns": "^4.1.0",
79
- "dotenv": "^17.2.1",
31
+ "dotenv": "^16.4.5",
80
32
  "eventsource": "^4.0.0",
81
- "inquirer": "^12.9.3",
33
+ "inquirer": "^9.3.6",
82
34
  "jwt-decode": "^4.0.0",
83
35
  "open": "^10.2.0",
84
- "ora": "^8.2.0",
36
+ "ora": "^8.0.1",
85
37
  "table": "^6.9.0",
86
38
  "word-wrap": "^1.2.5",
87
- "ws": "^8.18.3"
39
+ "ws": "^8.18.0",
40
+ "zod": "^3.24.4"
88
41
  },
89
42
  "devDependencies": {
90
43
  "@jest/globals": "^29.7.0",
44
+ "@types/cli-progress": "^3.11.6",
91
45
  "@types/inquirer": "^9.0.7",
92
- "@types/jest": "^29.5.14",
93
46
  "@types/node": "^22.10.2",
94
- "@typescript-eslint/eslint-plugin": "^8.18.1",
95
- "@typescript-eslint/parser": "^8.18.1",
96
- "eslint": "^9.17.0",
47
+ "@types/ws": "^8.5.12",
97
48
  "jest": "^29.7.0",
98
- "ts-jest": "^29.2.5",
99
- "tsx": "^4.19.2",
49
+ "rimraf": "^5.0.7",
50
+ "ts-jest": "^29.1.1",
100
51
  "typescript": "^5.7.2"
101
52
  },
102
- "engines": {
103
- "node": ">=18.0.0"
53
+ "scripts": {
54
+ "build": "rimraf dist && tsc -p tsconfig.json",
55
+ "prepublishOnly": "npm run build",
56
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
57
+ "test:watch": "npm test -- --watch",
58
+ "test:coverage": "npm test -- --coverage"
104
59
  }
105
60
  }
@@ -1,88 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Lanonasis/Onasis CLI Bash Completion
4
- # Installation: source this file or copy to /etc/bash_completion.d/
5
-
6
- _lanonasis_completions() {
7
- local cur prev words cword
8
- _init_completion || return
9
-
10
- # Get completion data from CLI
11
- local completion_data
12
- completion_data=$(lanonasis --completion-data 2>/dev/null || echo '{}')
13
-
14
- case "${COMP_CWORD}" in
15
- 1)
16
- # Main commands
17
- local commands=$(echo "$completion_data" | jq -r '.commands[]?.name // empty' 2>/dev/null)
18
- if [[ -z "$commands" ]]; then
19
- commands="init login auth logout status health docs memory mem topic topics config org organization api-keys mcp dashboard documentation sdk api rest deploy deployment service services"
20
- fi
21
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
22
- ;;
23
- 2)
24
- # Subcommands based on main command
25
- case "${words[1]}" in
26
- auth|login)
27
- COMPREPLY=($(compgen -W "login logout status vendor-key oauth" -- "$cur"))
28
- ;;
29
- memory|mem)
30
- COMPREPLY=($(compgen -W "list create get update delete search stats bulk-delete export import" -- "$cur"))
31
- ;;
32
- topic|topics)
33
- COMPREPLY=($(compgen -W "list create get update delete" -- "$cur"))
34
- ;;
35
- config)
36
- COMPREPLY=($(compgen -W "get set list reset" -- "$cur"))
37
- ;;
38
- api-keys)
39
- COMPREPLY=($(compgen -W "list create revoke rotate" -- "$cur"))
40
- ;;
41
- mcp)
42
- COMPREPLY=($(compgen -W "status connect disconnect servers tools resources" -- "$cur"))
43
- ;;
44
- dashboard)
45
- COMPREPLY=($(compgen -W "status logs open" -- "$cur"))
46
- ;;
47
- deploy|deployment)
48
- COMPREPLY=($(compgen -W "status health list" -- "$cur"))
49
- ;;
50
- service|services)
51
- COMPREPLY=($(compgen -W "list status restart logs" -- "$cur"))
52
- ;;
53
- esac
54
- ;;
55
- *)
56
- # Options and flags
57
- case "${prev}" in
58
- --memory-type)
59
- COMPREPLY=($(compgen -W "context project knowledge reference personal workflow" -- "$cur"))
60
- ;;
61
- --output)
62
- COMPREPLY=($(compgen -W "table json yaml csv" -- "$cur"))
63
- ;;
64
- --sort-by)
65
- COMPREPLY=($(compgen -W "created_at updated_at last_accessed access_count" -- "$cur"))
66
- ;;
67
- --sort-order)
68
- COMPREPLY=($(compgen -W "asc desc" -- "$cur"))
69
- ;;
70
- --api-url)
71
- COMPREPLY=($(compgen -W "https://api.lanonasis.com/api/v1" -- "$cur"))
72
- ;;
73
- esac
74
-
75
- # Global flags
76
- if [[ "$cur" == -* ]]; then
77
- local global_flags="--help --version --verbose --output --api-url --no-mcp"
78
- COMPREPLY=($(compgen -W "$global_flags" -- "$cur"))
79
- fi
80
- ;;
81
- esac
82
- }
83
-
84
- # Register completions for all command aliases
85
- complete -F _lanonasis_completions lanonasis
86
- complete -F _lanonasis_completions onasis
87
- complete -F _lanonasis_completions memory
88
- complete -F _lanonasis_completions maas
@@ -1,132 +0,0 @@
1
- # Lanonasis/Onasis CLI Fish Completion
2
- # Installation: Place in ~/.config/fish/completions/
3
-
4
- # Helper function to check if a command is being used
5
- function __fish_lanonasis_using_command
6
- set -l cmd (commandline -opc)
7
- if [ (count $cmd) -eq 2 ]
8
- if [ $argv[1] = $cmd[2] ]
9
- return 0
10
- end
11
- end
12
- return 1
13
- end
14
-
15
- function __fish_lanonasis_using_subcommand
16
- set -l cmd (commandline -opc)
17
- if [ (count $cmd) -eq 3 ]
18
- if [ $argv[1] = $cmd[2] ]; and [ $argv[2] = $cmd[3] ]
19
- return 0
20
- end
21
- end
22
- return 1
23
- end
24
-
25
- # Global options
26
- complete -c lanonasis -s h -l help -d 'Show help information'
27
- complete -c lanonasis -s v -l version -d 'Show version information'
28
- complete -c lanonasis -s V -l verbose -d 'Enable verbose logging'
29
- complete -c lanonasis -l output -d 'Output format' -xa 'table json yaml csv'
30
- complete -c lanonasis -l api-url -d 'Override API URL'
31
- complete -c lanonasis -l no-mcp -d 'Disable MCP and use direct API'
32
-
33
- # Main commands
34
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'init' -d 'Initialize CLI configuration'
35
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'login' -d 'Authenticate with your account'
36
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'auth' -d 'Authentication commands'
37
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'logout' -d 'Logout from your account'
38
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'status' -d 'Show system status'
39
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'health' -d 'Comprehensive health check'
40
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'docs' -d 'Open documentation'
41
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'memory' -d 'Memory management commands'
42
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'mem' -d 'Memory management (alias)'
43
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'topic' -d 'Topic management commands'
44
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'topics' -d 'Topic management (alias)'
45
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'config' -d 'Configuration management'
46
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'org' -d 'Organization management'
47
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'organization' -d 'Organization management (alias)'
48
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'api-keys' -d 'API key management'
49
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'mcp' -d 'Model Context Protocol commands'
50
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'dashboard' -d 'Dashboard management'
51
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'documentation' -d 'Documentation management'
52
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'sdk' -d 'SDK management'
53
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'api' -d 'REST API management'
54
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'rest' -d 'REST API management (alias)'
55
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'deploy' -d 'Deployment management'
56
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'deployment' -d 'Deployment management (alias)'
57
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'service' -d 'Service management'
58
- complete -c lanonasis -f -n '__fish_use_subcommand' -a 'services' -d 'Service management (alias)'
59
-
60
- # Auth subcommands
61
- complete -c lanonasis -f -n '__fish_lanonasis_using_command auth' -a 'login' -d 'Login to your account'
62
- complete -c lanonasis -f -n '__fish_lanonasis_using_command auth' -a 'logout' -d 'Logout from your account'
63
- complete -c lanonasis -f -n '__fish_lanonasis_using_command auth' -a 'status' -d 'Show authentication status'
64
- complete -c lanonasis -f -n '__fish_lanonasis_using_command auth' -a 'vendor-key' -d 'Authenticate with vendor key'
65
- complete -c lanonasis -f -n '__fish_lanonasis_using_command auth' -a 'oauth' -d 'Browser-based OAuth authentication'
66
-
67
- # Memory subcommands
68
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'list' -d 'List memories'
69
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'create' -d 'Create a new memory'
70
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'get' -d 'Get a specific memory'
71
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'update' -d 'Update an existing memory'
72
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'delete' -d 'Delete a memory'
73
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'search' -d 'Search memories'
74
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'stats' -d 'Show memory statistics'
75
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'bulk-delete' -d 'Delete multiple memories'
76
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'export' -d 'Export memories'
77
- complete -c lanonasis -f -n '__fish_lanonasis_using_command memory' -a 'import' -d 'Import memories'
78
-
79
- # Memory command options
80
- complete -c lanonasis -n '__fish_lanonasis_using_subcommand memory create' -l memory-type -xa 'context project knowledge reference personal workflow'
81
- complete -c lanonasis -n '__fish_lanonasis_using_subcommand memory update' -l memory-type -xa 'context project knowledge reference personal workflow'
82
- complete -c lanonasis -n '__fish_lanonasis_using_subcommand memory list' -l memory-type -xa 'context project knowledge reference personal workflow'
83
- complete -c lanonasis -n '__fish_lanonasis_using_subcommand memory list' -l sort-by -xa 'created_at updated_at last_accessed access_count'
84
- complete -c lanonasis -n '__fish_lanonasis_using_subcommand memory list' -l sort-order -xa 'asc desc'
85
-
86
- # Topic subcommands
87
- complete -c lanonasis -f -n '__fish_lanonasis_using_command topic' -a 'list' -d 'List topics'
88
- complete -c lanonasis -f -n '__fish_lanonasis_using_command topic' -a 'create' -d 'Create a new topic'
89
- complete -c lanonasis -f -n '__fish_lanonasis_using_command topic' -a 'get' -d 'Get a specific topic'
90
- complete -c lanonasis -f -n '__fish_lanonasis_using_command topic' -a 'update' -d 'Update an existing topic'
91
- complete -c lanonasis -f -n '__fish_lanonasis_using_command topic' -a 'delete' -d 'Delete a topic'
92
-
93
- # Config subcommands
94
- complete -c lanonasis -f -n '__fish_lanonasis_using_command config' -a 'get' -d 'Get configuration value'
95
- complete -c lanonasis -f -n '__fish_lanonasis_using_command config' -a 'set' -d 'Set configuration value'
96
- complete -c lanonasis -f -n '__fish_lanonasis_using_command config' -a 'list' -d 'List all configuration'
97
- complete -c lanonasis -f -n '__fish_lanonasis_using_command config' -a 'reset' -d 'Reset configuration'
98
-
99
- # API Keys subcommands
100
- complete -c lanonasis -f -n '__fish_lanonasis_using_command api-keys' -a 'list' -d 'List API keys'
101
- complete -c lanonasis -f -n '__fish_lanonasis_using_command api-keys' -a 'create' -d 'Create a new API key'
102
- complete -c lanonasis -f -n '__fish_lanonasis_using_command api-keys' -a 'revoke' -d 'Revoke an API key'
103
- complete -c lanonasis -f -n '__fish_lanonasis_using_command api-keys' -a 'rotate' -d 'Rotate an API key'
104
-
105
- # MCP subcommands
106
- complete -c lanonasis -f -n '__fish_lanonasis_using_command mcp' -a 'status' -d 'Show MCP server status'
107
- complete -c lanonasis -f -n '__fish_lanonasis_using_command mcp' -a 'connect' -d 'Connect to MCP server'
108
- complete -c lanonasis -f -n '__fish_lanonasis_using_command mcp' -a 'disconnect' -d 'Disconnect from MCP server'
109
- complete -c lanonasis -f -n '__fish_lanonasis_using_command mcp' -a 'servers' -d 'List MCP servers'
110
- complete -c lanonasis -f -n '__fish_lanonasis_using_command mcp' -a 'tools' -d 'List available tools'
111
- complete -c lanonasis -f -n '__fish_lanonasis_using_command mcp' -a 'resources' -d 'List available resources'
112
-
113
- # Dashboard subcommands
114
- complete -c lanonasis -f -n '__fish_lanonasis_using_command dashboard' -a 'status' -d 'Check dashboard status'
115
- complete -c lanonasis -f -n '__fish_lanonasis_using_command dashboard' -a 'logs' -d 'View dashboard logs'
116
- complete -c lanonasis -f -n '__fish_lanonasis_using_command dashboard' -a 'open' -d 'Open dashboard in browser'
117
-
118
- # Deploy subcommands
119
- complete -c lanonasis -f -n '__fish_lanonasis_using_command deploy' -a 'status' -d 'Show deployment status'
120
- complete -c lanonasis -f -n '__fish_lanonasis_using_command deploy' -a 'health' -d 'Check deployment health'
121
- complete -c lanonasis -f -n '__fish_lanonasis_using_command deploy' -a 'list' -d 'List deployments'
122
-
123
- # Service subcommands
124
- complete -c lanonasis -f -n '__fish_lanonasis_using_command service' -a 'list' -d 'List services'
125
- complete -c lanonasis -f -n '__fish_lanonasis_using_command service' -a 'status' -d 'Show service status'
126
- complete -c lanonasis -f -n '__fish_lanonasis_using_command service' -a 'restart' -d 'Restart a service'
127
- complete -c lanonasis -f -n '__fish_lanonasis_using_command service' -a 'logs' -d 'View service logs'
128
-
129
- # Apply same completions for all aliases
130
- complete -c onasis -w lanonasis
131
- complete -c memory -w lanonasis
132
- complete -c maas -w lanonasis
@@ -1,196 +0,0 @@
1
- #compdef lanonasis onasis memory maas
2
-
3
- # Lanonasis/Onasis CLI Zsh Completion
4
- # Installation: Place in your $fpath (e.g., ~/.zsh/completions/) and run 'compinit'
5
-
6
- _lanonasis() {
7
- local context curcontext="$curcontext" state line
8
- typeset -A opt_args
9
-
10
- _arguments -C \
11
- '1: :_lanonasis_commands' \
12
- '*:: :->args' \
13
- '--help[Show help information]' \
14
- '--version[Show version information]' \
15
- '--verbose[Enable verbose logging]' \
16
- '--output[Output format]:format:(table json yaml csv)' \
17
- '--api-url[Override API URL]:url:' \
18
- '--no-mcp[Disable MCP and use direct API]'
19
-
20
- case $state in
21
- args)
22
- case $words[1] in
23
- auth|login)
24
- _lanonasis_auth_commands
25
- ;;
26
- memory|mem)
27
- _lanonasis_memory_commands
28
- ;;
29
- topic|topics)
30
- _lanonasis_topic_commands
31
- ;;
32
- config)
33
- _lanonasis_config_commands
34
- ;;
35
- api-keys)
36
- _lanonasis_apikeys_commands
37
- ;;
38
- mcp)
39
- _lanonasis_mcp_commands
40
- ;;
41
- dashboard)
42
- _lanonasis_dashboard_commands
43
- ;;
44
- deploy|deployment)
45
- _lanonasis_deploy_commands
46
- ;;
47
- service|services)
48
- _lanonasis_service_commands
49
- ;;
50
- esac
51
- ;;
52
- esac
53
- }
54
-
55
- _lanonasis_commands() {
56
- local commands; commands=(
57
- 'init:Initialize CLI configuration'
58
- 'login:Authenticate with your account'
59
- 'auth:Authentication commands'
60
- 'logout:Logout from your account'
61
- 'status:Show system status'
62
- 'health:Comprehensive health check'
63
- 'docs:Open documentation'
64
- 'memory:Memory management commands'
65
- 'mem:Memory management (alias)'
66
- 'topic:Topic management commands'
67
- 'topics:Topic management (alias)'
68
- 'config:Configuration management'
69
- 'org:Organization management'
70
- 'organization:Organization management (alias)'
71
- 'api-keys:API key management'
72
- 'mcp:Model Context Protocol commands'
73
- 'dashboard:Dashboard management'
74
- 'documentation:Documentation management'
75
- 'sdk:SDK management'
76
- 'api:REST API management'
77
- 'rest:REST API management (alias)'
78
- 'deploy:Deployment management'
79
- 'deployment:Deployment management (alias)'
80
- 'service:Service management'
81
- 'services:Service management (alias)'
82
- )
83
- _describe 'commands' commands
84
- }
85
-
86
- _lanonasis_auth_commands() {
87
- local subcommands; subcommands=(
88
- 'login:Login to your account'
89
- 'logout:Logout from your account'
90
- 'status:Show authentication status'
91
- 'vendor-key:Authenticate with vendor key'
92
- 'oauth:Browser-based OAuth authentication'
93
- )
94
- _describe 'auth commands' subcommands
95
- }
96
-
97
- _lanonasis_memory_commands() {
98
- local subcommands; subcommands=(
99
- 'list:List memories'
100
- 'create:Create a new memory'
101
- 'get:Get a specific memory'
102
- 'update:Update an existing memory'
103
- 'delete:Delete a memory'
104
- 'search:Search memories'
105
- 'stats:Show memory statistics'
106
- 'bulk-delete:Delete multiple memories'
107
- 'export:Export memories'
108
- 'import:Import memories'
109
- )
110
- _describe 'memory commands' subcommands
111
-
112
- # Add memory type completion for relevant commands
113
- if [[ "$words[2]" == "create" || "$words[2]" == "update" || "$words[2]" == "list" ]]; then
114
- _arguments \
115
- '--memory-type[Memory type]:type:(context project knowledge reference personal workflow)' \
116
- '--tags[Tags]:tags:' \
117
- '--topic-id[Topic ID]:topic:'
118
- fi
119
- }
120
-
121
- _lanonasis_topic_commands() {
122
- local subcommands; subcommands=(
123
- 'list:List topics'
124
- 'create:Create a new topic'
125
- 'get:Get a specific topic'
126
- 'update:Update an existing topic'
127
- 'delete:Delete a topic'
128
- )
129
- _describe 'topic commands' subcommands
130
- }
131
-
132
- _lanonasis_config_commands() {
133
- local subcommands; subcommands=(
134
- 'get:Get configuration value'
135
- 'set:Set configuration value'
136
- 'list:List all configuration'
137
- 'reset:Reset configuration'
138
- )
139
- _describe 'config commands' subcommands
140
- }
141
-
142
- _lanonasis_apikeys_commands() {
143
- local subcommands; subcommands=(
144
- 'list:List API keys'
145
- 'create:Create a new API key'
146
- 'revoke:Revoke an API key'
147
- 'rotate:Rotate an API key'
148
- )
149
- _describe 'api-keys commands' subcommands
150
- }
151
-
152
- _lanonasis_mcp_commands() {
153
- local subcommands; subcommands=(
154
- 'status:Show MCP server status'
155
- 'connect:Connect to MCP server'
156
- 'disconnect:Disconnect from MCP server'
157
- 'servers:List MCP servers'
158
- 'tools:List available tools'
159
- 'resources:List available resources'
160
- )
161
- _describe 'mcp commands' subcommands
162
- }
163
-
164
- _lanonasis_dashboard_commands() {
165
- local subcommands; subcommands=(
166
- 'status:Check dashboard status'
167
- 'logs:View dashboard logs'
168
- 'open:Open dashboard in browser'
169
- )
170
- _describe 'dashboard commands' subcommands
171
- }
172
-
173
- _lanonasis_deploy_commands() {
174
- local subcommands; subcommands=(
175
- 'status:Show deployment status'
176
- 'health:Check deployment health'
177
- 'list:List deployments'
178
- )
179
- _describe 'deploy commands' subcommands
180
- }
181
-
182
- _lanonasis_service_commands() {
183
- local subcommands; subcommands=(
184
- 'list:List services'
185
- 'status:Show service status'
186
- 'restart:Restart a service'
187
- 'logs:View service logs'
188
- )
189
- _describe 'service commands' subcommands
190
- }
191
-
192
- # Initialize completion for all aliases
193
- compdef _lanonasis lanonasis
194
- compdef _lanonasis onasis
195
- compdef _lanonasis memory
196
- compdef _lanonasis maas