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: improve app start with ecosystem config, integrate soul into CoS agents

Adam Eivy0c70b2eeabaa
diff --git a/client/src/pages/Soul.jsx b/client/src/pages/Soul.jsx
index d75e61aa7e..6839a34f3a 100644
--- a/client/src/pages/Soul.jsx
+++ b/client/src/pages/Soul.jsx
@@ -99,7 +99,7 @@ export default function Soul() {
</div>
{/* Tab navigation */}
- <div className="flex overflow-x-auto border-b border-port-border scrollbar-hide">
+ <div className="flex gap-1 overflow-x-auto border-b border-port-border scrollbar-hide">
{TABS.map((tabItem) => {
const Icon = tabItem.icon;
const isActive = activeTab === tabItem.id;
@@ -107,16 +107,17 @@ export default function Soul() {
<button
key={tabItem.id}
onClick={() => handleTabChange(tabItem.id)}
- className={`flex items-center gap-2 px-3 sm:px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap min-h-[44px] ${
+ className={`flex items-center gap-2 px-3 sm:px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap min-h-[44px] border-b-2 -mb-px ${
isActive
- ? 'text-port-accent border-b-2 border-port-accent bg-port-accent/5'
- : 'text-gray-400 hover:text-white hover:bg-port-card'
+ ? 'text-port-accent border-port-accent bg-port-accent/5'
+ : 'text-gray-400 border-transparent hover:text-white hover:bg-port-card'
}`}
role="tab"
aria-selected={isActive}
>
<Icon size={16} aria-hidden="true" />
- <span className="hidden xs:inline sm:inline">{tabItem.label}</span>
+ <span className="hidden sm:inline">{tabItem.label}</span>
+ <span className="sr-only sm:hidden">{tabItem.label}</span>
</button>
);
})}
diff --git a/server/routes/apps.js b/server/routes/apps.js
index 0ea4902246..900ea1c2a5 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -129,17 +129,32 @@ router.post('/:id/start', asyncHandler(async (req, res, next) => {
throw new ServerError('App not found', { status: 404, code: 'NOT_FOUND' });
}
- const results = {};
- const commands = app.startCommands || ['npm run dev'];
const processNames = app.pm2ProcessNames || [app.name.toLowerCase().replace(/\s+/g, '-')];
- for (let i = 0; i < processNames.length; i++) {
- const name = processNames[i];
- const command = commands[i] || commands[0];
+ // Check if ecosystem config exists - prefer using it for proper env var handling
+ const hasEcosystem = ['ecosystem.config.cjs', 'ecosystem.config.js']
+ .some(f => existsSync(`${app.repoPath}/${f}`));
+
+ let results = {};
- const result = await pm2Service.startWithCommand(name, app.repoPath, command)
+ if (hasEcosystem) {
+ // Use ecosystem config for proper env/port configuration
+ const result = await pm2Service.startFromEcosystem(app.repoPath, processNames)
.catch(err => ({ success: false, error: err.message }));
- results[name] = result;
+ // Map result to each process name for consistent response format
+ for (const name of processNames) {
+ results[name] = result;
+ }
+ } else {
+ // Fallback to command-based start for apps without ecosystem config
+ const commands = app.startCommands || ['npm run dev'];
+ for (let i = 0; i < processNames.length; i++) {
+ const name = processNames[i];
+ const command = commands[i] || commands[0];
+ const result = await pm2Service.startWithCommand(name, app.repoPath, command)
+ .catch(err => ({ success: false, error: err.message }));
+ results[name] = result;
+ }
}
const allSuccess = Object.values(results).every(r => r.success !== false);
diff --git a/server/services/pm2.js b/server/services/pm2.js
index 3bcec44691..576ecb5cdc 100644
--- a/server/services/pm2.js
+++ b/server/services/pm2.js
@@ -1,5 +1,6 @@
import pm2 from 'pm2';
import { spawn } from 'child_process';
+import { existsSync } from 'fs';
/**
* Connect to PM2 daemon and run an action
@@ -229,3 +230,46 @@ export async function startWithCommand(name, cwd, command) {
});
});
}
+
+/**
+ * Start app(s) using ecosystem.config.cjs/js file
+ * This properly uses all env vars, scripts, args defined in the config
+ * @param {string} cwd Working directory containing ecosystem config
+ * @param {string[]} processNames Optional: specific processes to start (--only flag)
+ */
+export async function startFromEcosystem(cwd, processNames = []) {
+ return new Promise((resolve, reject) => {
+ const ecosystemFile = ['ecosystem.config.cjs', 'ecosystem.config.js']
+ .find(f => existsSync(`${cwd}/${f}`));
+
+ if (!ecosystemFile) {
+ return reject(new Error('No ecosystem.config.cjs or ecosystem.config.js found'));
+ }
+
+ const args = ['start', ecosystemFile];
+ if (processNames.length > 0) {
+ args.push('--only', processNames.join(','));
+ }
+
+ const child = spawn('pm2', args, { cwd, shell: false });
+ let stdout = '';
+ let stderr = '';
+
+ child.stdout.on('data', (data) => {
+ stdout += data.toString();
+ });
+
+ child.stderr.on('data', (data) => {
+ stderr += data.toString();
+ });
+
+ child.on('close', (code) => {
+ if (code !== 0) {
+ return reject(new Error(stderr || `pm2 start exited with code ${code}`));
+ }
+ resolve({ success: true, output: stdout });
+ });
+
+ child.on('error', reject);
+ });
+}
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 4eac7fbad5..f81d971c6a 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -22,6 +22,7 @@ import { buildPrompt } from './promptService.js';
import { registerSpawnedAgent, unregisterSpawnedAgent } from './agents.js';
import { getMemorySection } from './memoryRetriever.js';
import { extractAndStoreMemories } from './memoryExtractor.js';
+import { getSoulForPrompt } from './soul.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -1014,12 +1015,21 @@ async function buildAgentPrompt(task, config, workspaceDir) {
return null;
});
+ // Get soul context for persona alignment
+ const soulSection = await getSoulForPrompt({
+ maxTokens: config.soul?.maxContextTokens || 2000
+ }).catch(err => {
+ console.log(`⚠️ Soul context retrieval failed: ${err.message}`);
+ return null;
+ });
+
// Try to use the prompt template system
const promptData = await buildPrompt('cos-agent-briefing', {
task,
config,
memorySection,
claudeMdSection,
+ soulSection,
timestamp: new Date().toISOString()
}).catch(() => null);