mlgym-deploy 3.3.25 → 3.3.29
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/index.js +53 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import crypto from 'crypto';
|
|
|
18
18
|
const execAsync = promisify(exec);
|
|
19
19
|
|
|
20
20
|
// Current version of this MCP server - INCREMENT FOR WORKFLOW FIXES
|
|
21
|
-
const CURRENT_VERSION = '3.3.
|
|
21
|
+
const CURRENT_VERSION = '3.3.29'; // Fix SSH key per-user when using MLGYM_TOKEN env var
|
|
22
22
|
const PACKAGE_NAME = 'mlgym-deploy';
|
|
23
23
|
|
|
24
24
|
// Debug logging configuration - ENABLED BY DEFAULT
|
|
@@ -94,10 +94,29 @@ const CONFIG = {
|
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
// Helper to load/save authentication
|
|
97
|
+
// Helper to extract email from JWT token
|
|
98
|
+
function extractEmailFromJWT(token) {
|
|
99
|
+
try {
|
|
100
|
+
// JWT format: header.payload.signature
|
|
101
|
+
const parts = token.split('.');
|
|
102
|
+
if (parts.length !== 3) return null;
|
|
103
|
+
|
|
104
|
+
// Decode base64url payload (replace - with + and _ with /)
|
|
105
|
+
const base64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');
|
|
106
|
+
const payload = JSON.parse(Buffer.from(base64, 'base64').toString('utf8'));
|
|
107
|
+
|
|
108
|
+
return payload.email || payload.sub || null;
|
|
109
|
+
} catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
97
114
|
async function loadAuth() {
|
|
98
115
|
// First check environment variable
|
|
99
116
|
if (process.env.MLGYM_TOKEN) {
|
|
100
|
-
|
|
117
|
+
// Try to extract email from JWT token if MLGYM_EMAIL is not set
|
|
118
|
+
const email = process.env.MLGYM_EMAIL || extractEmailFromJWT(process.env.MLGYM_TOKEN) || 'env-token-user';
|
|
119
|
+
return { token: process.env.MLGYM_TOKEN, email };
|
|
101
120
|
}
|
|
102
121
|
|
|
103
122
|
// Fall back to config file
|
|
@@ -550,6 +569,24 @@ async function analyzeProject(local_path = '.') {
|
|
|
550
569
|
} catch {}
|
|
551
570
|
}
|
|
552
571
|
|
|
572
|
+
// Check for PHP project
|
|
573
|
+
if (analysis.project_type === 'unknown') {
|
|
574
|
+
try {
|
|
575
|
+
await fs.access(path.join(absolutePath, 'index.php'));
|
|
576
|
+
analysis.project_type = 'php';
|
|
577
|
+
analysis.framework = 'php';
|
|
578
|
+
analysis.detected_files.push('index.php');
|
|
579
|
+
} catch {
|
|
580
|
+
// Also check for composer.json (PHP with Composer)
|
|
581
|
+
try {
|
|
582
|
+
await fs.access(path.join(absolutePath, 'composer.json'));
|
|
583
|
+
analysis.project_type = 'php';
|
|
584
|
+
analysis.framework = 'composer';
|
|
585
|
+
analysis.detected_files.push('composer.json');
|
|
586
|
+
} catch {}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
553
590
|
// Check for static HTML project
|
|
554
591
|
if (analysis.project_type === 'unknown') {
|
|
555
592
|
try {
|
|
@@ -723,6 +760,13 @@ COPY . .
|
|
|
723
760
|
EXPOSE 8000
|
|
724
761
|
CMD ["python", "main.py"]`;
|
|
725
762
|
}
|
|
763
|
+
} else if (projectType === 'php') {
|
|
764
|
+
dockerfile = `FROM php:8.2-apache
|
|
765
|
+
WORKDIR /var/www/html
|
|
766
|
+
COPY . .
|
|
767
|
+
RUN chown -R www-data:www-data /var/www/html
|
|
768
|
+
EXPOSE 80
|
|
769
|
+
CMD ["apache2-foreground"]`;
|
|
726
770
|
} else if (projectType === 'static') {
|
|
727
771
|
dockerfile = `FROM nginx:alpine
|
|
728
772
|
COPY . /usr/share/nginx/html
|
|
@@ -1694,6 +1738,10 @@ async function initProject(args) {
|
|
|
1694
1738
|
|
|
1695
1739
|
const project = result.data;
|
|
1696
1740
|
|
|
1741
|
+
// Debug: Log the deployment_url received from backend
|
|
1742
|
+
log.debug('MCP >>> [initProject] Backend response - deployment_url:', project.deployment_url);
|
|
1743
|
+
log.debug('MCP >>> [initProject] Backend response - webhook_id:', project.webhook_id);
|
|
1744
|
+
|
|
1697
1745
|
// Add administrator (chka@stratus5.com) as project member for debugging
|
|
1698
1746
|
console.error('Adding administrator as project member...');
|
|
1699
1747
|
try {
|
|
@@ -1904,7 +1952,7 @@ async function initProject(args) {
|
|
|
1904
1952
|
deploymentStatus = {
|
|
1905
1953
|
status: 'pending',
|
|
1906
1954
|
message: 'Deployment is still in progress. Check status later.',
|
|
1907
|
-
expected_url:
|
|
1955
|
+
expected_url: project.deployment_url || null
|
|
1908
1956
|
};
|
|
1909
1957
|
}
|
|
1910
1958
|
}
|
|
@@ -1923,7 +1971,7 @@ async function initProject(args) {
|
|
|
1923
1971
|
description: project.description,
|
|
1924
1972
|
git_url: gitUrl,
|
|
1925
1973
|
deployment_enabled: enable_deployment,
|
|
1926
|
-
deployment_url:
|
|
1974
|
+
deployment_url: project.deployment_url || null
|
|
1927
1975
|
},
|
|
1928
1976
|
git_operations: gitSteps,
|
|
1929
1977
|
deployment: deploymentStatus,
|
|
@@ -1934,7 +1982,7 @@ async function initProject(args) {
|
|
|
1934
1982
|
'Future updates: git push mlgym main'
|
|
1935
1983
|
] : [
|
|
1936
1984
|
enable_deployment ? 'Deployment triggered - check URL in a few minutes' : 'Project ready',
|
|
1937
|
-
enable_deployment ? `Expected URL:
|
|
1985
|
+
enable_deployment && project.deployment_url ? `Expected URL: ${project.deployment_url}` : null,
|
|
1938
1986
|
'To update: git push mlgym main'
|
|
1939
1987
|
].filter(Boolean))
|
|
1940
1988
|
: [
|
package/package.json
CHANGED