@lanonasis/cli 1.5.1 → 1.5.2
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/README.md +292 -317
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +140 -1
- package/dist/commands/completion.d.ts +33 -0
- package/dist/commands/completion.js +378 -0
- package/dist/commands/guide.d.ts +19 -0
- package/dist/commands/guide.js +446 -0
- package/dist/completions/bash-completion.sh +88 -0
- package/dist/completions/fish-completion.fish +132 -0
- package/dist/completions/zsh-completion.zsh +196 -0
- package/dist/index-simple.js +128 -11
- package/dist/mcp-server.d.ts +37 -1
- package/dist/mcp-server.js +142 -507
- package/dist/utils/api.js +21 -4
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/config.js +39 -2
- package/dist/utils/mcp-client.js +1 -3
- package/package.json +7 -4
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
|
-
|
|
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
|
-
|
|
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
|
});
|
package/dist/utils/config.d.ts
CHANGED
|
@@ -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;
|
package/dist/utils/config.js
CHANGED
|
@@ -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.
|
|
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';
|
package/dist/utils/mcp-client.js
CHANGED
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lanonasis/cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
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,7 +42,7 @@
|
|
|
39
42
|
"README.md"
|
|
40
43
|
],
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@modelcontextprotocol/sdk": "^1.17.
|
|
45
|
+
"@modelcontextprotocol/sdk": "^1.17.1",
|
|
43
46
|
"@types/eventsource": "^1.1.15",
|
|
44
47
|
"@types/ws": "^8.18.1",
|
|
45
48
|
"axios": "^1.11.0",
|