Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: support non-PM2 app types (Swift/Xcode) in import and management

Adam Eivy65ea40785b27
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index ba809d94ad..a057b9b3e5 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
-import { ExternalLink, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, ChevronDown, ChevronUp, Ticket, GitBranch, Download, Hammer } from 'lucide-react';
+import { ExternalLink, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, ChevronDown, ChevronUp, Ticket, GitBranch, Download, Hammer, Smartphone } from 'lucide-react';
import toast from 'react-hot-toast';
import BrailleSpinner from '../components/BrailleSpinner';
import KanbanBoard from '../components/KanbanBoard';
@@ -10,6 +10,9 @@ import { useAppOperation } from '../hooks/useAppOperation';
import * as api from '../services/api';
import socket from '../services/socket';
+/** App types that do not use PM2 for process management */
+const NON_PM2_TYPES = new Set(['ios-native', 'macos-native', 'xcode', 'swift']);
+
export default function Apps() {
const [apps, setApps] = useState([]);
const [loading, setLoading] = useState(true);
@@ -191,7 +194,9 @@ export default function Apps() {
</div>
) : (
<div className="space-y-4">
- {displayedApps.map(app => (
+ {displayedApps.map(app => {
+ const isNonPm2 = isNonPm2;
+ return (
<div
key={app.id}
className="bg-port-card border border-port-border rounded-xl overflow-hidden"
@@ -217,32 +222,45 @@ export default function Apps() {
Archived
</span>
)}
- <StatusBadge status={app.overallStatus} size="sm" />
+ {isNonPm2 ? (
+ <span className="px-1.5 py-0.5 bg-port-accent/20 text-port-accent text-xs rounded">
+ {app.type === 'ios-native' ? '📱 iOS' :
+ app.type === 'macos-native' ? '🖥️ macOS' :
+ app.type === 'swift' ? '🐦 Swift' : '🔨 Xcode'}
+ </span>
+ ) : (
+ <StatusBadge status={app.overallStatus} size="sm" />
+ )}
</div>
<div className="text-xs text-gray-500 flex flex-wrap gap-x-2 mt-1">
- {(app.pm2ProcessNames || []).map((procName, i) => {
- const procInfo = app.processes?.find(p => p.name === procName);
- const ports = procInfo?.ports || {};
- const portEntries = Object.entries(ports);
- const portDisplay = portEntries.length > 1
- ? ` (${portEntries.map(([label, port]) => `${label}:${port}`).join(', ')})`
- : portEntries.length === 1
- ? `:${portEntries[0][1]}`
- : '';
- return (
- <span key={i}>
- {procName}<span className="text-cyan-500">{portDisplay}</span>
- {i < (app.pm2ProcessNames?.length || 0) - 1 ? ',' : ''}
- </span>
- );
- })}
+ {isNonPm2 ? (
+ <span className="text-gray-500">{app.repoPath}</span>
+ ) : (
+ (app.pm2ProcessNames || []).map((procName, i) => {
+ const procInfo = app.processes?.find(p => p.name === procName);
+ const ports = procInfo?.ports || {};
+ const portEntries = Object.entries(ports);
+ const portDisplay = portEntries.length > 1
+ ? ` (${portEntries.map(([label, port]) => `${label}:${port}`).join(', ')})`
+ : portEntries.length === 1
+ ? `:${portEntries[0][1]}`
+ : '';
+ return (
+ <span key={i}>
+ {procName}<span className="text-cyan-500">{portDisplay}</span>
+ {i < (app.pm2ProcessNames?.length || 0) - 1 ? ',' : ''}
+ </span>
+ );
+ })
+ )}
</div>
</div>
</div>
{/* Controls */}
<div className="flex flex-wrap items-center gap-2">
- {/* Start/Stop/Restart Button Group */}
+ {/* Start/Stop/Restart Button Group - only for PM2 apps */}
+ {!isNonPm2 && (
<div className="inline-flex rounded-lg overflow-hidden border border-port-border">
{app.overallStatus === 'online' ? (
<>
@@ -280,6 +298,7 @@ export default function Apps() {
</button>
)}
</div>
+ )}
{/* Launch buttons */}
{app.uiPort && app.overallStatus === 'online' && (
@@ -403,8 +422,8 @@ export default function Apps() {
</div>
)}
- {/* PM2 Processes Status */}
- {app.pm2Status && Object.keys(app.pm2Status).length > 0 && (
+ {/* PM2 Processes Status - only for PM2 apps */}
+ {!isNonPm2 && app.pm2Status && Object.keys(app.pm2Status).length > 0 && (
<div>
<div className="text-xs text-gray-500 uppercase tracking-wide mb-2">PM2 Processes</div>
<div className="flex flex-wrap gap-2">
@@ -518,24 +537,42 @@ export default function Apps() {
{building[app.id] ? 'Building...' : 'Build'}
</button>
)}
- <button
- onClick={() => handleRefreshConfig(app)}
- disabled={refreshingConfig[app.id]}
- className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"
- aria-label="Re-scan ecosystem config for PM2 processes and ports"
- >
- <RefreshCw size={14} aria-hidden="true" className={refreshingConfig[app.id] ? 'animate-spin' : ''} />
- Refresh Config
- </button>
- {(!app.processes?.length || app.processes.some(p => !p.ports || Object.keys(p.ports).length === 0)) && (
+ {/* PM2-specific actions */}
+ {!isNonPm2 && (
+ <>
+ <button
+ onClick={() => handleRefreshConfig(app)}
+ disabled={refreshingConfig[app.id]}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"
+ aria-label="Re-scan ecosystem config for PM2 processes and ports"
+ >
+ <RefreshCw size={14} aria-hidden="true" className={refreshingConfig[app.id] ? 'animate-spin' : ''} />
+ Refresh Config
+ </button>
+ {(!app.processes?.length || app.processes.some(p => !p.ports || Object.keys(p.ports).length === 0)) && (
+ <button
+ onClick={() => handleStandardize(app)}
+ disabled={isOperating}
+ className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"
+ aria-label="Standardize PM2 config: move all ports to ecosystem.config.cjs"
+ >
+ <Wrench size={14} aria-hidden="true" className={operatingAppId === app.id && operationType === 'standardize' ? 'animate-spin' : ''} />
+ {operatingAppId === app.id && operationType === 'standardize' ? 'Standardizing...' : 'Standardize PM2'}
+ </button>
+ )}
+ </>
+ )}
+ {/* Xcode-specific actions */}
+ {isNonPm2 && (
<button
- onClick={() => handleStandardize(app)}
- disabled={isOperating}
- className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"
- aria-label="Standardize PM2 config: move all ports to ecosystem.config.cjs"
+ onClick={() => {
+ const xcodeprojName = app.name + '.xcodeproj';
+ window.open(`xcode://open?url=file://${app.repoPath}/${xcodeprojName}`, '_self');
+ }}
+ className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg text-xs flex items-center gap-1"
+ aria-label={`Open ${app.name} in Xcode`}
>
- <Wrench size={14} aria-hidden="true" className={operatingAppId === app.id && operationType === 'standardize' ? 'animate-spin' : ''} />
- {operatingAppId === app.id && operationType === 'standardize' ? 'Standardizing...' : 'Standardize PM2'}
+ <Smartphone size={14} aria-hidden="true" /> Open in Xcode
</button>
)}
</div>
@@ -548,7 +585,8 @@ export default function Apps() {
</div>
)}
</div>
- ))}
+ );
+ })}
</div>
)}
diff --git a/client/src/pages/CreateApp.jsx b/client/src/pages/CreateApp.jsx
index d47a4be096..35ebc02072 100644
--- a/client/src/pages/CreateApp.jsx
+++ b/client/src/pages/CreateApp.jsx
@@ -7,7 +7,10 @@ import * as api from '../services/api';
import IconPicker from '../components/IconPicker';
import FolderPicker from '../components/FolderPicker';
-const DETECTION_STEPS = [
+/** App types that do not use PM2 for process management */
+const NON_PM2_TYPES = new Set(['ios-native', 'macos-native', 'xcode', 'swift']);
+
+const DETECTION_STEPS_PM2 = [
{ id: 'validate', label: 'Validating path' },
{ id: 'files', label: 'Scanning files' },
{ id: 'package', label: 'Reading package.json' },
@@ -17,6 +20,14 @@ const DETECTION_STEPS = [
{ id: 'standardize', label: 'Standardizing PM2 config' }
];
+const DETECTION_STEPS_NON_PM2 = [
+ { id: 'validate', label: 'Validating path' },
+ { id: 'files', label: 'Scanning files' },
+ { id: 'package', label: 'Reading project config' },
+ { id: 'config', label: 'Checking configs' },
+ { id: 'readme', label: 'Reading README' }
+];
+
export default function CreateApp() {
const navigate = useNavigate();
const socketRef = useRef(null);
@@ -41,6 +52,7 @@ export default function CreateApp() {
const [pm2Names, setPm2Names] = useState('');
const [pm2Status, setPm2Status] = useState(null);
const [icon, setIcon] = useState('package');
+ const [appType, setAppType] = useState('unknown');
// Submit state
const [submitting, setSubmitting] = useState(false);
@@ -73,6 +85,7 @@ export default function CreateApp() {
setDetectionLog(prev => [...prev, { step, status, ...data }]);
// Update form fields as data comes in
+ if (data.type) setAppType(data.type);
if (data.name) setName(data.name);
if (data.description) setDescription(data.description);
if (data.uiPort) setUiPort(String(data.uiPort));
@@ -94,6 +107,7 @@ export default function CreateApp() {
setDetecting(false);
if (success && result) {
setDetected(true);
+ if (result.type) setAppType(result.type);
if (result.name) setName(result.name);
if (result.description) setDescription(result.description);
if (result.uiPort) setUiPort(String(result.uiPort));
@@ -133,14 +147,16 @@ export default function CreateApp() {
};
}, []);
- // Auto-trigger standardization after detection completes
+ const isNonPm2 = NON_PM2_TYPES.has(appType);
+
+ // Auto-trigger standardization after detection completes (skip for non-PM2 apps)
useEffect(() => {
- if (detected && activeProvider && repoPath && !standardizing && !standardizeResult) {
+ if (detected && activeProvider && repoPath && !standardizing && !standardizeResult && !isNonPm2) {
setStandardizing(true);
setSteps(prev => ({ ...prev, standardize: { status: 'running', data: { message: 'Analyzing configuration...' } } }));
socketRef.current?.emit('standardize:start', { repoPath, providerId: activeProvider.id });
}
- }, [detected, activeProvider, repoPath, standardizing, standardizeResult]);
+ }, [detected, activeProvider, repoPath, standardizing, standardizeResult, isNonPm2]);
// Start streaming detection
const handleImport = () => {
@@ -167,15 +183,18 @@ export default function CreateApp() {
const data = {
name,
repoPath,
+ type: appType !== 'unknown' ? appType : undefined,
icon,
uiPort: uiPort ? parseInt(uiPort, 10) : null,
devUiPort: devUiPort ? parseInt(devUiPort, 10) : null,
apiPort: apiPort ? parseInt(apiPort, 10) : null,
buildCommand: buildCommand || undefined,
- startCommands: startCommands.split('\n').filter(Boolean),
- pm2ProcessNames: pm2Names
- ? pm2Names.split(',').map(s => s.trim()).filter(Boolean)
- : [name.toLowerCase().replace(/[^a-z0-9]/g, '-')]
+ startCommands: startCommands ? startCommands.split('\n').filter(Boolean) : [],
+ pm2ProcessNames: isNonPm2
+ ? []
+ : pm2Names
+ ? pm2Names.split(',').map(s => s.trim()).filter(Boolean)
+ : [name.toLowerCase().replace(/[^a-z0-9]/g, '-')]
};
const result = await api.createApp(data).catch(err => {
@@ -193,6 +212,7 @@ export default function CreateApp() {
setDetectionLog([]);
setName('');
setDescription('');
+ setAppType('unknown');
setUiPort('');
setDevUiPort('');
setApiPort('');
@@ -250,7 +270,7 @@ export default function CreateApp() {
{/* Detection Progress */}
{detecting && (
<div className="mt-4 space-y-2">
- {DETECTION_STEPS.map(({ id, label }) => (
+ {(isNonPm2 ? DETECTION_STEPS_NON_PM2 : DETECTION_STEPS_PM2).map(({ id, label }) => (
<div key={id} className="flex items-center gap-2 text-sm">
{getStepIcon(id)}
<span className={steps[id]?.status === 'running' ? 'text-port-accent' :
@@ -267,8 +287,20 @@ export default function CreateApp() {
</div>
)}
+ {/* App Type Badge */}
+ {detected && isNonPm2 && (
+ <div className="mt-3 p-3 bg-port-accent/10 border border-port-accent/30 rounded-lg">
+ <p className="text-sm text-port-accent font-medium">
+ {appType === 'ios-native' ? '📱 iOS App' :
+ appType === 'macos-native' ? '🖥️ macOS App' :
+ appType === 'swift' ? '🐦 Swift Package' :
+ '🔨 Xcode Project'} — not managed by PM2
+ </p>
+ </div>
+ )}
+
{/* PM2 Running Status */}
- {pm2Status && pm2Status.length > 0 && (
+ {pm2Status && pm2Status.length > 0 && !isNonPm2 && (
<div className="mt-3 p-3 bg-port-warning/10 border border-port-warning/30 rounded-lg">
<p className="text-sm text-port-warning font-medium flex items-center gap-2">
<Play size={14} /> Already running in PM2
@@ -299,7 +331,7 @@ export default function CreateApp() {
)}
{/* No Provider Warning */}
- {detected && !activeProvider && !standardizing && !standardizeResult && (
+ {detected && !activeProvider && !standardizing && !standardizeResult && !isNonPm2 && (
<div className="mt-3 p-3 bg-port-border/50 border border-port-border rounded-lg">
<p className="text-xs text-gray-400">
<span className="text-port-warning">⚠</span> No LLM provider configured. PM2 standardization skipped.
@@ -384,52 +416,58 @@ export default function CreateApp() {
/>
</div>
- <div className="grid grid-cols-3 gap-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">UI Port</label>
- <input
- type="number"
- value={uiPort}
- onChange={(e) => setUiPort(e.target.value)}
- placeholder="3000"
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
- />
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Dev UI Port</label>
- <input
- type="number"
- value={devUiPort}
- onChange={(e) => setDevUiPort(e.target.value)}
- placeholder="3001"
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
- />
+ {/* Port fields - only for PM2/server apps */}
+ {!isNonPm2 && (
+ <div className="grid grid-cols-3 gap-4">
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">UI Port</label>
+ <input
+ type="number"
+ value={uiPort}
+ onChange={(e) => setUiPort(e.target.value)}
+ placeholder="3000"
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
+ />
+ </div>
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Dev UI Port</label>
+ <input
+ type="number"
+ value={devUiPort}
+ onChange={(e) => setDevUiPort(e.target.value)}
+ placeholder="3001"
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
+ />
+ </div>
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">API Port</label>
+ <input
+ type="number"
+ value={apiPort}
+ onChange={(e) => setApiPort(e.target.value)}
+ placeholder="3002"
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
+ />
+ </div>
</div>
+ )}
+
+ {/* Start commands - only for PM2/server apps */}
+ {!isNonPm2 && (
<div>
- <label className="block text-sm text-gray-400 mb-1">API Port</label>
- <input
- type="number"
- value={apiPort}
- onChange={(e) => setApiPort(e.target.value)}
- placeholder="3002"
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
+ <label className="block text-sm text-gray-400 mb-1">Start Commands (one per line)</label>
+ <textarea
+ value={startCommands}
+ onChange={(e) => setStartCommands(e.target.value)}
+ placeholder="npm run dev"
+ rows={2}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden font-mono text-sm"
/>
+ <p className="text-xs text-gray-500 mt-1">
+ Commands to start your app. Multiple lines = multiple PM2 processes.
+ </p>
</div>
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">Start Commands (one per line)</label>
- <textarea
- value={startCommands}
- onChange={(e) => setStartCommands(e.target.value)}
- placeholder="npm run dev"
- rows={2}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden font-mono text-sm"
- />
- <p className="text-xs text-gray-500 mt-1">
- Commands to start your app. Multiple lines = multiple PM2 processes.
- </p>
- </div>
+ )}
<div>
<label className="block text-sm text-gray-400 mb-1">Build Command</label>
@@ -437,27 +475,30 @@ export default function CreateApp() {
type="text"
value={buildCommand}
onChange={(e) => setBuildCommand(e.target.value)}
- placeholder="npm run build"
+ placeholder={isNonPm2 ? 'xcodebuild -scheme MyApp build' : 'npm run build'}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden font-mono text-sm"
/>
<p className="text-xs text-gray-500 mt-1">
- Command to build the production UI. Enables the Build button.
+ {isNonPm2 ? 'Command to build the project.' : 'Command to build the production UI. Enables the Build button.'}
</p>
</div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">PM2 Process Names (comma-separated)</label>
- <input
- type="text"
- value={pm2Names}
- onChange={(e) => setPm2Names(e.target.value)}
- placeholder="my-app-ui, my-app-api"
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
- />
- <p className="text-xs text-gray-500 mt-1">
- Names for PM2 processes. Leave blank to auto-generate from app name.
- </p>
- </div>
+ {/* PM2 process names - only for PM2/server apps */}
+ {!isNonPm2 && (
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">PM2 Process Names (comma-separated)</label>
+ <input
+ type="text"
+ value={pm2Names}
+ onChange={(e) => setPm2Names(e.target.value)}
+ placeholder="my-app-ui, my-app-api"
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
+ />
+ <p className="text-xs text-gray-500 mt-1">
+ Names for PM2 processes. Leave blank to auto-generate from app name.
+ </p>
+ </div>
+ )}
</div>
)}
diff --git a/server/lib/validation.js b/server/lib/validation.js
index a2648d966a..01d833cf71 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -182,7 +182,7 @@ export const appSchema = z.object({
apiPort: z.number().int().min(1).max(65535).nullable().optional(),
buildCommand: z.string().max(200).optional(),
uiUrl: z.string().url().optional(),
- startCommands: z.array(z.string()).min(1).optional(),
+ startCommands: z.array(z.string()).optional(),
pm2ProcessNames: z.array(z.string()).optional(),
processes: z.array(processSchema).optional(), // Per-process port configs from ecosystem.config
envFile: z.string().optional(),
diff --git a/server/routes/apps.js b/server/routes/apps.js
index 8e3328810a..010b5b8795 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -14,7 +14,7 @@ import { validateRequest, appSchema, appUpdateSchema, sanitizeTaskMetadata } fro
import * as git from '../services/git.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
import { safeJSONParse } from '../lib/fileUtils.js';
-import { parseEcosystemFromPath } from '../services/streamingDetect.js';
+import { parseEcosystemFromPath, usesPm2 } from '../services/streamingDetect.js';
const router = Router();
@@ -66,6 +66,11 @@ router.get('/', asyncHandler(async (req, res) => {
// Enrich with PM2 status and auto-populate processes if needed
const enriched = await Promise.all(apps.map(async (app) => {
+ // Non-PM2 apps skip PM2 enrichment entirely
+ if (!usesPm2(app.type)) {
+ return { ...app, pm2Status: {}, overallStatus: 'n/a' };
+ }
+
const pm2Home = app.pm2Home || null;
const pm2Map = pm2Maps.get(pm2Home) || new Map();
@@ -127,22 +132,27 @@ router.get('/', asyncHandler(async (req, res) => {
router.get('/:id', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
- // Get PM2 status for each process (using app's custom PM2_HOME if set)
- const statuses = {};
- for (const processName of app.pm2ProcessNames || []) {
- const status = await pm2Service.getAppStatus(processName, app.pm2Home).catch(() => ({ status: 'unknown' }));
- statuses[processName] = status;
- }
+ // Non-PM2 apps skip PM2 status
+ let statuses = {};
+ let overallStatus = 'n/a';
- // Compute overall status (same logic as list endpoint)
- const statusValues = Object.values(statuses);
- let overallStatus = 'unknown';
- if (statusValues.some(s => s.status === 'online')) {
- overallStatus = 'online';
- } else if (statusValues.some(s => s.status === 'stopped')) {
- overallStatus = 'stopped';
- } else if (statusValues.every(s => s.status === 'not_found')) {
- overallStatus = 'not_started';
+ if (usesPm2(app.type)) {
+ // Get PM2 status for each process (using app's custom PM2_HOME if set)
+ for (const processName of app.pm2ProcessNames || []) {
+ const status = await pm2Service.getAppStatus(processName, app.pm2Home).catch(() => ({ status: 'unknown' }));
+ statuses[processName] = status;
+ }
+
+ // Compute overall status (same logic as list endpoint)
+ const statusValues = Object.values(statuses);
+ overallStatus = 'unknown';
+ if (statusValues.some(s => s.status === 'online')) {
+ overallStatus = 'online';
+ } else if (statusValues.some(s => s.status === 'stopped')) {
+ overallStatus = 'stopped';
+ } else if (statusValues.every(s => s.status === 'not_found')) {
+ overallStatus = 'not_started';
+ }
}
// Auto-derive uiPort/apiPort/devUiPort from processes when not explicitly set
@@ -303,6 +313,10 @@ router.put('/:id/task-types/:taskType', asyncHandler(async (req, res) => {
router.post('/:id/start', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
+ if (!usesPm2(app.type)) {
+ throw new ServerError(`${app.type} apps cannot be started via PM2`, { status: 400, code: 'NOT_PM2_APP' });
+ }
+
const processNames = app.pm2ProcessNames || [app.name.toLowerCase().replace(/\s+/g, '-')];
// Check if ecosystem config exists - prefer using it for proper env var handling
@@ -342,6 +356,11 @@ router.post('/:id/start', loadApp, asyncHandler(async (req, res) => {
// POST /api/apps/:id/stop - Stop app
router.post('/:id/stop', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
+
+ if (!usesPm2(app.type)) {
+ throw new ServerError(`${app.type} apps cannot be stopped via PM2`, { status: 400, code: 'NOT_PM2_APP' });
+ }
+
const results = {};
for (const name of app.pm2ProcessNames || []) {
@@ -361,6 +380,10 @@ router.post('/:id/stop', loadApp, asyncHandler(async (req, res) => {
router.post('/:id/restart', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
+ if (!usesPm2(app.type)) {
+ throw new ServerError(`${app.type} apps cannot be restarted via PM2`, { status: 400, code: 'NOT_PM2_APP' });
+ }
+
// Self-restart: respond first, then restart after a delay so the response reaches the client
if (app.id === PORTOS_APP_ID) {
await logAction('restart', app.id, app.name, { processNames: app.pm2ProcessNames }, true);
@@ -425,15 +448,15 @@ router.post('/:id/build', loadApp, asyncHandler(async (req, res) => {
const buildCommand = app.buildCommand || 'npm run build';
const [cmd, ...args] = buildCommand.split(/\s+/);
- // Only allow npm/npx as build commands
- if (!['npm', 'npx'].includes(cmd)) {
- throw new ServerError('Build command must start with npm or npx', { status: 400, code: 'INVALID_BUILD_COMMAND' });
+ if (!ALLOWED_BUILD_CMDS.has(cmd)) {
+ throw new ServerError(`Build command '${cmd}' is not allowed. Allowed: ${[...ALLOWED_BUILD_CMDS].join(', ')}`, { status: 400, code: 'INVALID_BUILD_COMMAND' });
}
console.log(`🔨 Building ${app.name}: ${buildCommand}`);
- // Install dependencies before building (root + common subdirs)
- for (const sub of ['', 'client', 'server', 'admin']) {
+ // Install dependencies before building (root + common subdirs) - skip for non-Node apps
+ const isNodeApp = ['npm', 'npx'].includes(cmd);
+ for (const sub of isNodeApp ? ['', 'client', 'server', 'admin'] : []) {
const subDir = sub ? join(app.repoPath, sub) : app.repoPath;
if (existsSync(join(subDir, 'package.json'))) {
const label = sub || 'root';
@@ -508,6 +531,11 @@ router.post('/:id/build', loadApp, asyncHandler(async (req, res) => {
// GET /api/apps/:id/status - Get PM2 status
router.get('/:id/status', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
+
+ if (!usesPm2(app.type)) {
+ return res.json({});
+ }
+
const statuses = {};
for (const name of app.pm2ProcessNames || []) {
@@ -535,6 +563,16 @@ router.get('/:id/logs', loadApp, asyncHandler(async (req, res) => {
res.json({ processName, lines, logs });
}));
+// Allowlist of safe build commands
+const ALLOWED_BUILD_CMDS = new Set([
+ 'npm', // Node.js
+ 'npx', // Node.js
+ 'xcodebuild', // Xcode
+ 'swift', // Swift Package Manager
+ 'make', // Make
+ 'cargo' // Rust
+]);
+
// Allowlist of safe editor commands
// Security: Only allow known-safe editor commands to prevent arbitrary code execution
const ALLOWED_EDITORS = new Set([
@@ -661,6 +699,10 @@ router.post('/:id/open-folder', loadApp, asyncHandler(async (req, res) => {
router.post('/:id/refresh-config', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
+ if (!usesPm2(app.type)) {
+ return res.json({ success: true, updated: false, app, processes: [] });
+ }
+
if (!existsSync(app.repoPath)) {
throw new ServerError('App path does not exist', { status: 400, code: 'PATH_NOT_FOUND' });
}
diff --git a/server/routes/apps.test.js b/server/routes/apps.test.js
index 64fdd409ea..553e71a95f 100644
--- a/server/routes/apps.test.js
+++ b/server/routes/apps.test.js
@@ -31,7 +31,9 @@ vi.mock('../services/history.js', () => ({
}));
vi.mock('../services/streamingDetect.js', () => ({
- parseEcosystemFromPath: vi.fn()
+ parseEcosystemFromPath: vi.fn(),
+ usesPm2: vi.fn((type) => !new Set(['ios-native', 'macos-native', 'xcode', 'swift']).has(type)),
+ NON_PM2_TYPES: new Set(['ios-native', 'macos-native', 'xcode', 'swift'])
}));
vi.mock('../services/appUpdater.js', () => ({
diff --git a/server/services/streamingDetect.js b/server/services/streamingDetect.js
index 7287ba8e7b..bd93cab84c 100644
--- a/server/services/streamingDetect.js
+++ b/server/services/streamingDetect.js
@@ -5,6 +5,12 @@ import { homedir } from 'os';
import { execPm2 } from './pm2.js';
import { safeJSONParse } from '../lib/fileUtils.js';
+/** App types that do not use PM2 for process management */
+export const NON_PM2_TYPES = new Set(['ios-native', 'macos-native', 'xcode', 'swift']);
+
+/** Check if an app type uses PM2 for process management */
+export const usesPm2 = (type) => !NON_PM2_TYPES.has(type);
+
/**
* Parse ecosystem.config.js/cjs to extract all processes with their ports
* Uses regex parsing since we can't safely execute arbitrary JS
@@ -393,6 +399,52 @@ export async function streamDetection(socket, dirPath) {
const files = entries.map(e => e.name);
emit('files', 'done', { message: `Found ${files.length} files`, files: files.slice(0, 20) });
+ // Detect Swift/Xcode projects from directory contents
+ const hasXcodeproj = files.some(f => f.endsWith('.xcodeproj') || f.endsWith('.xcworkspace'));
+ const hasProjectYml = files.includes('project.yml');
+ const hasPackageSwift = files.includes('Package.swift');
+
+ if (hasXcodeproj || hasProjectYml || hasPackageSwift) {
+ // Parse project.yml for XcodeGen projects
+ if (hasProjectYml) {
+ const ymlContent = await readFile(join(dirPath, 'project.yml'), 'utf-8').catch(() => '');
+ const nameMatch = ymlContent.match(/^name:\s*(.+)$/m);
+ if (nameMatch) result.name = nameMatch[1].trim();
+
+ // Detect platform from targets
+ const platformMatch = ymlContent.match(/platform:\s*\[?([^\]\n]+)/);
+ if (platformMatch) {
+ const platforms = platformMatch[1].toLowerCase();
+ if (platforms.includes('ios') && platforms.includes('macos')) {
+ result.type = 'xcode';
+ } else if (platforms.includes('ios')) {
+ result.type = 'ios-native';
+ } else if (platforms.includes('macos')) {
+ result.type = 'macos-native';
+ } else {
+ result.type = 'xcode';
+ }
+ } else {
+ result.type = 'xcode';
+ }
+
+ // Extract build command
+ result.buildCommand = 'xcodebuild -scheme ' + result.name + ' build';
+ } else if (hasPackageSwift) {
+ result.type = 'swift';
+ result.buildCommand = 'swift build';
+ } else {
+ // .xcodeproj without project.yml
+ const xcodeprojDir = files.find(f => f.endsWith('.xcodeproj'));
+ const schemeName = xcodeprojDir?.replace('.xcodeproj', '') || result.name;
+ result.type = 'xcode';
+ result.buildCommand = 'xcodebuild -scheme ' + schemeName + ' build';
+ }
+
+ result.startCommands = [];
+ result.pm2ProcessNames = [];
+ }
+
// Step 3: Read package.json
emit('package', 'running', { message: 'Reading package.json...' });
const pkgPath = join(dirPath, 'package.json');
@@ -542,55 +594,59 @@ export async function streamDetection(socket, dirPath) {
configFiles
});
- // Step 5: Check PM2 status
- emit('pm2', 'running', { message: 'Checking PM2 processes...' });
- // Use custom PM2_HOME if detected from ecosystem config
- const pm2Env = result.pm2Home ? { ...process.env, PM2_HOME: result.pm2Home } : undefined;
- const { stdout } = await execPm2(['jlist'], pm2Env ? { env: pm2Env } : {}).catch(() => ({ stdout: '[]' }));
- // pm2 jlist may output ANSI codes and warnings before JSON
- let jsonStart = stdout.indexOf('[{');
- if (jsonStart < 0) {
- const emptyMatch = stdout.match(/\[\](?![0-9])/);
- jsonStart = emptyMatch ? stdout.indexOf(emptyMatch[0]) : -1;
- }
- const pm2Json = jsonStart >= 0 ? stdout.slice(jsonStart) : '[]';
- const pm2Processes = safeJSONParse(pm2Json, []);
-
- // Look for processes that might be this app
- const possibleNames = [
- result.name,
- result.name.toLowerCase(),
- result.name.toLowerCase().replace(/[^a-z0-9]/g, '-'),
- `${result.name}-ui`,
- `${result.name}-api`
- ];
-
- const matchingProcesses = pm2Processes.filter(p =>
- possibleNames.some(name => p.name.includes(name) || name.includes(p.name))
- );
-
- if (matchingProcesses.length > 0) {
- result.pm2Status = matchingProcesses.map(p => ({
- name: p.name,
- status: p.pm2_env?.status,
- pid: p.pid
- }));
- // Use actual found PM2 process names
- result.pm2ProcessNames = matchingProcesses.map(p => p.name);
- emit('pm2', 'done', {
- message: `Found ${matchingProcesses.length} running process(es)`,
- pm2Status: result.pm2Status,
- pm2ProcessNames: result.pm2ProcessNames
- });
+ // Step 5: Check PM2 status (skip for non-PM2 app types)
+ if (!usesPm2(result.type)) {
+ emit('pm2', 'skipped', { message: `Not applicable for ${result.type} apps` });
} else {
- emit('pm2', 'done', { message: 'No matching PM2 processes found' });
- // Generate PM2 process names only if none found from ecosystem.config
- if (result.pm2ProcessNames.length === 0) {
- const baseName = result.name.toLowerCase().replace(/[^a-z0-9]/g, '-');
- if (result.type === 'vite+express') {
- result.pm2ProcessNames = [`${baseName}-ui`, `${baseName}-api`];
- } else {
- result.pm2ProcessNames = [baseName];
+ emit('pm2', 'running', { message: 'Checking PM2 processes...' });
+ // Use custom PM2_HOME if detected from ecosystem config
+ const pm2Env = result.pm2Home ? { ...process.env, PM2_HOME: result.pm2Home } : undefined;
+ const { stdout } = await execPm2(['jlist'], pm2Env ? { env: pm2Env } : {}).catch(() => ({ stdout: '[]' }));
+ // pm2 jlist may output ANSI codes and warnings before JSON
+ let jsonStart = stdout.indexOf('[{');
+ if (jsonStart < 0) {
+ const emptyMatch = stdout.match(/\[\](?![0-9])/);
+ jsonStart = emptyMatch ? stdout.indexOf(emptyMatch[0]) : -1;
+ }
+ const pm2Json = jsonStart >= 0 ? stdout.slice(jsonStart) : '[]';
+ const pm2Processes = safeJSONParse(pm2Json, []);
+
+ // Look for processes that might be this app
+ const possibleNames = [
+ result.name,
+ result.name.toLowerCase(),
+ result.name.toLowerCase().replace(/[^a-z0-9]/g, '-'),
+ `${result.name}-ui`,
+ `${result.name}-api`
+ ];
+
+ const matchingProcesses = pm2Processes.filter(p =>
+ possibleNames.some(name => p.name.includes(name) || name.includes(p.name))
+ );
+
+ if (matchingProcesses.length > 0) {
+ result.pm2Status = matchingProcesses.map(p => ({
+ name: p.name,
+ status: p.pm2_env?.status,
+ pid: p.pid
+ }));
+ // Use actual found PM2 process names
+ result.pm2ProcessNames = matchingProcesses.map(p => p.name);
+ emit('pm2', 'done', {
+ message: `Found ${matchingProcesses.length} running process(es)`,
+ pm2Status: result.pm2Status,
+ pm2ProcessNames: result.pm2ProcessNames
+ });
+ } else {
+ emit('pm2', 'done', { message: 'No matching PM2 processes found' });
+ // Generate PM2 process names only if none found from ecosystem.config
+ if (result.pm2ProcessNames.length === 0) {
+ const baseName = result.name.toLowerCase().replace(/[^a-z0-9]/g, '-');
+ if (result.type === 'vite+express') {
+ result.pm2ProcessNames = [`${baseName}-ui`, `${baseName}-api`];
+ } else {
+ result.pm2ProcessNames = [baseName];
+ }
}
}
}