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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: scope MTPLX bootstrap diagnostics to current launch (#5575)
[._.]/ Adam Eivy1335aaeecf78
diff --git a/server/services/mtplxServerManager.js b/server/services/mtplxServerManager.jsindex b658fc3bec..a319f71683 100644--- a/server/services/mtplxServerManager.js+++ b/server/services/mtplxServerManager.js@@ -115,7 +115,16 @@ export const MTPLX_UNSUPPORTED_REASON = 'MTPLX runs only on macOS with Apple Sil*/const MTPLX_NO_MODEL_ERROR = 'MTPLX has no model weights cached, so its server exits before it binds a port. Use "Download default checkpoint" on the MTPLX card (or search for another MTP model there) to fetch one — a multi-gigabyte download PortOS will not start without you asking — then start MTPLX again.';-const MTPLX_RUNTIME_BOOTSTRAP_ERROR = 'MTPLX\'s own Python runtime failed to bootstrap because Homebrew\'s Python does not provide a working `ensurepip`. Try `brew reinstall [email protected]` (or `brew install youssofal/mtplx/mtplx --build-from-source` to force a rebuild against a working interpreter), then start MTPLX again.';+const MTPLX_RUNTIME_BOOTSTRAP_ERROR = 'MTPLX\'s own Python runtime failed to bootstrap because Homebrew\'s Python does not provide a working `ensurepip`. Try `brew reinstall [email protected]` (or `brew reinstall --build-from-source youssofal/mtplx/mtplx` to force a rebuild against a working interpreter), then start MTPLX again.';++const MTPLX_LOG_DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ss.SSS';+const PM2_LOG_TIMESTAMP_PATTERN = /(?:^|\s)(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3})(?::|\s)/;++const currentMtplxLogLines = (lines, launchStartedAt) => lines.filter((line) => {+ const timestamp = line.match(PM2_LOG_TIMESTAMP_PATTERN)?.[1];+ const loggedAt = timestamp ? Date.parse(timestamp) : NaN;+ return Number.isFinite(loggedAt) && loggedAt >= launchStartedAt;+});const isMtplxRuntimeBootstrapFailure = (output) => {const text = String(output ?? '');@@ -456,11 +465,13 @@ export async function startMtplxServer(options = {}) {clearJlistCache();console.log(`🚄 MTPLX starting on ${DEFAULT_HOST}:${port}${model ? ` (model ${model})` : ' (MTPLX default model)'}${tuningArgs.length ? ` with ${tuningArgs.join(' ')}` : ''}`);+ const launchStartedAt = Date.now();await execPm2(['start', binaryPath,'--name', MTPLX_APP,'--interpreter', 'none','--no-autorestart',+ '--log-date-format', MTPLX_LOG_DATE_FORMAT,'--',...args,]);@@ -484,7 +495,7 @@ export async function startMtplxServer(options = {}) {for (const line of lines) appendLog(line);const tail = (lines.length ? lines : daemon.snapshotLogs()).slice(-4).join(' | ');lastExitError = `PM2 status: ${currentProc.status}`;- const message = isMtplxRuntimeBootstrapFailure(lines.join('\n'))+ const message = isMtplxRuntimeBootstrapFailure(currentMtplxLogLines(lines, launchStartedAt).join('\n'))? MTPLX_RUNTIME_BOOTSTRAP_ERROR: `MTPLX exited immediately (${lastExitError}).${tail ? ` Last output: ${tail}` : ''}`;diff --git a/server/services/mtplxServerManager.test.js b/server/services/mtplxServerManager.test.jsindex 5366a9c378..f09b8edc9f 100644--- a/server/services/mtplxServerManager.test.js+++ b/server/services/mtplxServerManager.test.js@@ -202,7 +202,17 @@ describe('mtplxServerManager', () => {pm2State = { name: MTPLX_APP, status: 'errored', pid: null, args: [] };}if (args[0] === 'delete') pm2State = null;- if (args[0] === 'logs') return { stdout: '', stderr: 'error: model is not available locally' };+ if (args[0] === 'logs') {+ return {+ stdout: '',+ stderr: [+ '2000-01-01T00:00:00.000: runtime is not installed',+ '2000-01-01T00:00:00.000: Bootstrapping with pip',+ '2000-01-01T00:00:00.000: python3.13 -m ensurepip --upgrade --default-pip',+ `${new Date().toISOString().slice(0, -1)}: error: model is not available locally`,+ ].join('\n'),+ };+ }return { stdout: '', stderr: '' };});await expect(startMtplxServer()).rejects.toThrow(/model is not available locally/);@@ -218,13 +228,16 @@ describe('mtplxServerManager', () => {}if (args[0] === 'delete') pm2State = null;if (args[0] === 'logs') {+ const timestamp = new Date().toISOString().slice(0, -1);return {stdout: '',stderr: [- 'runtime is not installed',- 'Bootstrapping with pip',- 'python3.13 -m ensurepip --upgrade --default-pip',- "Command '['python3.13', '-m', 'ensurepip']' returned non-zero exit status 1",+ ...[+ 'runtime is not installed',+ 'Bootstrapping with pip',+ 'python3.13 -m ensurepip --upgrade --default-pip',+ "Command '['python3.13', '-m', 'ensurepip']' returned non-zero exit status 1",+ ].map((line) => timestamp + ': ' + line),].join('\n'),};}@@ -236,6 +249,7 @@ describe('mtplxServerManager', () => {expect(err).toMatchObject({ code: 'MTPLX_EXITED' });expect(err.message).toContain('Homebrew\'s Python does not provide a working `ensurepip`');expect(err.message).toContain('brew reinstall [email protected]');+ expect(err.message).toContain('brew reinstall --build-from-source youssofal/mtplx/mtplx');expect(err.message).not.toContain('returned non-zero exit status 1');expect(pm2State).toBeNull();});