@172ai/containers-mcp-server 1.12.2 → 1.12.4
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/auth.d.ts +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +26 -33
- package/dist/auth.js.map +1 -1
- package/dist/cli-tool.js +67 -105
- package/dist/cli-tool.js.map +1 -1
- package/dist/cli.js +4 -37
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -42
- package/dist/config.js.map +1 -1
- package/dist/scripts/test-mcp-tools.js +9 -12
- package/dist/scripts/test-mcp-tools.js.map +1 -1
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +727 -87
- package/dist/server.js.map +1 -1
- package/dist/services/buildService.d.ts +1 -1
- package/dist/services/buildService.d.ts.map +1 -1
- package/dist/services/buildService.js +37 -41
- package/dist/services/buildService.js.map +1 -1
- package/dist/services/capabilityService.d.ts +1 -1
- package/dist/services/capabilityService.d.ts.map +1 -1
- package/dist/services/capabilityService.js +32 -36
- package/dist/services/capabilityService.js.map +1 -1
- package/dist/services/containerService.d.ts +1 -1
- package/dist/services/containerService.d.ts.map +1 -1
- package/dist/services/containerService.js +47 -51
- package/dist/services/containerService.js.map +1 -1
- package/dist/services/executionService.d.ts +1 -1
- package/dist/services/executionService.d.ts.map +1 -1
- package/dist/services/executionService.js +48 -52
- package/dist/services/executionService.js.map +1 -1
- package/dist/services/exportService.d.ts +108 -0
- package/dist/services/exportService.d.ts.map +1 -0
- package/dist/services/exportService.js +659 -0
- package/dist/services/exportService.js.map +1 -0
- package/dist/services/fileService.d.ts +1 -1
- package/dist/services/fileService.d.ts.map +1 -1
- package/dist/services/fileService.js +73 -77
- package/dist/services/fileService.js.map +1 -1
- package/dist/services/importService.d.ts +90 -0
- package/dist/services/importService.d.ts.map +1 -0
- package/dist/services/importService.js +570 -0
- package/dist/services/importService.js.map +1 -0
- package/dist/services/streamingService.js +16 -23
- package/dist/services/streamingService.js.map +1 -1
- package/dist/services/userNotificationManager.d.ts +22 -4
- package/dist/services/userNotificationManager.d.ts.map +1 -1
- package/dist/services/userNotificationManager.js +59 -19
- package/dist/services/userNotificationManager.js.map +1 -1
- package/dist/services/userService.d.ts +1 -5
- package/dist/services/userService.d.ts.map +1 -1
- package/dist/services/userService.js +19 -43
- package/dist/services/userService.js.map +1 -1
- package/dist/setup.js +28 -67
- package/dist/setup.js.map +1 -1
- package/dist/types.d.ts +121 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/types.js.map +1 -1
- package/dist/utils/enhancedErrorHandler.d.ts +1 -1
- package/dist/utils/enhancedErrorHandler.d.ts.map +1 -1
- package/dist/utils/enhancedErrorHandler.js +47 -52
- package/dist/utils/enhancedErrorHandler.js.map +1 -1
- package/dist/utils/errorHandler.d.ts +1 -1
- package/dist/utils/errorHandler.d.ts.map +1 -1
- package/dist/utils/errorHandler.js +15 -20
- package/dist/utils/errorHandler.js.map +1 -1
- package/dist/utils/logBuffer.js +2 -6
- package/dist/utils/logBuffer.js.map +1 -1
- package/dist/utils/retryHandler.js +7 -13
- package/dist/utils/retryHandler.js.map +1 -1
- package/package.json +2 -1
package/dist/auth.d.ts
CHANGED
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAqB,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAqB,UAAU,EAAE,MAAM,YAAY,CAAC;AAI3D;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,WAAW,CAAC,CAAO;;IAwC3B;;OAEG;YACW,aAAa;IAqC3B;;OAEG;YACW,aAAa;IA2B3B;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB;;OAEG;IACH,aAAa,IAAI,aAAa;IAI9B;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAY5C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IASzC;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAgBzD;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAY3C;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;OAEG;IACH,aAAa,IAAI;QACf,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,oBAAoB,GAAG,MAAM,CAAC;QAClE,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,IAAI,CAAC;KAClB;CAiBF;AAGD,eAAO,MAAM,WAAW,aAAoB,CAAC"}
|
package/dist/auth.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.authManager = exports.AuthManager = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const config_1 = require("./config");
|
|
9
|
-
const errorHandler_1 = require("./utils/errorHandler");
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { config } from './config.js';
|
|
3
|
+
import { ErrorHandler, ApiError } from './utils/errorHandler.js';
|
|
10
4
|
/**
|
|
11
5
|
* Authentication manager for the MCP server
|
|
12
6
|
*/
|
|
13
|
-
class AuthManager {
|
|
7
|
+
export class AuthManager {
|
|
14
8
|
constructor() {
|
|
15
|
-
this.httpClient =
|
|
16
|
-
baseURL:
|
|
17
|
-
timeout:
|
|
9
|
+
this.httpClient = axios.create({
|
|
10
|
+
baseURL: config.get('baseUrl'),
|
|
11
|
+
timeout: config.getTimeoutConfig().request,
|
|
18
12
|
headers: {
|
|
19
13
|
'Content-Type': 'application/json',
|
|
20
14
|
'User-Agent': '@172ai/containers-mcp-server/1.0.0'
|
|
@@ -30,18 +24,18 @@ class AuthManager {
|
|
|
30
24
|
}, (error) => Promise.reject(error));
|
|
31
25
|
// Add response interceptor for error handling
|
|
32
26
|
this.httpClient.interceptors.response.use((response) => response, (error) => {
|
|
33
|
-
const processedError =
|
|
34
|
-
|
|
35
|
-
return Promise.reject(new
|
|
27
|
+
const processedError = ErrorHandler.processError(error, 'AuthManager');
|
|
28
|
+
ErrorHandler.logError(processedError);
|
|
29
|
+
return Promise.reject(new ApiError(processedError.message, processedError.status, processedError.code, processedError.details));
|
|
36
30
|
});
|
|
37
31
|
}
|
|
38
32
|
/**
|
|
39
33
|
* Get a valid authentication token
|
|
40
34
|
*/
|
|
41
35
|
async getValidToken() {
|
|
42
|
-
const authConfig =
|
|
36
|
+
const authConfig = config.getAuthConfig();
|
|
43
37
|
// Debug logging for authentication
|
|
44
|
-
if (
|
|
38
|
+
if (config.isDevelopment()) {
|
|
45
39
|
console.log('[AuthManager] Getting valid token...');
|
|
46
40
|
console.log('[AuthManager] API key available:', !!authConfig.apiKey);
|
|
47
41
|
console.log('[AuthManager] OAuth token available:', !!authConfig.oauthToken);
|
|
@@ -49,7 +43,7 @@ class AuthManager {
|
|
|
49
43
|
}
|
|
50
44
|
// Use API key if available (preferred method)
|
|
51
45
|
if (authConfig.apiKey) {
|
|
52
|
-
if (
|
|
46
|
+
if (config.isDevelopment()) {
|
|
53
47
|
console.log('[AuthManager] Using API key for authentication');
|
|
54
48
|
}
|
|
55
49
|
return authConfig.apiKey;
|
|
@@ -65,17 +59,17 @@ class AuthManager {
|
|
|
65
59
|
return token;
|
|
66
60
|
}
|
|
67
61
|
catch (error) {
|
|
68
|
-
throw
|
|
62
|
+
throw ErrorHandler.createAuthError('Failed to obtain OAuth token', { error: error.message });
|
|
69
63
|
}
|
|
70
64
|
}
|
|
71
|
-
throw
|
|
65
|
+
throw ErrorHandler.createAuthError('No valid authentication method configured');
|
|
72
66
|
}
|
|
73
67
|
/**
|
|
74
68
|
* Get OAuth token using client credentials flow
|
|
75
69
|
*/
|
|
76
70
|
async getOAuthToken(clientId, clientSecret) {
|
|
77
71
|
try {
|
|
78
|
-
const response = await
|
|
72
|
+
const response = await axios.post(`${config.get('baseUrl')}/oauth/token`, {
|
|
79
73
|
grant_type: 'client_credentials',
|
|
80
74
|
client_id: clientId,
|
|
81
75
|
client_secret: clientSecret,
|
|
@@ -84,7 +78,7 @@ class AuthManager {
|
|
|
84
78
|
headers: {
|
|
85
79
|
'Content-Type': 'application/json'
|
|
86
80
|
},
|
|
87
|
-
timeout:
|
|
81
|
+
timeout: config.getTimeoutConfig().request
|
|
88
82
|
});
|
|
89
83
|
const tokenData = response.data;
|
|
90
84
|
this.currentToken = tokenData.access_token;
|
|
@@ -92,7 +86,7 @@ class AuthManager {
|
|
|
92
86
|
return tokenData.access_token;
|
|
93
87
|
}
|
|
94
88
|
catch (error) {
|
|
95
|
-
throw
|
|
89
|
+
throw ErrorHandler.createAuthError('OAuth token request failed', {
|
|
96
90
|
clientId,
|
|
97
91
|
error: error.response?.data || error.message
|
|
98
92
|
});
|
|
@@ -124,7 +118,7 @@ class AuthManager {
|
|
|
124
118
|
return response.status === 200;
|
|
125
119
|
}
|
|
126
120
|
catch (error) {
|
|
127
|
-
if (error instanceof
|
|
121
|
+
if (error instanceof ApiError && (error.status === 401 || error.status === 403)) {
|
|
128
122
|
return false;
|
|
129
123
|
}
|
|
130
124
|
throw error;
|
|
@@ -139,7 +133,7 @@ class AuthManager {
|
|
|
139
133
|
return response.data;
|
|
140
134
|
}
|
|
141
135
|
catch (error) {
|
|
142
|
-
throw
|
|
136
|
+
throw ErrorHandler.createAuthError('Failed to retrieve API keys', { error: error.message });
|
|
143
137
|
}
|
|
144
138
|
}
|
|
145
139
|
/**
|
|
@@ -147,24 +141,24 @@ class AuthManager {
|
|
|
147
141
|
*/
|
|
148
142
|
async validateApiKey(apiKey) {
|
|
149
143
|
try {
|
|
150
|
-
const response = await
|
|
144
|
+
const response = await axios.get(`${config.get('baseUrl')}/v1/auth/validate`, {
|
|
151
145
|
headers: {
|
|
152
146
|
'Authorization': `Bearer ${apiKey}`,
|
|
153
147
|
'Content-Type': 'application/json'
|
|
154
148
|
},
|
|
155
|
-
timeout:
|
|
149
|
+
timeout: config.getTimeoutConfig().request
|
|
156
150
|
});
|
|
157
151
|
return response.data;
|
|
158
152
|
}
|
|
159
153
|
catch (error) {
|
|
160
|
-
throw
|
|
154
|
+
throw ErrorHandler.createAuthError('API key validation failed', { error: error.message });
|
|
161
155
|
}
|
|
162
156
|
}
|
|
163
157
|
/**
|
|
164
158
|
* Refresh OAuth token if needed
|
|
165
159
|
*/
|
|
166
160
|
async refreshTokenIfNeeded() {
|
|
167
|
-
const authConfig =
|
|
161
|
+
const authConfig = config.getAuthConfig();
|
|
168
162
|
if (!authConfig.clientId || !authConfig.clientSecret) {
|
|
169
163
|
return; // Cannot refresh without client credentials
|
|
170
164
|
}
|
|
@@ -183,7 +177,7 @@ class AuthManager {
|
|
|
183
177
|
* Get authentication status
|
|
184
178
|
*/
|
|
185
179
|
getAuthStatus() {
|
|
186
|
-
const authConfig =
|
|
180
|
+
const authConfig = config.getAuthConfig();
|
|
187
181
|
if (authConfig.apiKey) {
|
|
188
182
|
return { method: 'api_key', isValid: true };
|
|
189
183
|
}
|
|
@@ -196,7 +190,6 @@ class AuthManager {
|
|
|
196
190
|
return { method: 'none', isValid: false };
|
|
197
191
|
}
|
|
198
192
|
}
|
|
199
|
-
exports.AuthManager = AuthManager;
|
|
200
193
|
// Export singleton instance
|
|
201
|
-
|
|
194
|
+
export const authManager = new AuthManager();
|
|
202
195
|
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,WAAW;IAKtB;QACE,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;YAC7B,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;YAC9B,OAAO,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,OAAO;YAC1C,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,YAAY,EAAE,oCAAoC;aACnD;SACF,CAAC,CAAC;QAEH,mCAAmC;QACnC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CACtC,KAAK,EAAE,MAAM,EAAE,EAAE;YACf,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YACzC,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAC;YACnD,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CACjC,CAAC;QAEF,8CAA8C;QAC9C,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CACvC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EACtB,CAAC,KAAK,EAA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aAAa,EAAE,CAAC;QAE1C,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC9C,CAAC;QAED,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;YAC1B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9F,CAAC;QAED,IAAI,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;YACnD,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QACrG,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
|
package/dist/cli-tool.js
CHANGED
|
@@ -1,46 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
/**
|
|
4
3
|
* 172.ai Container CLI Tool
|
|
5
4
|
* Command line interface that reuses MCP service code for container operations
|
|
6
5
|
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
6
|
// Check for commands that don't require config before importing anything
|
|
45
7
|
const requiresSetup = !process.argv.includes('--help') &&
|
|
46
8
|
!process.argv.includes('-h') &&
|
|
@@ -48,11 +10,11 @@ const requiresSetup = !process.argv.includes('--help') &&
|
|
|
48
10
|
!process.argv.includes('setup') &&
|
|
49
11
|
!process.argv.includes('--version') &&
|
|
50
12
|
process.argv.length > 2;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const program = new
|
|
55
|
-
const spinner = (
|
|
13
|
+
import { Command } from 'commander';
|
|
14
|
+
import chalk from 'chalk';
|
|
15
|
+
import ora from 'ora';
|
|
16
|
+
const program = new Command();
|
|
17
|
+
const spinner = ora();
|
|
56
18
|
// Lazy load services only when needed
|
|
57
19
|
let containerService;
|
|
58
20
|
let buildService;
|
|
@@ -67,14 +29,14 @@ const loadServices = async () => {
|
|
|
67
29
|
return; // Already loaded
|
|
68
30
|
try {
|
|
69
31
|
const services = await Promise.all([
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
32
|
+
import('./services/containerService'),
|
|
33
|
+
import('./services/buildService'),
|
|
34
|
+
import('./services/fileService'),
|
|
35
|
+
import('./services/capabilityService'),
|
|
36
|
+
import('./services/userService'),
|
|
37
|
+
import('./auth'),
|
|
38
|
+
import('./config'),
|
|
39
|
+
import('./utils/errorHandler')
|
|
78
40
|
]);
|
|
79
41
|
containerService = services[0].containerService;
|
|
80
42
|
buildService = services[1].buildService;
|
|
@@ -87,8 +49,8 @@ const loadServices = async () => {
|
|
|
87
49
|
}
|
|
88
50
|
catch (error) {
|
|
89
51
|
if (error.message.includes('Authentication configuration required')) {
|
|
90
|
-
console.error(
|
|
91
|
-
console.error(
|
|
52
|
+
console.error(chalk.red('Configuration required. Please run:'));
|
|
53
|
+
console.error(chalk.yellow('containers-cli setup'));
|
|
92
54
|
process.exit(1);
|
|
93
55
|
}
|
|
94
56
|
throw error;
|
|
@@ -125,12 +87,12 @@ const formatTimestamp = (timestamp) => {
|
|
|
125
87
|
};
|
|
126
88
|
const formatContainer = (container) => {
|
|
127
89
|
return `
|
|
128
|
-
${
|
|
129
|
-
${
|
|
130
|
-
${
|
|
131
|
-
${
|
|
132
|
-
${
|
|
133
|
-
${
|
|
90
|
+
${chalk.bold.blue(container.name)} (${container.id})
|
|
91
|
+
${chalk.gray('Description:')} ${container.description}
|
|
92
|
+
${chalk.gray('Private:')} ${container.isPrivate ? chalk.red('Yes') : chalk.green('No')}
|
|
93
|
+
${chalk.gray('Tags:')} ${container.tags?.join(', ') || 'None'}
|
|
94
|
+
${chalk.gray('Created:')} ${formatTimestamp(container.createdAt)}
|
|
95
|
+
${chalk.gray('URL:')} ${container.url || 'N/A'}`;
|
|
134
96
|
};
|
|
135
97
|
const formatFileSize = (bytes) => {
|
|
136
98
|
if (bytes === 0)
|
|
@@ -144,9 +106,9 @@ const formatFileSize = (bytes) => {
|
|
|
144
106
|
const handleError = (error) => {
|
|
145
107
|
spinner.stop();
|
|
146
108
|
const processedError = ErrorHandler.processError(error, 'CLI');
|
|
147
|
-
console.error(
|
|
109
|
+
console.error(chalk.red('Error:'), processedError.message);
|
|
148
110
|
if (config.isDevelopment()) {
|
|
149
|
-
console.error(
|
|
111
|
+
console.error(chalk.gray('Details:'), processedError.details);
|
|
150
112
|
}
|
|
151
113
|
process.exit(1);
|
|
152
114
|
};
|
|
@@ -157,8 +119,8 @@ const withAuth = (fn) => {
|
|
|
157
119
|
await loadServices();
|
|
158
120
|
const isAuthenticated = await authManager.testAuthentication();
|
|
159
121
|
if (!isAuthenticated) {
|
|
160
|
-
console.error(
|
|
161
|
-
console.error(
|
|
122
|
+
console.error(chalk.red('Authentication failed. Please check your credentials.'));
|
|
123
|
+
console.error(chalk.yellow('Run with --setup to configure authentication.'));
|
|
162
124
|
process.exit(1);
|
|
163
125
|
}
|
|
164
126
|
return await fn(...args);
|
|
@@ -185,11 +147,11 @@ program
|
|
|
185
147
|
});
|
|
186
148
|
spinner.stop();
|
|
187
149
|
if (response.containers.length === 0) {
|
|
188
|
-
console.log(
|
|
150
|
+
console.log(chalk.yellow('No containers found.'));
|
|
189
151
|
return;
|
|
190
152
|
}
|
|
191
153
|
const limitedContainers = response.containers.slice(0, parseInt(options.limit));
|
|
192
|
-
console.log(
|
|
154
|
+
console.log(chalk.bold(`Found ${response.total} container(s), showing ${limitedContainers.length}:\n`));
|
|
193
155
|
limitedContainers.forEach((container, index) => {
|
|
194
156
|
console.log(`${index + 1}.${formatContainer(container)}\n`);
|
|
195
157
|
});
|
|
@@ -213,17 +175,17 @@ program
|
|
|
213
175
|
.option('-p, --private', 'Make container private', false)
|
|
214
176
|
.action(withAuth(async (options) => {
|
|
215
177
|
if (!options.name || !options.description || !options.dockerfile) {
|
|
216
|
-
console.error(
|
|
178
|
+
console.error(chalk.red('Name, description, and dockerfile are required.'));
|
|
217
179
|
console.error('Usage: create -n "My Container" -d "Description" -f ./Dockerfile');
|
|
218
180
|
process.exit(1);
|
|
219
181
|
}
|
|
220
182
|
let dockerfileContent;
|
|
221
183
|
try {
|
|
222
|
-
const fs = await
|
|
184
|
+
const fs = await import('fs/promises');
|
|
223
185
|
dockerfileContent = await fs.readFile(options.dockerfile, 'utf8');
|
|
224
186
|
}
|
|
225
187
|
catch (error) {
|
|
226
|
-
console.error(
|
|
188
|
+
console.error(chalk.red(`Failed to read Dockerfile: ${options.dockerfile}`));
|
|
227
189
|
process.exit(1);
|
|
228
190
|
}
|
|
229
191
|
spinner.start('Creating container...');
|
|
@@ -235,7 +197,7 @@ program
|
|
|
235
197
|
isPrivate: options.private
|
|
236
198
|
});
|
|
237
199
|
spinner.stop();
|
|
238
|
-
console.log(
|
|
200
|
+
console.log(chalk.green('Container created successfully!'));
|
|
239
201
|
console.log(formatContainer(container));
|
|
240
202
|
}));
|
|
241
203
|
program
|
|
@@ -244,7 +206,7 @@ program
|
|
|
244
206
|
.option('-y, --yes', 'Skip confirmation prompt')
|
|
245
207
|
.action(withAuth(async (containerId, options) => {
|
|
246
208
|
if (!options.yes) {
|
|
247
|
-
const { default: inquirer } = await
|
|
209
|
+
const { default: inquirer } = await import('inquirer');
|
|
248
210
|
const { confirm } = await inquirer.prompt([{
|
|
249
211
|
type: 'confirm',
|
|
250
212
|
name: 'confirm',
|
|
@@ -259,7 +221,7 @@ program
|
|
|
259
221
|
spinner.start('Deleting container...');
|
|
260
222
|
const result = await containerService.deleteContainer({ containerId });
|
|
261
223
|
spinner.stop();
|
|
262
|
-
console.log(
|
|
224
|
+
console.log(chalk.green(result.message));
|
|
263
225
|
}));
|
|
264
226
|
// Build Commands
|
|
265
227
|
program
|
|
@@ -270,44 +232,44 @@ program
|
|
|
270
232
|
spinner.start('Starting build...');
|
|
271
233
|
const buildResult = await buildService.buildContainer({ containerId });
|
|
272
234
|
spinner.stop();
|
|
273
|
-
console.log(
|
|
235
|
+
console.log(chalk.green('Build started successfully!'));
|
|
274
236
|
console.log(`Build ID: ${buildResult.id}`);
|
|
275
237
|
console.log(`Status: ${buildResult.status}`);
|
|
276
238
|
if (options.watch) {
|
|
277
|
-
console.log(
|
|
239
|
+
console.log(chalk.blue('\n🔍 Watching build progress...'));
|
|
278
240
|
let lastStatus = buildResult.status;
|
|
279
241
|
const pollInterval = 3000; // 3 seconds
|
|
280
242
|
const watchBuild = async () => {
|
|
281
243
|
try {
|
|
282
244
|
const status = await buildService.getBuildStatus({ containerId, buildId: buildResult.id });
|
|
283
245
|
if (status.status !== lastStatus) {
|
|
284
|
-
console.log(`Status changed: ${
|
|
246
|
+
console.log(`Status changed: ${chalk.yellow(lastStatus)} → ${status.status === 'completed' ? chalk.green(status.status) : status.status === 'failed' ? chalk.red(status.status) : chalk.yellow(status.status)}`);
|
|
285
247
|
lastStatus = status.status;
|
|
286
248
|
}
|
|
287
249
|
if (status.status === 'completed') {
|
|
288
|
-
console.log(
|
|
250
|
+
console.log(chalk.green('\n✅ Build completed successfully!'));
|
|
289
251
|
if (status.endTime) {
|
|
290
252
|
console.log(`Duration: ${formatTimestamp(status.startTime)} → ${formatTimestamp(status.endTime)}`);
|
|
291
253
|
}
|
|
292
254
|
return;
|
|
293
255
|
}
|
|
294
256
|
else if (status.status === 'failed') {
|
|
295
|
-
console.log(
|
|
257
|
+
console.log(chalk.red('\n❌ Build failed!'));
|
|
296
258
|
if (status.endTime) {
|
|
297
259
|
console.log(`Duration: ${formatTimestamp(status.startTime)} → ${formatTimestamp(status.endTime)}`);
|
|
298
260
|
}
|
|
299
|
-
console.log(
|
|
261
|
+
console.log(chalk.yellow('Use "containers-cli builds <containerId>" to see build details'));
|
|
300
262
|
return;
|
|
301
263
|
}
|
|
302
264
|
else if (status.status === 'cancelled') {
|
|
303
|
-
console.log(
|
|
265
|
+
console.log(chalk.yellow('\n⚠️ Build was cancelled'));
|
|
304
266
|
return;
|
|
305
267
|
}
|
|
306
268
|
// Continue watching
|
|
307
269
|
setTimeout(watchBuild, pollInterval);
|
|
308
270
|
}
|
|
309
271
|
catch (error) {
|
|
310
|
-
console.error(
|
|
272
|
+
console.error(chalk.red('Error watching build:'), error.message);
|
|
311
273
|
}
|
|
312
274
|
};
|
|
313
275
|
// Start watching
|
|
@@ -326,14 +288,14 @@ program
|
|
|
326
288
|
});
|
|
327
289
|
spinner.stop();
|
|
328
290
|
if (response.builds.length === 0) {
|
|
329
|
-
console.log(
|
|
291
|
+
console.log(chalk.yellow('No builds found.'));
|
|
330
292
|
return;
|
|
331
293
|
}
|
|
332
|
-
console.log(
|
|
294
|
+
console.log(chalk.bold(`Found ${response.total} build(s):\n`));
|
|
333
295
|
response.builds.forEach((build, index) => {
|
|
334
|
-
const statusColor = build.status === 'completed' ?
|
|
335
|
-
build.status === 'failed' ?
|
|
336
|
-
console.log(`${index + 1}. ${
|
|
296
|
+
const statusColor = build.status === 'completed' ? chalk.green :
|
|
297
|
+
build.status === 'failed' ? chalk.red : chalk.yellow;
|
|
298
|
+
console.log(`${index + 1}. ${chalk.bold(build.id)}`);
|
|
337
299
|
console.log(` Status: ${statusColor(build.status)}`);
|
|
338
300
|
console.log(` Started: ${formatTimestamp(build.startTime)}`);
|
|
339
301
|
if (build.endTime) {
|
|
@@ -355,14 +317,14 @@ program
|
|
|
355
317
|
});
|
|
356
318
|
spinner.stop();
|
|
357
319
|
if (response.files.length === 0) {
|
|
358
|
-
console.log(
|
|
320
|
+
console.log(chalk.yellow('No files found.'));
|
|
359
321
|
return;
|
|
360
322
|
}
|
|
361
|
-
console.log(
|
|
323
|
+
console.log(chalk.bold(`Files in ${response.path}:\n`));
|
|
362
324
|
response.files.forEach((file, index) => {
|
|
363
325
|
const typeIcon = file.type === 'directory' ? '📁' : '📄';
|
|
364
326
|
const sizeStr = file.size ? formatFileSize(file.size) : 'N/A';
|
|
365
|
-
console.log(`${index + 1}. ${typeIcon} ${
|
|
327
|
+
console.log(`${index + 1}. ${typeIcon} ${chalk.bold(file.name)}`);
|
|
366
328
|
console.log(` Path: ${file.path}`);
|
|
367
329
|
console.log(` Size: ${sizeStr}`);
|
|
368
330
|
if (file.lastModified) {
|
|
@@ -379,11 +341,11 @@ program
|
|
|
379
341
|
const targetPath = remotePath || `/${localFilePath.split('/').pop()}`;
|
|
380
342
|
let content;
|
|
381
343
|
try {
|
|
382
|
-
const fs = await
|
|
344
|
+
const fs = await import('fs/promises');
|
|
383
345
|
content = await fs.readFile(localFilePath, 'utf8');
|
|
384
346
|
}
|
|
385
347
|
catch (error) {
|
|
386
|
-
console.error(
|
|
348
|
+
console.error(chalk.red(`Failed to read file: ${localFilePath}`));
|
|
387
349
|
process.exit(1);
|
|
388
350
|
}
|
|
389
351
|
spinner.start('Uploading file...');
|
|
@@ -393,7 +355,7 @@ program
|
|
|
393
355
|
content
|
|
394
356
|
});
|
|
395
357
|
spinner.stop();
|
|
396
|
-
console.log(
|
|
358
|
+
console.log(chalk.green('File uploaded successfully!'));
|
|
397
359
|
console.log(`Local: ${localFilePath}`);
|
|
398
360
|
console.log(`Remote: ${result.path}`);
|
|
399
361
|
console.log(`Size: ${formatFileSize(result.size)}`);
|
|
@@ -406,8 +368,8 @@ program
|
|
|
406
368
|
spinner.start('Fetching token balance...');
|
|
407
369
|
const balance = await userService.getTokenBalance();
|
|
408
370
|
spinner.stop();
|
|
409
|
-
console.log(
|
|
410
|
-
console.log(`Tokens: ${
|
|
371
|
+
console.log(chalk.bold('Token Balance:'));
|
|
372
|
+
console.log(`Tokens: ${chalk.green(balance.tokenBalance.toLocaleString())}`);
|
|
411
373
|
console.log(`Last Updated: ${formatTimestamp(balance.lastUpdated)}`);
|
|
412
374
|
}));
|
|
413
375
|
program
|
|
@@ -417,7 +379,7 @@ program
|
|
|
417
379
|
spinner.start('Fetching profile...');
|
|
418
380
|
const profile = await userService.getUserProfile();
|
|
419
381
|
spinner.stop();
|
|
420
|
-
console.log(
|
|
382
|
+
console.log(chalk.bold('User Profile:'));
|
|
421
383
|
console.log(`Email: ${profile.email}`);
|
|
422
384
|
console.log(`ID: ${profile.id}`);
|
|
423
385
|
if (profile.displayName) {
|
|
@@ -435,12 +397,12 @@ program
|
|
|
435
397
|
const response = await userService.getTransactionHistory(parseInt(options.limit));
|
|
436
398
|
spinner.stop();
|
|
437
399
|
if (response.transactions.length === 0) {
|
|
438
|
-
console.log(
|
|
400
|
+
console.log(chalk.yellow('No transactions found.'));
|
|
439
401
|
return;
|
|
440
402
|
}
|
|
441
|
-
console.log(
|
|
403
|
+
console.log(chalk.bold(`Transaction History (${response.transactions.length} of ${response.total}):\n`));
|
|
442
404
|
response.transactions.forEach((transaction, index) => {
|
|
443
|
-
const typeColor = transaction.type === 'purchase' ?
|
|
405
|
+
const typeColor = transaction.type === 'purchase' ? chalk.green : chalk.red;
|
|
444
406
|
const typeSymbol = transaction.type === 'purchase' ? '+' : '-';
|
|
445
407
|
console.log(`${index + 1}. ${typeColor(typeSymbol + transaction.tokens)} tokens`);
|
|
446
408
|
console.log(` Type: ${transaction.type}`);
|
|
@@ -456,7 +418,7 @@ program
|
|
|
456
418
|
.command('setup')
|
|
457
419
|
.description('Configure authentication and settings')
|
|
458
420
|
.action(async () => {
|
|
459
|
-
const { MCPServerSetup } = await
|
|
421
|
+
const { MCPServerSetup } = await import('./setup.js');
|
|
460
422
|
const setup = new MCPServerSetup();
|
|
461
423
|
await setup.run();
|
|
462
424
|
});
|
|
@@ -465,23 +427,23 @@ program
|
|
|
465
427
|
.command('test')
|
|
466
428
|
.description('Test authentication and connection')
|
|
467
429
|
.action(async () => {
|
|
468
|
-
console.log(
|
|
430
|
+
console.log(chalk.blue('🔍 Testing authentication and connection...\n'));
|
|
469
431
|
try {
|
|
470
432
|
await loadServices();
|
|
471
433
|
const isAuthenticated = await authManager.testAuthentication();
|
|
472
434
|
if (isAuthenticated) {
|
|
473
|
-
console.log(
|
|
474
|
-
console.log(
|
|
435
|
+
console.log(chalk.green('✅ Authentication successful!'));
|
|
436
|
+
console.log(chalk.green('✅ Connection to API is working'));
|
|
475
437
|
// Test a simple API call
|
|
476
438
|
spinner.start('Testing API endpoints...');
|
|
477
439
|
const response = await containerService.listContainers({ limit: 1 });
|
|
478
440
|
spinner.stop();
|
|
479
|
-
console.log(
|
|
480
|
-
console.log(
|
|
441
|
+
console.log(chalk.green('✅ API endpoints are accessible'));
|
|
442
|
+
console.log(chalk.blue(`Found ${response.total} containers in your account`));
|
|
481
443
|
}
|
|
482
444
|
else {
|
|
483
|
-
console.log(
|
|
484
|
-
console.log(
|
|
445
|
+
console.log(chalk.red('❌ Authentication failed'));
|
|
446
|
+
console.log(chalk.yellow('Run "setup" command to configure authentication'));
|
|
485
447
|
process.exit(1);
|
|
486
448
|
}
|
|
487
449
|
}
|
|
@@ -506,7 +468,7 @@ program
|
|
|
506
468
|
});
|
|
507
469
|
// Handle unknown commands
|
|
508
470
|
program.on('command:*', () => {
|
|
509
|
-
console.error(
|
|
471
|
+
console.error(chalk.red('Invalid command: %s'), program.args.join(' '));
|
|
510
472
|
console.log('See --help for a list of available commands.');
|
|
511
473
|
process.exit(1);
|
|
512
474
|
});
|