@lanonasis/cli 1.5.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils/api.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import axios from 'axios';
2
2
  import chalk from 'chalk';
3
+ import { randomUUID } from 'crypto';
3
4
  import { CLIConfig } from './config.js';
4
5
  export class APIClient {
5
6
  client;
@@ -7,16 +8,32 @@ export class APIClient {
7
8
  constructor() {
8
9
  this.config = new CLIConfig();
9
10
  this.client = axios.create();
10
- // Setup request interceptor to add auth token
11
+ // Setup request interceptor to add auth token and headers
11
12
  this.client.interceptors.request.use(async (config) => {
12
13
  await this.config.init();
14
+ // Service Discovery
15
+ await this.config.discoverServices();
16
+ config.baseURL = this.config.getDiscoveredApiUrl();
17
+ // Enhanced Authentication Support
13
18
  const token = this.config.getToken();
14
- if (token) {
19
+ const vendorKey = this.config.getVendorKey();
20
+ if (vendorKey) {
21
+ // Vendor key authentication (pk_*.sk_* format)
22
+ config.headers['X-API-Key'] = vendorKey;
23
+ config.headers['X-Auth-Method'] = 'vendor_key';
24
+ }
25
+ else if (token) {
26
+ // JWT token authentication
15
27
  config.headers.Authorization = `Bearer ${token}`;
28
+ config.headers['X-Auth-Method'] = 'jwt';
16
29
  }
17
- config.baseURL = this.config.getApiUrl();
30
+ // Add request ID for correlation
31
+ const requestId = randomUUID();
32
+ config.headers['X-Request-ID'] = requestId;
33
+ // Add project scope for Golden Contract compliance
34
+ config.headers['X-Project-Scope'] = 'lanonasis-maas';
18
35
  if (process.env.CLI_VERBOSE === 'true') {
19
- console.log(chalk.dim(`→ ${config.method?.toUpperCase()} ${config.url}`));
36
+ console.log(chalk.dim(`→ ${config.method?.toUpperCase()} ${config.url} [${requestId}]`));
20
37
  }
21
38
  return config;
22
39
  });
@@ -13,6 +13,11 @@ export declare class CLIConfig {
13
13
  load(): Promise<void>;
14
14
  save(): Promise<void>;
15
15
  getApiUrl(): string;
16
+ discoverServices(): Promise<void>;
17
+ getDiscoveredApiUrl(): string;
18
+ setVendorKey(vendorKey: string): Promise<void>;
19
+ getVendorKey(): string | undefined;
20
+ hasVendorKey(): boolean;
16
21
  setApiUrl(url: string): Promise<void>;
17
22
  setToken(token: string): Promise<void>;
18
23
  getToken(): string | undefined;
@@ -39,7 +39,42 @@ export class CLIConfig {
39
39
  getApiUrl() {
40
40
  return process.env.MEMORY_API_URL ||
41
41
  this.config.apiUrl ||
42
- 'https://api.lanonasis.com';
42
+ 'https://api.lanonasis.com/api/v1';
43
+ }
44
+ // Service Discovery Integration
45
+ async discoverServices() {
46
+ try {
47
+ // Use axios instead of fetch for consistency
48
+ const axios = (await import('axios')).default;
49
+ const discoveryUrl = 'https://api.lanonasis.com/.well-known/onasis.json';
50
+ const response = await axios.get(discoveryUrl);
51
+ this.config.discoveredServices = response.data;
52
+ await this.save();
53
+ }
54
+ catch (error) {
55
+ // Service discovery failed, use defaults
56
+ if (process.env.CLI_VERBOSE === 'true') {
57
+ console.log('Service discovery failed, using defaults');
58
+ }
59
+ }
60
+ }
61
+ getDiscoveredApiUrl() {
62
+ return this.config.discoveredServices?.auth_base || this.getApiUrl();
63
+ }
64
+ // Enhanced authentication support
65
+ async setVendorKey(vendorKey) {
66
+ // Validate vendor key format (pk_*.sk_*)
67
+ if (!vendorKey.match(/^pk_[a-zA-Z0-9]+\.sk_[a-zA-Z0-9]+$/)) {
68
+ throw new Error('Invalid vendor key format. Expected: pk_xxx.sk_xxx');
69
+ }
70
+ this.config.vendorKey = vendorKey;
71
+ await this.save();
72
+ }
73
+ getVendorKey() {
74
+ return this.config.vendorKey;
75
+ }
76
+ hasVendorKey() {
77
+ return !!this.config.vendorKey;
43
78
  }
44
79
  async setApiUrl(url) {
45
80
  this.config.apiUrl = url;
@@ -120,7 +155,9 @@ export class CLIConfig {
120
155
  return this.config.mcpServerPath || path.join(__dirname, '../../../../onasis-gateway/mcp-server/server.js');
121
156
  }
122
157
  getMCPServerUrl() {
123
- return this.config.mcpServerUrl || 'https://dashboard.lanonasis.com';
158
+ return this.config.discoveredServices?.mcp_ws_base ||
159
+ this.config.mcpServerUrl ||
160
+ 'https://api.lanonasis.com';
124
161
  }
125
162
  shouldUseRemoteMCP() {
126
163
  const preference = this.config.mcpPreference || 'auto';
@@ -66,9 +66,7 @@ export class MCPClient {
66
66
  });
67
67
  this.client = new Client({
68
68
  name: '@lanonasis/cli',
69
- version: '1.0.0'
70
- }, {
71
- capabilities: {}
69
+ version: '2.0.0'
72
70
  });
73
71
  await this.client.connect(localTransport);
74
72
  }
package/package.json CHANGED
@@ -1,22 +1,25 @@
1
1
  {
2
2
  "name": "@lanonasis/cli",
3
- "version": "1.5.1",
3
+ "version": "2.0.0",
4
4
  "description": "LanOnasis Enterprise CLI - Memory as a Service, API Key Management, and Infrastructure Orchestration",
5
5
  "main": "dist/index-simple.js",
6
6
  "bin": {
7
7
  "lanonasis": "dist/index-simple.js",
8
+ "onasis": "dist/index-simple.js",
8
9
  "lanonasis-mcp-server": "dist/mcp-server.js",
10
+ "lanonasis-mcp-cli-aligned": "dist/mcp-server.js",
9
11
  "memory": "dist/index-simple.js",
10
12
  "maas": "dist/index-simple.js"
11
13
  },
12
14
  "type": "module",
13
15
  "scripts": {
14
16
  "dev": "tsx src/index.ts",
15
- "build": "tsc && chmod +x dist/index-simple.js",
17
+ "build": "tsc && chmod +x dist/index-simple.js && chmod +x dist/mcp-server.js && cp -r src/completions dist/",
16
18
  "start": "node dist/index.js",
17
19
  "test": "jest",
18
20
  "lint": "eslint src/**/*.ts",
19
- "type-check": "tsc --noEmit"
21
+ "type-check": "tsc --noEmit",
22
+ "prepare": "npm run build"
20
23
  },
21
24
  "keywords": [
22
25
  "lanonasis",
@@ -39,17 +42,19 @@
39
42
  "README.md"
40
43
  ],
41
44
  "dependencies": {
42
- "@modelcontextprotocol/sdk": "^1.17.0",
45
+ "@modelcontextprotocol/sdk": "^1.17.2",
43
46
  "@types/eventsource": "^1.1.15",
44
47
  "@types/ws": "^8.18.1",
45
48
  "axios": "^1.11.0",
46
- "chalk": "^5.4.1",
49
+ "boxen": "^7.1.1",
50
+ "chalk": "^5.5.0",
51
+ "cli-progress": "^3.12.0",
47
52
  "cli-table3": "^0.6.5",
48
53
  "commander": "^12.1.0",
49
54
  "date-fns": "^4.1.0",
50
55
  "dotenv": "^17.2.1",
51
56
  "eventsource": "^4.0.0",
52
- "inquirer": "^12.9.0",
57
+ "inquirer": "^12.9.1",
53
58
  "jwt-decode": "^4.0.0",
54
59
  "open": "^10.2.0",
55
60
  "ora": "^8.2.0",