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

fix(providers): end the MTPLX catch-22 by reading its model cache up front

Adam Eivy105d89169fa7
diff --git a/client/src/components/providers/ProviderReadiness.jsx b/client/src/components/providers/ProviderReadiness.jsx
index 8a43ed76fc..0a8ccaba79 100644
--- a/client/src/components/providers/ProviderReadiness.jsx
+++ b/client/src/components/providers/ProviderReadiness.jsx
@@ -18,10 +18,16 @@
* (`setup.action`), a "use the served model as default" button when the
* running server answers under a different id, or an in-app Local LLM
* settings link. Vendor setup docs are never the way forward.
+ *
+ * That includes the case where the daemon is installed but has NO model weights
+ * cached: the server can't start, so `setup.action` is `pull-start` and the
+ * button downloads the runtime's own default checkpoint before starting it.
+ * Offering a bare "Start" there was a catch-22 — the start could only ever fail,
+ * and its error message was the only place the missing weights were named.
*/
import { Link } from 'react-router';
-import { CheckCircle2, HelpCircle, Wand2, Wrench, XCircle } from 'lucide-react';
+import { CheckCircle2, Download, HelpCircle, Wand2, Wrench, XCircle } from 'lucide-react';
import Banner from '../ui/Banner';
import Pill from '../ui/Pill';
@@ -115,9 +121,13 @@ export default function ProviderReadiness({ readiness, onAutoSetup, onUseServedM
type="button"
onClick={() => onAutoSetup(setup)}
className={ACTION_CLASS}
- title={`PortOS runs this on ${endpoint} for you — no terminal needed.`}
+ // A weights download is the one action here that spends gigabytes,
+ // so the button says so before it is clicked rather than after.
+ title={setup.action === 'pull-start'
+ ? `Fetches ${label}'s own default checkpoint — a multi-gigabyte download — then starts the server on ${endpoint}.`
+ : `PortOS runs this on ${endpoint} for you — no terminal needed.`}
>
- <Wand2 size={12} />
+ {setup.action === 'pull-start' ? <Download size={12} /> : <Wand2 size={12} />}
{setup.actionLabel}
</button>
)}
diff --git a/client/src/components/providers/ProviderReadiness.test.jsx b/client/src/components/providers/ProviderReadiness.test.jsx
index 3708a6e3cb..025c701956 100644
--- a/client/src/components/providers/ProviderReadiness.test.jsx
+++ b/client/src/components/providers/ProviderReadiness.test.jsx
@@ -77,6 +77,37 @@ describe('ProviderReadiness', () => {
expect(screen.queryByText(/setup docs/i)).toBeNull();
});
+ it('names the download in the button that fetches weights, before it is clicked', () => {
+ // The catch-22 the `pull-start` action ends: an installed MTPLX with an
+ // empty cache used to be offered a bare "Start MTPLX" that could only fail.
+ // The replacement spends gigabytes, so the label and the tooltip both say
+ // so up front rather than after the click.
+ const onAutoSetup = vi.fn();
+ const setup = { runtime: 'mtplx', label: 'MTPLX', action: 'pull-start', actionLabel: 'Download the default model & start MTPLX', blockedReason: null };
+ renderWithRouter(
+ <ProviderReadiness
+ readiness={readiness({
+ label: 'MTPLX',
+ manageUrl: null,
+ setup,
+ checks: [
+ { id: 'runtime', label: 'MTPLX installed', ok: true, detail: '`mtplx` is on PortOS\'s PATH.', fixHint: null },
+ { id: 'server', label: 'MTPLX server responding', ok: false, detail: 'Nothing answered at http://127.0.0.1:8000/v1 (ECONNREFUSED). MTPLX has no model weights cached, so its server exits before it binds a port.', fixHint: 'Use “Download the default model & start MTPLX” below — PortOS does this for you.' },
+ ],
+ })}
+ onAutoSetup={onAutoSetup}
+ />,
+ );
+
+ const button = screen.getByRole('button', { name: /Download the default model & start MTPLX/ });
+ expect(button.getAttribute('title')).toMatch(/multi-gigabyte download/);
+ // The blocking fact is on the checklist itself, not only inside the error
+ // the old Start button produced.
+ expect(screen.getByText(/no model weights cached/)).toBeTruthy();
+ fireEvent.click(button);
+ expect(onAutoSetup).toHaveBeenCalledWith(setup);
+ });
+
it('offers a one-click default-model match when the daemon is serving a different id', () => {
const onUseServedModel = vi.fn();
const mismatch = readiness({
diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsx
index 57044881db..688889b399 100644
--- a/client/src/pages/AIProviders.jsx
+++ b/client/src/pages/AIProviders.jsx
@@ -828,13 +828,15 @@ export default function AIProviders() {
runtime={settingUpRuntime?.runtime}
label={settingUpRuntime?.label}
title={settingUpRuntime?.actionLabel}
- params={settingUpRuntime ? { provider: settingUpRuntime.providerId } : undefined}
+ params={settingUpRuntime ? { provider: settingUpRuntime.providerId, action: settingUpRuntime.action } : undefined}
onClose={() => setSettingUpRuntime(null)}
onComplete={handleRuntimeSetupComplete}
installUrlBase="/api/providers/readiness/setup"
streamMethod="POST"
flushMs={250}
- description={`${settingUpRuntime?.actionLabel || 'Setting up'} — this can take several minutes on a first install.`}
+ description={settingUpRuntime?.action === 'pull-start'
+ ? `${settingUpRuntime.actionLabel} — model weights are a multi-gigabyte download, so this can run for a long time.`
+ : `${settingUpRuntime?.actionLabel || 'Setting up'} — this can take several minutes on a first install.`}
/>
</div>
</div>
diff --git a/client/src/pages/AIProviders.test.jsx b/client/src/pages/AIProviders.test.jsx
index 1f27c6d6fe..94defe8444 100644
--- a/client/src/pages/AIProviders.test.jsx
+++ b/client/src/pages/AIProviders.test.jsx
@@ -39,8 +39,10 @@ vi.mock('../components/settings/SettingsTabsHeader', () => ({
default: () => <div data-testid="settings-tabs-header" />,
}));
vi.mock('../components/install/RuntimeInstallModal', () => ({
- default: ({ open, runtime, streamMethod, flushMs }) => open
- ? <div data-testid="runtime-install-modal" data-runtime={runtime} data-stream-method={streamMethod} data-flush-ms={flushMs} />
+ // `params` becomes the setup request's query string, so the test can assert
+ // WHICH setup step the clicked button asked for.
+ default: ({ open, runtime, streamMethod, flushMs, params }) => open
+ ? <div data-testid="runtime-install-modal" data-runtime={runtime} data-stream-method={streamMethod} data-flush-ms={flushMs} data-params={JSON.stringify(params || {})} />
: null,
}));
@@ -322,6 +324,35 @@ describe('local-daemon readiness on the provider card', () => {
expect(screen.queryByText(/setup docs/i)).not.toBeInTheDocument();
});
+ it('sends the weights-download action when the checklist offers it', async () => {
+ // MTPLX installed, nothing cached: the button is the download, and the
+ // action has to reach the setup request — sending the default would run a
+ // plain start, which is the failure this whole path exists to avoid.
+ api.getProviderReadiness.mockResolvedValue({
+ readiness: {
+ 'opencode-llama-tui': {
+ kind: 'mtplx',
+ label: 'MTPLX',
+ endpoint: 'http://127.0.0.1:8000/v1',
+ manageUrl: null,
+ ready: false,
+ setup: { runtime: 'mtplx', label: 'MTPLX', action: 'pull-start', actionLabel: 'Download the default model & start MTPLX', blockedReason: null },
+ checks: [
+ { id: 'runtime', label: 'MTPLX installed', ok: true, detail: 'on PATH', fixHint: null },
+ { id: 'server', label: 'MTPLX server responding', ok: false, detail: 'MTPLX has no model weights cached, so its server exits before it binds a port.', fixHint: 'Use “Download the default model & start MTPLX” below — PortOS does this for you.' },
+ ],
+ },
+ },
+ });
+
+ renderPage();
+
+ fireEvent.click(await screen.findByRole('button', { name: /Download the default model & start MTPLX/ }));
+ const modal = await screen.findByTestId('runtime-install-modal');
+ expect(JSON.parse(modal.getAttribute('data-params'))).toEqual({ provider: 'opencode-llama-tui', action: 'pull-start' });
+ expect(modal.getAttribute('data-runtime')).toBe('mtplx');
+ });
+
it('lets the user match this provider to the model llama.cpp is actually serving', async () => {
api.updateProvider.mockResolvedValue({ id: 'opencode-llama-tui', defaultModel: 'dflash' });
api.getProviderReadiness.mockResolvedValue({
diff --git a/docs/features/mtplx.md b/docs/features/mtplx.md
index dfee97410a..01c0ca5aac 100644
--- a/docs/features/mtplx.md
+++ b/docs/features/mtplx.md
@@ -35,11 +35,14 @@ valid CoS coding-agent runner.
then runs `mtplx serve --port <the port your provider points at> --model <a
model already in your MTPLX cache>` and waits for `/v1/models` to answer.
Progress streams into the install modal.
-3. **If it reports that no weights are cached**, pull a checkpoint yourself —
- `mtplx pull` fetches MTPLX's default verified model, `mtplx pull
- <hf-repo-id>` any other MTP model — then click **Start MTPLX** again. PortOS
- never downloads weights, and `mtplx serve` exits before it binds a port when
- its cache is empty.
+3. **If no weights are cached**, the checklist says so on the "server
+ responding" and "model available" rows — MTPLX's server exits before it
+ binds a port with an empty cache — and the button becomes **Download the
+ default model & start MTPLX**. That runs `mtplx pull` (MTPLX's own default
+ verified checkpoint, a multi-gigabyte download) and then starts the server,
+ with the download's progress streaming into the same modal. To use a
+ different MTP checkpoint instead, run `mtplx pull <hf-repo-id>` in a
+ terminal and click **Start MTPLX**.
4. Use **Refresh Models** once the server is up; PortOS then reads `/v1/models`
on demand. The seed model alias is `mtplx` — refresh it if your running
server publishes a different one.
@@ -56,15 +59,22 @@ start a server on the loopback OpenAI-compatible endpoint the preset points at,
optional `mtplx max --install` fan-control helper — the one privileged path
in that project — is never invoked; it stays an explicit operator action
outside PortOS.
-- It does **not** download model weights. It does read `mtplx models --json` —
- a local directory listing, no network — and starts the server on a checkpoint
- already in that cache, because `mtplx serve` otherwise defaults to one
- hard-coded repo id and exits 1 before binding when that particular repo was
- never pulled, even on a machine holding a different MTP model. An empty cache
- (or one holding only a half-finished `mtplx pull`) is reported with the
- `mtplx pull` command that fixes it, never fetched. A running server serving a
- different alias than the provider names is reported by the checklist's model
- check and left for you to resolve.
+- **Install & start** and **Start** never download model weights. They read
+ `mtplx models --json` — a local directory listing, no network — and start the
+ server on a checkpoint already in that cache, because `mtplx serve` otherwise
+ defaults to one hard-coded repo id and exits 1 before binding when that
+ particular repo was never pulled, even on a machine holding a different MTP
+ model. A running server serving a different alias than the provider names is
+ reported by the checklist's model check and left for you to resolve.
+- The **Download the default model & start MTPLX** button is the one action
+ here that fetches weights, and it appears only when that same cache listing
+ proves there is nothing servable — an empty cache, or one holding only a
+ half-finished `mtplx pull`. It runs `mtplx pull` with no repo id, so it can
+ only ever fetch MTPLX's own default verified checkpoint; nothing from the
+ page picks what is downloaded. It exists because the checklist otherwise
+ offered a **Start MTPLX** that could only fail, and named the missing weights
+ solely inside that failure — the one blocking fact was reachable only by
+ clicking the button it made impossible.
- It only ever runs for an endpoint on **this** machine. A preset pointed at
another host gets no checklist and no button — that install is whoever runs
it.
diff --git a/server/lib/README.md b/server/lib/README.md
index 03343a4b28..1c9bc30b81 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -136,7 +136,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `providerTranscriptUsage.js` | Parsers for the real per-message token counts the coding CLIs write to disk (0 tokens to read) — `parseClaudeTranscript` (`~/.claude/projects/<cwd-slug>/*.jsonl`), `parseCodexRollout` (`~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl`), `claudeProjectSlug`, `totalTranscriptTokens`. Both de-duplicate a format hazard that otherwise inflates counts badly: Claude repeats one response across several lines sharing a `message.id`, and Codex's `total_token_usage` is cumulative and repeated. Each parser returns per-model buckets (`byModel`) plus the message keys it counted (`countedKeys`), and accepts an `exclude` set — that is what stops two overlapping PortOS runs from both billing the same messages. Tolerant of truncated (mid-write) files; consumed by `services/usageReconciler.js`. |
| `opencodeConfig.js` | OpenCode config builder — `buildOpencodeEnvVars(provider, model)` builds dynamic `OPENCODE_CONFIG_CONTENT` declaring bare model ids under the selected local provider (`ollama` or `mtplx`) for marked OpenCode providers. Fixes --model rejection. |
| `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`. |
-| `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. |
+| `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. |
| `vllmQwenProject.js` | `resolveVllmProjectDir()` / `inspectVllmQwenProject()` → `{dir, hasProject, composeFile, hasWeights, weightsRoot}` for the operator-cloned syv-ai/qwen38-27b-rtx3090 compose project, plus `vllmStartBlockedReason(project)` → the prose refusal (or `null`). Directory reads only — never runs docker or touches a registry. `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. Overrides: `VLLM_QWEN_PROJECT_DIR`, `VLLM_QWEN_WEIGHTS_DIR`. |
| `openAiModelsProbe.js` | `probeOpenAiModels(baseUrl, { timeoutMs, apiKey })` → `{ reachable, models, error }` — the one `GET {base}/models` probe for the local OpenAI-compatible daemons, shared by `services/providerReadiness.js` and `services/llamaServerManager.js`. Distinguishes unreachable from reachable-but-unlistable (`models: null`) from up-with-nothing-loaded (`[]`), names the real transport failure via `describeFetchError` (undici reports every one as a bare `fetch failed`), and cancels an unread body on a non-OK response. `apiKey` attaches a Bearer header for a key-gated daemon (vLLM's compose stack), and a 401/403 answers `reachable: true` with `error: 'authentication required'` — a server that refused the request is definitively running, and calling it unreachable would send the user to start it again. Consolidated after the two copies drifted — one passed its timeout as a `timeout` key inside the fetch init object, where it is not an option, silently running a 500ms poll loop on the 15s default. |
| `openAiChatStream.js` | `streamOpenAiChat({ endpoint, apiKey, model, messages, temperature, maxTokens, extraBody, signal, onChunk })` → the streamed text — one streaming `POST {base}/chat/completions` against any local OpenAI-compatible daemon, plus `buildMessages`, `extractStreamDelta` (skips a malformed SSE frame instead of aborting the stream) and `resolvePartialOutput` (content, else reasoning, else `''`). Sibling of `openAiModelsProbe.js`. Shared by `services/localLlmPlayground.js` (provider-backed runs with a `/runs` record) and its `runEndpointLlmTest` (a bare loopback daemon PortOS holds no provider record for, which is how `services/localModelAssessments.js` measures llama.cpp / MTPLX / vLLM). An abort mid-stream throws with `.partialOutput` carrying what already streamed. |
@@ -402,7 +402,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `staticImportGraph.js` | Static ES-module import scanning for structural test guards. `staticImportSpecifiers(file)` → every specifier a file statically imports (verbatim, source order); `staticImportClosure(entry)` → `{files, packages}` for the whole reachable graph; `specifierMatchesPackage(spec, pkg)` matches a package or any subpath. Static imports only — `await import()` is deferred and can't create a load-time cycle or drag a native dep into an init graph. Shared by `agentImportCycles.test.js` (acyclicity) and `sprites/animationTracks.test.js` (the request-validation graph reaches no sharp/ffmpeg). |
| `sseUtils.js` | Per-job SSE stream helpers (imageGen + others) plus `createSseRunner` — the shared batch-runner lifecycle (runs map, terminal-frame replay, cancel, fire-and-forget coordinator) used by the pipeline completeness/analysis/checks runners. |
| `streamBackpressure.js` | `awaitWritableDrain(res)` — park a streaming-response producer on the socket's next `drain` (or `close`) when `res.write()` returned false, so SSE/NDJSON writes stay bounded for a slow reader. Shared by `routes/ask.js` (SSE) and `routes/localLlm.js` (NDJSON). |
-| `streamingSpawn.js` | `runStreamingCommand(cmd, args, onLine, {timeoutMs?, cwd?, env?})` — run one command to completion and forward its stdout/stderr LINES to a hook, resolving `{ success, error? }`. Never rejects (spawn error, non-zero exit, and timeout all resolve as `success: false`) because every caller is an install/setup flow running outside the Express request lifecycle, and the `onLine` hook is guarded for the same reason. A failure carries the last ~1KB of streamed output, so `brew upgrade ollama` exiting 1 with "Error: ollama not installed" surfaces that string instead of "exited with code 1". Shared by `services/localLlm.js`'s package-manager installs and `services/localRuntimeSetup.js`'s one-click daemon setup. `bufferedSpawn.js` is the sibling for run-and-collect; use this one when live output IS the progress. |
+| `streamingSpawn.js` | `runStreamingCommand(cmd, args, onLine, {timeoutMs?, cwd?, env?, splitRe?})` — run one command to completion and forward its stdout/stderr LINES to a hook, resolving `{ success, error? }`. Never rejects (spawn error, non-zero exit, and timeout all resolve as `success: false`) because every caller is an install/setup flow running outside the Express request lifecycle, and the `onLine` hook is guarded for the same reason. A failure carries the last ~1KB of streamed output, so `brew upgrade ollama` exiting 1 with "Error: ollama not installed" surfaces that string instead of "exited with code 1". Shared by `services/localLlm.js`'s package-manager installs and `services/localRuntimeSetup.js`'s one-click daemon setup. `splitRe` is forwarded to the line readers — pass `/[\r\n]+/` for a downloader whose progress bar redraws one line with a bare `\r`, or the stream goes silent for the whole download. `bufferedSpawn.js` is the sibling for run-and-collect; use this one when live output IS the progress. |
| `repoIntakeActions.js` | `REPO_INTAKE_KEYS` + `normalizeRepoIntake(input)` — the opt-in post-clone agent actions a Brain capture can request for a GitHub repo URL (`malwareScan` → `/do:scan`, `learn` → a `repo-study` review). Pure half of `services/repoIntake.js` (which pulls the CoS task graph), so the link write path and the Zod schemas can import it freely. Normalizes to null when nothing was ticked, so "no intake" is never persisted onto a link. |
| `tombstones.js` | Generic timestamped tombstones (`{ <keyField>, deletedAt }`) that let an otherwise add-only peer merge represent a DELETE, so a record removed on one machine is not resurrected by a peer that still has it (#3530). `normalizeTombstones` / `recordTombstone` / `clearTombstone` / `tombstoneTimestamp` maintain the list; `mergeTombstones` unions it in both directions (newest deletion per key wins) so a delete propagates rather than only defending locally; `isTombstoned(list, key, createdAt)` suppresses a record unless its own creation stamp is strictly NEWER than the deletion; `pruneTombstones(list, records)` drops tombstones a re-created record has superseded (otherwise a stale peer copy keeps reaping it); `supersedingTimestamp(deletedAt)` stamps a re-create that lands in the same millisecond (or behind a skewed peer clock). Comparison goes through `lwwTimestamp.js`, so polarity matches every other sync merge. Key on a field that means the same thing on every machine — locally-minted ids usually do not. `DEFAULT_TOMBSTONE_LIMIT` (200) caps growth. |
| `uploadLimits.js` | Single source of truth for upload size caps — `JSON_BODY_LIMIT`/`JSON_BODY_LIMIT_BYTES` (the express.json limit applied in `index.js`), `MAX_BASE64_UPLOAD_BYTES` derived from it (base64 ×4/3, so a bigger per-route cap is unreachable), `MAX_SCREENSHOT_BYTES`. Mirrored client-side as `JSON_UPLOAD_MAX_FILE_SIZE`. |
diff --git a/server/lib/localProviderRuntime.js b/server/lib/localProviderRuntime.js
index 986f4b581b..26c4b702fe 100644
--- a/server/lib/localProviderRuntime.js
+++ b/server/lib/localProviderRuntime.js
@@ -176,10 +176,11 @@ export const LOCAL_RUNTIMES = Object.freeze({
defaultBaseUrl: opencodeLocalBaseUrl('mtplx'),
// No Models → LLMs entry — MTPLX has no model catalog inside PortOS. The
// one-click setup on the readiness checklist
- // (`services/localRuntimeSetup.js`) is what installs and starts it.
+ // (`services/localRuntimeSetup.js`) is what installs it, downloads its
+ // default checkpoint when the cache is empty, and starts it.
manageUrl: null,
docsUrl: 'https://github.com/atomantic/PortOS/blob/main/docs/features/mtplx.md',
- modelsHint: 'Point the server at the Qwen MTP checkpoint you want; PortOS does not download weights.',
+ modelsHint: 'Point the server at the Qwen MTP checkpoint you want, or let the checklist fetch MTPLX\'s default one when nothing is cached.',
}),
});
diff --git a/server/lib/mtplxModels.js b/server/lib/mtplxModels.js
index 581b00e0a6..49e1d77f5a 100644
--- a/server/lib/mtplxModels.js
+++ b/server/lib/mtplxModels.js
@@ -15,9 +15,10 @@
*
* 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. PortOS still
+ * 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,
- * exactly as `docs/features/mtplx.md` promises.
+ * made on a button that says so (`services/localRuntimeSetup.js`'s `pull-start`
+ * action), exactly as `docs/features/mtplx.md` promises.
*/
import { bufferedSpawn } from './bufferedSpawn.js';
@@ -86,3 +87,31 @@ export function pickMtplxCachedModel(models) {
const verified = usable.find((row) => row.has_runtime_contract === true);
return (verified || usable[0])?.repo_id ?? null;
}
+
+/**
+ * The one value the readiness checklist and the setup button both key on:
+ * can MTPLX serve anything right now, and if not, why not.
+ *
+ * The checklist used to answer "MTPLX installed ✓ / server not responding ✗ —
+ * use Start MTPLX, PortOS does this for you", and Start then failed with "no
+ * model weights are cached". Both statements were true and the pair was a
+ * catch-22: the blocking fact (an empty cache) was only discoverable by
+ * clicking the button that could not work. Reading it up front is what lets the
+ * checklist say what is missing and offer the download instead of the start.
+ *
+ * States are deliberately four, not two — `unknown` (the cache could not be
+ * read) must not read as `empty` (read, and nothing is there), for the same
+ * reason `listMtplxCachedModels` distinguishes `null` from `[]`; and `partial`
+ * (an interrupted `mtplx pull`) needs a different sentence than a cache nobody
+ * has ever pulled into.
+ *
+ * @param {{models: object[]|null, error: string|null}} [cache] - a
+ * `listMtplxCachedModels` result
+ * @returns {{state: 'unknown'|'empty'|'partial'|'ready', model: string|null, count: number, error: string|null}}
+ */
+export function describeMtplxCache({ models, error } = {}) {
+ if (!Array.isArray(models)) return { state: 'unknown', model: null, count: 0, error: error || null };
+ const model = pickMtplxCachedModel(models);
+ if (model) return { state: 'ready', model, count: models.length, error: null };
+ return { state: models.length === 0 ? 'empty' : 'partial', model: null, count: models.length, error: null };
+}
diff --git a/server/lib/mtplxModels.test.js b/server/lib/mtplxModels.test.js
index f7fee6601d..c1b3aa05e9 100644
--- a/server/lib/mtplxModels.test.js
+++ b/server/lib/mtplxModels.test.js
@@ -6,7 +6,7 @@ vi.mock('./bufferedSpawn.js', () => spawned);
const pathLookup = vi.hoisted(() => ({ findCommandOnPath: vi.fn(() => '/opt/homebrew/bin/mtplx') }));
vi.mock('./processEnv.js', () => pathLookup);
-import { listMtplxCachedModels, pickMtplxCachedModel } from './mtplxModels.js';
+import { describeMtplxCache, listMtplxCachedModels, pickMtplxCachedModel } from './mtplxModels.js';
const ok = (stdout) => ({ success: true, code: 0, signal: null, stdout, stderr: '', timedOut: false });
@@ -97,3 +97,29 @@ describe('pickMtplxCachedModel', () => {
expect(pickMtplxCachedModel([{ path: '/cache/broken' }])).toBeNull();
});
});
+
+describe('describeMtplxCache', () => {
+ it('reports a servable cache with the model a start would use', () => {
+ expect(describeMtplxCache({
+ models: [{ repo_id: 'Example/Plain', validation: { ok: true } }, { repo_id: 'Example/Verified', has_runtime_contract: true, validation: { ok: true } }],
+ error: null,
+ })).toEqual({ state: 'ready', model: 'Example/Verified', count: 2, error: null });
+ });
+
+ it('separates a cache nobody pulled into from one holding a half-finished pull', () => {
+ // Different sentences on the checklist: "no weights cached" vs "only an
+ // unfinished download". Both block a start; only the second implies a retry
+ // of something the user already began.
+ expect(describeMtplxCache({ models: [], error: null })).toEqual({ state: 'empty', model: null, count: 0, error: null });
+ expect(describeMtplxCache({ models: [{ repo_id: 'Example/Partial', validation: { ok: false } }], error: null }))
+ .toEqual({ state: 'partial', model: null, count: 1, error: null });
+ });
+
+ it('never calls an UNREADABLE cache empty — that would claim a fact PortOS lacks', () => {
+ // The whole point of `models: null`: an empty cache blocks a start, an
+ // unreadable one must not.
+ expect(describeMtplxCache({ models: null, error: '`mtplx models` timed out' }))
+ .toEqual({ state: 'unknown', model: null, count: 0, error: '`mtplx models` timed out' });
+ expect(describeMtplxCache()).toMatchObject({ state: 'unknown', error: null });
+ });
+});
diff --git a/server/lib/streamingSpawn.js b/server/lib/streamingSpawn.js
index adbbd93be8..3b8e36a927 100644
--- a/server/lib/streamingSpawn.js
+++ b/server/lib/streamingSpawn.js
@@ -27,11 +27,14 @@ import { createLineReader, createOutputTail } from './streamLines.js';
* @param {string} cmd
* @param {string[]} args
* @param {(line: string) => void} [onLine] - called once per non-empty line
- * @param {{timeoutMs?: number, cwd?: string, env?: object, spawnImpl?: Function}} [options]
- * `timeoutMs: 0` (default) means no timeout.
+ * @param {{timeoutMs?: number, cwd?: string, env?: object, spawnImpl?: Function, splitRe?: RegExp}} [options]
+ * `timeoutMs: 0` (default) means no timeout. `splitRe` is forwarded to the
+ * line readers — pass `/[\r\n]+/` for a tool whose progress bar redraws the
+ * same line with a bare `\r`, so each redraw surfaces instead of the stream
+ * going silent for the length of a multi-gigabyte download.
* @returns {Promise<{success: boolean, error?: string}>}
*/
-export function runStreamingCommand(cmd, args, onLine, { timeoutMs = 0, cwd, env, spawnImpl = spawn } = {}) {
+export function runStreamingCommand(cmd, args, onLine, { timeoutMs = 0, cwd, env, spawnImpl = spawn, splitRe } = {}) {
return new Promise((resolve) => {
const child = spawnImpl(cmd, args, safeChildProcessOptions({
env: env ? safeChildProcessEnv(env) : process.env,
@@ -71,8 +74,9 @@ export function runStreamingCommand(cmd, args, onLine, { timeoutMs = 0, cwd, env
// `added 42 ` and a warning arriving mid-line yields one corrupt line and
// loses both real ones. (Inherited from the hand-rolled splitter this was
// extracted from; `streamLines.js` carries the rule.)
- const stdoutReader = createLineReader((line) => safeLine(line.trim()));
- const stderrReader = createLineReader((line) => safeLine(line.trim()));
+ const readerOptions = splitRe ? { splitRe } : undefined;
+ const stdoutReader = createLineReader((line) => safeLine(line.trim()), readerOptions);
+ const stderrReader = createLineReader((line) => safeLine(line.trim()), readerOptions);
child.stdout?.on('data', stdoutReader.push);
child.stderr?.on('data', stderrReader.push);
diff --git a/server/routes/providers.js b/server/routes/providers.js
index a676e8607b..5e7b6b05dd 100644
--- a/server/routes/providers.js
+++ b/server/routes/providers.js
@@ -17,7 +17,7 @@ import {
} from '../services/providerRuntimeInstaller.js';
import { getProviderReadinessMap, resetProviderReadinessCache } from '../services/providerReadiness.js';
import { getProviderPrerequisiteMap } from '../services/providerPrerequisites.js';
-import { runLocalRuntimeSetup } from '../services/localRuntimeSetup.js';
+import { runLocalRuntimeSetup, SETUP_ACTIONS } from '../services/localRuntimeSetup.js';
import { localRuntimeForProvider } from '../lib/localProviderRuntime.js';
import { buildTuiShellLaunch } from '../lib/tuiShellLaunch.js';
@@ -379,6 +379,14 @@ export function createPortOSProviderRoutes(aiToolkit) {
if (requested !== runtime.kind) {
throw new ServerError('This provider no longer uses that runtime — reload the page and try again.', { status: 409, code: 'RUNTIME_MISMATCH' });
}
+ // Which of the fixed steps the checklist's button named. Matched against the
+ // closed set rather than passed through, so the only thing an unexpected
+ // value can do is 400 — it never reaches a command. `install-start` is the
+ // default because that is the shape every pre-`action` client sends.
+ const action = req.query.action ? String(req.query.action) : 'install-start';
+ if (!SETUP_ACTIONS.includes(action)) {
+ throw new ServerError('Unknown setup action.', { status: 400, code: 'UNKNOWN_SETUP_ACTION', context: { action } });
+ }
const { send, safeEnd } = openSseStream(res);
const installLog = createInstallLogger({ installer: runtime.label, target: runtime.endpoint });
@@ -419,6 +427,7 @@ export function createPortOSProviderRoutes(aiToolkit) {
endpoint: runtime.endpoint,
emit,
isCancelled: () => clientGone,
+ action,
}).catch((err) => ({ success: false, error: err.message }));
if (holdsLock) { runtimeSetupInFlight = false; holdsLock = false; }
diff --git a/server/routes/providers.readiness.test.js b/server/routes/providers.readiness.test.js
index 6f1def4ae1..a6836b1d59 100644
--- a/server/routes/providers.readiness.test.js
+++ b/server/routes/providers.readiness.test.js
@@ -9,7 +9,10 @@ const readinessService = vi.hoisted(() => ({
}));
vi.mock('../services/providerReadiness.js', () => readinessService);
const setupService = vi.hoisted(() => ({ runLocalRuntimeSetup: vi.fn() }));
-vi.mock('../services/localRuntimeSetup.js', () => setupService);
+// PARTIAL mock: `SETUP_ACTIONS` is the closed set the route validates against,
+// and a stubbed copy would let a route accepting an action the service cannot
+// run still pass here.
+vi.mock('../services/localRuntimeSetup.js', async (importOriginal) => ({ ...(await importOriginal()), ...setupService }));
import { createPortOSProviderRoutes } from './providers.js';
// A provider whose real base URL lives in an env var the user marked secret —
@@ -88,6 +91,24 @@ describe('POST /api/providers/readiness/setup', () => {
expect(frames(response.text).at(-1)).toEqual({ type: 'complete', message: 'Ollama is running.' });
});
+ it('forwards the action the checklist button named, defaulting to install-start', async () => {
+ // `pull-start` is the only action that downloads model weights, so it has
+ // to survive the trip from the button to the service — and every older
+ // client, which sends no action at all, must keep its old behavior.
+ await request(app([CLAUDE_OLLAMA])).post('/api/providers/readiness/setup?provider=claude-ollama&action=pull-start');
+ expect(setupService.runLocalRuntimeSetup.mock.calls[0][1]).toMatchObject({ action: 'pull-start' });
+
+ await request(app([CLAUDE_OLLAMA])).post('/api/providers/readiness/setup?provider=claude-ollama');
+ expect(setupService.runLocalRuntimeSetup.mock.calls[1][1]).toMatchObject({ action: 'install-start' });
+ });
+
+ it('rejects an action outside the fixed set rather than passing it through', async () => {
+ const response = await request(app([CLAUDE_OLLAMA]))
+ .post('/api/providers/readiness/setup?provider=claude-ollama&action=rm-rf');
+ expect(response.status).toBe(400);
+ expect(setupService.runLocalRuntimeSetup).not.toHaveBeenCalled();
+ });
+
it('drops the probe caches so the next poll sees the daemon that just came up', async () => {
await request(app([CLAUDE_OLLAMA])).post('/api/providers/readiness/setup?provider=claude-ollama');
expect(readinessService.resetProviderReadinessCache).toHaveBeenCalled();
diff --git a/server/services/localRuntimeSetup.js b/server/services/localRuntimeSetup.js
index e849fb3942..54f77cd825 100644
--- a/server/services/localRuntimeSetup.js
+++ b/server/services/localRuntimeSetup.js
@@ -16,14 +16,19 @@
* word, which keeps this as narrow as `providerRuntimeInstaller.js`'s CLI
* install surface while removing the docs dead end.
*
- * Two deliberate limits, because guessing here would be worse than a link:
+ * Three deliberate limits, because guessing here would be worse than a link:
*
- * - **Weights are never downloaded.** llama.cpp cannot be started without a
- * GGUF path the user chooses, and no runtime's *model* check is auto-fixed
- * — a multi-gigabyte download is a decision, and the Models → LLMs page already
- * owns that flow with a picker. MTPLX is started on a checkpoint ALREADY in
- * its cache (`lib/mtplxModels.js`); an empty cache is reported with the
- * `mtplx pull` command that fixes it, never fetched.
+ * - **Weights are never downloaded behind a start.** llama.cpp cannot be
+ * started without a GGUF path the user chooses, and no runtime's *model*
+ * check is auto-fixed by a start — a multi-gigabyte download is a decision,
+ * and the Models → LLMs page already owns that flow with a picker. `start`
+ * runs MTPLX on a checkpoint ALREADY in its cache (`lib/mtplxModels.js`).
+ * A cache that is empty (or holds only a half-finished pull) is a SEPARATE
+ * action the user clicks by name — `pull-start`, "Download the default
+ * model & start MTPLX" — never something a Start button does silently.
+ * Before that action existed the checklist offered only Start, which then
+ * failed with "no model weights are cached": the one fact that mattered was
+ * reachable only by clicking the button it made impossible.
* - **MTPLX's privileged paths are never touched.** Upstream ships an
* optional `mtplx max --install` fan-control helper behind a sudo prompt.
* PortOS installs the package and starts the loopback API server; that
@@ -40,7 +45,7 @@ import { spawn } from '../lib/childProcess.js';
import { commandExists } from '../lib/commandExists.js';
import { sleep } from '../lib/fileUtils.js';
import { LOCAL_RUNTIMES, localEndpointPort } from '../lib/localProviderRuntime.js';
-import { listMtplxCachedModels, pickMtplxCachedModel } from '../lib/mtplxModels.js';
+import { describeMtplxCache, listMtplxCachedModels } from '../lib/mtplxModels.js';
import { probeOpenAiModels } from '../lib/openAiModelsProbe.js';
import { inspectVllmQwenProject, vllmStartBlockedReason } from '../lib/vllmQwenProject.js';
import { findCommandOnPath, safeChildProcessEnv, safeChildProcessOptions } from '../lib/processEnv.js';
@@ -56,6 +61,20 @@ const INSTALL_TIMEOUT_MS = 20 * 60 * 1000;
/** A short command that only asks a running daemon to do something. */
const CONTROL_TIMEOUT_MS = 60 * 1000;
+/**
+ * A model pull moves tens of gigabytes. Sized for a slow domestic line rather
+ * than for a fast one — a bound that kills a download at 90% is worse than no
+ * bound at all, and the user can close the modal to stop watching at any point.
+ */
+const WEIGHTS_TIMEOUT_MS = 6 * 60 * 60 * 1000;
+
+/**
+ * Split a downloader's output on bare `\r` too, so a tqdm-style progress bar
+ * that redraws one line surfaces each redraw instead of buffering silently for
+ * the length of the download (`lib/streamLines.js`).
+ */
+const PROGRESS_SPLIT_RE = /[\r\n]+/;
+
/**
* How long to wait for a just-started daemon to answer `/v1/models`. MTPLX
* loads a multi-gigabyte MLX checkpoint before it binds, so this is sized for a
@@ -82,19 +101,30 @@ const PROBE_TIMEOUT_MS = 2_000;
const CONFIRM_TIMEOUT_MS = 5_000;
/**
- * Why an installed MTPLX still cannot be started. Weights are a multi-gigabyte
- * download and stay the user's decision (`docs/features/mtplx.md`), so the
- * button names the one command that fixes this instead of running it.
+ * Why an installed MTPLX still cannot be started. Weights stay the user's
+ * decision (`docs/features/mtplx.md`), so a plain Start never fetches them —
+ * it names the button that does, plus the terminal command for a checkpoint
+ * other than MTPLX's own default.
*/
-const MTPLX_NO_MODEL_ERROR = 'no model weights are cached, so its server exits before it binds a port. Run `mtplx pull` in a terminal to fetch its default checkpoint (or `mtplx pull <hf-repo-id>` for another MTP model) — a multi-gigabyte download PortOS will not start for you — then click Start MTPLX again.';
+const MTPLX_NO_MODEL_ERROR = 'no model weights are cached, so its server exits before it binds a port. Close this window — the checklist now offers “Download the default model & start MTPLX”, which fetches MTPLX\'s own verified checkpoint (a multi-gigabyte download) and then starts the server. To use a different MTP checkpoint instead, run `mtplx pull <hf-repo-id>` in a terminal, then click Start MTPLX again.';
+
+/** The same dead end, reached from a cache holding only interrupted pulls. */
+const mtplxPartialCacheError = (count) =>
+ `its cache holds ${count} model${count === 1 ? '' : 's'}, but none passed its own file check — an interrupted \`mtplx pull\` leaves a partial download behind. Use “Download the default model & start MTPLX” on the checklist to re-fetch it, or run \`mtplx pull <hf-repo-id>\` in a terminal for another checkpoint.`;
/** What each `action` is called on the button and in the log. */
const ACTION_LABELS = {
install: (label) => `Install ${label}`,
start: (label) => `Start ${label}`,
'install-start': (label) => `Install & start ${label}`,
+ // Names the download so the click IS the consent — the one action here that
+ // spends bandwidth measured in gigabytes.
+ 'pull-start': (label) => `Download the default model & start ${label}`,
};
+/** Every action `runLocalRuntimeSetup` accepts — route validation reads this. */
+export const SETUP_ACTIONS = Object.freeze(Object.keys(ACTION_LABELS));
+
/**
* Spawn a long-lived local daemon and wait until its OpenAI-compatible endpoint
* answers. Detached (own process group) so PortOS restarting does not take the
@@ -220,26 +250,34 @@ const SETUP_ROWS = Object.freeze({
}
return { success: false, error: 'Neither Homebrew nor python3 is available. Install Homebrew from https://brew.sh, then try again.' };
},
+ /**
+ * Fetch MTPLX's OWN default verified checkpoint — no repo id from the
+ * request, so this cannot be pointed at an arbitrary download. Runs only
+ * for the `pull-start` action, which the user clicks by its full name.
+ */
+ async pull({ emit }) {
+ const binary = findCommandOnPath('mtplx');
+ if (!binary) return { success: false, error: '`mtplx` was not found on PortOS\'s PATH. Restart PortOS so it picks up the new bin directory, then try again.' };
+ emit('Downloading MTPLX\'s default verified checkpoint. This is a multi-gigabyte download and can take a long while — leave this window open to watch it.');
+ // `mtplx pull` redraws one progress line with a bare `\r`; splitting on
+ // newlines alone would leave the stream silent for the whole download.
+ return runStreamingCommand(binary, ['pull'], emit, { timeoutMs: WEIGHTS_TIMEOUT_MS, splitRe: PROGRESS_SPLIT_RE });
+ },
async start({ emit, endpoint, isCancelled }) {
// `mtplx serve` defaults `--model` to ONE hard-coded checkpoint and exits
// 1 before binding when that repo is not in its cache — even on a machine
// holding a different MTP model that would have served fine. Ask the
// cache first and name what is actually there.
- const cache = await listMtplxCachedModels();
- if (cache.models === null) {
+ const cache = describeMtplxCache(await listMtplxCachedModels());
+ 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 may
// well work.
emit(`Could not read MTPLX's model cache (${cache.error}) — starting with its default model.`);
- } else if (cache.models.length === 0) {
- return { success: false, error: MTPLX_NO_MODEL_ERROR };
- }
- const model = pickMtplxCachedModel(cache.models);
- if (cache.models && !model) {
- const count = cache.models.length;
- return { success: false, error: `its cache holds ${count} model${count === 1 ? '' : 's'}, but none passed its own file check — an interrupted \`mtplx pull\` leaves a partial download behind. Re-run \`mtplx pull <hf-repo-id>\` in a terminal, then try again.` };
}
- if (model) emit(`Serving the cached MTPLX model ${model}.`);
+ if (cache.state === 'empty') return { success: false, error: MTPLX_NO_MODEL_ERROR };
+ if (cache.state === 'partial') return { success: false, error: mtplxPartialCacheError(cache.count) };
+ if (cache.model) emit(`Serving the cached MTPLX model ${cache.model}.`);
// The cache lookup is an awaited subprocess — the modal can close while it
// runs, and the caller's cancellation check happened BEFORE it. Without
// this, a cancelled setup still spawns a detached daemon nobody asked to
@@ -249,7 +287,7 @@ const SETUP_ROWS = Object.freeze({
// API-only server, which is the half PortOS actually talks to. The daemon
// must bind where the PROVIDER points — a user who moved MTPLX to 8010
// would otherwise get a second server on 8000 that nothing talks to.
- const args = ['serve', '--port', localEndpointPort(endpoint) || '8000', ...(model ? ['--model', model] : [])];
+ const args = ['serve', '--port', localEndpointPort(endpoint) || '8000', ...(cache.model ? ['--model', cache.model] : [])];
return startDaemon({ command: 'mtplx', args, endpoint, emit, isCancelled });
},
}),
@@ -349,10 +387,18 @@ function platformSupported(row) {
* unmet check is the model, which PortOS will not choose), or a runtime PortOS
* can install but not start when the install is already done.
*
+ * `weights` is what the caller already learned about the runtime's local model
+ * cache (`lib/mtplxModels.js`'s `describeMtplxCache`), and only `'empty'` /
+ * `'partial'` change the answer: those are the states where a Start CANNOT
+ * work, so the button becomes the download that makes it possible instead of
+ * the start that is guaranteed to fail. `'unknown'` — the default, and what
+ * every runtime with no cache to read reports — deliberately keeps the old
+ * behavior; a cache PortOS could not read must not be treated as an empty one.
+ *
* @param {string} kind - `mtplx` | `llama` | `ollama` | `lmstudio` | `vllm`
- * @param {{installed: boolean, running: boolean}} state
+ * @param {{installed: boolean, running: boolean, weights?: 'unknown'|'empty'|'partial'|'ready'}} state
*/
-export function describeRuntimeSetup(kind, { installed, running }) {
+export function describeRuntimeSetup(kind, { installed, running, weights = 'unknown' }) {
const row = SETUP_ROWS[kind];
const runtime = LOCAL_RUNTIMES[kind];
if (!row || !runtime) return null;
@@ -365,7 +411,13 @@ export function describeRuntimeSetup(kind, { installed, running }) {
return { runtime: kind, label: runtime.label, action: null, actionLabel: null, blockedReason: row.unsupportedReason };
}
- const action = needsInstall && needsStart ? 'install-start' : needsInstall ? 'install' : 'start';
+ // Only offered once the binary is here: the cache cannot be read without it,
+ // so an uninstalled runtime's `weights` says nothing and `install-start`
+ // stays the honest first step.
+ const needsWeights = Boolean(row.pull) && !needsInstall && needsStart && (weights === 'empty' || weights === 'partial');
+ const action = needsWeights ? 'pull-start'
+ : needsInstall && needsStart ? 'install-start'
+ : needsInstall ? 'install' : 'start';
return {
runtime: kind,
label: runtime.label,
@@ -386,12 +438,14 @@ export function describeRuntimeSetup(kind, { installed, running }) {
* so a failure has to come back as a value it can turn into a terminal frame.
*
* @param {string} kind
- * @param {{endpoint: string, emit: (line: string) => void, isCancelled?: () => boolean}} ctx
+ * @param {{endpoint: string, emit: (line: string) => void, isCancelled?: () => boolean, action?: string}} ctx
* `isCancelled` is checked between steps so a closed modal does not go on to
- * start a daemon nobody is watching for.
+ * start a daemon nobody is watching for. `action` is the one the checklist's
+ * button named; only `pull-start` adds a step (the model download), and it is
+ * opt-in precisely so no other action can spend gigabytes of bandwidth.
* @returns {Promise<{success: boolean, error?: string, message?: string}>}
*/
-export async function runLocalRuntimeSetup(kind, { endpoint, emit = () => {}, isCancelled = () => false }) {
+export async function runLocalRuntimeSetup(kind, { endpoint, emit = () => {}, isCancelled = () => false, action = 'install-start' }) {
const row = SETUP_ROWS[kind];
const runtime = LOCAL_RUNTIMES[kind];
if (!row || !runtime) return { success: false, error: `PortOS has no automatic setup for \`${String(kind)}\`.` };
@@ -427,6 +481,18 @@ export async function runLocalRuntimeSetup(kind, { endpoint, emit = () => {}, is
}
if (isCancelled()) return { success: false, error: 'Cancelled after the install — nothing was started.' };
+ // The ONLY path that downloads weights, and it runs only because the user
+ // clicked a button that says so. `describeRuntimeSetup` offers it exactly
+ // when the cache is provably unusable, which is the state where a plain
+ // Start would exit before binding a port.
+ if (action === 'pull-start') {
+ if (!row.pull) return { success: false, error: `PortOS cannot download model weights for ${runtime.label}.` };
+ const pulled = await row.pull({ emit });
+ if (!pulled.success) return { success: false, error: `${runtime.label} model download failed: ${pulled.error}` };
+ emit(`${runtime.label}'s default checkpoint is cached.`);
+ if (isCancelled()) return { success: false, error: 'Cancelled after the download — the weights are cached, but nothing was started.' };
+ }
+
// The install step may have started it (Ollama's Homebrew service does), so
// re-probe rather than launching a second copy onto the same port.
const afterInstall = await probeOpenAiModels(target, { timeoutMs: PROBE_TIMEOUT_MS });
diff --git a/server/services/localRuntimeSetup.test.js b/server/services/localRuntimeSetup.test.js
index 0dcb2ba601..a48160a8a8 100644
--- a/server/services/localRuntimeSetup.test.js
+++ b/server/services/localRuntimeSetup.test.js
@@ -31,11 +31,11 @@ const child = vi.hoisted(() => ({ spawn: vi.fn() }));
vi.mock('../lib/childProcess.js', () => child);
// MTPLX's model cache — the setup asks it what is actually cached before it
// starts a server that would otherwise exit 1 looking for a checkpoint.
-const mtplxCache = vi.hoisted(() => ({
- listMtplxCachedModels: vi.fn(),
- pickMtplxCachedModel: vi.fn((models) => (Array.isArray(models) && models[0]?.repo_id) || null),
-}));
-vi.mock('../lib/mtplxModels.js', () => mtplxCache);
+const mtplxCache = vi.hoisted(() => ({ listMtplxCachedModels: vi.fn() }));
+// PARTIAL mock: only the subprocess call is faked. `describeMtplxCache` and
+// `pickMtplxCachedModel` are pure classifiers of that output, and stubbing them
+// would let a wrong reading of a real cache listing pass here.
+vi.mock('../lib/mtplxModels.js', async (importOriginal) => ({ ...(await importOriginal()), ...mtplxCache }));
vi.mock('../lib/fileUtils.js', () => ({ sleep: async () => {} }));
// The vLLM compose project on disk. Mocked so the suite never stats a real
// checkout, and so each start case can pick its own refusal.
@@ -45,7 +45,7 @@ const vllmProject = vi.hoisted(() => ({
}));
vi.mock('../lib/vllmQwenProject.js', () => vllmProject);
-import { describeRuntimeSetup, runLocalRuntimeSetup, SETUP_RUNTIME_KINDS } from './localRuntimeSetup.js';
+import { describeRuntimeSetup, runLocalRuntimeSetup, SETUP_ACTIONS, SETUP_RUNTIME_KINDS } from './localRuntimeSetup.js';
const unreachable = { reachable: false, models: null, error: 'ECONNREFUSED' };
/** A spawned daemon whose stdio never emits, driven entirely by the poll loop. */
@@ -77,7 +77,6 @@ beforeEach(() => {
probe.probeOpenAiModels.mockReset();
child.spawn.mockReset();
mtplxCache.listMtplxCachedModels.mockResolvedValue(cachedModels([{ repo_id: 'Example/MTP-Model', validation: { ok: true } }]));
- mtplxCache.pickMtplxCachedModel.mockImplementation((models) => (Array.isArray(models) && models[0]?.repo_id) || null);
});
afterEach(() => {
@@ -113,6 +112,36 @@ describe('describeRuntimeSetup', () => {
restore();
});
+ it('offers the DOWNLOAD, not a start, when the installed runtime has no weights', () => {
+ // The catch-22 this exists to end: "installed ✓ / not responding — press
+ // Start", where Start could only ever answer "no model weights are cached".
+ const restore = pinPlatform('darwin');
+ for (const weights of ['empty', 'partial']) {
+ expect(describeRuntimeSetup('mtplx', { installed: true, running: false, weights })).toMatchObject({
+ action: 'pull-start',
+ actionLabel: 'Download the default model & start MTPLX',
+ });
+ }
+ restore();
+ });
+
+ it('keeps a plain start when the cache is READY or unreadable', () => {
+ const restore = pinPlatform('darwin');
+ // Weights are already there — nothing to download.
+ expect(describeRuntimeSetup('mtplx', { installed: true, running: false, weights: 'ready' })).toMatchObject({ action: 'start' });
+ // Unreadable is not empty: a start that would have worked must not be
+ // turned into a multi-gigabyte download.
+ expect(describeRuntimeSetup('mtplx', { installed: true, running: false, weights: 'unknown' })).toMatchObject({ action: 'start' });
+ restore();
+ });
+
+ it('never offers a download for a runtime with no pull step', () => {
+ // Ollama's weights come from the Models → LLMs page, so an empty cache
+ // there must not conjure a button this module cannot honour.
+ expect(describeRuntimeSetup('ollama', { installed: true, running: false, weights: 'empty' }))
+ .toMatchObject({ action: 'start' });
+ });
+
it('offers nothing once the daemon is installed and up — the model is the user\'s choice', () => {
const restore = pinPlatform('darwin');
// A running daemon serving the wrong alias is the remaining unmet check,
@@ -338,9 +367,67 @@ describe('runLocalRuntimeSetup', () => {
expect(result).toMatchObject({ success: false, error: expect.stringContaining('mtplx pull') });
});
+ it('downloads the default checkpoint and then starts, but ONLY for `pull-start`', async () => {
+ // The other half of the fix: the button the checklist now offers actually
+ // fetches the weights, so the user is not sent to a terminal.
+ const daemon = fakeChild();
+ child.spawn.mockReturnValue(daemon);
+ pathLookup.findCommandOnPath.mockReturnValue('/opt/homebrew/bin/mtplx');
+ // The cache is read by the START step, which runs AFTER the pull — so what
+ // it reports here is what the download just landed.
+ mtplxCache.listMtplxCachedModels
+ .mockResolvedValueOnce(cachedModels([{ repo_id: 'Example/Fresh', validation: { ok: true } }]));
+ probe.probeOpenAiModels
+ .mockResolvedValueOnce(unreachable)
+ .mockResolvedValueOnce(unreachable)
+ .mockResolvedValueOnce(reachable(['mtplx']))
+ .mockResolvedValueOnce(reachable(['mtplx']));
+ const restore = pinPlatform('darwin');
+
+ const result = await runLocalRuntimeSetup('mtplx', { endpoint: 'http://127.0.0.1:8000/v1', action: 'pull-start' });
+ restore();
+
+ expect(streaming.runStreamingCommand).toHaveBeenCalledWith(
+ '/opt/homebrew/bin/mtplx', ['pull'], expect.any(Function), expect.objectContaining({ splitRe: expect.any(RegExp) }),
+ );
+ expect(child.spawn.mock.calls[0][1]).toEqual(['serve', '--port', '8000', '--model', 'Example/Fresh']);
+ expect(result.success).toBe(true);
+ });
+
+ it('never downloads weights behind a plain start', async () => {
+ // A multi-gigabyte download is a decision; only the button that says so
+ // may spend it. Both of the refusals below reach `mtplx pull` in PROSE.
+ mtplxCache.listMtplxCachedModels.mockResolvedValue(cachedModels([]));
+ pathLookup.findCommandOnPath.mockReturnValue('/opt/homebrew/bin/mtplx');
+ probe.probeOpenAiModels.mockResolvedValue(unreachable);
+ const restore = pinPlatform('darwin');
+
+ await runLocalRuntimeSetup('mtplx', { endpoint: 'http://127.0.0.1:8000/v1', action: 'start' });
+ await runLocalRuntimeSetup('mtplx', { endpoint: 'http://127.0.0.1:8000/v1' });
+ restore();
+
+ expect(streaming.runStreamingCommand).not.toHaveBeenCalled();
+ });
+
+ it('stops at a failed download rather than starting a server that cannot serve', async () => {
+ streaming.runStreamingCommand.mockResolvedValue({ success: false, error: 'exit 1: connection reset' });
+ pathLookup.findCommandOnPath.mockReturnValue('/opt/homebrew/bin/mtplx');
+ probe.probeOpenAiModels.mockResolvedValue(unreachable);
+ const restore = pinPlatform('darwin');
+
+ const result = await runLocalRuntimeSetup('mtplx', { endpoint: 'http://127.0.0.1:8000/v1', action: 'pull-start' });
+ restore();
+
+ expect(child.spawn).not.toHaveBeenCalled();
+ expect(result).toMatchObject({ success: false, error: expect.stringContaining('connection reset') });
+ });
+
+ it('exposes every action the route may accept', () => {
+ expect([...SETUP_ACTIONS].sort()).toEqual(['install', 'install-start', 'pull-start', 'start']);
+ });
+
it('refuses when every cached MTPLX model is an incomplete download', async () => {
mtplxCache.listMtplxCachedModels.mockResolvedValue(cachedModels([{ repo_id: 'Example/Partial', validation: { ok: false } }]));
- mtplxCache.pickMtplxCachedModel.mockReturnValue(null);
pathLookup.findCommandOnPath.mockReturnValue('/opt/homebrew/bin/mtplx');
probe.probeOpenAiModels.mockResolvedValue(unreachable);
const restore = pinPlatform('darwin');
diff --git a/server/services/providerReadiness.js b/server/services/providerReadiness.js
index 0a24f73024..d03ef23c83 100644
--- a/server/services/providerReadiness.js
+++ b/server/services/providerReadiness.js
@@ -35,6 +35,7 @@
import { localRuntimeForProvider } from '../lib/localProviderRuntime.js';
import { isConfiguredDefaultModel } from '../lib/providerModels.js';
+import { describeMtplxCache, listMtplxCachedModels } from '../lib/mtplxModels.js';
import { probeOpenAiModels } from '../lib/openAiModelsProbe.js';
import { findCommandOnPath } from '../lib/processEnv.js';
import { describeRuntimeSetup } from './localRuntimeSetup.js';
@@ -65,6 +66,26 @@ const PROBE_TTL_MS = 15_000;
*/
const BINARY_TTL_MS = 60_000;
+/**
+ * A `mtplx models --json` listing walks the cache directories to size them, so
+ * it is far too expensive to repeat on every 20s page poll — and the answer
+ * only changes when a `mtplx pull` finishes, which is minutes of downloading
+ * away. Longer than the probe TTL for exactly that reason.
+ */
+const WEIGHTS_TTL_MS = 60_000;
+
+/**
+ * How to read a runtime's model cache WITHOUT starting it, for the runtimes
+ * where that is possible. Ollama and LM Studio need their daemon up to list
+ * anything (and the Models → LLMs page owns their downloads anyway);
+ * llama.cpp's weights are a GGUF path the user picks; the vLLM stack's weights
+ * ship inside an operator-prepared compose project. MTPLX alone answers
+ * `mtplx models --json` offline.
+ */
+const WEIGHT_CACHE_READERS = Object.freeze({
+ mtplx: async () => describeMtplxCache(await listMtplxCachedModels()).state,
+});
+
// endpoint + key → { at, promise } — the PROMISE, not the settled value, so N
// providers sharing one endpoint in the same batch share one socket instead of
// all missing a not-yet-written cache entry at once. The key is part of the
@@ -74,6 +95,9 @@ const BINARY_TTL_MS = 60_000;
const probeCache = new Map();
// command → { at, path }
const binaryCache = new Map();
+// runtime kind → { at, promise } — the local model cache behind a daemon that
+// is NOT running, which is the only time PortOS cannot ask `/v1/models`.
+const weightsCache = new Map();
/**
* Ask an OpenAI-compatible endpoint what it serves. `llamaServerManager` runs the
@@ -109,6 +133,40 @@ ${apiKey}`;
return promise;
}
+/**
+ * What a runtime's own model cache holds, for the runtimes that have one PortOS
+ * can read without starting them (today: MTPLX).
+ *
+ * This is the fact that turned the MTPLX checklist into a catch-22: "installed
+ * ✓ / server not responding ✗ — use Start MTPLX, PortOS does this for you",
+ * and Start then failed with "no model weights are cached, so its server exits
+ * before it binds a port". Reading the cache HERE is what lets the checklist
+ * say so up front and offer the download instead of the start.
+ *
+ * A cache that could not be read reports `'unknown'` — never `'empty'`, which
+ * would claim a fact PortOS does not have. Only called for a kind in
+ * `WEIGHT_CACHE_READERS`; everything else answers `'unknown'` at the call site
+ * without spending a subprocess.
+ *
+ * TTL-cached — see WEIGHTS_TTL_MS.
+ *
+ * @returns {Promise<'unknown'|'empty'|'partial'|'ready'>}
+ */
+function readWeightsStateCached(kind) {
+ const now = Date.now();
+ const cached = weightsCache.get(kind);
+ if (cached && now - cached.at < WEIGHTS_TTL_MS) return cached.promise;
+ // Cached BEFORE the await so concurrent providers on one runtime share the
+ // subprocess; dropped on an unexpected throw so a transient failure cannot
+ // poison the entry for its whole TTL (same shape as the probe cache above).
+ const promise = WEIGHT_CACHE_READERS[kind]().catch((err) => {
+ weightsCache.delete(kind);
+ throw err;
+ });
+ weightsCache.set(kind, { at: now, promise });
+ return promise;
+}
+
/** TTL-cached PATH lookup for the handful of daemon binaries — see BINARY_TTL_MS. */
function findCommandCached(command) {
const cached = binaryCache.get(command);
@@ -149,6 +207,22 @@ function setupHint(setup, covers) {
return setup.action?.includes(covers) ? `Use “${setup.actionLabel}” below — PortOS does this for you.` : null;
}
+/**
+ * What a runtime's own model cache says while its server is down — the half of
+ * the model check `GET /v1/models` cannot answer because nothing is listening.
+ *
+ * `null` when there is nothing to add, so the caller keeps its own prose.
+ */
+function weightsDetail(runtime, weights) {
+ if (weights === 'empty') return `${runtime.label} has no model weights cached, so its server exits before it binds a port.`;
+ if (weights === 'partial') return `${runtime.label}'s cache holds only an unfinished download — no complete checkpoint to serve.`;
+ if (weights === 'ready') return 'Weights are cached locally; this can be confirmed once the server is running.';
+ return null;
+}
+
+/** True for the cache states that make a start impossible. */
+const blocksStart = (weights) => weights === 'empty' || weights === 'partial';
+
/** The `runtime` check — is the daemon's software here at all? */
function runtimeCheck(runtime, { onPath, appInstalled, installed, reachable, setup }) {
const detail = onPath ? `\`${runtime.command}\` is on PortOS's PATH.`
@@ -163,7 +237,7 @@ function runtimeCheck(runtime, { onPath, appInstalled, installed, reachable, set
}
/** The `server` check — is it running where THIS provider points? */
-function serverCheck(runtime, { installed, result, setup }) {
+function serverCheck(runtime, { installed, result, setup, weights = 'unknown' }) {
if (result.reachable) {
return {
id: 'server',
@@ -177,11 +251,15 @@ function serverCheck(runtime, { installed, result, setup }) {
const fallback = installed
? `${start} ${runtime.modelsHint}`
: `Install ${runtime.label} first, then start it. ${runtime.modelsHint}`;
+ // Name the blocker in the SAME line that says nothing answered. Otherwise the
+ // checklist reads "installed ✓ / not responding — just press Start", and
+ // Start is the thing that cannot work until the weights land.
+ const blocked = blocksStart(weights) ? weightsDetail(runtime, weights) : null;
return {
id: 'server',
label: `${runtime.label} server responding`,
ok: false,
- detail: `Nothing answered at ${runtime.endpoint}${result.error ? ` (${result.error})` : ''}.`,
+ detail: `Nothing answered at ${runtime.endpoint}${result.error ? ` (${result.error})` : ''}.${blocked ? ` ${blocked}` : ''}`,
fixHint: setupHint(setup, 'start') || fallback,
};
}
@@ -195,7 +273,7 @@ function serverCheck(runtime, { installed, result, setup }) {
* which says nothing about the model — reported as unknown, never as missing,
* so the user chases the check that IS actionable.
*/
-function modelCheck(runtime, wanted, served, probeError = null) {
+function modelCheck(runtime, wanted, served, probeError = null, { weights = 'unknown', setup = null } = {}) {
const label = `Model \`${wanted}\` available`;
if (!Array.isArray(served)) {
// A server that answered 401 IS responding — "until the server responds"
@@ -203,8 +281,11 @@ function modelCheck(runtime, wanted, served, probeError = null) {
// actual fix is to paste its key onto this provider.
const detail = probeError === 'authentication required'
? `${runtime.label} refused the model listing without an API key — paste the server's key on this provider.`
- : 'Cannot be checked until the server responds.';
- return { id: 'model', label, ok: null, detail, fixHint: null };
+ : weightsDetail(runtime, weights) || 'Cannot be checked until the server responds.';
+ // An unservable cache is the ONE unknown here that has a fix: the download
+ // that makes a start possible at all.
+ const fixHint = blocksStart(weights) ? setupHint(setup, 'pull') : null;
+ return { id: 'model', label, ok: null, detail, fixHint };
}
if (served.includes(wanted)) {
return { id: 'model', label, ok: true, detail: `${runtime.label} is serving \`${wanted}\`.`, fixHint: null };
@@ -263,18 +344,25 @@ export async function getProviderReadiness(provider, deps = {}) {
const appInstalled = runtime.kind === 'lmstudio' && (deps.isAppInstalled || isLmStudioAppInstalled)();
const installed = onPath || appInstalled || result.reachable;
+ // What the runtime's own model cache holds. Only worth asking when the daemon
+ // is installed and NOT answering: a running server's `/v1/models` is the
+ // better answer, and an uninstalled runtime has no cache to read.
+ const weights = installed && !result.reachable && WEIGHT_CACHE_READERS[runtime.kind]
+ ? await (deps.readWeights || readWeightsStateCached)(runtime.kind)
+ : 'unknown';
+
// Resolved BEFORE the checks so each unmet one can point at the button that
// fixes it rather than at a setup doc.
- const setup = describeRuntimeSetup(runtime.kind, { installed, running: result.reachable });
+ const setup = describeRuntimeSetup(runtime.kind, { installed, running: result.reachable, weights });
const checks = [
runtimeCheck(runtime, { onPath, appInstalled, installed, reachable: result.reachable, setup }),
- serverCheck(runtime, { installed, result, setup }),
+ serverCheck(runtime, { installed, result, setup, weights }),
];
const wanted = servedModelId(provider, runtime.kind);
// `probeEndpoint` returns `models: null` on every unreachable path, so this
// needs no second reachability test.
- if (wanted) checks.push(modelCheck(runtime, wanted, result.models, result.error));
+ if (wanted) checks.push(modelCheck(runtime, wanted, result.models, result.error, { weights, setup }));
return {
kind: runtime.kind,
@@ -313,11 +401,14 @@ export async function getProviderReadinessMap(providers, deps = {}) {
// would otherwise bypass the module-level caches that normally collapse them.
const findCommand = memoize(deps.findCommand || findCommandCached);
const probe = memoize(deps.probe || probeEndpointCached);
+ // Same reasoning as the two above: one `mtplx models` subprocess per batch,
+ // not one per provider pointed at the same runtime.
+ const readWeights = memoize(deps.readWeights || readWeightsStateCached);
const entries = await Promise.all(list.map(async (provider) => {
// Spread `deps` first so any other injected dep (isAppInstalled) survives,
- // then override the two the batch memoizes.
- const readiness = await getProviderReadiness(provider, { ...deps, findCommand, probe });
+ // then override the three the batch memoizes.
+ const readiness = await getProviderReadiness(provider, { ...deps, findCommand, probe, readWeights });
return readiness ? [provider.id, readiness] : null;
}));
return Object.fromEntries(entries.filter(Boolean));
@@ -347,4 +438,5 @@ function memoize(fn) {
export function resetProviderReadinessCache() {
probeCache.clear();
binaryCache.clear();
+ weightsCache.clear();
}
diff --git a/server/services/providerReadiness.test.js b/server/services/providerReadiness.test.js
index 669d83d4a4..4dc8c64b19 100644
--- a/server/services/providerReadiness.test.js
+++ b/server/services/providerReadiness.test.js
@@ -207,6 +207,75 @@ describe('getProviderReadiness', () => {
expect(checkById(readiness, 'server').fixHint).toMatch(/Install & start MTPLX/);
});
+ it('names the empty model cache on the checklist, and offers the download instead of a start', async () => {
+ // The catch-22 as reported: "MTPLX installed ✓ / server not responding —
+ // use Start MTPLX, PortOS does this for you", and Start answered "no model
+ // weights are cached, so its server exits before it binds a port". The one
+ // blocking fact was reachable ONLY by clicking the button it made
+ // impossible. It now rides on the checklist itself.
+ const restore = pinPlatform('darwin');
+ const readiness = await getProviderReadiness(
+ { id: 'opencode-mtplx', command: 'opencode', mtplxBacked: true, defaultModel: 'mtplx' },
+ { findCommand: () => '/opt/homebrew/bin/mtplx', probe: unreachable(), readWeights: async () => 'empty' },
+ );
+ restore();
+
+ expect(readiness.setup).toMatchObject({ action: 'pull-start' });
+ expect(checkById(readiness, 'server').detail).toMatch(/no model weights cached/);
+ expect(checkById(readiness, 'server').fixHint).toMatch(/Download the default model & start MTPLX/);
+ // The model check is still unknowable, but no longer says only "cannot be
+ // checked until the server responds" — it says what to do about it.
+ expect(checkById(readiness, 'model')).toMatchObject({ ok: null, detail: expect.stringMatching(/no model weights cached/) });
+ expect(checkById(readiness, 'model').fixHint).toMatch(/Download the default model & start MTPLX/);
+ });
+
+ it('distinguishes a half-finished pull from a cache nobody ever pulled into', async () => {
+ const restore = pinPlatform('darwin');
+ const readiness = await getProviderReadiness(
+ { id: 'opencode-mtplx', command: 'opencode', mtplxBacked: true, defaultModel: 'mtplx' },
+ { findCommand: () => '/opt/homebrew/bin/mtplx', probe: unreachable(), readWeights: async () => 'partial' },
+ );
+ restore();
+ expect(readiness.setup.action).toBe('pull-start');
+ expect(checkById(readiness, 'server').detail).toMatch(/unfinished download/);
+ });
+
+ it('keeps a plain start — and says the weights are there — when the cache is ready', async () => {
+ const restore = pinPlatform('darwin');
+ const readiness = await getProviderReadiness(
+ { id: 'opencode-mtplx', command: 'opencode', mtplxBacked: true, defaultModel: 'mtplx' },
+ { findCommand: () => '/opt/homebrew/bin/mtplx', probe: unreachable(), readWeights: async () => 'ready' },
+ );
+ restore();
+ expect(readiness.setup.action).toBe('start');
+ // The server check must not claim a blocker that isn't one...
+ expect(checkById(readiness, 'server').detail).not.toMatch(/weights/);
+ // ...while the model check reassures that the download is already done.
+ expect(checkById(readiness, 'model').detail).toMatch(/Weights are cached locally/);
+ });
+
+ it('never reads a model cache it has no reason to — or cannot', async () => {
+ // A running daemon answers `/v1/models`, which is a better source than its
+ // cache; an uninstalled one has no cache to read at all. Spawning `mtplx
+ // models` (a directory walk) on either would burn a subprocess per 20s poll
+ // for nothing.
+ const restore = pinPlatform('darwin');
+ const reads = [];
+ const readWeights = async (kind) => { reads.push(kind); return 'empty'; };
+ await getProviderReadiness(
+ { id: 'opencode-mtplx', command: 'opencode', mtplxBacked: true, defaultModel: 'mtplx' },
+ { findCommand: () => '/opt/homebrew/bin/mtplx', probe: reachable(['mtplx']), readWeights },
+ );
+ await getProviderReadiness(
+ { id: 'opencode-mtplx', command: 'opencode', mtplxBacked: true, defaultModel: 'mtplx' },
+ { findCommand: () => null, probe: unreachable(), readWeights },
+ );
+ // ...and a runtime with no cache PortOS can read never asks either.
+ await getProviderReadiness(llamaProvider(), { findCommand: () => '/opt/homebrew/bin/llama-server', probe: unreachable(), readWeights });
+ restore();
+ expect(reads).toEqual([]);
+ });
+
it('explains why the host cannot run the runtime instead of pointing at a doc', async () => {
const restore = pinPlatform('linux');
const readiness = await getProviderReadiness(