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
feat: run CoS agents on a local vLLM Qwen3.8-27B container (#4716)
[._.]/ Adam Eivy72ee1bbf0600
diff --git a/client/src/components/providers/ProviderCard.jsx b/client/src/components/providers/ProviderCard.jsxindex 98781ddec9..9f12b2f771 100644--- a/client/src/components/providers/ProviderCard.jsx+++ b/client/src/components/providers/ProviderCard.jsx@@ -122,6 +122,11 @@ export default function ProviderCard({LLAMA.CPP / DFLASH</span>)}+ {provider.vllmBacked && (+ <span className="text-xs px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-300 border border-emerald-500/30">+ vLLM / DFLASH2+ </span>+ )}{provider.mtplxBacked && (<span className="text-xs px-2 py-0.5 rounded bg-blue-500/20 text-blue-300 border border-blue-500/30">MTPLX@@ -286,6 +291,11 @@ export default function ProviderCard({Local llama.cpp / llama-server harness (endpoint: <code className="text-purple-200">{provider.endpoint}</code>) — supports DFlash 2 speculative drafting.</p>)}+ {provider.vllmBacked && (+ <p className="text-xs text-emerald-300/90">+ Local vLLM container (endpoint: <code className="text-emerald-200">{provider.endpoint}</code>) — Qwen3.8-27B with DFlash 2 drafting. It holds the whole GPU, so stop it before running local image/video generation.+ </p>+ )}{isProcessProvider(provider) && (<p className="break-words">Command: <code className="text-gray-300 break-all">{provider.command} {provider.args?.join(' ')}</code></p>)}diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsxindex 0faa33191d..a1c8b52b5e 100644--- a/client/src/pages/AIProviders.jsx+++ b/client/src/pages/AIProviders.jsx@@ -559,6 +559,11 @@ export default function AIProviders() {LLAMA.CPP / DFLASH</span>)}+ {provider.vllmBacked && (+ <span className="text-xs px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-300 border border-emerald-500/30">+ vLLM / DFLASH2+ </span>+ )}{provider.mtplxBacked && (<span className="text-xs px-2 py-0.5 rounded bg-blue-500/20 text-blue-300 border border-blue-500/30">MTPLX@@ -1131,6 +1136,27 @@ function ProviderForm({ provider, onClose, onSave, onEditProvider, allProviders/></FormField>+ {/* The one CLI/TUI backend that authenticates: the vLLM compose+ stack is started with VLLM_API_KEY, so without this field+ there is nowhere to put it and the container 401s every+ model refresh and every run. Reads `capabilityProvider`+ because `vllmBacked` is a stored marker, not a form field. */}+ {capabilityProvider?.vllmBacked && (+ <FormField label="API Key">+ <input+ type="password"+ value={formData.apiKey}+ onChange={(e) => setFormData(prev => ({ ...prev, apiKey: e.target.value }))}+ placeholder={provider?.hasApiKey ? 'Key set — leave blank to keep' : 'Paste VLLM_API_KEY from the stack’s .env'}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"+ />+ <p className="text-xs text-gray-500 mt-1">+ The <code>VLLM_API_KEY</code> your compose stack was started with. PortOS puts it on the+ spawned OpenCode provider and on the model-refresh probe; the container rejects both without it.+ </p>+ </FormField>+ )}+{formData.type === 'cli' && (<FormField label="Headless Args (for simple prompt tasks)"><inputdiff --git a/client/src/pages/AIProviders.test.jsx b/client/src/pages/AIProviders.test.jsxindex 08fd60ab5f..6e73b3343e 100644--- a/client/src/pages/AIProviders.test.jsx+++ b/client/src/pages/AIProviders.test.jsx@@ -1122,3 +1122,61 @@ describe('provider card layout', () => {expect(headerRow.textContent).not.toContain('Default:');});});++describe('vLLM-backed TUI provider', () => {+ const vllmTui = (overrides = {}) => ({+ id: 'opencode-vllm-tui',+ name: 'OpenCode vLLM TUI (Qwen3.8-27B)',+ type: 'tui',+ command: 'opencode',+ args: [],+ enabled: true,+ endpoint: 'http://127.0.0.1:18020/v1',+ models: ['qwen3.8-27b'],+ defaultModel: 'qwen3.8-27b',+ vllmBacked: true,+ ...overrides,+ });++ beforeEach(() => {+ vi.clearAllMocks();+ api.getApps.mockResolvedValue([]);+ api.getProviderStatuses.mockResolvedValue({ providers: {} });+ api.getProviderRuntimes.mockResolvedValue({ runtimes: {} });+ api.getProviderReadiness.mockResolvedValue({ readiness: {} });+ localModels.value = { ctxById: {}, installed: { ollama: null, lmstudio: null } };+ });++ it('badges the card so the GPU-exclusive backend is visible at a glance', async () => {+ api.getProviders.mockResolvedValue({ providers: [vllmTui()], activeProvider: null });+ renderPage();+ expect(await screen.findByText('vLLM / DFLASH2')).toBeInTheDocument();+ });++ it('offers an API Key field on a TUI provider — the container is key-gated', async () => {+ api.getProviders.mockResolvedValue({ providers: [vllmTui()], activeProvider: null });+ renderPage();++ fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));+ const key = await screen.findByLabelText('API Key');+ fireEvent.change(key, { target: { value: 'vllm-key-example' } });+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));++ await waitFor(() => expect(api.updateProvider).toHaveBeenCalledWith(+ 'opencode-vllm-tui',+ expect.objectContaining({ apiKey: 'vllm-key-example' }),+ ));+ });++ it('keeps the field off an unauthenticated local TUI backend', async () => {+ api.getProviders.mockResolvedValue({+ providers: [vllmTui({ id: 'opencode-mtplx-tui', name: 'OpenCode MTPLX TUI', vllmBacked: undefined, mtplxBacked: true })],+ activeProvider: null,+ });+ renderPage();++ fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));+ await screen.findByDisplayValue('opencode');+ expect(screen.queryByLabelText('API Key')).toBeNull();+ });+});diff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex 4cafa1c6b1..3f06777fdc 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -561,7 +561,7 @@ export const isToolUseModel = (id) =>* @returns {{toolCapable:boolean}|null}*/export const localToolUseHint = (id, provider, toolUseIdsByProvider = null) =>- (localBackendForProvider(provider) || isOllamaBackedProvider(provider) || provider?.mtplxBacked === true || provider?.llamaBacked === true)+ (localBackendForProvider(provider) || isOllamaBackedProvider(provider) || provider?.mtplxBacked === true || provider?.llamaBacked === true || provider?.vllmBacked === true)&& typeof id === 'string' && id.length > 0? { toolCapable: toolUseIdsByProvider?.[provider?.id]?.has(id) === true || isToolUseModel(id) }: null;@@ -1157,7 +1157,7 @@ export const PROVIDER_CARD_STATE = Object.freeze({** NOT the same thing as `ProviderReadiness` /* `GET /api/providers/readiness`, which probes whether the local DAEMON a- * provider points at (llama.cpp, Ollama, LM Studio, MTPLX) is up and serving+ * provider points at (llama.cpp, Ollama, LM Studio, MTPLX, vLLM) is up and serving* the right model. This decides the card's bucket from its toggle, its* credentials and the server's bench status; the two render side by side.*diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 453a9e4e8e..5f2472784f 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -902,6 +902,7 @@ describe('supportsModelRefresh', () => {'opencode-llama-tui','opencode-mtplx', 'opencode-mtplx-tui', 'opencode-ollama','opencode-ollama-tui', 'opencode-orcarouter', 'opencode-orcarouter-tui',+ 'opencode-vllm', 'opencode-vllm-tui','orcarouter',]);});diff --git a/data.reference/providers.json b/data.reference/providers.jsonindex d2583c5d26..63a9ed0c9a 100644--- a/data.reference/providers.json+++ b/data.reference/providers.json@@ -249,6 +249,45 @@"tuiPromptDelayMs": 2500,"tuiIdleTimeoutMs": 180000},+ "opencode-vllm": {+ "id": "opencode-vllm",+ "name": "OpenCode vLLM (Qwen3.8-27B)",+ "type": "cli",+ "command": "opencode",+ "args": ["run"],+ "endpoint": "http://127.0.0.1:18020/v1",+ "apiKey": "",+ "models": ["qwen3.8-27b"],+ "defaultModel": "qwen3.8-27b",+ "vllmBacked": true,+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"allow\",\"provider\":{\"vllm\":{\"npm\":\"@ai-sdk/openai-compatible\",\"name\":\"vLLM Qwen3.8-27B (local)\",\"options\":{\"baseURL\":\"http://127.0.0.1:18020/v1\"}}}}"+ },+ "secretEnvVars": [],+ "headlessArgs": []+ },+ "opencode-vllm-tui": {+ "id": "opencode-vllm-tui",+ "name": "OpenCode vLLM TUI (Qwen3.8-27B)",+ "type": "tui",+ "command": "opencode",+ "args": [],+ "endpoint": "http://127.0.0.1:18020/v1",+ "apiKey": "",+ "models": ["qwen3.8-27b"],+ "defaultModel": "qwen3.8-27b",+ "vllmBacked": true,+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"allow\",\"provider\":{\"vllm\":{\"npm\":\"@ai-sdk/openai-compatible\",\"name\":\"vLLM Qwen3.8-27B (local)\",\"options\":{\"baseURL\":\"http://127.0.0.1:18020/v1\"}}}}"+ },+ "secretEnvVars": [],+ "tuiPromptDelayMs": 2500,+ "tuiIdleTimeoutMs": 180000+ },"orcarouter": {"id": "orcarouter","name": "OrcaRouter",diff --git a/docs/PORTS.md b/docs/PORTS.mdindex a6fe0eddc2..c32f71fafd 100644--- a/docs/PORTS.md+++ b/docs/PORTS.md@@ -35,6 +35,7 @@ Common port labels:| 5560 | portos-autofixer-ui | ui | Autofixer web UI || 5561 | portos-db (Docker container) | - | Infrastructure dependency: PostgreSQL Docker container provisioned by `scripts/setup-db.js` / Docker Compose (not a PM2 process in `server/services/apps.js`; native mode uses system pg on 5432). || 5568 | llama-server | - | Loopback speculative-decoding server managed from Settings → Local LLM |+| 18020 | vLLM (Docker) | - | Loopback vLLM Qwen3.8-27B / DFlash 2 container on an RTX 3090 host. Operator-started (`docker compose --profile single up -d`) — PortOS never brings it up on boot. See [features/qwen38-rtx3090.md](./features/qwen38-rtx3090.md). |## How `:5555`, `:5553`, and `:5554` Relate@@ -126,7 +127,9 @@ PortOS automatically detects ports from env vars:| 5562-5569 | Reserved for PortOS extensions (5568 is the managed llama-server default) || 5570-5599 | User applications |-PostgreSQL in native mode listens on the system default `:5432`, outside these ranges.+PostgreSQL in native mode listens on the system default `:5432`, outside these ranges. The vLLM+Qwen3.8-27B container listens on `:18020` — upstream's own default, kept as-is so an operator's+unmodified `syv-ai/qwen38-27b-rtx3090` checkout works against PortOS without editing its compose file.## Viewing Port Usagediff --git a/docs/README.md b/docs/README.mdindex fd07d5a82d..4d9d7198b2 100644--- a/docs/README.md+++ b/docs/README.md@@ -34,7 +34,7 @@ Start with the [product surface map](./features/product-surfaces.md) for a complApp management: [app-wizard](./features/app-wizard.md) · [autofixer](./features/autofixer.md) · [browser](./features/browser.md) · [error-handling](./features/error-handling.md) · [jira-sprint-manager](./features/jira-sprint-manager.md)-Chief of Staff: [chief-of-staff](./features/chief-of-staff.md) · [cos-agent-runner](./features/cos-agent-runner.md) · [cos-enhancement](./features/cos-enhancement.md) · [agent-context](./features/agent-context.md) · [agent-skills](./features/agent-skills.md) · [memory-system](./features/memory-system.md) · [claude-ollama](./features/claude-ollama.md) · [mtplx](./features/mtplx.md) · [dflash2](./features/dflash2.md) ([DSpark vs DFlash 2](./research/2026-08-19-dspark-vs-dflash2.md)) · [prompt-manager](./features/prompt-manager.md)+Chief of Staff: [chief-of-staff](./features/chief-of-staff.md) · [cos-agent-runner](./features/cos-agent-runner.md) · [cos-enhancement](./features/cos-enhancement.md) · [agent-context](./features/agent-context.md) · [agent-skills](./features/agent-skills.md) · [memory-system](./features/memory-system.md) · [claude-ollama](./features/claude-ollama.md) · [mtplx](./features/mtplx.md) · [dflash2](./features/dflash2.md) ([DSpark vs DFlash 2](./research/2026-08-19-dspark-vs-dflash2.md)) · [qwen38-rtx3090](./features/qwen38-rtx3090.md) · [prompt-manager](./features/prompt-manager.md)Identity & self: [digital-twin](./features/digital-twin.md) · [identity-system](./features/identity-system.md) · [soul-system](./features/soul-system.md) · [privacy-center](./features/privacy-center.md) · [post](./features/post.md) (insights design spike: [plans/2026-06-03](./plans/2026-06-03-cross-domain-insights-engine.md))diff --git a/docs/features/qwen38-rtx3090.md b/docs/features/qwen38-rtx3090.mdnew file mode 100644index 0000000000..698bb3cbc5--- /dev/null+++ b/docs/features/qwen38-rtx3090.md@@ -0,0 +1,137 @@+# vLLM Qwen3.8-27B (DFlash 2) on an RTX 3090++[syv-ai/qwen38-27b-rtx3090](https://github.com/syv-ai/qwen38-27b-rtx3090) is a+frozen, reproducible packaging of patched vLLM 0.27.1 + a requantized+Qwen3.8-27B + a Docker compose file, targeted at **one specific card**: a 24 GB+RTX 3090. It serves an OpenAI-compatible API with DFlash 2 speculative drafting+and prefix caching turned on.++PortOS fronts it the same way it fronts [MTPLX](./mtplx.md) and the+[llama-server DSpark/DFlash 2 setup](./dflash2.md): as a local OpenAI-compatible+daemon behind two OpenCode wrappers. Nothing about the engine is vendored here —+PortOS talks to `http://127.0.0.1:18020/v1` and nothing more.++## Two hard constraints, before anything else++**It holds the entire GPU.** The stack occupies roughly 23 GB of the 3090's+24 GB. Local image and video generation on the same card cannot run alongside+it. There is no arbitration in PortOS: stop the container before a media job, or+run media generation on a different machine. This is also why PortOS never+auto-starts it — a container that came up on boot would silently take the card+away from whatever else the box does.++**Apple Silicon is not supported.** DFlash 2 has not been proven on Apple+Silicon in this project, and this is a CUDA / Marlin / FlashInfer container —+it will not run on a Mac at all. The readiness checklist says so on `darwin`+rather than offering a button that cannot work. Mac users wanting the same shape+(a local OpenAI-compatible daemon under an OpenCode TUI) already have+[MTPLX](./mtplx.md) and [DSpark](./dflash2.md).++## Why OpenCode and not Claude Code++vLLM speaks the OpenAI API. Claude Code speaks the Anthropic Messages API, so+pointing it here would mean running a LiteLLM translation layer in between —+another process to install, run, and debug for no capability gain. OpenCode+talks to an OpenAI-compatible endpoint natively, which is exactly what+`OPENCODE_CONFIG_CONTENT` already declares for Ollama, MTPLX, and llama.cpp.++## What PortOS adds++After this version is installed, the **AI Providers** page includes two disabled+presets:++- **OpenCode vLLM (Qwen3.8-27B)** — a headless `cli` coding-agent provider.+- **OpenCode vLLM TUI (Qwen3.8-27B)** — the attachable `tui` provider CoS agent+ tasks run in.++Both are disabled, hold a blank API key, and point at+`http://127.0.0.1:18020/v1`. No API-only preset ships: the container is+key-gated and the two coding harnesses cover everything a text-only record+would.++## Setup++### 1. Prepare the stack (operator, on the 3090 host)++This step is yours, in a terminal. PortOS does not clone the project, pull the+~9.5 GB image, or download the ~20 GB of weights — those are decisions with a+bandwidth and disk cost, and a button that started them by surprise would be the+wrong default.++On Windows you need WSL2 with Docker and the NVIDIA Container Toolkit (driver+≥ 580 / CUDA 13); on Linux, the same toolkit natively.++```bash+git clone https://github.com/syv-ai/qwen38-27b-rtx3090 ~/qwen-serving+cd ~/qwen-serving+echo "VLLM_API_KEY=$(openssl rand -hex 24)" > .env+printf 'SPEC=dflash2\nPREFIX_CACHE=1\n' >> .env+docker compose --profile single up -d+```++If startup dies on memory, upstream's escape hatches are `GPU_UTIL=0.93` and+`PYTORCH_CUDA_ALLOC_CONF=expandable_segments:False` in `.env`. Capping board+power with `nvidia-smi -pl 250` is worth doing on a 3090.++Confirm it serves before touching PortOS:++```bash+curl -H "Authorization: Bearer $VLLM_API_KEY" http://127.0.0.1:18020/v1/models+```++On Windows, confirm the same URL answers from the PortOS side too — Docker+Desktop / WSL2 localhost forwarding is what makes a container in the VM+reachable at `127.0.0.1` on the host.++**`DFLASH_TOKENS=15` is deliberately not a default.** It is the setting behind+the headline throughput number, but it costs KV cache: 56k context across 4+slots is too tight for CoS agent prompts, which carry a repo's worth of files.+Lookup drafting stays on either way. Set it in `.env` yourself if you have a+workload that fits.++### 2. Enable the provider (PortOS)++1. On **AI Providers**, enable **OpenCode vLLM TUI (Qwen3.8-27B)**.+2. Paste the `VLLM_API_KEY` from your `.env` into the provider's API key field.+ PortOS injects it into the spawned OpenCode's `provider.vllm.options.apiKey`;+ without it the container answers 401 and the model list stays empty.+3. Click **Refresh Models**. The served model should appear; the seeded alias is+ `qwen3.8-27b`, so update the default model if your container publishes a+ different id.+4. Assign the provider to a CoS agent task.++The provider card's requirements checklist probes `:18020` directly. Its+**Start** button runs `docker compose --profile single up -d` — but only when it+can see a prepared project (a compose file in `~/qwen-serving`, or wherever+`VLLM_QWEN_PROJECT_DIR` points) **and** confirm the weights are already cached.+It never pulls. If your HuggingFace cache lives in a docker named volume PortOS+cannot see — the normal case on Windows — the button says so and asks you to+start compose yourself, or to point `VLLM_QWEN_WEIGHTS_DIR` at the cache.++## What the numbers mean++The ~381 tok/s figure quoted upstream is *document reproduction*: 15 of 16+drafted tokens accepted straight from the context lookup. Ordinary chat is+around 133 tok/s. A coding agent — files in context, patches written back — sits+between the two, which is the workload the speculative path is actually for.+Prefix caching is the other half: on a 25k-token document, upstream measured+time-to-first-token dropping from 22.4 s on the first turn to 0.56 s on the+follow-up, which is what makes a multi-turn TUI session feel different from a+one-shot completion.++## Environment overrides++| Variable | Default | Purpose |+|---|---|---|+| `VLLM_QWEN_PROJECT_DIR` | `~/qwen-serving` | Where the compose project was cloned. |+| `VLLM_QWEN_WEIGHTS_DIR` | *(unset)* | HuggingFace hub cache holding the weights, when PortOS cannot find it — e.g. a docker named volume bind-mounted elsewhere. |++## Related++- [MTPLX](./mtplx.md) — the Apple Silicon native-MTP equivalent.+- [DFlash 2 / DSpark on llama.cpp](./dflash2.md) — the llama-server path, and the+ 2026-08-19 evaluation that concluded PortOS should not vendor an unmerged+ engine patch. That conclusion still holds; what changed is that upstream froze+ a working container for this exact card, so PortOS points at it instead of+ building it.+- [docs/PORTS.md](../PORTS.md) — why `:18020` sits outside the 5553–5569 range.diff --git a/ecosystem.config.cjs b/ecosystem.config.cjsindex 4503501d04..f50f2e6a55 100644--- a/ecosystem.config.cjs+++ b/ecosystem.config.cjs@@ -49,6 +49,7 @@ const PORTS = {AUTOFIXER_UI: 5560, // Autofixer UIPOSTGRES_DOCKER: 5561, // PostgreSQL Docker container (host port mapping)LLAMA_SERVER: 5568, // Loopback llama.cpp speculative-decoding server+ VLLM_QWEN: 18020, // Loopback vLLM Qwen3.8-27B (DFlash 2) container — started by the operator, never by PortOSPOSTGRES: pgMode === 'native' ? 5432 : 5561 // Active PostgreSQL port (unused in file mode)};diff --git a/scripts/migrations/285-opencode-vllm-providers.js b/scripts/migrations/285-opencode-vllm-providers.jsnew file mode 100644index 0000000000..f788d34de9--- /dev/null+++ b/scripts/migrations/285-opencode-vllm-providers.js@@ -0,0 +1,77 @@+/**+ * Ship disabled OpenCode vLLM provider presets to existing installs.+ *+ * The [syv-ai/qwen38-27b-rtx3090](https://github.com/syv-ai/qwen38-27b-rtx3090)+ * stack serves Qwen3.8-27B with DFlash 2 drafting and prefix caching from a+ * patched vLLM container on a single RTX 3090. It is an OpenAI-compatible+ * daemon, so PortOS fronts it exactly the way it fronts MTPLX and llama-server:+ * two OpenCode wrappers — a headless `cli` twin and the attachable `tui` that+ * CoS agent tasks actually run in.+ *+ * No API preset. The container is started behind a `VLLM_API_KEY` the operator+ * generates per install, and a text-only preset would add a third record to+ * paste it into for no capability the two coding harnesses do not already+ * provide.+ *+ * Both presets are DISABLED, and this migration installs nothing: it does not+ * clone the compose project, pull the ~9.5 GB image, download weights, start a+ * container, or contact the endpoint. The stack holds the whole GPU, so an+ * install that also runs local image/video generation must not have it come up+ * on its own. An install that already owns one of these ids is left untouched.+ *+ * Kept in lockstep with data.reference/providers.json and+ * server/lib/aiToolkit/defaults/providers.sample.json. These frozen literals+ * are the historical upgrade payload; later default changes require a new+ * migration rather than rewriting this record.+ */++import { makeProviderSeedMigration } from './_lib.js';++const ENDPOINT = 'http://127.0.0.1:18020/v1';++const OPENCODE_CONFIG_CONTENT = '{"permission":"allow","provider":{"vllm":{"npm":"@ai-sdk/openai-compatible","name":"vLLM Qwen3.8-27B (local)","options":{"baseURL":"http://127.0.0.1:18020/v1"}}}}';++const OPENCODE_VLLM_CLI = {+ id: 'opencode-vllm',+ name: 'OpenCode vLLM (Qwen3.8-27B)',+ type: 'cli',+ command: 'opencode',+ args: ['run'],+ endpoint: ENDPOINT,+ // Blank, not absent: the operator pastes the compose stack's VLLM_API_KEY+ // here, and the spawner copies it onto the OpenCode provider's+ // `options.apiKey`.+ apiKey: '',+ models: ['qwen3.8-27b'],+ defaultModel: 'qwen3.8-27b',+ vllmBacked: true,+ timeout: 600000,+ enabled: false,+ envVars: { OPENCODE_CONFIG_CONTENT },+ secretEnvVars: [],+ headlessArgs: [],+};++const OPENCODE_VLLM_TUI = {+ id: 'opencode-vllm-tui',+ name: 'OpenCode vLLM TUI (Qwen3.8-27B)',+ type: 'tui',+ command: 'opencode',+ args: [],+ endpoint: ENDPOINT,+ apiKey: '',+ models: ['qwen3.8-27b'],+ defaultModel: 'qwen3.8-27b',+ vllmBacked: true,+ timeout: 600000,+ enabled: false,+ envVars: { OPENCODE_CONFIG_CONTENT },+ secretEnvVars: [],+ tuiPromptDelayMs: 2500,+ tuiIdleTimeoutMs: 180000,+};++export default makeProviderSeedMigration({+ label: 'OpenCode vLLM (Qwen3.8-27B)',+ defs: [OPENCODE_VLLM_CLI, OPENCODE_VLLM_TUI],+});diff --git a/scripts/migrations/285-opencode-vllm-providers.test.js b/scripts/migrations/285-opencode-vllm-providers.test.jsnew file mode 100644index 0000000000..180624119a--- /dev/null+++ b/scripts/migrations/285-opencode-vllm-providers.test.js@@ -0,0 +1,87 @@+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';++import migration from './285-opencode-vllm-providers.js';++const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));++describe('migration 285 — OpenCode vLLM providers', () => {+ let rootDir;+ let providersPath;++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-285-'));+ mkdirSync(join(rootDir, 'data'), { recursive: true });+ providersPath = join(rootDir, 'data/providers.json');+ });++ afterEach(() => rmSync(rootDir, { recursive: true, force: true }));++ it('adds both OpenCode vLLM presets, disabled, without changing the active provider', async () => {+ writeJson(providersPath, {+ activeProvider: 'claude-code',+ providers: { 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude' } },+ });++ await migration.up({ rootDir });+ const out = readJson(providersPath);++ expect(out.providers['opencode-vllm']).toMatchObject({+ name: 'OpenCode vLLM (Qwen3.8-27B)',+ type: 'cli',+ command: 'opencode',+ endpoint: 'http://127.0.0.1:18020/v1',+ models: ['qwen3.8-27b'],+ defaultModel: 'qwen3.8-27b',+ vllmBacked: true,+ enabled: false,+ });+ expect(out.providers['opencode-vllm-tui']).toMatchObject({+ type: 'tui',+ vllmBacked: true,+ enabled: false,+ tuiIdleTimeoutMs: 180000,+ });+ expect(out.activeProvider).toBe('claude-code');+ });++ it('declares the vllm namespace at the container endpoint in the OpenCode config', async () => {+ writeJson(providersPath, { providers: {} });+ await migration.up({ rootDir });++ for (const id of ['opencode-vllm', 'opencode-vllm-tui']) {+ const config = JSON.parse(readJson(providersPath).providers[id].envVars.OPENCODE_CONFIG_CONTENT);+ expect(config.provider.vllm.options.baseURL).toBe('http://127.0.0.1:18020/v1');+ }+ });++ it('ships a blank apiKey so the operator pastes the compose stack key rather than a shipped secret', async () => {+ writeJson(providersPath, { providers: {} });+ await migration.up({ rootDir });+ const out = readJson(providersPath);++ expect(out.providers['opencode-vllm'].apiKey).toBe('');+ expect(out.providers['opencode-vllm-tui'].apiKey).toBe('');+ });++ it('preserves an existing customized vLLM provider', async () => {+ const existing = {+ id: 'opencode-vllm-tui',+ name: 'Custom vLLM TUI',+ type: 'tui',+ endpoint: 'http://127.0.0.1:19000/v1',+ apiKey: 'operator-key',+ enabled: true,+ };+ writeJson(providersPath, { providers: { 'opencode-vllm-tui': existing } });++ await migration.up({ rootDir });+ const out = readJson(providersPath);+ expect(out.providers['opencode-vllm-tui']).toEqual(existing);+ // The sibling it did not already own is still added.+ expect(out.providers['opencode-vllm']).toBeDefined();+ });+});diff --git a/server/lib/README.md b/server/lib/README.mdindex ba2ec5faeb..f865a199f2 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -135,9 +135,10 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `providerFamilies.js` | Subscription-quota FAMILY identity — `PROVIDER_FAMILIES` (`{ id, label, matches }` for claude/codex/agy/grok), `PROVIDER_FAMILY_IDS`, `familyLabel`, `familyForProvider(config)` → family id or null (local-runtime wrappers and API-only providers belong to none). The pure half of the registry `services/providerUsage.js` attaches quota `fetch`ers to, so cost attribution and route validation can ask "which plan is this provider on?" without importing the PTY-scrape graph. Distinct from `providerVendors.js`, which is argv-shaped and includes vendors with no subscription quota. || `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: 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`. |+| `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. |-| `openAiModelsProbe.js` | `probeOpenAiModels(baseUrl, { timeoutMs })` → `{ 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. 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. |+| `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. || `cliChildEnv.js` | The one place the AI-CLI child environment is composed, replacing the hand-rolled copy every spawn site carried — which made each env-level fix an N-file sweep (#3194). `buildCliChildEnv({ baseEnv, before, provider, model, cwd, extra, guard })` returns a COMPLETE env for `spawn`: layers `baseEnv → before → Ollama-Claude defaults → provider.envVars → buildOpencodeEnvVars → extra`, pins `PWD` to `cwd`, strips `CLAUDECODE`, and (with `guard: true`) prepends the pm2 guard shim onto the final `PATH`. The Ollama-Claude layer raises Claude Code's default output ceiling to 65,536 tokens so a thinking-capable local model cannot finish its reasoning past the stock 32K ceiling and die before its final tool call; an explicit provider env value wins. `composeProviderEnv({ before, provider, model, extra })` returns just the ordered provider layers, for sites that build a DELTA someone else bases and spawns (the CoS runner payload, a shell-session overlay). The two slots are not interchangeable: `before` sits UNDER `provider.envVars` (forgeTokenEnv/claudeSettingsEnv, so a provider override still wins), `extra` sits OVER it (TERM/COLORTERM for a PTY). `cliChildEnv.test.js` asserts the composed order per call site and **discovers** any new site that hand-rolls the tuple instead of calling these — so the call-site list stays in the test, not in prose here. || `cliProviderArgs.js` | Per-CLI argv conventions (`buildCliArgs`) for stdin prompt delivery — dependency-light extraction from runner.js so out-of-process callers (autofixer) can import it. || `cliProviderRun.js` | One-shot CLI provider invocation (`pickCliProvider` + `runCliProviderPrompt`) — lightweight path for the autofixer + calendar MCP sync to honor the configured provider/model. |diff --git a/server/lib/aiToolkit/defaults/providers.sample.json b/server/lib/aiToolkit/defaults/providers.sample.jsonindex c65d01b675..d1e90447dd 100644--- a/server/lib/aiToolkit/defaults/providers.sample.json+++ b/server/lib/aiToolkit/defaults/providers.sample.json@@ -169,6 +169,45 @@"tuiPromptDelayMs": 2500,"tuiIdleTimeoutMs": 180000},+ "opencode-vllm": {+ "id": "opencode-vllm",+ "name": "OpenCode vLLM (Qwen3.8-27B)",+ "type": "cli",+ "command": "opencode",+ "args": ["run"],+ "endpoint": "http://127.0.0.1:18020/v1",+ "apiKey": "",+ "models": ["qwen3.8-27b"],+ "defaultModel": "qwen3.8-27b",+ "vllmBacked": true,+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"allow\",\"provider\":{\"vllm\":{\"npm\":\"@ai-sdk/openai-compatible\",\"name\":\"vLLM Qwen3.8-27B (local)\",\"options\":{\"baseURL\":\"http://127.0.0.1:18020/v1\"}}}}"+ },+ "secretEnvVars": [],+ "headlessArgs": []+ },+ "opencode-vllm-tui": {+ "id": "opencode-vllm-tui",+ "name": "OpenCode vLLM TUI (Qwen3.8-27B)",+ "type": "tui",+ "command": "opencode",+ "args": [],+ "endpoint": "http://127.0.0.1:18020/v1",+ "apiKey": "",+ "models": ["qwen3.8-27b"],+ "defaultModel": "qwen3.8-27b",+ "vllmBacked": true,+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"allow\",\"provider\":{\"vllm\":{\"npm\":\"@ai-sdk/openai-compatible\",\"name\":\"vLLM Qwen3.8-27B (local)\",\"options\":{\"baseURL\":\"http://127.0.0.1:18020/v1\"}}}}"+ },+ "secretEnvVars": [],+ "tuiPromptDelayMs": 2500,+ "tuiIdleTimeoutMs": 180000+ },"orcarouter": {"id": "orcarouter","name": "OrcaRouter",diff --git a/server/lib/aiToolkit/internal/modelFetchers.js b/server/lib/aiToolkit/internal/modelFetchers.jsindex 4a8fcbf9a8..0322bbc818 100644--- a/server/lib/aiToolkit/internal/modelFetchers.js+++ b/server/lib/aiToolkit/internal/modelFetchers.js@@ -78,6 +78,16 @@ export const MODEL_FETCHERS = [tuiMatch: (p) => p?.llamaBacked === true,fetch: '_fetchLlamaModels',},+ {+ key: 'vllm',+ // The vLLM container publishes its served model through the same+ // OpenAI-compatible `/v1/models` contract. It answers only WITH the+ // compose stack's API key, which the wrapper stores on `apiKey` —+ // `_refreshAPIProviderModels` attaches it as a Bearer header.+ cliMatch: (p) => p?.vllmBacked === true,+ tuiMatch: (p) => p?.vllmBacked === true,+ fetch: '_fetchVllmModels',+ },{key: 'orcarouter',// OrcaRouter-backed OpenCode wrappers probe the sibling API provider'sdiff --git a/server/lib/aiToolkit/internal/modelFetchers.test.js b/server/lib/aiToolkit/internal/modelFetchers.test.jsindex 85e716eddb..1838514464 100644--- a/server/lib/aiToolkit/internal/modelFetchers.test.js+++ b/server/lib/aiToolkit/internal/modelFetchers.test.js@@ -21,6 +21,7 @@ const SHIPPED_REFRESHABLE = ['opencode-llama-tui','opencode-mtplx', 'opencode-mtplx-tui', 'opencode-ollama', 'opencode-ollama-tui','opencode-orcarouter', 'opencode-orcarouter-tui', 'orcarouter',+ 'opencode-vllm', 'opencode-vllm-tui',];const SHIPPED_NOT_REFRESHABLE = ['claude-code-tui', 'claude-code-tui-bedrock', 'codex', 'codex-tui',diff --git a/server/lib/aiToolkit/providers.js b/server/lib/aiToolkit/providers.jsindex ddca966527..288b192958 100644--- a/server/lib/aiToolkit/providers.js+++ b/server/lib/aiToolkit/providers.js@@ -606,6 +606,10 @@ export function createProviderService(config = {}) {// namespace and model refresh probes its local endpoint....(providerData.mtplxBacked === true ? { mtplxBacked: true } : {}),...(providerData.llamaBacked === true ? { llamaBacked: true } : {}),+ // The local vLLM container is a third distinct local backend: preserve+ // the marker so OpenCode receives the `vllm/` namespace and model+ // refresh probes the container rather than the OpenCode harness.+ ...(providerData.vllmBacked === true ? { vllmBacked: true } : {}),...(providerData.orcarouterBacked === true ? { orcarouterBacked: true } : {}),// Explicit opt-in to send the API key to an arbitrary (non-local,// non-allowlisted) endpoint — see internal/endpointGuard.js. Only@@ -1096,6 +1100,19 @@ export function createProviderService(config = {}) {return this._refreshAPIProviderModels(provider);},+ /**+ * Fetch the served catalog from a local vLLM container for its OpenCode+ * CLI/TUI wrappers. Same OpenAI-compatible contract as MTPLX/llama-server,+ * plus the compose stack's API key as a Bearer header (attached by+ * `_refreshAPIProviderModels` from the wrapper's own `apiKey`).+ *+ * Refresh-only, like every other local fetcher here: it never starts the+ * container, pulls the image, or issues a completion.+ */+ async _fetchVllmModels(provider) {+ return this._refreshAPIProviderModels(provider);+ },+/** Fetch the OrcaRouter catalog for its OpenCode CLI/TUI wrappers. */async _fetchOrcaRouterModels(provider) {return this._refreshAPIProviderModels(provider);diff --git a/server/lib/aiToolkit/validation.js b/server/lib/aiToolkit/validation.jsindex d8eaf54bb9..f3b1eaf918 100644--- a/server/lib/aiToolkit/validation.js+++ b/server/lib/aiToolkit/validation.js@@ -107,6 +107,11 @@ export const providerSchema = z.object({// Marks an OpenCode CLI/TUI wrapper for a separately started local llama.cpp// server (e.g. DFlash 2 speculative decoding).llamaBacked: z.boolean().optional(),+ // Marks an OpenCode CLI/TUI wrapper for a separately started local vLLM+ // container serving Qwen3.8-27B with DFlash 2 drafting. Distinct from+ // `llamaBacked`: a different engine, a different port, and a different auth+ // story (vLLM is started behind an API key; llama-server is not).+ vllmBacked: z.boolean().optional(),// Marks an OpenCode CLI/TUI wrapper for the OrcaRouter OpenAI-compatible// gateway. Its API key is read from the sibling `orcarouter` API record at// spawn/refresh time and is never stored in this wrapper's config.diff --git a/server/lib/cliChildEnv.js b/server/lib/cliChildEnv.jsindex 86859f5395..580b9a62dd 100644--- a/server/lib/cliChildEnv.js+++ b/server/lib/cliChildEnv.js@@ -75,7 +75,7 @@ function claudeOllamaEnvDefaults(provider) {* @param {object} options* @param {object|null} [options.before] - layered first, so `provider.envVars`* overrides it (forgeTokenEnv, claudeSettingsEnv).- * @param {{command?:string, envVars?:object, models?:string[], defaultModel?:string|null, ollamaBacked?:boolean, mtplxBacked?:boolean, llamaBacked?:boolean, orcarouterBacked?:boolean, thinking?:boolean}|null} [options.provider]+ * @param {{command?:string, envVars?:object, models?:string[], defaultModel?:string|null, ollamaBacked?:boolean, mtplxBacked?:boolean, llamaBacked?:boolean, vllmBacked?:boolean, orcarouterBacked?:boolean, thinking?:boolean}|null} [options.provider]* @param {string|null} [options.model] - the model being run this invocation,* unioned into the OpenCode declared-models map. Omit when the site has no* per-call model — `provider.defaultModel` is always declared regardless.diff --git a/server/lib/index.js b/server/lib/index.jsindex e13ee09b17..68525dee07 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -153,6 +153,7 @@ export * from './quotaWindows.js';export * from './opencodeConfig.js';export * from './localProviderRuntime.js';export * from './mtplxModels.js';+export * from './vllmQwenProject.js';export * from './openAiModelsProbe.js';// `runners.js` re-defines `isFlux2`/`isZImage`/`isErnie` that also live in// mediaModels.js — namespace it so the barrel surface is unambiguous.diff --git a/server/lib/localProviderRuntime.js b/server/lib/localProviderRuntime.jsindex 9b6c57a5cd..8d99ee7305 100644--- a/server/lib/localProviderRuntime.js+++ b/server/lib/localProviderRuntime.js@@ -4,13 +4,14 @@* A provider like `opencode-llama-tui` is only half a configuration: PortOS can* spawn the OpenCode CLI perfectly and the run still dies with "Cannot connect* to API: Unable to connect" because the daemon it points at — `llama-server`,- * the Ollama daemon, LM Studio's server, an MTPLX process — was never installed+ * the Ollama daemon, LM Studio's server, an MTPLX process, a vLLM container —+ * was never installed* or never started. The binary check in `providerRuntimeInstaller.js` answers* "can PortOS run `opencode`?", which is a different question and stays green in* exactly that failure.** This module is the pure half of the answer: given a provider record, which- * local runtime backs it (`llama` / `ollama` / `lmstudio` / `mtplx`) and what+ * local runtime backs it (`llama` / `ollama` / `lmstudio` / `mtplx` / `vllm`) and what* base URL should be probed. `services/providerReadiness.js` does the probing.* Kept side-effect-free so both the readiness service and its tests can reason* about the mapping without a daemon on the host.@@ -153,6 +154,21 @@ export const LOCAL_RUNTIMES = Object.freeze({docsUrl: 'https://lmstudio.ai/download',modelsHint: 'Download a model in LM Studio and start its local server.',}),+ vllm: Object.freeze({+ id: 'vllm',+ label: 'vLLM (Qwen3.8-27B)',+ // Docker is the harness: the stack ships as an upstream compose project+ // (syv-ai/qwen38-27b-rtx3090), and PortOS never vendors the engine or the+ // ~9.5 GB image. "Is docker here?" is the only install question PortOS can+ // answer about it.+ command: 'docker',+ defaultBaseUrl: opencodeLocalBaseUrl('vllm'),+ // No Local LLM tab entry — the weights and the compose project are an+ // operator-owned ~20 GB prepare step, not something PortOS downloads.+ manageUrl: null,+ docsUrl: 'https://github.com/atomantic/PortOS/blob/main/docs/features/qwen38-rtx3090.md',+ modelsHint: 'Clone syv-ai/qwen38-27b-rtx3090 and run its prepare step once — PortOS never pulls the image or the ~20 GB of weights.',+ }),mtplx: Object.freeze({id: 'mtplx',label: 'MTPLX',@@ -218,7 +234,7 @@ function opencodeConfiguredBaseUrl(provider, namespace) {* *namespace* but a remote hosted API, so there is no local daemon to check.** @param {object|null|undefined} provider- * @returns {'llama'|'ollama'|'lmstudio'|'mtplx'|null}+ * @returns {'llama'|'ollama'|'lmstudio'|'mtplx'|'vllm'|null}*/export function localRuntimeKind(provider) {if (!provider || typeof provider !== 'object') return null;diff --git a/server/lib/localProviderRuntime.test.js b/server/lib/localProviderRuntime.test.jsindex 81fc8d434c..5e9ede5bc8 100644--- a/server/lib/localProviderRuntime.test.js+++ b/server/lib/localProviderRuntime.test.js@@ -56,6 +56,7 @@ describe('localRuntimeKind', () => {it('reads the explicit backing markers first', () => {expect(localRuntimeKind({ command: 'opencode', llamaBacked: true })).toBe('llama');expect(localRuntimeKind({ command: 'opencode', mtplxBacked: true })).toBe('mtplx');+ expect(localRuntimeKind({ command: 'opencode', vllmBacked: true })).toBe('vllm');expect(localRuntimeKind({ command: 'opencode', ollamaBacked: true })).toBe('ollama');// claude-ollama is not an OpenCode provider but is still Ollama-backed.expect(localRuntimeKind({ command: 'claude', ollamaBacked: true })).toBe('ollama');@@ -181,6 +182,7 @@ describe('localRuntimeForProvider', () => {expect(LOCAL_RUNTIMES.llama.defaultBaseUrl).toBe(opencodeLocalBaseUrl('llama'));expect(LOCAL_RUNTIMES.ollama.defaultBaseUrl).toBe(opencodeLocalBaseUrl('ollama'));expect(LOCAL_RUNTIMES.mtplx.defaultBaseUrl).toBe(opencodeLocalBaseUrl('mtplx'));+ expect(LOCAL_RUNTIMES.vllm.defaultBaseUrl).toBe(opencodeLocalBaseUrl('vllm'));});it('honors the env override the backend managers themselves read', () => {diff --git a/server/lib/modelPricing.js b/server/lib/modelPricing.jsindex c7c68cf134..25b9c05489 100644--- a/server/lib/modelPricing.js+++ b/server/lib/modelPricing.js@@ -287,7 +287,7 @@ export function isFreeModelId(model) {/*** True when a provider's usage is free — local inference (Ollama, LM Studio,- * any Ollama-/MTPLX-backed CLI wrapper, or an API provider pointed at localhost).+ * any Ollama-/MTPLX-/llama-/vLLM-backed CLI wrapper, or an API provider pointed at localhost).* Accepts a provider config object or a bare provider-id string (usage records* can outlive their provider config).* @param {object|string|null|undefined} providerOrId@@ -297,7 +297,7 @@ export function isFreeProvider(providerOrId) {if (providerOrId == null) return false;if (typeof providerOrId === 'string') return FREE_ID.test(providerOrId);const p = providerOrId;- if (p.ollamaBacked === true || p.mtplxBacked === true || p.llamaBacked === true) return true;+ if (p.ollamaBacked === true || p.mtplxBacked === true || p.llamaBacked === true || p.vllmBacked === true) return true;if (FREE_ID.test(p.id || '') || FREE_ID.test(p.command || '')) return true;if (typeof p.endpoint === 'string' && LOCALHOST_ENDPOINT.test(p.endpoint.trim())) return true;return false;diff --git a/server/lib/openAiModelsProbe.js b/server/lib/openAiModelsProbe.jsindex 6694271ca2..c6a6e6cb78 100644--- a/server/lib/openAiModelsProbe.js+++ b/server/lib/openAiModelsProbe.js@@ -13,6 +13,12 @@* - `reachable: false` — nothing is serving here (with `error` naming why)* - `reachable: true, models: null`— it answered, but the listing was unreadable* - `reachable: true, models: []` — it is up and genuinely serving nothing+ *+ * A daemon started behind an API key (vLLM's compose stack sets `VLLM_API_KEY`)+ * answers 401/403 to an unauthenticated probe. That is a REACHABLE server whose+ * listing we cannot read — reporting it as unreachable would tell the user to+ * start a container that is already running. Pass `apiKey` to read the listing+ * too.*/import { fetchWithTimeout } from './fetchWithTimeout.js';@@ -37,12 +43,13 @@ function shortFailureReason(err) {/*** @param {string} baseUrl - an OpenAI-compatible base (…/v1); trailing slashes tolerated- * @param {{timeoutMs?: number}} [opts]+ * @param {{timeoutMs?: number, apiKey?: string}} [opts]* @returns {Promise<{reachable:boolean, models:string[]|null, error:string|null}>}*/-export async function probeOpenAiModels(baseUrl, { timeoutMs = 2_000 } = {}) {+export async function probeOpenAiModels(baseUrl, { timeoutMs = 2_000, apiKey = '' } = {}) {const url = `${String(baseUrl || '').replace(/\/+$/, '')}/models`;- const res = await fetchWithTimeout(url, { method: 'GET' }, timeoutMs)+ const init = { method: 'GET', ...(apiKey ? { headers: { Authorization: `Bearer ${apiKey}` } } : {}) };+ const res = await fetchWithTimeout(url, init, timeoutMs)// undici reports every network failure as a bare `TypeError: fetch failed`;// the real reason (ECONNREFUSED vs. ETIMEDOUT — "nothing is listening" vs.// "the host is wedged", two different fixes for the user) lives in the@@ -54,6 +61,12 @@ export async function probeOpenAiModels(baseUrl, { timeoutMs = 2_000 } = {}) {// Undici holds the socket until an unread body is consumed; an endpoint// answering 404 on every poll would otherwise leak one each time.await res.body?.cancel().catch(() => {});+ // 401/403 is the ONE failure status that proves a daemon is up: something+ // read the request and refused it. Collapsing that into "nothing answered"+ // sends the user off to start a server that is already serving.+ if (res.status === 401 || res.status === 403) {+ return { reachable: true, models: null, error: 'authentication required' };+ }return { reachable: false, models: null, error: `HTTP ${res.status}` };}diff --git a/server/lib/openAiModelsProbe.test.js b/server/lib/openAiModelsProbe.test.jsindex a8d36a7cbd..ac609973b4 100644--- a/server/lib/openAiModelsProbe.test.js+++ b/server/lib/openAiModelsProbe.test.js@@ -84,4 +84,35 @@ describe('probeOpenAiModels', () => {// on a poll loop.expect(cancel).toHaveBeenCalled();});+it('attaches a Bearer header only when a key is supplied', async () => {+ const fetchMock = mockFetch(async () => jsonResponse({ data: [] }));++ await probeOpenAiModels('http://127.0.0.1:18020/v1', { timeoutMs: 500, apiKey: 'vllm-key' });+ expect(fetchMock).toHaveBeenCalledWith(+ 'http://127.0.0.1:18020/v1/models',+ { method: 'GET', headers: { Authorization: 'Bearer vllm-key' } },+ 500,+ );++ fetchMock.mockClear();+ await probeOpenAiModels('http://127.0.0.1:18020/v1', { timeoutMs: 500 });+ expect(fetchMock).toHaveBeenCalledWith('http://127.0.0.1:18020/v1/models', { method: 'GET' }, 500);+ });++ it('treats 401/403 as REACHABLE-but-unlistable, not as nothing answering', async () => {+ // A key-gated daemon (vLLM's compose stack sets VLLM_API_KEY) refuses an+ // unauthenticated probe. Reporting that as unreachable would tell the user+ // to start a container that is already up.+ for (const status of [401, 403]) {+ const cancel = vi.fn().mockResolvedValue(undefined);+ mockFetch(async () => ({ ok: false, status, body: { cancel } }));+ await expect(probeOpenAiModels('http://x/v1')).resolves.toEqual({+ reachable: true,+ models: null,+ error: 'authentication required',+ });+ expect(cancel).toHaveBeenCalled();+ vi.restoreAllMocks();+ }+ });});diff --git a/server/lib/opencodeConfig.js b/server/lib/opencodeConfig.jsindex a146585b3d..b46573e76a 100644--- a/server/lib/opencodeConfig.js+++ b/server/lib/opencodeConfig.js@@ -22,6 +22,7 @@ import { getOpencodeLocalProviderNamespace, isOpencodeCommand } from './providerimport { PORTS } from './ports.js';const LLAMA_SERVER_BASE_URL = `http://127.0.0.1:${PORTS.LLAMA_SERVER}/v1`;+const VLLM_QWEN_BASE_URL = `http://127.0.0.1:${PORTS.VLLM_QWEN}/v1`;/*** Base OpenCode provider entries for the local OpenAI-compatible daemons.@@ -44,6 +45,11 @@ const OPENCODE_LOCAL_BASE_PROVIDERS = {name: 'llama.cpp (local)',options: { baseURL: LLAMA_SERVER_BASE_URL },},+ vllm: {+ npm: '@ai-sdk/openai-compatible',+ name: 'vLLM Qwen3.8-27B (local)',+ options: { baseURL: VLLM_QWEN_BASE_URL },+ },orcarouter: {npm: '@ai-sdk/openai-compatible',name: 'OrcaRouter',@@ -56,12 +62,19 @@ const OPENCODE_LOCAL_BASE_PROVIDERS = {* — what a spawned OpenCode talks to when the provider stores no config of its* own. Read by `lib/localProviderRuntime.js` so the readiness probe and the* spawn agree on the endpoint instead of keeping two copies of these ports.- * @param {'ollama'|'mtplx'|'llama'|'orcarouter'} providerKey+ * @param {'ollama'|'mtplx'|'llama'|'vllm'|'orcarouter'} providerKey* @returns {string|null}*/export const opencodeLocalBaseUrl = (providerKey) =>OPENCODE_LOCAL_BASE_PROVIDERS[providerKey]?.options?.baseURL || null;+/**+ * OpenCode local namespaces whose backend authenticates the request. Everything+ * else here is an unauthenticated loopback daemon, and attaching a key to those+ * would put a secret into a config file that never needed one.+ */+const KEY_BEARING_NAMESPACES = new Set(['orcarouter', 'vllm']);+const localProviderBase = (providerKey) => {if (!Object.hasOwn(OPENCODE_LOCAL_BASE_PROVIDERS, providerKey)) {throw new Error(`Unsupported OpenCode local provider '${providerKey}'`);@@ -82,7 +95,7 @@ const stripProviderPrefix = (id, providerKey) =>* Normalize an id or list of ids to the unique, non-empty, prefix-stripped bare* model ids that key the OpenCode `models` map.* @param {string|string[]|null|undefined} models- * @param {'ollama'|'mtplx'|'llama'|'orcarouter'} [providerKey='ollama']+ * @param {'ollama'|'mtplx'|'llama'|'vllm'|'orcarouter'} [providerKey='ollama']* @returns {string[]}*/export function toBareModelIds(models, providerKey = 'ollama') {@@ -111,7 +124,7 @@ export function toBareModelIds(models, providerKey = 'ollama') {** @param {string|string[]|null|undefined} models* @param {object|null} [base] - existing config to merge into (a fresh clone is made)- * @param {'ollama'|'mtplx'|'llama'|'orcarouter'} [providerKey='ollama']+ * @param {'ollama'|'mtplx'|'llama'|'vllm'|'orcarouter'} [providerKey='ollama']* @returns {object} OpenCode config object*/export function buildOpencodeConfig(models, base = null, providerKey = 'ollama', generation = null) {@@ -167,7 +180,7 @@ export function buildOpencodeConfig(models, base = null, providerKey = 'ollama',** @param {string|string[]|null|undefined} models* @param {object|null} [base] - existing config to merge into- * @param {'ollama'|'mtplx'|'llama'|'orcarouter'} [providerKey='ollama']+ * @param {'ollama'|'mtplx'|'llama'|'vllm'|'orcarouter'} [providerKey='ollama']* @returns {string} JSON string for OPENCODE_CONFIG_CONTENT*/export function buildOpencodeConfigContent(models, base = null, providerKey = 'ollama', generation = null) {@@ -177,7 +190,7 @@ export function buildOpencodeConfigContent(models, base = null, providerKey = 'o/*** Build dynamic env vars for an OpenCode local-provider spawn. Returns an* object with `OPENCODE_CONFIG_CONTENT` (models map declared) for Ollama-,- * MTPLX-, Llama-, or OrcaRouter-backed OpenCode providers, otherwise an empty object (caller keeps+ * MTPLX-, Llama-, vLLM-, or OrcaRouter-backed OpenCode providers, otherwise an empty object (caller keeps* existing env).** The provider's already-stored `OPENCODE_CONFIG_CONTENT` is used as the base and@@ -187,7 +200,7 @@ export function buildOpencodeConfigContent(models, base = null, providerKey = 'o* model, and the model being run this invocation — so whichever namespaced* `--model` the spawner passes is always accepted.*- * @param {{command?:string, ollamaBacked?:boolean, mtplxBacked?:boolean, llamaBacked?:boolean, orcarouterBacked?:boolean, models?:string[], defaultModel?:string|null, apiKey?:string, orcarouterApiKey?:string, envVars?:object}} provider+ * @param {{command?:string, ollamaBacked?:boolean, mtplxBacked?:boolean, llamaBacked?:boolean, vllmBacked?:boolean, orcarouterBacked?:boolean, models?:string[], defaultModel?:string|null, apiKey?:string, orcarouterApiKey?:string, envVars?:object}} provider* @param {string|null|undefined} model - the model being run (may differ from defaultModel)* @returns {{OPENCODE_CONFIG_CONTENT?: string}} env vars to merge*/@@ -214,15 +227,22 @@ export function buildOpencodeEnvVars(provider, model) {model,];const config = buildOpencodeConfig(ids, base, providerKey, provider);- const apiKey = providerKey === 'orcarouter' ? (provider?.apiKey || provider?.orcarouterApiKey) : null;+ // Both key-bearing namespaces read the SAME `provider.apiKey` field; the+ // OrcaRouter alias is legacy. vLLM's compose stack is started with+ // `VLLM_API_KEY`, so a wrapper pointed at it needs the key on+ // `options.apiKey` exactly the way the hosted gateway does — the endpoint is+ // loopback, but the server still 401s without it.+ const apiKey = KEY_BEARING_NAMESPACES.has(providerKey)+ ? (provider?.apiKey || (providerKey === 'orcarouter' ? provider?.orcarouterApiKey : null))+ : null;if (apiKey) {- config.provider.orcarouter.options = {- ...config.provider.orcarouter.options,+ config.provider[providerKey].options = {+ ...config.provider[providerKey].options,apiKey,};}return {OPENCODE_CONFIG_CONTENT: JSON.stringify(config),- ...(apiKey ? { ORCAROUTER_API_KEY: apiKey } : {}),+ ...(apiKey && providerKey === 'orcarouter' ? { ORCAROUTER_API_KEY: apiKey } : {}),};}diff --git a/server/lib/opencodeConfig.test.js b/server/lib/opencodeConfig.test.jsindex bf5fac40d4..ad65c1771a 100644--- a/server/lib/opencodeConfig.test.js+++ b/server/lib/opencodeConfig.test.js@@ -203,6 +203,33 @@ describe('buildOpencodeEnvVars', () => {expect(storedConfig).not.toContain('sk-orca-example');});+ it('declares the run model under provider.vllm at the container endpoint', () => {+ const result = buildOpencodeEnvVars({ command: 'opencode', vllmBacked: true, models: ['qwen3.8-27b'] }, 'qwen3.8-27b');+ const cfg = JSON.parse(result.OPENCODE_CONFIG_CONTENT);+ expect(cfg.provider.vllm.options.baseURL).toBe('http://127.0.0.1:18020/v1');+ expect(cfg.provider.vllm.models['qwen3.8-27b']).toEqual({ name: 'qwen3.8-27b', tool_call: true });+ });++ it("injects the vLLM container's API key into options.apiKey, and no ORCAROUTER_API_KEY", () => {+ const result = buildOpencodeEnvVars({+ command: 'opencode',+ vllmBacked: true,+ models: ['qwen3.8-27b'],+ apiKey: 'vllm-key-example',+ }, 'qwen3.8-27b');+ const cfg = JSON.parse(result.OPENCODE_CONFIG_CONTENT);+ expect(cfg.provider.vllm.options.apiKey).toBe('vllm-key-example');+ // The OrcaRouter env var is that vendor's, not a generic key channel.+ expect(result.ORCAROUTER_API_KEY).toBeUndefined();+ });++ it('leaves options.apiKey off a keyless local namespace even when the provider carries a key', () => {+ const cfg = JSON.parse(buildOpencodeEnvVars({+ command: 'opencode', mtplxBacked: true, models: ['mtplx'], apiKey: 'should-not-leak',+ }, 'mtplx').OPENCODE_CONFIG_CONTENT);+ expect(cfg.provider.mtplx.options.apiKey).toBeUndefined();+ });+it('unions the provider models, defaultModel, and the run model (deduped, bare)', () => {const provider = {command: 'opencode', ollamaBacked: true,diff --git a/server/lib/ports.js b/server/lib/ports.jsindex d98e4df94d..953b3c1e78 100644--- a/server/lib/ports.js+++ b/server/lib/ports.js@@ -16,6 +16,7 @@ export const PORTS = {AUTOFIXER_UI: 5560, // Autofixer UIPOSTGRES_DOCKER: 5561, // PostgreSQL Docker container (host port mapping)LLAMA_SERVER: 5568, // Loopback llama.cpp speculative-decoding server+ VLLM_QWEN: 18020, // Loopback vLLM Qwen3.8-27B (DFlash 2) container — operator-started, never by PortOSPOSTGRES_NATIVE: 5432 // System PostgreSQL (PGMODE=native)};diff --git a/server/lib/providerFamilies.js b/server/lib/providerFamilies.jsindex a6a0f49fd0..c609f93e79 100644--- a/server/lib/providerFamilies.js+++ b/server/lib/providerFamilies.js@@ -18,7 +18,7 @@ import { isGrokCommand } from './grok.js';/*** A provider config belongs to at most one family. CLI/TUI commands are matched* by binary basename; the Grok/Kimi-style API providers by id or endpoint.- * Local-runtime CLI wrappers (Ollama or MTPLX) are local/free and have no+ * Local-runtime CLI wrappers (Ollama, MTPLX, llama.cpp, vLLM) are local/free and have no* subscription quota, so they map to no family (see `familyForProvider`).*/export const PROVIDER_FAMILIES = [@@ -57,6 +57,6 @@ export const familyLabel = (id) => PROVIDER_FAMILIES.find((f) => f.id === id)?.l* provider's spend to the subscription that actually covered it.*/export function familyForProvider(provider) {- if (!provider || provider.ollamaBacked === true || provider.mtplxBacked === true || provider.llamaBacked === true) return null;+ if (!provider || provider.ollamaBacked === true || provider.mtplxBacked === true || provider.llamaBacked === true || provider.vllmBacked === true) return null;return PROVIDER_FAMILIES.find((f) => f.matches(provider))?.id ?? null;}diff --git a/server/lib/providerModels.js b/server/lib/providerModels.jsindex bbca36bd86..0fdb927fd4 100644--- a/server/lib/providerModels.js+++ b/server/lib/providerModels.js@@ -555,7 +555,7 @@ export function isOpencodeCommand(command) {* already-qualified id (`openai/gpt-4o`, `anthropic/claude-sonnet`), and blindly* prefixing `ollama/` would route it to the wrong backend. No-op for* non-local / non-OpenCode providers and empty models.- * @param {{command?:string, ollamaBacked?:boolean, mtplxBacked?:boolean, llamaBacked?:boolean, orcarouterBacked?:boolean}} provider+ * @param {{command?:string, ollamaBacked?:boolean, mtplxBacked?:boolean, llamaBacked?:boolean, vllmBacked?:boolean, orcarouterBacked?:boolean}} provider* @param {string|null|undefined} model* @returns {string|null|undefined}*/@@ -574,13 +574,14 @@ export function prefixOpencodeModel(provider, model) {* opted into one. Structural markers avoid deriving a backend from an editable* display name or endpoint and preserve the legacy Ollama outcome if a malformed* record carries both markers.- * @param {{ollamaBacked?:boolean, mtplxBacked?:boolean, llamaBacked?:boolean, orcarouterBacked?:boolean}|null|undefined} provider- * @returns {'ollama'|'mtplx'|'llama'|'orcarouter'|null}+ * @param {{ollamaBacked?:boolean, mtplxBacked?:boolean, llamaBacked?:boolean, vllmBacked?:boolean, orcarouterBacked?:boolean}|null|undefined} provider+ * @returns {'ollama'|'mtplx'|'llama'|'vllm'|'orcarouter'|null}*/export function getOpencodeLocalProviderNamespace(provider) {if (provider?.ollamaBacked === true) return 'ollama';if (provider?.mtplxBacked === true) return 'mtplx';if (provider?.llamaBacked === true) return 'llama';+ if (provider?.vllmBacked === true) return 'vllm';if (provider?.orcarouterBacked === true) return 'orcarouter';return null;}diff --git a/server/lib/providerModels.test.js b/server/lib/providerModels.test.jsindex 4af6ca2790..940567910c 100644--- a/server/lib/providerModels.test.js+++ b/server/lib/providerModels.test.js@@ -190,6 +190,7 @@ describe('providerModels', () => {it('uses explicit markers and keeps Ollama as the malformed dual-marker fallback', () => {expect(getOpencodeLocalProviderNamespace({ ollamaBacked: true })).toBe('ollama');expect(getOpencodeLocalProviderNamespace({ mtplxBacked: true })).toBe('mtplx');+ expect(getOpencodeLocalProviderNamespace({ vllmBacked: true })).toBe('vllm');expect(getOpencodeLocalProviderNamespace({ llamaBacked: true })).toBe('llama');expect(getOpencodeLocalProviderNamespace({ orcarouterBacked: true })).toBe('orcarouter');expect(getOpencodeLocalProviderNamespace({ ollamaBacked: true, mtplxBacked: true })).toBe('ollama');diff --git a/server/lib/validation.js b/server/lib/validation.jsindex f1957d4e6a..b1035775d6 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -415,6 +415,9 @@ export const providerSchema = z.object({// Marks an OpenCode CLI/TUI wrapper for a separately started local llama.cpp// server (e.g. DFlash 2 speculative decoding).llamaBacked: z.boolean().optional(),+ // Marks an OpenCode CLI/TUI wrapper for a separately started local vLLM+ // container (the Qwen3.8-27B DFlash 2 stack on an RTX 3090).+ vllmBacked: z.boolean().optional(),// Marks an OpenCode CLI/TUI wrapper for the OrcaRouter OpenAI-compatible// gateway; the sibling API record owns its key.orcarouterBacked: z.boolean().optional(),diff --git a/server/lib/vllmQwenProject.js b/server/lib/vllmQwenProject.jsnew file mode 100644index 0000000000..6ed2ac4a8b--- /dev/null+++ b/server/lib/vllmQwenProject.js@@ -0,0 +1,154 @@+/**+ * Where the vLLM Qwen3.8-27B compose project lives, and whether its weights are+ * already on disk.+ *+ * PortOS does not vendor this stack. It is an upstream compose project+ * (`syv-ai/qwen38-27b-rtx3090`) an operator clones and prepares once, on a box+ * with an RTX 3090 and a working NVIDIA container runtime — a ~9.5 GB image plus+ * ~20 GB of weights. The readiness checklist's start button is a convenience for+ * a project that is ALREADY prepared: `docker compose --profile single up -d` in+ * a directory that has never been prepared would kick off exactly the multi-tens-+ * of-gigabytes download PortOS promises never to start on its own.+ *+ * So the button asks first, and this module is the question. It only reads+ * directory entries — it never runs docker, contacts a registry, or reads a+ * weight file.+ *+ * **Sentinels matter here.** `hasWeights` is a tri-state: `true` (an HF hub cache+ * entry for a Qwen repo was found), `false` (every candidate root was readable+ * and none held one), `null` (no candidate root could be read at all). The start+ * path treats anything other than `true` as "not verified" and refuses — but the+ * three cases get different copy, because "your cache is empty" and "I cannot see+ * your cache" send the operator to different fixes. The common `null` case is a+ * real deployment shape, not a bug: the compose stack can keep its HuggingFace+ * cache in a docker named volume, which on Windows/WSL lives inside the VM and is+ * invisible to a native-Win32 PortOS. `VLLM_QWEN_WEIGHTS_DIR` is the escape hatch+ * for that setup; otherwise the operator simply runs compose themselves, which is+ * the documented path anyway.+ */++import { readdir, stat } from 'fs/promises';+import { homedir } from 'os';+import { join } from 'path';++/** Operator override for where the compose project was cloned. */+export const VLLM_PROJECT_DIR_ENV = 'VLLM_QWEN_PROJECT_DIR';++/**+ * Operator override for the HuggingFace cache holding the weights — the answer+ * for a stack whose cache is a docker named volume PortOS cannot see.+ */+export const VLLM_WEIGHTS_DIR_ENV = 'VLLM_QWEN_WEIGHTS_DIR';++/**+ * The user's home, read from the passed env before falling back to the OS —+ * so every path this module derives is injectable, and a test can never be+ * answered by the developer's real HuggingFace cache.+ */+const resolveHome = (env) =>+ String(env?.HOME || env?.USERPROFILE || '').trim() || homedir();++/** Where the upstream README tells the operator to clone it. */+export const vllmDefaultProjectDir = (env = process.env) => join(resolveHome(env), 'qwen-serving');++/** Compose file names the upstream project may ship under. */+const COMPOSE_FILENAMES = ['docker-compose.yml', 'docker-compose.yaml', 'compose.yml', 'compose.yaml'];++/**+ * HuggingFace's hub cache names every repo directory `models--<org>--<repo>`.+ * Matching on `qwen` rather than an exact repo id is deliberate: the stack ships+ * a requant whose repo id upstream is free to rename, and a stale exact id would+ * report a perfectly prepared machine as empty.+ */+const QWEN_CACHE_ENTRY = /^models--.*qwen/i;++const isDirectory = (path) => stat(path).then((s) => s.isDirectory(), () => false);+const isFile = (path) => stat(path).then((s) => s.isFile(), () => false);++/** The configured project directory, or upstream's documented default. */+export function resolveVllmProjectDir(env = process.env) {+ const configured = String(env?.[VLLM_PROJECT_DIR_ENV] || '').trim();+ return configured || vllmDefaultProjectDir(env);+}++/**+ * Candidate HuggingFace hub caches, most specific first: the operator's explicit+ * override, then the caches the compose project may bind-mount from its own+ * directory, then the user-level default `HF_HOME`/`~/.cache/huggingface`.+ */+function weightsCandidateRoots(projectDir, env = process.env) {+ const override = String(env?.[VLLM_WEIGHTS_DIR_ENV] || '').trim();+ const hfHome = String(env?.HF_HOME || '').trim();+ return [+ ...(override ? [override] : []),+ join(projectDir, 'models'),+ join(projectDir, 'hf-cache'),+ join(projectDir, 'huggingface', 'hub'),+ join(projectDir, '.cache', 'huggingface', 'hub'),+ ...(hfHome ? [join(hfHome, 'hub')] : []),+ join(resolveHome(env), '.cache', 'huggingface', 'hub'),+ ];+}++/**+ * Inspect the operator's vLLM project without touching docker.+ *+ * @param {NodeJS.ProcessEnv} [env]+ * @returns {Promise<{dir:string, hasProject:boolean, composeFile:string|null,+ * hasWeights:boolean|null, weightsRoot:string|null}>}+ */+export async function inspectVllmQwenProject(env = process.env) {+ const dir = resolveVllmProjectDir(env);+ const hasProject = await isDirectory(dir);++ let composeFile = null;+ if (hasProject) {+ for (const name of COMPOSE_FILENAMES) {+ // eslint-disable-next-line no-await-in-loop -- four stats on one directory+ if (await isFile(join(dir, name))) { composeFile = name; break; }+ }+ }++ let readAnyRoot = false;+ let weightsRoot = null;+ for (const root of weightsCandidateRoots(dir, env)) {+ // eslint-disable-next-line no-await-in-loop -- short, ordered, first-match-wins+ const entries = await readdir(root).catch(() => null);+ if (entries === null) continue; // absent or unreadable — says nothing either way+ readAnyRoot = true;+ if (entries.some((name) => QWEN_CACHE_ENTRY.test(name))) { weightsRoot = root; break; }+ }++ return {+ dir,+ hasProject,+ composeFile,+ // `null` = no candidate cache could be read, which is NOT "no weights".+ hasWeights: weightsRoot ? true : (readAnyRoot ? false : null),+ weightsRoot,+ };+}++/**+ * Why the start button must not run compose, or `null` when it may. Prose, not a+ * code — the checklist renders it verbatim, and each case names the one command+ * that fixes it.+ *+ * @param {{dir:string, hasProject:boolean, composeFile:string|null, hasWeights:boolean|null}} project+ * @returns {string|null}+ */+export function vllmStartBlockedReason(project) {+ if (!project?.hasProject) {+ return `the compose project was not found at ${project?.dir}. Clone https://github.com/syv-ai/qwen38-27b-rtx3090 there (or set ${VLLM_PROJECT_DIR_ENV}) and run its prepare step once — PortOS never downloads the image or the weights.`;+ }+ if (!project.composeFile) {+ return `${project.dir} exists but holds no docker-compose file. Point ${VLLM_PROJECT_DIR_ENV} at the cloned syv-ai/qwen38-27b-rtx3090 checkout.`;+ }+ if (project.hasWeights === false) {+ return `the project is cloned but no Qwen weights are cached yet. Run its prepare step in a terminal — starting compose now would pull roughly 20 GB, which PortOS will not do for you.`;+ }+ if (project.hasWeights === null) {+ return `PortOS cannot see a HuggingFace cache for this project, so it cannot confirm the weights are already downloaded (a cache kept in a docker volume is invisible from here). Start it yourself with \`docker compose --profile single up -d\` in ${project.dir}, or set ${VLLM_WEIGHTS_DIR_ENV} to the cache directory once the weights are on disk.`;+ }+ return null;+}diff --git a/server/lib/vllmQwenProject.test.js b/server/lib/vllmQwenProject.test.jsnew file mode 100644index 0000000000..259824a52a--- /dev/null+++ b/server/lib/vllmQwenProject.test.js@@ -0,0 +1,123 @@+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';++import {+ VLLM_PROJECT_DIR_ENV,+ VLLM_WEIGHTS_DIR_ENV,+ inspectVllmQwenProject,+ resolveVllmProjectDir,+ vllmDefaultProjectDir,+ vllmStartBlockedReason,+} from './vllmQwenProject.js';++let root;+const projectDir = () => join(root, 'qwen-serving');++/**+ * An env with HOME/USERPROFILE/HF_HOME pointed inside the sandbox. Without it,+ * the developer's own `~/.cache/huggingface/hub` is a readable candidate root+ * and the "nothing readable" case can never be exercised.+ */+const env = (extra = {}) => ({+ [VLLM_PROJECT_DIR_ENV]: projectDir(),+ HOME: join(root, 'home'),+ USERPROFILE: join(root, 'home'),+ HF_HOME: join(root, 'no-hf'),+ ...extra,+});++beforeEach(() => {+ root = mkdtempSync(join(tmpdir(), 'vllm-project-'));+});++afterEach(() => rmSync(root, { recursive: true, force: true }));++describe('resolveVllmProjectDir', () => {+ it('prefers the operator override over upstream default', () => {+ expect(resolveVllmProjectDir({ [VLLM_PROJECT_DIR_ENV]: '/srv/qwen' })).toBe('/srv/qwen');+ });++ it('ignores a blank override rather than resolving to an empty path', () => {+ const home = { HOME: '/home/example', USERPROFILE: '/home/example' };+ expect(resolveVllmProjectDir({ ...home, [VLLM_PROJECT_DIR_ENV]: ' ' }))+ .toBe(vllmDefaultProjectDir(home));+ });+});++describe('inspectVllmQwenProject', () => {+ it('reports no project when the directory is absent', async () => {+ const project = await inspectVllmQwenProject(env());+ expect(project).toMatchObject({ hasProject: false, composeFile: null });+ expect(vllmStartBlockedReason(project)).toContain('syv-ai/qwen38-27b-rtx3090');+ });++ it('reports a directory with no compose file as not a project', async () => {+ mkdirSync(projectDir(), { recursive: true });+ const project = await inspectVllmQwenProject(env());+ expect(project).toMatchObject({ hasProject: true, composeFile: null });+ expect(vllmStartBlockedReason(project)).toContain('no docker-compose file');+ });++ it('finds the compose file but blocks while no weights cache is readable', async () => {+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');++ const project = await inspectVllmQwenProject(env());+ expect(project.composeFile).toBe('docker-compose.yml');+ // `null`, not `false` — nothing was READ, which is a different fix than an+ // empty cache. The distinction is the point of the sentinel.+ expect(project.hasWeights).toBeNull();+ expect(vllmStartBlockedReason(project)).toContain('cannot see a HuggingFace cache');+ });++ it('distinguishes a readable-but-empty cache from an unreadable one', async () => {+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'compose.yaml'), 'services: {}\n');+ mkdirSync(join(projectDir(), 'models'), { recursive: true });++ const project = await inspectVllmQwenProject(env());+ expect(project).toMatchObject({ composeFile: 'compose.yaml', hasWeights: false });+ expect(vllmStartBlockedReason(project)).toContain('no Qwen weights are cached');+ });++ it('clears the block once a Qwen hub-cache entry is present', async () => {+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');+ mkdirSync(join(projectDir(), 'models', 'models--syv-ai--Qwen3.8-27B-w4a16'), { recursive: true });++ const project = await inspectVllmQwenProject(env());+ expect(project.hasWeights).toBe(true);+ expect(project.weightsRoot).toBe(join(projectDir(), 'models'));+ expect(vllmStartBlockedReason(project)).toBeNull();+ });++ it('ignores a cache holding only unrelated models', async () => {+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');+ mkdirSync(join(projectDir(), 'models', 'models--meta-llama--Llama-3.1-8B'), { recursive: true });++ expect((await inspectVllmQwenProject(env())).hasWeights).toBe(false);+ });++ it('honors the weights-directory override, for a cache PortOS cannot otherwise see', async () => {+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');+ const cache = join(root, 'elsewhere', 'hub');+ mkdirSync(join(cache, 'models--syv-ai--qwen3.8-27b'), { recursive: true });++ const project = await inspectVllmQwenProject(env({ [VLLM_WEIGHTS_DIR_ENV]: cache }));+ expect(project).toMatchObject({ hasWeights: true, weightsRoot: cache });+ });++ it('finds an HF_HOME hub cache', async () => {+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');+ const hfHome = join(root, 'hf');+ mkdirSync(join(hfHome, 'hub', 'models--Qwen--Qwen3.8-27B'), { recursive: true });++ const project = await inspectVllmQwenProject(env({ HF_HOME: hfHome }));+ expect(project.hasWeights).toBe(true);+ });+});diff --git a/server/services/localRuntimeSetup.js b/server/services/localRuntimeSetup.jsindex abe4b623a1..8564d7f352 100644--- a/server/services/localRuntimeSetup.js+++ b/server/services/localRuntimeSetup.js@@ -11,7 +11,7 @@* endpoint answers — from the button next to the failing check.** Every command here comes from the fixed table below. A request names a- * runtime *kind* (`mtplx` / `llama` / `ollama` / `lmstudio`) and nothing else —+ * runtime *kind* (`mtplx` / `llama` / `ollama` / `lmstudio` / `vllm`) and nothing else —* no package, URL, port, or argument from the request ever reaches a shell* word, which keeps this as narrow as `providerRuntimeInstaller.js`'s CLI* install surface while removing the docs dead end.@@ -29,6 +29,10 @@* PortOS installs the package and starts the loopback API server; that* helper stays an explicit operator action outside PortOS, exactly as* `docs/features/mtplx.md` promised before this button existed.+ * - **The vLLM container is never provisioned.** Its start row brings up an+ * already-prepared compose project and nothing else: no image pull, no+ * weight download, no docker/WSL2/NVIDIA-toolkit install. A project that is+ * not demonstrably prepared is refused with the command that prepares it.*/import { IS_WIN32 } from '../lib/bufferedSpawn.js';@@ -38,6 +42,7 @@ import { sleep } from '../lib/fileUtils.js';import { LOCAL_RUNTIMES, localEndpointPort } from '../lib/localProviderRuntime.js';import { listMtplxCachedModels, pickMtplxCachedModel } 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';import { createLineReader, createOutputTail } from '../lib/streamLines.js';import { runStreamingCommand } from '../lib/streamingSpawn.js';@@ -249,6 +254,39 @@ const SETUP_ROWS = Object.freeze({},}),+ vllm: Object.freeze({+ // CUDA + Marlin + FlashInfer in a Linux container. On macOS there is no card+ // to give it, and DFlash 2 on Apple Silicon is unproven in this project —+ // the analogous local-daemon path there already ships as MTPLX / DSpark.+ platforms: ['linux', 'win32'],+ unsupportedReason: 'The vLLM Qwen3.8-27B stack needs an NVIDIA GPU (RTX 3090) and a Linux container runtime. On Apple Silicon use the MTPLX or llama.cpp DSpark presets instead.',+ async install() {+ // Deliberately never installs anything. Docker Desktop / the NVIDIA+ // container toolkit / WSL2 are host-level operator decisions with driver+ // requirements PortOS cannot judge, and the payload is a ~9.5 GB image.+ return {+ success: false,+ error: 'PortOS does not install this stack. On the RTX 3090 host, set up WSL2 (or Linux) with Docker and the NVIDIA Container Toolkit, then follow docs/features/qwen38-rtx3090.md to clone and prepare syv-ai/qwen38-27b-rtx3090.',+ };+ },+ async start({ emit, isCancelled }) {+ // Only ever brings up an ALREADY-prepared project — see+ // `lib/vllmQwenProject.js` for why each refusal below exists.+ const project = await inspectVllmQwenProject();+ const blocked = vllmStartBlockedReason(project);+ if (blocked) return { success: false, error: blocked };+ if (isCancelled()) return { success: false, error: 'Cancelled before the container was started.' };+ emit(`Starting the vLLM container from ${project.dir} (${project.composeFile}).`);+ emit('The image and weights are already on disk — this only brings the service up.');+ return runStreamingCommand(+ 'docker',+ ['compose', '--profile', 'single', 'up', '-d'],+ emit,+ { timeoutMs: CONTROL_TIMEOUT_MS, cwd: project.dir },+ );+ },+ }),+ollama: Object.freeze({async install({ emit }) {// `installBackend` already registers the Homebrew service / runs the@@ -311,7 +349,7 @@ 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.*- * @param {string} kind - `mtplx` | `llama` | `ollama` | `lmstudio`+ * @param {string} kind - `mtplx` | `llama` | `ollama` | `lmstudio` | `vllm`* @param {{installed: boolean, running: boolean}} state*/export function describeRuntimeSetup(kind, { installed, running }) {diff --git a/server/services/localRuntimeSetup.test.js b/server/services/localRuntimeSetup.test.jsindex 8b0384b1e0..4fb0127cb6 100644--- a/server/services/localRuntimeSetup.test.js+++ b/server/services/localRuntimeSetup.test.js@@ -37,6 +37,13 @@ const mtplxCache = vi.hoisted(() => ({}));vi.mock('../lib/mtplxModels.js', () => 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.+const vllmProject = vi.hoisted(() => ({+ inspectVllmQwenProject: vi.fn(),+ vllmStartBlockedReason: vi.fn(() => null),+}));+vi.mock('../lib/vllmQwenProject.js', () => vllmProject);import { describeRuntimeSetup, runLocalRuntimeSetup, SETUP_RUNTIME_KINDS } from './localRuntimeSetup.js';@@ -58,7 +65,11 @@ const reachable = (models = ['mtplx']) => ({ reachable: true, models, error: nulconst cachedModels = (models) => ({ models, error: null });+const preparedVllmProject = { dir: '/home/example/qwen-serving', hasProject: true, composeFile: 'docker-compose.yml', hasWeights: true, weightsRoot: '/home/example/qwen-serving/models' };+beforeEach(() => {+ vllmProject.inspectVllmQwenProject.mockResolvedValue(preparedVllmProject);+ vllmProject.vllmStartBlockedReason.mockReturnValue(null);// Implementations AND return values (not just call records) survive// `clearAllMocks`. A probe implementation left over from an earlier test drives// this module's poll loop for its full three-minute timeout, and a leftover@@ -78,7 +89,7 @@ afterEach(() => {describe('describeRuntimeSetup', () => {it('covers every runtime the readiness checklist can report', () => {- expect([...SETUP_RUNTIME_KINDS].sort()).toEqual(['llama', 'lmstudio', 'mtplx', 'ollama']);+ expect([...SETUP_RUNTIME_KINDS].sort()).toEqual(['llama', 'lmstudio', 'mtplx', 'ollama', 'vllm']);});it('offers install AND start when nothing is there yet', () => {@@ -418,3 +429,74 @@ describe('runLocalRuntimeSetup', () => {expect(result).toMatchObject({ success: false, error: expect.stringMatching(/no automatic setup/) });});});++describe('vllm — the container is brought up, never provisioned', () => {+ const vllmEndpoint = 'http://127.0.0.1:18020/v1';++ it('is unsupported on darwin, and says where Mac users should go instead', () => {+ const restore = pinPlatform('darwin');+ expect(describeRuntimeSetup('vllm', { installed: false, running: false })).toMatchObject({+ runtime: 'vllm',+ action: null,+ blockedReason: expect.stringMatching(/MTPLX or llama.cpp DSpark/),+ });+ restore();+ });++ it('offers a start button on a Linux/Windows host with docker present', () => {+ const restore = pinPlatform('linux');+ expect(describeRuntimeSetup('vllm', { installed: true, running: false })).toMatchObject({+ runtime: 'vllm',+ action: 'start',+ blockedReason: null,+ });+ restore();+ });++ it('brings up an already-prepared compose project in its own directory', async () => {+ const restore = pinPlatform('linux');+ pathLookup.findCommandOnPath.mockReturnValue('/usr/bin/docker');+ probe.probeOpenAiModels+ .mockResolvedValueOnce(unreachable) // initial+ .mockResolvedValueOnce(unreachable) // after "install"+ .mockResolvedValue(reachable(['qwen3.8-27b'])); // confirm++ const result = await runLocalRuntimeSetup('vllm', { endpoint: vllmEndpoint, emit: () => {} });++ expect(result.success).toBe(true);+ expect(streaming.runStreamingCommand).toHaveBeenCalledWith(+ 'docker',+ ['compose', '--profile', 'single', 'up', '-d'],+ expect.any(Function),+ expect.objectContaining({ cwd: preparedVllmProject.dir }),+ );+ restore();+ });++ it('refuses to run compose when the project is not demonstrably prepared', async () => {+ const restore = pinPlatform('linux');+ pathLookup.findCommandOnPath.mockReturnValue('/usr/bin/docker');+ probe.probeOpenAiModels.mockResolvedValue(unreachable);+ vllmProject.vllmStartBlockedReason.mockReturnValue('no Qwen weights are cached yet');++ const result = await runLocalRuntimeSetup('vllm', { endpoint: vllmEndpoint, emit: () => {} });++ expect(result).toMatchObject({ success: false, error: expect.stringMatching(/no Qwen weights are cached/) });+ // The whole point: a 20 GB pull is never started on the user's behalf.+ expect(streaming.runStreamingCommand).not.toHaveBeenCalled();+ restore();+ });++ it('never installs docker, WSL2, or the container toolkit', async () => {+ const restore = pinPlatform('linux');+ pathLookup.findCommandOnPath.mockReturnValue(null); // docker not on PATH+ probe.probeOpenAiModels.mockResolvedValue(unreachable);++ const result = await runLocalRuntimeSetup('vllm', { endpoint: vllmEndpoint, emit: () => {} });++ expect(result).toMatchObject({ success: false, error: expect.stringMatching(/does not install this stack/) });+ expect(streaming.runStreamingCommand).not.toHaveBeenCalled();+ expect(localLlm.installBackend).not.toHaveBeenCalled();+ restore();+ });+});diff --git a/server/services/providerReadiness.js b/server/services/providerReadiness.jsindex dc3d00fb63..4b62cb6737 100644--- a/server/services/providerReadiness.js+++ b/server/services/providerReadiness.js@@ -65,9 +65,12 @@ const PROBE_TTL_MS = 15_000;*/const BINARY_TTL_MS = 60_000;-// endpoint → { at, promise } — the PROMISE, not the settled value, so N+// 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.+// all missing a not-yet-written cache entry at once. The key is part of the+// cache key because two providers can point at one authenticated endpoint with+// different credentials, and one of them getting the other's 401 would be a+// false "not running".const probeCache = new Map();// command → { at, path }const binaryCache = new Map();@@ -79,12 +82,15 @@ const binaryCache = new Map();* `models: null` means reachable but the listing could not be read — distinct* from `[]`, a server that is up with nothing loaded.*/-const probeEndpoint = (endpoint) => probeOpenAiModels(endpoint, { timeoutMs: PROBE_TIMEOUT_MS });+const probeEndpoint = (endpoint, apiKey = '') =>+ probeOpenAiModels(endpoint, { timeoutMs: PROBE_TIMEOUT_MS, apiKey });/** TTL-cached endpoint probe, shared across requests — see PROBE_TTL_MS. */-function probeEndpointCached(endpoint) {+function probeEndpointCached(endpoint, apiKey = '') {const now = Date.now();- const cached = probeCache.get(endpoint);+ const cacheKey = `${endpoint}+${apiKey}`;+ const cached = probeCache.get(cacheKey);if (cached && now - cached.at < PROBE_TTL_MS) return cached.promise;// Sweep while we are here: entries are keyed by endpoint, and an edited or// deleted provider would otherwise leave its old endpoint behind forever.@@ -95,11 +101,11 @@ function probeEndpointCached(endpoint) {// probe would poison the entry for its TTL, so drop it on failure —// `probeEndpoint` resolves for every expected failure, making this the// unexpected-throw path only.- const promise = probeEndpoint(endpoint).catch((err) => {- probeCache.delete(endpoint);+ const promise = probeEndpoint(endpoint, apiKey).catch((err) => {+ probeCache.delete(cacheKey);throw err;});- probeCache.set(endpoint, { at: now, promise });+ probeCache.set(cacheKey, { at: now, promise });return promise;}@@ -189,10 +195,16 @@ 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) {+function modelCheck(runtime, wanted, served, probeError = null) {const label = `Model \`${wanted}\` available`;if (!Array.isArray(served)) {- return { id: 'model', label, ok: null, detail: 'Cannot be checked until the server responds.', fixHint: null };+ // A server that answered 401 IS responding — "until the server responds"+ // would send the user to start a container that is already up, when the+ // 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 };}if (served.includes(wanted)) {return { id: 'model', label, ok: true, detail: `${runtime.label} is serving \`${wanted}\`.`, fixHint: null };@@ -228,7 +240,10 @@ export async function getProviderReadiness(provider, deps = {}) {const findCommand = deps.findCommand || findCommandCached;const probe = deps.probe || probeEndpointCached;- const result = await probe(runtime.endpoint);+ // The wrapper's own key: a vLLM container is started behind `VLLM_API_KEY`+ // and 401s an unauthenticated `/v1/models`, which would leave the model check+ // permanently unknown on an otherwise-healthy stack.+ const result = await probe(runtime.endpoint, provider?.apiKey || '');// A daemon that answers is installed, whatever PATH says — Ollama's macOS app// and LM Studio both serve without putting a CLI on PortOS's PATH.const onPath = Boolean(runtime.command && findCommand(runtime.command));@@ -252,7 +267,7 @@ export async function getProviderReadiness(provider, deps = {}) {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));+ if (wanted) checks.push(modelCheck(runtime, wanted, result.models, result.error));return {kind: runtime.kind,diff --git a/server/services/providerReadiness.test.js b/server/services/providerReadiness.test.jsindex 684d2143f1..670be4b7a5 100644--- a/server/services/providerReadiness.test.js+++ b/server/services/providerReadiness.test.js@@ -248,3 +248,46 @@ describe('getProviderReadinessMap', () => {await expect(getProviderReadinessMap(null, { findCommand: () => null, probe: unreachable() })).resolves.toEqual({});});});++describe('vLLM — a key-gated container', () => {+ const vllmProvider = (overrides = {}) => ({+ id: 'opencode-vllm-tui',+ name: 'OpenCode vLLM TUI (Qwen3.8-27B)',+ type: 'tui',+ command: 'opencode',+ vllmBacked: true,+ endpoint: 'http://127.0.0.1:18020/v1',+ models: ['qwen3.8-27b'],+ defaultModel: 'qwen3.8-27b',+ ...overrides,+ });++ it('maps the marker to the vLLM runtime at the container endpoint', async () => {+ const readiness = await getProviderReadiness(vllmProvider(), {+ findCommand: () => '/usr/bin/docker',+ probe: reachable(['qwen3.8-27b']),+ });+ expect(readiness).toMatchObject({ kind: 'vllm', endpoint: 'http://127.0.0.1:18020/v1' });+ expect(checkById(readiness, 'model').ok).toBe(true);+ });++ it("hands the provider's key to the probe so a gated container can be listed", async () => {+ const keys = [];+ await getProviderReadiness(vllmProvider({ apiKey: 'vllm-key-example' }), {+ findCommand: () => '/usr/bin/docker',+ probe: async (_endpoint, apiKey) => { keys.push(apiKey); return { reachable: true, models: ['qwen3.8-27b'], error: null }; },+ });+ expect(keys).toEqual(['vllm-key-example']);+ });++ it('calls a 401 a running server, and points at the key rather than at starting it', async () => {+ const readiness = await getProviderReadiness(vllmProvider(), {+ findCommand: () => '/usr/bin/docker',+ probe: async () => ({ reachable: true, models: null, error: 'authentication required' }),+ });+ expect(checkById(readiness, 'server').ok).toBe(true);+ const model = checkById(readiness, 'model');+ expect(model.ok).toBeNull();+ expect(model.detail).toMatch(/paste the server's key/);+ });+});diff --git a/server/services/providerUsage.js b/server/services/providerUsage.jsindex 2e27ad2866..0c66fcb347 100644--- a/server/services/providerUsage.js+++ b/server/services/providerUsage.js@@ -614,7 +614,7 @@ const FAMILIES = PROVIDER_FAMILIES.map((family) => ({ ...family, fetch: FAMILY_F* wrapper its family's card).*/export function resolveEnabledFamilies(providers) {- const enabled = (providers || []).filter((p) => p?.enabled && p.ollamaBacked !== true && p.mtplxBacked !== true && p.llamaBacked !== true);+ const enabled = (providers || []).filter((p) => p?.enabled && p.ollamaBacked !== true && p.mtplxBacked !== true && p.llamaBacked !== true && p.vllmBacked !== true);return FAMILIES.filter((family) => enabled.some((p) => family.matches(p)));}@@ -651,7 +651,7 @@ const fetchFamilyQuota = (family, { wait, providers }) =>export async function getProviderQuotas({ wait = WAIT.CACHED, family = null } = {}) {const result = await getAllProviders();const providers = Array.isArray(result) ? result : (result?.providers || []);- const enabled = providers.filter((p) => p?.enabled && p.ollamaBacked !== true && p.mtplxBacked !== true && p.llamaBacked !== true);+ const enabled = providers.filter((p) => p?.enabled && p.ollamaBacked !== true && p.mtplxBacked !== true && p.llamaBacked !== true && p.vllmBacked !== true);const families = resolveEnabledFamilies(providers).filter((f) => !family || f.id === family);const familyCards = await Promise.all(families.map((f) =>fetchFamilyQuota(f, { wait, providers: enabled.filter((p) => f.matches(p)) })));diff --git a/server/services/quotaBurnJobs/providerPick.js b/server/services/quotaBurnJobs/providerPick.jsindex 4f1d607f73..fa6053e5a7 100644--- a/server/services/quotaBurnJobs/providerPick.js+++ b/server/services/quotaBurnJobs/providerPick.js@@ -40,7 +40,7 @@ import { commandBasename } from '../../lib/providerModels.js';*/export function providerForFamily(providers, { familyId, providerId, prefer = 'tui' }) {const available = (providers || []).filter((provider) =>- provider?.enabled && provider.ollamaBacked !== true && provider.mtplxBacked !== true && provider.llamaBacked !== true+ provider?.enabled && provider.ollamaBacked !== true && provider.mtplxBacked !== true && provider.llamaBacked !== true && provider.vllmBacked !== true&& (provider.type === 'cli' || provider.type === 'tui'));if (providerId) return available.find((provider) => provider.id === providerId) || null;const inFamily = available.filter((provider) => matchesFamily(provider, familyId));