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: download MTPLX's Python runtime from the install button, not from a status poll
[._.]/ Adam Eivy04f3f7ab7be5
diff --git a/client/src/components/settings/MtplxServerCard.jsx b/client/src/components/settings/MtplxServerCard.jsxindex 8569cde2b8..dc4df08503 100644--- a/client/src/components/settings/MtplxServerCard.jsx+++ b/client/src/components/settings/MtplxServerCard.jsx@@ -44,6 +44,12 @@ export default function MtplxServerCard({// payloads (a peer or a tab open across an upgrade) carry only the ids.const cachedRows = status?.cachedModelRows || cached.map((repo) => ({ repo }));const emptyCache = Boolean(status?.installed) && cached.length === 0 && !status?.cacheError;+ // The Homebrew `mtplx` is a wrapper that downloads its real Python runtime on+ // first run, so "on PATH" and "can serve" are two different facts. Older+ // status payloads (a peer, or a tab left open across an upgrade) carry no+ // `runtimeReady` at all — treat those as ready, which is what the card did+ // before this field existed.+ const runtimeMissing = Boolean(status?.installed) && status?.runtimeReady === false;const external = status?.running && status?.managed === false;const tuningFlags = status?.tuningFlags || [];@@ -119,6 +125,22 @@ export default function MtplxServerCard({)}</div></div>+ ) : runtimeMissing ? (+ <div className="bg-port-warning/10 border border-port-warning/30 rounded-lg p-3 text-xs text-port-warning flex flex-col sm:flex-row sm:items-center justify-between gap-3">+ <div className="space-y-1">+ <p className="font-semibold">Installed — runtime not yet downloaded.</p>+ <p className="text-gray-300">+ Homebrew installs a wrapper that fetches MTPLX itself (several hundred megabytes of+ Python and MLX) the first time it runs. PortOS will not do that inside a status poll+ or a server start, so run it here — it streams into the install progress and takes a+ few minutes.+ </p>+ </div>+ <button onClick={onInstall} disabled={busy} className={`${btnClass} bg-port-accent/20 hover:bg-port-accent/30 text-port-accent shrink-0`}>+ {actionInProgress === 'runtime-install-mtplx' ? <BrailleSpinner /> : <Download size={13} />}+ Download MTPLX runtime+ </button>+ </div>) : (<div className="bg-port-bg border border-port-border rounded-lg p-3 space-y-3">{emptyCache ? (@@ -184,7 +206,7 @@ export default function MtplxServerCard({</div>)}- {status?.installed && status?.supported !== false && (+ {status?.installed && status?.supported !== false && !runtimeMissing && (<MtplxCheckpointscached={cachedRows}cacheError={status?.cacheError || null}diff --git a/client/src/components/settings/MtplxServerCard.test.jsx b/client/src/components/settings/MtplxServerCard.test.jsxindex 8fc00c7b59..4baa1e25e2 100644--- a/client/src/components/settings/MtplxServerCard.test.jsx+++ b/client/src/components/settings/MtplxServerCard.test.jsx@@ -190,6 +190,34 @@ describe('MtplxServerCard', () => {expect(handlers.onInstall).toHaveBeenCalled();});+ // The Homebrew `mtplx` is a wrapper that downloads MTPLX itself on first run,+ // so "on PATH" and "can serve a request" are two different facts. A card that+ // conflated them offered a Start button guaranteed to fail.+ it('offers the runtime download, not a Start button, when only the wrapper is installed', async () => {+ const handlers = await renderCard({+ installed: true, runtimeReady: false, running: false, supported: true, port: 8000, cachedModels: [],+ });++ expect(screen.getByText(/Installed — runtime not yet downloaded/)).toBeInTheDocument();+ expect(screen.queryByRole('button', { name: /Start MTPLX/ })).toBeNull();+ // Nor the checkpoint panel: every action in it invokes the same wrapper.+ expect(screen.queryByRole('button', { name: /Download default checkpoint/ })).toBeNull();++ fireEvent.click(screen.getByRole('button', { name: /Download MTPLX runtime/ }));+ expect(handlers.onInstall).toHaveBeenCalled();+ });++ // A peer, or a tab left open across an upgrade, sends a payload predating the+ // field. Reading its absence as "not downloaded" would replace a working+ // card with a download prompt.+ it('treats a status payload with no runtimeReady as ready', async () => {+ await renderCard({+ installed: true, running: false, supported: true, port: 8000, cachedModels: ['Example/Qwen-MTP'],+ });+ expect(screen.queryByText(/runtime not yet downloaded/)).toBeNull();+ expect(screen.getByRole('button', { name: /Start MTPLX/ })).toBeInTheDocument();+ });+it('says why, and offers nothing, on a host that cannot run MLX', async () => {await renderCard({ installed: false, running: false, supported: false, unsupportedReason: 'MTPLX runs only on macOS with Apple Silicon.' });expect(screen.getByText('MTPLX runs only on macOS with Apple Silicon.')).toBeInTheDocument();diff --git a/docs/features/mtplx.md b/docs/features/mtplx.mdindex 37a2746339..b9b376ecc0 100644--- a/docs/features/mtplx.md+++ b/docs/features/mtplx.md@@ -58,6 +58,25 @@ you are already on.1. Install MTPLX from **Local Runtime Servers**. PortOS installs the packagefrom upstream's Homebrew tap (`brew install youssofal/mtplx/mtplx`), fallingback to `python3 -m pip install mtplx` on a host without Homebrew.++ The Homebrew formula does **not** install MTPLX itself. It installs a small+ shell wrapper that builds a version-keyed Python venv — several hundred+ megabytes of pip downloads (fastapi, huggingface_hub, numpy/scipy, the MLX+ stack) — the first time anything runs `mtplx`, and `brew upgrade mtplx`+ re-arms it, because the venv path carries the version.++ PortOS runs that bootstrap **here**, as part of the install: after `brew+ install` returns it invokes `mtplx --version` once, streaming the pip output+ into the install progress under the same 20-minute budget, and fails the+ install if the bootstrap fails. Nothing else invokes the wrapper before then+ — a status poll skips its `mtplx models --json` cache read and a start+ refuses with `MTPLX_RUNTIME_NOT_BOOTSTRAPPED`, because neither can survive a+ package download inside its timeout, and a start never performs a large+ silent download. Readiness is decided by READING the wrapper (the venv it+ names, and whether `<venv>/bin/mtplx` is executable — its own guard), never+ by running it; a pip install or any other layout is treated as ready. The+ card reports it as **Installed — runtime not yet downloaded**, with a+ **Download MTPLX runtime** button that re-runs the install flow.2. **Download a checkpoint** from the MTPLX card's **Cached checkpoints** /**Find a checkpoint** panel. Search runs `mtplx forge discover` — upstream'sindex of MTPLX-branded MTP models, which is exactly the set `mtplx serve` candiff --git a/server/lib/README.md b/server/lib/README.mdindex cd8284e1e3..ec23050749 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -176,7 +176,8 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `opencodeConfig.js` | OpenCode config builder — `buildOpencodeEnvVars(provider, model)` builds dynamic `OPENCODE_CONFIG_CONTENT` declaring model ids under the namespace the provider's marker selects: a local runtime (`ollama` / `mtplx` / `llama` / `vllm` / `sglang`, bare ids) or a hosted gateway from `providerGateways.js` (`vendor/model` ids kept whole). Fixes --model rejection. Also attaches the key for a key-bearing namespace, and pins `small_model` to the run model for a gateway so OpenCode's own side calls (titles, summarization) can't land on its built-in default — a billed model the operator never chose. || `localProviderRuntime.js` | Which LOCAL daemon a provider talks to, and where — `LOCAL_RUNTIMES` (llama.cpp / Ollama / LM Studio / MTPLX / vLLM: label, binary, canonical base URL read from `opencodeConfig.js` rather than re-typed, manage/docs links, model-download hint), `localBackendForProvider` + `localEndpointPort` + `isLocalInstanceHost` (moved here from `services/localModelHealing.js`, which re-exports them, so the healing path and the readiness checklist classify a provider identically — loopback/bind-all only, so a LAN/Tailscale peer on port 11434 is NOT claimed as a local daemon), `localRuntimeKind(provider)` (the `*Backed` markers first, then that classifier; `orcarouter` excluded as a remote API), `localRuntimeForProvider(provider)` → the row with the endpoint the provider ITSELF configures (`OPENCODE_CONFIG_CONTENT`'s `baseURL`, `ANTHROPIC_BASE_URL`, or `endpoint`), then the `OLLAMA_URL`/`OLLAMA_HOST`/`LM_STUDIO_URL` override the backend managers read, then the canonical default — and `null` when that resolved endpoint fails `isLocalInstanceEndpoint` (an API provider on another machine has no local daemon to check, whatever its name says) — plus `normalizeOpenAiBaseUrl`. Pure; the probing half is `services/providerReadiness.js`. Optional `setupStateDetail` overrides `providerReadiness`'s per-state prose for a runtime whose local setup is not a model cache (vLLM's is a compose project); `standbyWhenStopped` marks an installed runtime such as llama.cpp whose stopped state is intentional standby rather than incomplete setup. || `managedDaemon.js` | Shared mechanism for the local daemons PortOS runs as optional PM2 processes (`services/llamaServerManager.js` → `portos-llama-server`, `services/mtplxServerManager.js` → `portos-mtplx`). Owns their PM2 process names — `LLAMA_APP`, `MTPLX_APP`, and the `isModelServerProcess(name)` predicate over them — so a caller like the CoS health monitor can recognize a model server without importing a manager; the managers re-export the two names. `createDaemonWatcher({...})` supplies the common PM2 launch-line re-adoption, endpoint probe, status skeleton, bounded log view, and port-release wait while managers retain daemon-specific parsing and lifecycle policy. `createDaemonLogBuffer({maxLines?})` is the bounded timestamped ring buffer of what PortOS logged around a launch, plus `withPm2Logs(output)` → that buffer followed by anything `pm2 logs` has which it doesn't already hold, deduped and re-capped (PM2's lines are a VIEW, never folded into the buffer — PM2 owns them and re-reads them every status call). `pm2ArgValue(args, flag)` reads one value back out of a PM2 process's recorded argv so a manager can recover a still-online daemon's launch config after a PortOS restart; `null` means the flag was absent, which a relaunch must leave off rather than defaulting. Also the shared **idle reaper**, for a daemon that cannot release its weights any other way: `registerIdleDaemon({name, getIdleMs, stop})` (seeds `lastUsedAt` to NOW, so a hand-started daemon gets a full window), `markDaemonUsed(name)` — call on real traffic, NEVER on a status poll — `daemonLastUsedAt(name)`, `idleWindowMs(minutes)` (minutes → ms; `0` = never, `null` = not configured, kept distinct), `reapIdleDaemons(now?)` → the names stopped, and `startIdleReaper({intervalMs?})` / `stopIdleReaper()` (ONE interval for all registrants, `unref`'d, idempotent). `mtplxServerManager` is the only registrant: llama.cpp releases its checkpoint in place via `--sleep-idle-seconds` and must NOT be stopped for it. Deliberately mechanism only — what a launch line means and when a daemon may start is exactly what differs between the two. |-| `mtplxModels.js` | `listMtplxCachedModels({command?})` → `{models, error}` from `mtplx models --json` (a local directory listing — no network, no model load) and `pickMtplxCachedModel(models)` → the repo id to hand `mtplx serve --model`. `models: null` means the cache could not be READ (no binary, command failed, unparseable) and is deliberately distinct from `[]` (read, and empty), because `services/localRuntimeSetup.js` starts MTPLX on its own default in the first case and refuses with the `mtplx pull` command in the second. Exists because `mtplx serve` defaults `--model` to one hard-coded checkpoint and exits 1 before binding when that repo is not cached — even on a host holding a different MTP model that serves fine. Picks only entries MTPLX itself calls complete (`validation.ok !== false`, so a half-finished pull is not served), preferring one with a recorded `mtplx_runtime.json` exactness contract. `describeMtplxCache(cache)` → `{state: 'unknown'\|'empty'\|'partial'\|'ready', model, count, error}` folds both into the one value `services/providerReadiness.js` puts on the checklist and `describeRuntimeSetup` picks a button from — so an empty cache is named up front instead of only inside the failure of a Start that could never work. |+| `mtplxModels.js` | `listMtplxCachedModels({command?})` → `{models, error}` from `mtplx models --json` (walks local directories — pulls no weights, loads no model, but see `mtplxRuntime.js`: on an un-warmed Homebrew wrapper the spawn ITSELF is a several-hundred-megabyte runtime download, so poll callers must gate on `describeMtplxRuntime().ready` first) and `pickMtplxCachedModel(models)` → the repo id to hand `mtplx serve --model`. `models: null` means the cache could not be READ (no binary, command failed, unparseable) and is deliberately distinct from `[]` (read, and empty), because `services/localRuntimeSetup.js` starts MTPLX on its own default in the first case and refuses with the `mtplx pull` command in the second. Exists because `mtplx serve` defaults `--model` to one hard-coded checkpoint and exits 1 before binding when that repo is not cached — even on a host holding a different MTP model that serves fine. Picks only entries MTPLX itself calls complete (`validation.ok !== false`, so a half-finished pull is not served), preferring one with a recorded `mtplx_runtime.json` exactness contract. `describeMtplxCache(cache)` → `{state: 'unknown'\|'empty'\|'partial'\|'ready', model, count, error}` folds both into the one value `services/providerReadiness.js` puts on the checklist and `describeRuntimeSetup` picks a button from — so an empty cache is named up front instead of only inside the failure of a Start that could never work. |+| `mtplxRuntime.js` | `describeMtplxRuntime(binaryPath, {env?})` → `{ready, wrapper, venvPath}` — is MTPLX's own Python runtime on disk, decided by READING the binary rather than running it. Homebrew's `mtplx` is a shell wrapper that lazily bootstraps a version-keyed Python venv (a multi-hundred-megabyte pip install) on its first invocation, and `brew upgrade` re-arms it, so a status poll or an 8s-judged PM2 start is really a package download. This parses the wrapper's own `VENV=` assignment, honours `$MTPLX_BREW_VENV` the way `${MTPLX_BREW_VENV:-…}` does, and tests `<venv>/bin/mtplx` for executability — the wrapper's own `[ ! -x … ]` guard, so the two cannot disagree. Anything unrecognisable (a pip install, a compiled binary, an unparseable script) reports `ready: true, wrapper: false`, i.e. the status quo — never a block over a parse failure. || `vllmQwenProject.js` | `resolveVllmProjectDir()` / `inspectVllmQwenProject()` → `{dir, hasProject, composeFile, hasWeights, weightsRoot}` for the syv-ai/qwen38-27b-rtx3090 compose project, plus `vllmStartBlockedReason(project)` → the prose refusal (or `null`), and `vllmProjectSetupState(project)` → `ready`/`empty`/`unknown` for the readiness checklist. `hasWeights` is tri-state: `true` found / `false` caches read and empty / `null` no cache readable (a docker-volume cache is invisible from a native-Win32 PortOS), and `services/localRuntimeSetup.js` refuses to `docker compose up` on anything but `true` so the start button can never kick off the ~20 GB prepare. Also owns WHERE the project lives: `readRecordedVllmProjectDir(envPath?)` / `recordVllmProjectDir(dir, envPath?)` keep PortOS's auto-detected directory as one line in the INSTALL's `.env` (`PATHS.installRoot`, so a worktree-booted server writes where the real install reads), and `vllmProjectDirIsSettled()` answers "is detection still worth a subprocess?" so the manager never re-lists the precedence. That order is `VLLM_QWEN_PROJECT_DIR` (this run's decision) → the record → `~/qwen-serving`; `envPath` is a parameter so a test's sandbox answers instead of the developer's install. Directory reads plus that one config line — never docker, never a registry. Other override: `VLLM_QWEN_WEIGHTS_DIR`. || `wslDistro.js` | Which WSL2 distro a native-Win32 PortOS should put Linux-side work in. `detectWslProjectDir(leaf)` → `{dir, distro, home}` or `{dir: null, reason}` (`no-wsl` / `no-distro` / `internal-distro` / `unreadable-share`), built from `wsl.exe -e sh -c 'echo "$WSL_DISTRO_NAME"; echo "$HOME"'` — the distro's OWN shell, because `wsl --list` prints UTF-16LE that a UTF-8 reader mangles while an executed program's stdout passes through byte for byte. Verifies the derived `\\wsl.localhost\…` path is readable from Windows before returning it (WSL running and its share answering are separate facts) and refuses a container engine's own distro (`docker-desktop` and friends are recreated on a reset). `parseWslProbe` / `parseWslDistroList` (NUL-stripping the UTF-16 bytes, for an error message only) are exported for their own tests; `WSL_UNC_PREFIX` names the share root for callers writing refusal prose. Exists so the vLLM stack places its ~20 GB of weights on the distro filesystem instead of asking a human to fill in a UNC template — every read from a `C:\` checkout would cross a 9p share. || `qwenAgentParsers.js` | The tool-call / reasoning parser flags a local runtime MUST carry to serve a Qwen3-family model to a coding agent — one table PortOS owns instead of three docs. `QWEN_AGENT_PARSERS` maps runtime → `{toolCallParser, reasoningParser, enableAutoToolChoice}` (vLLM `qwen3_xml` + `--enable-auto-tool-choice`, SGLang `qwen3_coder` + `--reasoning-parser qwen3`, llama both `null` — a positive "no such flag today", not a placeholder). `parserFlagsFor(runtime)` returns the argv fragment (always an array, so no caller type-checks) and `vllmExtraArgs()` its string form for the compose project's `.env` `EXTRA_ARGS`; an unknown runtime THROWS, because the failure it prevents is silent — a parser-less server answers fluently and returns tool markup as ordinary text with `tool_calls: null`, so the agent never touches a file. Spellings are empirical (`docs/research/2026-08-21-qwen38-rtx3090-vllm.md`, `…-sglang-qwen38-27b.md`); never auto-detect one from the chat template — that is how `hermes` got picked. Pure. |diff --git a/server/lib/index.js b/server/lib/index.jsindex 719a39a1e2..0befd98879 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -182,6 +182,7 @@ export * from './recurrenceValidation.js';export * from './opencodeConfig.js';export * from './localProviderRuntime.js';export * from './mtplxModels.js';+export * from './mtplxRuntime.js';export * from './managedDaemon.js';export * from './vllmQwenProject.js';export * from './wslDistro.js';diff --git a/server/lib/mtplxModels.js b/server/lib/mtplxModels.jsindex aa1a5b42ba..067eb9eff8 100644--- a/server/lib/mtplxModels.js+++ b/server/lib/mtplxModels.js@@ -13,12 +13,21 @@* readiness checklist's "Start MTPLX" button into "MTPLX did not start: mtplx* exited early (code 1)".*- * So PortOS asks first. `mtplx models --json` is a local directory listing (no- * network, no model load), and naming a cached repo on the command line is the- * difference between a server that comes up and one that cannot. A start still- * never downloads weights — a multi-gigabyte pull stays the user's decision,- * made on a button that says so (`services/localRuntimeSetup.js`'s `pull-start`- * action), exactly as `docs/features/mtplx.md` promises.+ * So PortOS asks first. `mtplx models --json` walks local directories — it+ * pulls no weights and loads no model — and naming a cached repo on the command+ * line is the difference between a server that comes up and one that cannot. A+ * start still never downloads weights: a multi-gigabyte pull stays the user's+ * decision, made on a button that says so (`services/localRuntimeSetup.js`'s+ * `pull-start` action), exactly as `docs/features/mtplx.md` promises.+ *+ * **It is NOT free, and it is NOT safe on an un-warmed status poll.** The+ * `mtplx` Homebrew puts on PATH is a wrapper that bootstraps a version-keyed+ * Python venv — several hundred megabytes over the network — on its first+ * invocation, and `brew upgrade` re-arms it. So on such a host THIS spawn is+ * that download: it outruns the timeout below, gets killed, and the next caller+ * starts it over. Callers on a poll must gate on `lib/mtplxRuntime.js`'s+ * `describeMtplxRuntime().ready` first — `services/mtplxServerManager.js` and+ * `services/localRuntimeSetup.js` both do.*/import { bufferedSpawn, spawnFailureDetail } from './bufferedSpawn.js';diff --git a/server/lib/mtplxRuntime.js b/server/lib/mtplxRuntime.jsnew file mode 100644index 0000000000..65afdb719e--- /dev/null+++ b/server/lib/mtplxRuntime.js@@ -0,0 +1,102 @@+/**+ * Whether MTPLX's own Python runtime is on disk yet — decided WITHOUT running it.+ *+ * The `mtplx` Homebrew installs is not MTPLX. It is a few-line shell wrapper+ * that lazily bootstraps a version-keyed Python venv the first time anybody+ * invokes it:+ *+ * VENV="${MTPLX_BREW_VENV:-/opt/homebrew/var/mtplx/venv-<version>}"+ * if [ ! -x "$VENV/bin/mtplx" ]; then+ * ... python -m venv "$VENV" && pip install <the real package tarball>+ * fi+ * exec "$VENV/bin/mtplx" "$@"+ *+ * That bootstrap is a multi-hundred-megabyte network install (fastapi,+ * huggingface_hub, numpy/scipy, the MLX stack), and `brew upgrade mtplx` re-arms+ * it, because the venv path carries the version. So ANY invocation of the+ * wrapper on a fresh version — a status poll running `mtplx models --json`, a+ * PM2 start judged on an eight-second window — is really a package download,+ * budgeted as if it were free and local. It reliably outruns both, and the+ * failure is reported as a timed-out cache read or a crashed daemon.+ *+ * This module answers the question the wrapper itself asks, by reading rather+ * than executing: parse the wrapper's own `VENV=` assignment, honour+ * `$MTPLX_BREW_VENV` exactly as `${MTPLX_BREW_VENV:-…}` does, and test+ * `<venv>/bin/mtplx` for executability — byte-for-byte the wrapper's+ * `[ ! -x "$VENV/bin/mtplx" ]` guard, so the two cannot disagree.+ *+ * **Anything that is not a recognisable wrapper reports READY.** A pip install+ * puts the real console script on PATH, a future Homebrew formula may drop the+ * shim entirely, and a script this parser cannot read is not evidence of a+ * missing runtime. Reporting "not ready" there would block a working install+ * over a parse failure; reporting "ready" is exactly today's behaviour.+ *+ * Rejected alternative: a persisted "PortOS warmed it" flag. It goes stale on+ * the next `brew upgrade` (new version ⇒ new venv path ⇒ the bootstrap is armed+ * again while the flag still says warmed) and is simply absent for an `mtplx`+ * the user installed outside PortOS.+ */++import { constants } from 'fs';+import { access, readFile, stat } from 'fs/promises';+import { isAbsolute, join } from 'path';++/**+ * Above this, the file on PATH is a compiled binary or a bundled script, not+ * the handful of lines Homebrew writes — reading it whole to hunt for `VENV=`+ * would be pointless I/O on every status poll.+ */+const MAX_WRAPPER_BYTES = 64 * 1024;++/**+ * The venv path the wrapper would use, or `null` when this is not a wrapper.+ *+ * Returns `''` for a wrapper that names no default (`VENV="$MTPLX_BREW_VENV"`),+ * which is distinct from `null`: the caller still has `$MTPLX_BREW_VENV` to+ * fall back on, whereas `null` means there was no assignment to honour at all.+ */+const parseWrapperVenvDefault = (text) => {+ const match = /^[ \t]*VENV=(.*)$/m.exec(text);+ if (!match) return null;+ let value = match[1].trim();+ if (value.length >= 2 && ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith('\'') && value.endsWith('\'')))) {+ value = value.slice(1, -1);+ }+ const braced = /^\$\{MTPLX_BREW_VENV:-(.*)\}$/.exec(value);+ if (braced) return braced[1];+ if (value === '$MTPLX_BREW_VENV' || value === '${MTPLX_BREW_VENV}') return '';+ // A literal path (a formula that dropped the env override). Any other shape+ // carries shell expansion this parser will not guess at — say "not a wrapper"+ // and let the caller keep today's behaviour.+ return isAbsolute(value) ? value : null;+};++/**+ * Describe the runtime behind a resolved `mtplx` executable.+ *+ * @param {string|null|undefined} binaryPath - what `findCommandOnPath('mtplx')` resolved+ * @param {{env?: object}} [options]+ * @returns {Promise<{ready: boolean, wrapper: boolean, venvPath: string|null}>}+ * `wrapper: false` means the probe recognised nothing to check and is+ * reporting the status quo, NOT that it proved a runtime present.+ */+export async function describeMtplxRuntime(binaryPath, { env = process.env } = {}) {+ if (!binaryPath) return { ready: false, wrapper: false, venvPath: null };++ const size = await stat(binaryPath).then((s) => s.size).catch(() => null);+ if (size === null || size > MAX_WRAPPER_BYTES) return { ready: true, wrapper: false, venvPath: null };++ const buffer = await readFile(binaryPath).catch(() => null);+ // A NUL byte anywhere means a compiled executable, not a shell script — and+ // `includes` on the buffer avoids decoding a binary into a throwaway string.+ if (!buffer || buffer.includes(0)) return { ready: true, wrapper: false, venvPath: null };++ const parsed = parseWrapperVenvDefault(buffer.toString('utf8'));+ if (parsed === null) return { ready: true, wrapper: false, venvPath: null };++ const venvPath = env?.MTPLX_BREW_VENV || parsed;+ if (!venvPath) return { ready: true, wrapper: false, venvPath: null };++ const ready = await access(join(venvPath, 'bin', 'mtplx'), constants.X_OK).then(() => true).catch(() => false);+ return { ready, wrapper: true, venvPath };+}diff --git a/server/lib/mtplxRuntime.test.js b/server/lib/mtplxRuntime.test.jsnew file mode 100644index 0000000000..42e7b10131--- /dev/null+++ b/server/lib/mtplxRuntime.test.js@@ -0,0 +1,95 @@+import { chmod, mkdtemp, mkdir, rm, writeFile } from 'fs/promises';+import { tmpdir } from 'os';+import { join } from 'path';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';++import { describeMtplxRuntime } from './mtplxRuntime.js';++// The real Homebrew shim, trimmed to the two lines the probe reads.+const wrapperScript = (venv) => `#!/bin/bash+set -euo pipefail+VENV="\${MTPLX_BREW_VENV:-${venv}}"+PYTHON="/opt/homebrew/opt/[email protected]/bin/python3.13"++if [ ! -x "$VENV/bin/mtplx" ]; then+ echo "MTPLX runtime is not installed. Bootstrapping with pip..."+ "$PYTHON" -m venv "$VENV"+fi+exec "$VENV/bin/mtplx" "$@"+`;++describe('describeMtplxRuntime', () => {+ let dir = null;+ const wrapperAt = async (name, body) => {+ const path = join(dir, name);+ await writeFile(path, body);+ await chmod(path, 0o755);+ return path;+ };+ const buildVenv = async (venv) => {+ await mkdir(join(venv, 'bin'), { recursive: true });+ const real = join(venv, 'bin', 'mtplx');+ await writeFile(real, '#!/bin/sh\necho 2.10.1\n');+ await chmod(real, 0o755);+ };++ beforeEach(async () => { dir = await mkdtemp(join(tmpdir(), 'portos-mtplx-runtime-')); });+ afterEach(async () => { await rm(dir, { recursive: true, force: true }); });++ it('reports NOT ready for a wrapper whose version-keyed venv has never been built', async () => {+ // The whole point: this is the state in which running the binary would+ // start a several-hundred-megabyte pip install.+ const path = await wrapperAt('mtplx', wrapperScript(join(dir, 'var', 'venv-2.10.1')));+ expect(await describeMtplxRuntime(path, { env: {} })).toEqual({+ ready: false,+ wrapper: true,+ venvPath: join(dir, 'var', 'venv-2.10.1'),+ });+ });++ it('reports ready once the venv holds an executable mtplx', async () => {+ const venv = join(dir, 'var', 'venv-2.10.1');+ await buildVenv(venv);+ const path = await wrapperAt('mtplx', wrapperScript(venv));+ expect(await describeMtplxRuntime(path, { env: {} })).toMatchObject({ ready: true, wrapper: true });+ });++ it('honours $MTPLX_BREW_VENV, exactly as the wrapper\'s ${MTPLX_BREW_VENV:-…} does', async () => {+ const override = join(dir, 'elsewhere', 'venv');+ await buildVenv(override);+ // The wrapper's own default is empty, so a probe that ignored the override+ // would report "not ready" for a runtime that is right there.+ const path = await wrapperAt('mtplx', wrapperScript(join(dir, 'var', 'venv-2.10.1')));+ expect(await describeMtplxRuntime(path, { env: { MTPLX_BREW_VENV: override } }))+ .toMatchObject({ ready: true, venvPath: override });+ });++ // Everything below is the "keep today's behaviour" half. Reporting `false`+ // for a binary this parser does not recognise would block a working install+ // over a parse failure, so each of these must come back ready.+ it('reports ready for a pip install — the real console script, not a wrapper', async () => {+ const path = await wrapperAt('mtplx', '#!/usr/bin/env python3\nfrom mtplx.cli import main\nmain()\n');+ expect(await describeMtplxRuntime(path, { env: {} })).toEqual({ ready: true, wrapper: false, venvPath: null });+ });++ it('reports ready for a compiled binary rather than decoding it', async () => {+ const path = join(dir, 'mtplx');+ await writeFile(path, Buffer.from([0xcf, 0xfa, 0xed, 0xfe, 0x00, 0x01, 0x00, 0x00]));+ await chmod(path, 0o755);+ expect(await describeMtplxRuntime(path, { env: {} })).toMatchObject({ ready: true, wrapper: false });+ });++ it('reports ready for a wrapper-shaped script whose VENV it cannot resolve', async () => {+ const path = await wrapperAt('mtplx', '#!/bin/bash\nVENV="$(dirname "$0")/../var/venv"\nexec "$VENV/bin/mtplx" "$@"\n');+ expect(await describeMtplxRuntime(path, { env: {} })).toMatchObject({ ready: true, wrapper: false });+ });++ it('reports ready when the file cannot be read at all', async () => {+ expect(await describeMtplxRuntime(join(dir, 'not-here'), { env: {} }))+ .toMatchObject({ ready: true, wrapper: false });+ });++ it('reports not-ready for no binary at all — there is nothing installed to warm', async () => {+ expect(await describeMtplxRuntime(null, { env: {} })).toEqual({ ready: false, wrapper: false, venvPath: null });+ });+});diff --git a/server/services/localRuntimeSetup.js b/server/services/localRuntimeSetup.jsindex faf6bab6b0..ad6cbe9782 100644--- a/server/services/localRuntimeSetup.js+++ b/server/services/localRuntimeSetup.js@@ -56,6 +56,7 @@import { LOCAL_RUNTIMES, localEndpointPort } from '../lib/localProviderRuntime.js';import { describeMtplxCache, listMtplxCachedModels } from '../lib/mtplxModels.js';+import { describeMtplxRuntime } from '../lib/mtplxRuntime.js';import { probeOpenAiModels } from '../lib/openAiModelsProbe.js';import { inspectSglangQwenProject, sglangStartBlockedReason } from '../lib/sglangQwenProject.js';import { sglangUnsupportedReason } from '../lib/sglangQwenRecipe.js';@@ -112,6 +113,30 @@ const MTPLX_NO_MODEL_ERROR = 'no model weights are cached, so its server exits bconst mtplxPartialCacheError = (count) =>`its cache holds ${count} model${count === 1 ? '' : 's'}, but none passed its own file check — an interrupted download leaves a partial pack behind. Use “Download the default model & start MTPLX” on the checklist to re-fetch it, or pick another checkpoint on the MTPLX card in Models → LLMs.`;+/**+ * MTPLX's cache state, read WITHOUT invoking `mtplx`'s Homebrew wrapper before+ * its Python runtime exists.+ *+ * `mtplx models --json` touches no network — but on a host where the wrapper+ * has not bootstrapped its version-keyed venv yet, spawning it IS a+ * several-hundred-megabyte pip install (`lib/mtplxRuntime.js`). The readiness+ * checklist polls this, so without the gate a checklist refresh would kick off+ * that download unannounced and then time out on it.+ *+ * A runtime that is not bootstrapped reports `unknown` — the cache genuinely+ * could not be read, which is deliberately NOT `empty` — so the checklist does+ * not claim MTPLX has no weights. A start attempted anyway is refused by+ * `startMtplxServer` with `MTPLX_RUNTIME_NOT_BOOTSTRAPPED`, which names the+ * download step rather than the checkpoint one.+ */+async function readMtplxCacheState() {+ const runtime = await describeMtplxRuntime(findCommandOnPath('mtplx'));+ if (!runtime.ready) {+ return { state: 'unknown', model: null, count: 0, error: 'MTPLX\'s Python runtime has not been downloaded yet' };+ }+ return describeMtplxCache(await listMtplxCachedModels());+}+/*** The `platforms` gate below is a static list, so its refusal has to be static* too — read from the recipe module rather than re-typed, so the platform@@ -247,7 +272,7 @@ const SETUP_ROWS = Object.freeze({* `readRuntimeWeights` to put the same fact on the checklist.*/async weights() {- return describeMtplxCache(await listMtplxCachedModels()).state;+ return (await readMtplxCacheState()).state;},provision: Object.freeze({action: 'pull-start',@@ -264,7 +289,7 @@ const SETUP_ROWS = Object.freeze({// checklist can offer the `pull-start` download button, and the messages// above say so; the Models → LLMs launcher has no such button and names// `mtplx pull` instead.- const cache = describeMtplxCache(await listMtplxCachedModels());+ const cache = await readMtplxCacheState();if (cache.state === 'unknown') {// The cache could not be READ — which is not "read, and empty". Fall// through to MTPLX's own default rather than blocking a start that maydiff --git a/server/services/mtplxServerManager.js b/server/services/mtplxServerManager.jsindex 42a6b630ba..f1318f717b 100644--- a/server/services/mtplxServerManager.js+++ b/server/services/mtplxServerManager.js@@ -31,6 +31,7 @@ import { ServerError } from '../lib/errorHandler.js';import { launchArgs, normalizeTuning, tuningSpecsFor } from '../lib/localModelTuning.js';import { LOCAL_RUNTIMES, localEndpointPort, localRuntimeKind, isLocalInstanceEndpoint } from '../lib/localProviderRuntime.js';import { listMtplxCachedModels, pickMtplxCachedModel } from '../lib/mtplxModels.js';+import { describeMtplxRuntime } from '../lib/mtplxRuntime.js';import { probeOpenAiModels } from '../lib/openAiModelsProbe.js';import { createDaemonWatcher, pm2ArgValue, idleWindowMs, markDaemonUsed, registerIdleDaemon, MTPLX_APP } from '../lib/managedDaemon.js';// `settings.js` is lazy-imported at its call sites below, never statically: it@@ -120,6 +121,16 @@ const MTPLX_NO_MODEL_ERROR = 'MTPLX has no model weights cached, so its server econst 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.';+/**+ * Why an installed MTPLX still cannot be started, one layer below a missing+ * checkpoint: the Homebrew wrapper on PATH has not built its Python venv yet, so+ * its first act would be a multi-hundred-megabyte pip install — inside an+ * eight-second startup window, reported afterwards as a crashed daemon. Same+ * contract as MTPLX_NO_MODEL_ERROR: a large download is a button the user+ * presses, never something a start does behind them.+ */+const MTPLX_RUNTIME_NOT_BOOTSTRAPPED_ERROR = `MTPLX's Python runtime has not been downloaded yet — Homebrew installs a wrapper that fetches it (several hundred megabytes) on first run, and PortOS will not do that inside a server start. Use "Download MTPLX runtime" on the MTPLX card to run it as its own step, then start MTPLX again.`;+/*** Keep MTPLX startup logs raw while scoping each diagnosis to the current* launch. PM2 appends to its configured files across process deletion, so@@ -304,13 +315,19 @@ export async function getMtplxServerEndpoint() {}/**- * Current MTPLX state: binary availability, process state, endpoint, config,- * logs, and what is in its model cache.- *- * The cache listing is a local directory walk (`mtplx models --json`) — no- * network, no model load — so it is safe on a status poll, and it is what lets- * the UI say "installed, but nothing to serve" instead of making the user press- * Start to find out.+ * Current MTPLX state: binary availability, runtime readiness, process state,+ * endpoint, config, logs, and what is in its model cache.+ *+ * The cache listing (`mtplx models --json`) reads a local directory and pulls+ * nothing over the network — but it does so by INVOKING `mtplx`, and the+ * Homebrew `mtplx` is a wrapper whose first invocation on a given version+ * bootstraps a several-hundred-megabyte Python venv (`lib/mtplxRuntime.js`).+ * On a host where that has not happened yet, this poll WAS the bootstrap: it+ * outran the 30s cache-query budget, got killed, reported `cacheError`, and the+ * next poll started the download over. So the cache is only read once+ * `runtimeReady` says the wrapper will exec straight through to the real+ * binary; until then `cachedModels` stays empty with `cacheError: null` —+ * "not read", never "read and empty".*/export async function getMtplxServerStatus() {const binaryPath = resolveMtplxBinary();@@ -323,14 +340,21 @@ export async function getMtplxServerStatus() {const base = await daemon.getStatusBase({ installed });+ // Reading the wrapper, never running it — see `lib/mtplxRuntime.js`.+ const runtimeReady = installed ? (await describeMtplxRuntime(binaryPath)).ready : false;+// `models: null` means the cache could NOT be read — deliberately not the same// as `[]` (read, and empty). Only the latter blocks a start.- const cache = installed ? await listMtplxCachedModels() : { models: null, error: null };+ const cache = installed && runtimeReady ? await listMtplxCachedModels() : { models: null, error: null };return {...base,supported,unsupportedReason: supported ? null : MTPLX_UNSUPPORTED_REASON,+ // Installed ≠ runnable: the Homebrew binary is a wrapper that downloads the+ // real runtime on first use. The card needs the two apart so it offers the+ // download instead of a Start button that is guaranteed to fail.+ runtimeReady,// The tuning flags the running daemon was LAUNCHED with, rendered by the// catalog that owns the transport rather than re-derived in the UI. A// measured assessment relaunches this daemon and leaves its flags on, so a@@ -361,6 +385,38 @@ export async function getMtplxServerStatus() {};}+/**+ * Run the Homebrew wrapper's deferred bootstrap HERE, where the user pressed a+ * button and the budget fits.+ *+ * `brew install` finishes with only a shell shim on PATH; the actual MTPLX —+ * fastapi, huggingface_hub, numpy/scipy, the MLX stack — is downloaded by the+ * wrapper's first invocation (`lib/mtplxRuntime.js`). Left alone, that lands on+ * whatever runs `mtplx` next: a 30s status poll or an 8s-judged PM2 start,+ * neither of which can survive it, both of which misreport it. `mtplx --version`+ * is the cheapest invocation that trips the same guard, and it streams into the+ * install modal under the 20-minute install budget.+ *+ * A failure here FAILS the install: returning success would leave a card+ * reporting `installed: true` for something that cannot serve a request.+ *+ * Skipped when the runtime is already present — a re-run of the install (the+ * card's "Download MTPLX runtime" button drives this same flow) then costs a+ * `brew install` no-op rather than another invocation.+ */+async function warmMtplxRuntime(emit) {+ const binaryPath = resolveMtplxBinary();+ if (!binaryPath) return;+ const runtime = await describeMtplxRuntime(binaryPath);+ if (runtime.ready) return;++ emit('MTPLX bootstraps its own Python runtime on first run — downloading it now. This can take several minutes.');+ const result = await runStreamingCommand(binaryPath, ['--version'], emit, { timeoutMs: INSTALL_TIMEOUT_MS });+ if (!result.success) {+ throw new ServerError(`MTPLX installed, but its Python runtime failed to bootstrap: ${result.error}`, { status: 500, code: 'MTPLX_RUNTIME_BOOTSTRAP_FAILED' });+ }+}+/*** Install MTPLX from upstream's Homebrew tap, falling back to pip on a host* without Homebrew. Both install the same `mtplx` binary, and neither runs the@@ -375,9 +431,12 @@ export async function installMtplx({ onProgress = () => {} } = {}) {emit('Installing MTPLX via Homebrew (youssofal/mtplx/mtplx)…');const result = await runStreamingCommand('brew', ['install', 'youssofal/mtplx/mtplx'], emit, { timeoutMs: INSTALL_TIMEOUT_MS });if (!result.success) throw new ServerError(`MTPLX install failed: ${result.error}`, { status: 500 });+ await warmMtplxRuntime(emit);return { success: true, message: 'MTPLX installed' };}if (await commandExists('python3', ['--version'])) {+ // No warm-up here: pip installs the REAL package, not a wrapper, so there is+ // no deferred runtime left to fetch.emit('Homebrew was not found — installing MTPLX with pip instead…');const result = await runStreamingCommand('python3', ['-m', 'pip', 'install', '--upgrade', 'mtplx'], emit, { timeoutMs: INSTALL_TIMEOUT_MS });if (!result.success) throw new ServerError(`MTPLX install failed: ${result.error}`, { status: 500 });@@ -449,6 +508,14 @@ export async function startMtplxServer(options = {}) {);}+ // A start never performs a large silent download — the same limit that keeps+ // it off model weights. Launching the wrapper before its venv exists would+ // hand PM2 a process whose first act is a pip install, judged (and killed) by+ // an eight-second startup window and reported as a crashed daemon.+ if (!(await describeMtplxRuntime(binaryPath)).ready) {+ throw new ServerError(MTPLX_RUNTIME_NOT_BOOTSTRAPPED_ERROR, { status: 400, code: 'MTPLX_RUNTIME_NOT_BOOTSTRAPPED' });+ }+const pm2Status = await getAppStatusStrict(MTPLX_APP);if (pm2Status && pm2Status.status === 'online') {throw new ServerError(`MTPLX is already running with PID ${pm2Status.pid}`, { status: 409 });diff --git a/server/services/mtplxServerManager.test.js b/server/services/mtplxServerManager.test.jsindex f99a82e617..2a34592773 100644--- a/server/services/mtplxServerManager.test.js+++ b/server/services/mtplxServerManager.test.js@@ -1,4 +1,4 @@-import { mkdtemp, readFile, rm, writeFile } from 'fs/promises';+import { chmod, mkdir, mkdtemp, readFile, rm, writeFile } from 'fs/promises';import { tmpdir } from 'os';import { join } from 'path';import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';@@ -668,6 +668,141 @@ describe('mtplxServerManager', () => {});});+ /**+ * The Homebrew `mtplx` is a shell wrapper that downloads MTPLX itself — a+ * several-hundred-megabyte pip install — on its first invocation, and+ * `brew upgrade` re-arms it (the venv path carries the version). These pin+ * the two hot paths OFF that download and the install flow ON to it.+ *+ * Real files on disk rather than a mocked probe: what is being mirrored is+ * the wrapper's own `[ ! -x "$VENV/bin/mtplx" ]` guard, and only the+ * filesystem can prove the two agree.+ */+ describe('the lazily-bootstrapped Python runtime', () => {+ let runtimeDir = null;++ const wrapperOnPath = async (venv) => {+ const path = join(runtimeDir, 'mtplx');+ await writeFile(path, [+ '#!/bin/bash',+ `VENV="\${MTPLX_BREW_VENV:-${venv}}"`,+ 'if [ ! -x "$VENV/bin/mtplx" ]; then echo "MTPLX runtime is not installed. Bootstrapping with pip..."; fi',+ 'exec "$VENV/bin/mtplx" "$@"',+ '',+ ].join('\n'));+ await chmod(path, 0o755);+ vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue(path);+ return path;+ };+ const buildVenv = async (venv) => {+ await mkdir(join(venv, 'bin'), { recursive: true });+ await writeFile(join(venv, 'bin', 'mtplx'), '#!/bin/sh\n');+ await chmod(join(venv, 'bin', 'mtplx'), 0o755);+ };++ beforeEach(async () => {+ runtimeDir = await mkdtemp(join(tmpdir(), 'portos-mtplx-runtime-'));+ // The probe honours $MTPLX_BREW_VENV exactly as the wrapper does, so a+ // value in the developer's own environment would decide these tests.+ vi.stubEnv('MTPLX_BREW_VENV', '');+ });+ afterEach(async () => {+ vi.unstubAllEnvs();+ await rm(runtimeDir, { recursive: true, force: true });+ });++ it('does not spawn the cache read while the runtime is missing — that spawn IS the download', async () => {+ await wrapperOnPath(join(runtimeDir, 'venv-2.10.1'));++ const status = await getMtplxServerStatus();++ expect(status.installed).toBe(true);+ expect(status.runtimeReady).toBe(false);+ expect(mtplxModels.listMtplxCachedModels).not.toHaveBeenCalled();+ // "Not read" must not read as "read, and empty" — and a phantom error+ // here would say MTPLX's cache is broken rather than never fetched into.+ expect(status.cachedModels).toEqual([]);+ expect(status.cachedModelRows).toEqual([]);+ expect(status.cacheError).toBeNull();+ });++ it('reads the cache once the venv the wrapper names is actually there', async () => {+ const venv = join(runtimeDir, 'venv-2.10.1');+ await buildVenv(venv);+ await wrapperOnPath(venv);++ const status = await getMtplxServerStatus();++ expect(status.runtimeReady).toBe(true);+ expect(mtplxModels.listMtplxCachedModels).toHaveBeenCalled();+ expect(status.cachedModels).toEqual(['Example/Qwen-MTP']);+ });++ it('treats an mtplx that is not a Homebrew wrapper as ready — a pip install keeps working', async () => {+ const path = join(runtimeDir, 'mtplx');+ await writeFile(path, '#!/usr/bin/env python3\nfrom mtplx.cli import main\nmain()\n');+ await chmod(path, 0o755);+ vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue(path);++ const status = await getMtplxServerStatus();++ expect(status.runtimeReady).toBe(true);+ expect(mtplxModels.listMtplxCachedModels).toHaveBeenCalled();+ });++ it('refuses a start rather than handing PM2 a process whose first act is a package download', async () => {+ await wrapperOnPath(join(runtimeDir, 'venv-2.10.1'));++ await expect(startMtplxServer()).rejects.toMatchObject({+ code: 'MTPLX_RUNTIME_NOT_BOOTSTRAPPED',+ status: 400,+ });+ // The eight-second startup window cannot survive the bootstrap, so this+ // start would have been reported to the user as a crashed daemon.+ expect(execPm2Calls.some((args) => args[0] === 'start')).toBe(false);+ });++ it('warms the runtime inside the install, where the user pressed a button and the budget fits', async () => {+ const binary = await wrapperOnPath(join(runtimeDir, 'venv-2.10.1'));+ vi.spyOn(commandExistsModule, 'commandExists').mockResolvedValue(true);+ vi.spyOn(streamingSpawn, 'runStreamingCommand').mockResolvedValue({ success: true });+ const emitted = [];++ const result = await installMtplx({ onProgress: (p) => emitted.push(p.message) });++ expect(result.success).toBe(true);+ const calls = streamingSpawn.runStreamingCommand.mock.calls;+ expect(calls[0][0]).toBe('brew');+ // One invocation of the wrapper, AFTER the package install, on the+ // 20-minute install budget rather than a status poll's 30 seconds.+ expect(calls[1].slice(0, 2)).toEqual([binary, ['--version']]);+ expect(calls[1][3].timeoutMs).toBeGreaterThanOrEqual(20 * 60 * 1000);+ expect(emitted.join(' ')).toMatch(/bootstraps its own Python runtime/i);+ });++ it('fails the install when the bootstrap fails, instead of succeeding into a card that cannot start', async () => {+ await wrapperOnPath(join(runtimeDir, 'venv-2.10.1'));+ vi.spyOn(commandExistsModule, 'commandExists').mockResolvedValue(true);+ vi.spyOn(streamingSpawn, 'runStreamingCommand').mockImplementation(async (cmd) => (+ cmd === 'brew' ? { success: true } : { success: false, error: 'ensurepip returned non-zero exit status 1' }+ ));++ await expect(installMtplx()).rejects.toMatchObject({ code: 'MTPLX_RUNTIME_BOOTSTRAP_FAILED' });+ });++ it('skips the warm-up when the runtime is already bootstrapped', async () => {+ const venv = join(runtimeDir, 'venv-2.10.1');+ await buildVenv(venv);+ await wrapperOnPath(venv);+ vi.spyOn(commandExistsModule, 'commandExists').mockResolvedValue(true);+ vi.spyOn(streamingSpawn, 'runStreamingCommand').mockResolvedValue({ success: true });++ await installMtplx();++ expect(streamingSpawn.runStreamingCommand).toHaveBeenCalledTimes(1);+ });+ });+describe('stopMtplxServer', () => {it('deletes the PM2 process it manages', async () => {vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue(BINARY);