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: let the llama-server launcher load a vision projector (--mmproj) (#7611)
[._.]/ Adam Eivy62412081cfeb
diff --git a/client/src/components/settings/LocalLlmRuntimesView.jsx b/client/src/components/settings/LocalLlmRuntimesView.jsxindex 14963aecc0..f091aeb561 100644--- a/client/src/components/settings/LocalLlmRuntimesView.jsx+++ b/client/src/components/settings/LocalLlmRuntimesView.jsx@@ -27,9 +27,15 @@ import { LOCAL_LLM_BACKENDS as BACKENDS, localLlmBackendLabel as labelFor } from// list a path the Download button had no source for.const DEFAULT_SPEC_PRESET_ID = 'qwen3.8-27b-dspark';const downloadKey = (presetId, role) => `${presetId}:${role}`;+// The projector is the one weight a launch is fine WITHOUT — no `--mmproj` just+// means text-only. So unlike the base model and the drafter, its path is seeded+// only once the GGUF is actually on disk: seeding a path that isn't there would+// block Start on an optional 629 MB download, behind a field that lives under+// Advanced. Downloading it from the row below fills this in (see startSpecDownload).+const seededProjectorPath = (preset) => (preset?.projector?.exists ? preset.projector.path : '');// Each entry carries its own `role`, so the rows come straight off the preset// rather than from a second copy of the role list.-const specWeightEntries = (preset) => [preset?.model, preset?.draftModel].filter((e) => e?.path);+const specWeightEntries = (preset) => [preset?.model, preset?.draftModel, preset?.projector].filter((e) => e?.path);// Defaults for the advanced numeric fields. They are applied when the server is// launched rather than on every keystroke: a controlled number input that coerces@@ -86,6 +92,9 @@ export default function LocalLlmRuntimesView() {const [llamaForm, setLlamaForm] = useState({model: '',draftModel: '',+ // llama.cpp's `--mmproj` vision sidecar. Empty = text-only, which is what a+ // preset with no projector launches.+ projector: '',specType: 'draft-dspark',port: 5568,host: '127.0.0.1',@@ -112,6 +121,12 @@ export default function LocalLlmRuntimesView() {// but only the starting tab owns the toast and the cleanup.const [llamaDownloads, setLlamaDownloads] = useState({});const specPresetSeeded = useRef(false);+ // The LIVE preset id. A multi-gigabyte download outlives many renders, so a+ // handler resuming from its await must compare against this rather than the+ // `llamaPresetId` its own closure captured — that one can only ever equal the+ // value the handler already started with.+ const llamaPresetIdRef = useRef(llamaPresetId);+ llamaPresetIdRef.current = llamaPresetId;const [showLlamaAdvanced, setShowLlamaAdvanced] = useState(false);const [showLlamaLogs, setShowLlamaLogs] = useState(false);@@ -182,6 +197,7 @@ export default function LocalLlmRuntimesView() {...prev,model: preset.model?.path || '',draftModel: preset.draftModel?.path || '',+ projector: seededProjectorPath(preset),specType: preset.specType || prev.specType,}));}, [llamaStatus?.presets]);@@ -451,10 +467,11 @@ export default function LocalLlmRuntimesView() {// is what the launcher would reject with LLAMA_MODEL_FILE_MISSING, so block// Start here and point at the Download button instead of spending a request// to produce an error the card can already answer.+ // Every role's form field is named after the role, so no mapping is needed —+ // adding `projector` to the vocabulary did not add a branch here.const missingWeight = (role) => {const entry = activeSpecPreset?.[role];- const field = role === 'model' ? llamaForm.model : llamaForm.draftModel;- return Boolean(entry?.path && !entry.exists && entry.path === (field || '').trim());+ return Boolean(entry?.path && !entry.exists && entry.path === (llamaForm[role] || '').trim());};const baseWeightMissing = missingWeight('model');// Rendered from the server's list (status payload) so the card never carries a@@ -472,7 +489,11 @@ export default function LocalLlmRuntimesView() {// load one — an `ngram-*` run needs no drafter, so a preset's undownloaded// drafter path must not hold it hostage.const draftWeightMissing = drafterInUse && missingWeight('draftModel');- const llamaStartBlocked = llamaModelMissing || baseWeightMissing || draftWeightMissing;+ // No spec type turns vision on or off: a projector path in the field is one the+ // launch line will carry, so an undownloaded one blocks Start unconditionally —+ // the server would reject it with LLAMA_MODEL_FILE_MISSING anyway.+ const projectorWeightMissing = missingWeight('projector');+ const llamaStartBlocked = llamaModelMissing || baseWeightMissing || draftWeightMissing || projectorWeightMissing;// Say what the launcher will do with a mismatched pair rather than letting the// server quietly rewrite the launch line the user thought they were starting.const specTypeNotice = !drafterConfigured && draftSpecTypes.length > 0@@ -489,7 +510,9 @@ export default function LocalLlmRuntimesView() {? 'Download the base model to enable Start': draftWeightMissing? 'Download the drafter, or clear the field to run without it'- : '';+ : projectorWeightMissing+ ? 'Download the vision projector, or clear the field to run text-only'+ : '';const startSpecDownload = async (role) => {const presetId = llamaPresetId;@@ -499,6 +522,13 @@ export default function LocalLlmRuntimesView() {// Custom catch below owns the failure toast — `silent` keeps apiCore from// firing a second one for the same error.const res = await downloadSpecDecodeModel(presetId, role, { silent: true });+ // Fetching the projector is the user saying they want vision — arm it on+ // the launch line rather than leaving the field they can't see (it lives+ // under Advanced) empty and the download with no visible effect. Only when+ // the field is still empty, so a hand-entered path is never overwritten.+ if (role === 'projector' && res?.path && presetId === llamaPresetIdRef.current) {+ setLlamaForm((prev) => (prev.projector.trim() ? prev : { ...prev, projector: res.path }));+ }toast.success(res?.alreadyDownloaded? `${res.path} is already on disk`: `${res?.path || 'Model'} downloaded`);@@ -551,7 +581,14 @@ export default function LocalLlmRuntimesView() {const handleDeleteSpecModel = async (role) => {try {- const res = await removeSpecDecodeModel(llamaPresetId, role, { silent: true });+ const presetId = llamaPresetId;+ const res = await removeSpecDecodeModel(presetId, role, { silent: true });+ // Deleting the sidecar is the inverse of fetching it, so release the field+ // it armed — otherwise the path stays behind and blocks Start on a file the+ // user just chose to remove, with the only Clear button under Advanced.+ if (role === 'projector' && presetId === llamaPresetIdRef.current) {+ setLlamaForm((prev) => (prev.projector.trim() === (res?.path || '').trim() ? { ...prev, projector: '' } : prev));+ }toast.success(res?.path ? `Deleted ${res.path}` : 'Weight file deleted');} catch (err) {toast.error(err?.message || 'Could not delete the weight file');@@ -567,7 +604,7 @@ export default function LocalLlmRuntimesView() {toast.error('Please specify a base model path (e.g. models/Qwen3.8-27B-Q4_K_M.gguf)');return;}- if (baseWeightMissing || draftWeightMissing) {+ if (baseWeightMissing || draftWeightMissing || projectorWeightMissing) {toast.error(`${llamaStartBlockedReason} — the GGUF isn't on this machine yet.`);return;}@@ -635,11 +672,12 @@ export default function LocalLlmRuntimesView() {if (!preset) return;setLlamaPresetId(preset.id);// `custom` carries no paths — it exists so hand-entered fields keep a label.- if (preset.model?.path || preset.draftModel?.path) {+ if (preset.model?.path || preset.draftModel?.path || preset.projector?.path) {setLlamaForm((prev) => ({...prev,model: preset.model?.path || '',draftModel: preset.draftModel?.path || '',+ projector: seededProjectorPath(preset),specType: preset.specType || prev.specType,}));}@@ -835,6 +873,12 @@ export default function LocalLlmRuntimesView() {{llamaStatus.config?.draftModel && (<p><span className="text-gray-500">Drafter:</span> <code className="text-port-accent">{llamaStatus.config.draftModel}</code></p>)}+ {/* Only shown when one is loaded. A launch with no `--mmproj` is+ text-only, and "Vision: none" on every non-multimodal run+ would be noise on the card's most-read lines. */}+ {llamaStatus.config?.projector && (+ <p><span className="text-gray-500">Vision projector:</span> <code className="text-port-accent">{llamaStatus.config.projector}</code></p>+ )}{llamaStatus.config && (<p><span className="text-gray-500">Model id:</span>{' '}@@ -1017,6 +1061,26 @@ export default function LocalLlmRuntimesView() {<p className="text-[11px] text-port-warning mt-1">{specTypeNotice}</p>)}</FormField>+ {/* Under Advanced rather than beside the two model paths: only a+ multimodal GGUF has a projector at all, so for most presets+ this field is permanently empty and would only crowd the+ fold. It is independent of Spec Type — nothing about+ speculative decoding turns vision on or off. */}+ <FormField label="Vision Projector / --mmproj (Optional)" labelClassName="text-[11px] text-gray-400 block mb-1" className="col-span-2 sm:col-span-4">+ <input+ id="llama-projector"+ aria-label="Vision Projector / --mmproj (Optional)"+ type="text"+ value={llamaForm.projector}+ onChange={(e) => setLlamaField('projector', e.target.value)}+ placeholder={activeSpecPreset?.projector?.path || 'models/your-model-mmproj-Q8_0.gguf'}+ className="w-full bg-port-card border border-port-border rounded px-2 py-1 text-xs text-white placeholder-gray-600"+ />+ <p className="text-[11px] text-gray-500 mt-1">+ A multimodal model's vision tower ships as a separate <code className="text-gray-400">mmproj</code> GGUF.+ Leave this empty to launch text-only — the model still loads and answers, it just cannot see images.+ </p>+ </FormField><FormField label="Model id (alias)" labelClassName="text-[11px] text-gray-400 block mb-1"><inputid="llama-alias"diff --git a/client/src/components/settings/LocalLlmRuntimesView.test.jsx b/client/src/components/settings/LocalLlmRuntimesView.test.jsxindex 3d95fa2696..dac7fff09d 100644--- a/client/src/components/settings/LocalLlmRuntimesView.test.jsx+++ b/client/src/components/settings/LocalLlmRuntimesView.test.jsx@@ -372,7 +372,7 @@ describe('LocalLlmTab runtime context window', () => {// The launcher presets (and their weights' on-disk state) come from the server// on the llama-server status response — the component holds no copy.-const specPresets = ({ baseExists = true, draftExists = true } = {}) => ([+const specPresets = ({ baseExists = true, draftExists = true, projectorExists = false } = {}) => ([{id: 'qwen3.8-27b-dspark',label: 'Qwen 3.8 27B + DSpark Drafter (Recommended — stock llama.cpp)',@@ -426,7 +426,36 @@ const specPresets = ({ baseExists = true, draftExists = true } = {}) => ([downloading: false,},},- { id: 'custom', label: 'Custom GGUF / Manual Paths', specType: 'draft-dspark', model: null, draftModel: null },+ // A multimodal preset: one language pack plus a `--mmproj` vision sidecar and+ // no drafter at all. The mixed shape the other two fixtures cannot stand in+ // for, and what the projector rows below are rendered from (#7611).+ {+ id: 'vision-preset',+ label: 'Example Vision 27B — no drafter',+ specType: 'none',+ model: {+ role: 'model',+ path: 'models/Example-Vision-27B-Q4_K_M.gguf',+ exists: true,+ sizeBytes: 6_700_000_000,+ repo: 'example-org/Example-Vision-27B-GGUF',+ repoUrl: 'https://huggingface.co/example-org/Example-Vision-27B-GGUF',+ downloadable: true,+ downloading: false,+ },+ draftModel: null,+ projector: {+ role: 'projector',+ path: 'models/Example-Vision-27B-mmproj-Q8_0.gguf',+ exists: projectorExists,+ sizeBytes: projectorExists ? 629_000_000 : null,+ repo: 'example-org/Example-Vision-27B-GGUF',+ repoUrl: 'https://huggingface.co/example-org/Example-Vision-27B-GGUF',+ downloadable: true,+ downloading: false,+ },+ },+ { id: 'custom', label: 'Custom GGUF / Manual Paths', specType: 'draft-dspark', model: null, draftModel: null, projector: null },]);const llamaReady = (overrides = {}) => ({@@ -673,6 +702,114 @@ describe('LocalLlmRuntimesView llama-server management', () => {});});+ // #7611: a multimodal preset launched text-only and silently, because the+ // launcher had no projector role at all. The user-visible contract is the+ // whole round trip — a row with its own Download button, and the fetched+ // sidecar landing on the launch payload as `projector` — so it is asserted+ // end to end rather than as three separate wiring checks.+ it('downloads a preset projector and sends it on the next start', async () => {+ const { getLlamaServerStatus, downloadSpecDecodeModel, startLlamaServer } = await import('../../services/api');+ // The transfer really does put the file on disk, so the status the card+ // re-reads afterwards has to say so — otherwise this asserts against a+ // state the server can never report.+ let projectorOnDisk = false;+ getLlamaServerStatus.mockImplementation(async () => (+ llamaReady({ presets: specPresets({ projectorExists: projectorOnDisk }) })+ ));+ downloadSpecDecodeModel.mockImplementationOnce(async () => {+ projectorOnDisk = true;+ return { success: true, path: 'models/Example-Vision-27B-mmproj-Q8_0.gguf' };+ });+ startLlamaServer.mockResolvedValueOnce({ success: true, pid: 4242 });++ await renderRuntimes();+ await screen.findByText(/Launch Speculative Decoding Server/);+ fireEvent.change(screen.getByLabelText('Preset'), { target: { value: 'vision-preset' } });++ // Two rows for a drafter-free multimodal preset: the base model (on disk)+ // and the projector (not yet), so exactly one Download button is offered.+ expect(await screen.findByText('Vision projector')).toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: /^Download$/ }));+ await clickStartDownload();+ await waitFor(() => {+ expect(downloadSpecDecodeModel).toHaveBeenCalledWith('vision-preset', 'projector', { silent: true });+ });++ fireEvent.click(screen.getByRole('button', { name: /Start Speculative Server/ }));+ await waitFor(() => {+ expect(startLlamaServer).toHaveBeenCalledWith(expect.objectContaining({+ model: 'models/Example-Vision-27B-Q4_K_M.gguf',+ projector: 'models/Example-Vision-27B-mmproj-Q8_0.gguf',+ }));+ });+ });++ // The other half of the same contract: the projector is OPTIONAL, so a preset+ // whose sidecar was never fetched must still start — text-only, with an empty+ // `projector` the server leaves off the launch line entirely.+ it('starts a multimodal preset text-only when its projector is not on disk', async () => {+ const { getLlamaServerStatus, startLlamaServer } = await import('../../services/api');+ getLlamaServerStatus.mockResolvedValue(llamaReady({ presets: specPresets() }));+ startLlamaServer.mockResolvedValueOnce({ success: true, pid: 4243 });++ await renderRuntimes();+ await screen.findByText(/Launch Speculative Decoding Server/);+ fireEvent.change(screen.getByLabelText('Preset'), { target: { value: 'vision-preset' } });+ await screen.findByText('Vision projector');++ const startBtn = screen.getByRole('button', { name: /Start Speculative Server/ });+ expect(startBtn).toBeEnabled();+ fireEvent.click(startBtn);+ await waitFor(() => {+ expect(startLlamaServer).toHaveBeenCalledWith(expect.objectContaining({ projector: '' }));+ });+ });++ // A projector already on disk is armed from the moment the preset is picked —+ // there is no second action to discover, and the field under Advanced is where+ // a user clears it back to a text-only launch.+ it('pre-fills the projector field from a preset whose sidecar is already downloaded', async () => {+ const { getLlamaServerStatus } = await import('../../services/api');+ getLlamaServerStatus.mockResolvedValue(llamaReady({ presets: specPresets({ projectorExists: true }) }));++ await renderRuntimes();+ await screen.findByText(/Launch Speculative Decoding Server/);+ fireEvent.change(screen.getByLabelText('Preset'), { target: { value: 'vision-preset' } });++ fireEvent.click(await screen.findByRole('button', { name: /Advanced options/ }));+ expect(screen.getByLabelText(/Vision Projector/)).toHaveValue('models/Example-Vision-27B-mmproj-Q8_0.gguf');+ });++ // Deleting the sidecar to reclaim disk must not leave its path behind arming a+ // launch line that can no longer load it — that would block Start on a file the+ // user deliberately removed, with the only way to clear it under Advanced.+ it('releases the projector field when its sidecar is deleted', async () => {+ const { getLlamaServerStatus, removeSpecDecodeModel } = await import('../../services/api');+ let projectorOnDisk = true;+ getLlamaServerStatus.mockImplementation(async () => (+ llamaReady({ presets: specPresets({ projectorExists: projectorOnDisk }) })+ ));+ removeSpecDecodeModel.mockImplementationOnce(async () => {+ projectorOnDisk = false;+ return { success: true, deleted: true, path: 'models/Example-Vision-27B-mmproj-Q8_0.gguf' };+ });++ await renderRuntimes();+ await screen.findByText(/Launch Speculative Decoding Server/);+ fireEvent.change(screen.getByLabelText('Preset'), { target: { value: 'vision-preset' } });++ const projectorRow = (await screen.findByText('Vision projector')).closest('div').parentElement;+ fireEvent.click(within(projectorRow).getByRole('button', { name: /Delete/ }));+ fireEvent.click(within(projectorRow).getByRole('button', { name: /Yes, delete/ }));++ await waitFor(() => {+ expect(removeSpecDecodeModel).toHaveBeenCalledWith('vision-preset', 'projector', { silent: true });+ });+ fireEvent.click(await screen.findByRole('button', { name: /Advanced options/ }));+ await waitFor(() => expect(screen.getByLabelText(/Vision Projector/)).toHaveValue(''));+ expect(screen.getByRole('button', { name: /Start Speculative Server/ })).toBeEnabled();+ });+// A dropped request (reload, proxy idle timeout) does not stop the transfer —// reporting it as a failure sends the user hunting a problem that isn't there.it('reports a lost request as still-running when the server is still downloading', async () => {diff --git a/client/src/components/settings/SpecDecodeWeightRow.jsx b/client/src/components/settings/SpecDecodeWeightRow.jsxindex 47cf19812d..c763c247c6 100644--- a/client/src/components/settings/SpecDecodeWeightRow.jsx+++ b/client/src/components/settings/SpecDecodeWeightRow.jsx@@ -4,7 +4,9 @@ import ConfirmButtonPair from '../ui/ConfirmButtonPair.jsx';import useConfirmDelete from '../../hooks/useConfirmDelete.js';import { formatBytes } from '../../utils/formatters';-const ROLE_LABELS = { model: 'Target base model', draftModel: 'Drafter' };+// Mirrors `SPEC_ROLE_LABELS` in server/lib/specDecodePresets.js — same three+// roles, title-cased for a row heading.+const ROLE_LABELS = { model: 'Target base model', draftModel: 'Drafter', projector: 'Vision projector' };/*** One GGUF of a speculative-decoding preset: where it goes, whether it's on@@ -108,7 +110,7 @@ export default function SpecDecodeWeightRow({ entry, progress, onDownload, onCantarget="_blank"rel="noopener noreferrer"className="text-[11px] text-port-warning hover:underline flex items-center gap-1"- title="No single-file GGUF is published for this drafter — download one yourself and point the field at it"+ title={`No single-file GGUF is published for this ${label.toLowerCase()} — download one yourself and point the field at it`}>Find on Hugging Face <ExternalLink size={10} /></a>diff --git a/docs/features/dflash2.md b/docs/features/dflash2.mdindex 2f038758a5..45dd242e8b 100644--- a/docs/features/dflash2.md+++ b/docs/features/dflash2.md@@ -179,6 +179,35 @@ has no entry in the Ollama/LM Studio catalog. Build recipe, PATH wiring, and themeasured cost of using the fork's *prebuilt* macOS binary instead of afrom-source build: [Ternary Bonsai 2 27B on Apple M5 Max](../research/2026-09-18-ternary-bonsai-2-27b.md).+### 2e. Vision — the `--mmproj` projector++A multimodal GGUF keeps its vision tower in a **separate projector sidecar**, and+llama.cpp loads it only when the launch line names one. Without the flag the+model still loads and answers — text-only, with no error to read, which is why+PortOS carries the projector as a weight of its own rather than a path you are+expected to remember:++```bash+llama-server \+ -m models/Ternary-Bonsai-2-27B-PQ2_0.gguf \+ --mmproj models/Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf \+ --spec-type none --port 5568 --host 127.0.0.1 --alias dflash --parallel 1+```++In PortOS, a preset with a projector shows a third **Vision projector** row in+the weights list — same on-disk state, Download button, progress and delete as+the base model and the drafter — and the path lands in **Advanced options →+Vision Projector / --mmproj**. Notes:++- **It is independent of Spec Type.** Nothing about speculative decoding turns+ vision on or off, so unlike the drafter the projector is never dropped from a+ launch line that still names it.+- **It is optional, and empty means text-only.** A preset whose sidecar is not+ downloaded starts exactly as it did before — clear the field to go back to a+ text-only launch on a model that has one.+- **A path that isn't on disk fails before the process spawns**, the same way a+ missing base model or drafter does.+### 3. Use in PortOS1. Navigate to **AI Providers** (`/ai`) or **Models → Runtimes**.2. Verify **OpenCode llama TUI** is enabled.diff --git a/docs/research/2026-09-18-ternary-bonsai-2-27b.md b/docs/research/2026-09-18-ternary-bonsai-2-27b.mdindex b7e613698c..2c5bcd353c 100644--- a/docs/research/2026-09-18-ternary-bonsai-2-27b.md+++ b/docs/research/2026-09-18-ternary-bonsai-2-27b.md@@ -116,14 +116,26 @@ The preset launches with no drafter (`--spec-type none`). Sampling thepublisher recommends: thinking mode `temperature=1.0, top_p=0.95, top_k=20`;instruct mode `temperature=0.7, top_p=0.80, top_k=20`.-## Known gaps+### Turning on vision++The model's image input is a separate 629 MB projector sidecar. The preset+carries it as a third weight, so **Models → Runtimes** shows a *Vision+projector* row beside the base model with its own Download button; fetching it+fills the **Vision Projector / --mmproj** field under Advanced options, and the+next Start puts `--mmproj` on the launch line. Clearing that field launches the+model text-only, which is what a preset with no projector on disk does. By hand:-- **Vision is not reachable through PortOS.** The model's image input needs- `--mmproj` pointed at a sidecar (`Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf`,- 629 MB), and the launcher builds no such flag — `pickGgufSibling` in- `server/services/specDecodeModels.js` actively filters projector files out of- the download candidates. A text-only launch is what the preset delivers;- tracked as #7611.+```bash+curl -L -o ~/.portos/models/Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf \+ https://huggingface.co/prism-ml/Ternary-Bonsai-2-27B-gguf/resolve/main/Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf+```++The repo also publishes a `BF16` projector (931 MB). PortOS pins the `Q8_0` one:+the projector is a fraction of the 6.7 GiB target either way, and a pin rather+than a quant hint because both projectors carry tags that also match language+packs in the same repo.++## Known gaps- **Speculative decoding is untested here.** The preset drafts with nothing.PrismML's demo repository documents a speculative setup; nothing in thisevaluation measured whether a drafter helps this pack.diff --git a/server/lib/mediaValidation.js b/server/lib/mediaValidation.jsindex b9c55e967c..224df5bdc0 100644--- a/server/lib/mediaValidation.js+++ b/server/lib/mediaValidation.js@@ -14,6 +14,7 @@ import { ASSESSABLE_RUNTIMES } from './localProviderRuntime.js';import { SWEEP_SCOPES } from './localModelAssessment.js';import { CAPABILITY_TEST_IDS } from './modelCapabilityTests.js';import { HF_REPO_ID_RE } from './huggingfaceLora.js';+import { SPEC_MODEL_ROLES } from './specDecodePresets.js';import { isLoopbackHostname, parseBrowserOrigin } from './beeperOAuthOrigin.js';// iMessage ingestion config (#2151) — the `settings.imessage` slice. Sync is OFF@@ -306,6 +307,10 @@ export const localLlmMtplxRemoveSchema = z.object({ model: mtplxRepoIdSchema });export const localLlmLlamaServerStartSchema = z.object({model: z.string().trim().min(1).max(500),draftModel: z.string().trim().max(500).optional().nullable(),+ // llama.cpp's multimodal projector sidecar (`--mmproj`). Optional and shaped+ // like the drafter path: empty/absent means the launch is text-only, which is+ // exactly the line every pre-#7611 PortOS produced.+ projector: z.string().trim().max(500).optional().nullable(),// A comma-separated list of llama.cpp `--spec-type` implementations// (`ngram-map-k`, `draft-dflash,ngram-map-k`). Free vocabulary on purpose —// fork builds ship their own — but shaped, since it lands in the launch argv.@@ -335,12 +340,15 @@ export const localLlmLlamaServerStartSchema = z.object({cacheTypeV: z.enum(['f16', 'q8_0', 'q4_0']).optional().nullable().default(null),draftMax: z.coerce.number().int().min(0).max(64).optional().nullable().default(null),});-// Speculative-decoding weight download: which curated preset, and which half of-// the pair. Both are enum-ish server-owned ids — no path or repo ever arrives+// Speculative-decoding weight download: which curated preset, and which of its+// weights. Both are enum-ish server-owned ids — no path or repo ever arrives// from the client, so a request can only ever write to a curated `models/` file.+// The role list comes from `specDecodePresets.js` rather than a literal here, so+// a role added to the launcher's vocabulary cannot be rejected at the route by a+// copy nobody updated.export const localLlmSpecModelDownloadSchema = z.object({presetId: z.string().trim().min(1).max(100),- role: z.enum(['model', 'draftModel']),+ role: z.enum(SPEC_MODEL_ROLES),});// Confirm-step disk preflight for a weight download. Discriminated on `kind`// so the server resolves dest + expected size — the client never supplies a@@ -351,7 +359,7 @@ export const localLlmDownloadPreflightSchema = z.discriminatedUnion('kind', [z.object({kind: z.literal('spec-decode'),presetId: z.string().trim().min(1).max(100),- role: z.enum(['model', 'draftModel']),+ role: z.enum(SPEC_MODEL_ROLES),}),z.object({kind: z.literal('mtplx'),diff --git a/server/lib/specDecodePresets.js b/server/lib/specDecodePresets.jsindex 5b58616538..c7e8ea65c9 100644--- a/server/lib/specDecodePresets.js+++ b/server/lib/specDecodePresets.js@@ -138,6 +138,19 @@ export const SPEC_DECODE_PRESETS = Object.freeze([quant: 'PQ2_0',},draftModel: { path: '' },+ // The vision tower, in the same repo as the language weights. A `file` PIN+ // rather than a quant hint: both projectors carry a quant tag (`Q8_0`,+ // `BF16`) that also matches language packs in this repo, so the hint alone+ // cannot say which of the two to fetch. Q8_0 (629 MB) over BF16 (931 MB) —+ // the projector is a fraction of the 6.7 GiB target either way, and Q8_0 is+ // what the evaluation in docs/research/2026-09-18-ternary-bonsai-2-27b.md+ // ran. Optional: the preset launches text-only until this is downloaded.+ projector: {+ path: 'models/Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf',+ repo: 'prism-ml/Ternary-Bonsai-2-27B-gguf',+ file: 'Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf',+ quant: 'Q8_0',+ },},{id: 'custom',@@ -198,7 +211,21 @@ export const isDraftSpecType = (type) => String(type).startsWith('draft-');// The preset the launcher mounts on, and the roles a download request may name.export const DEFAULT_SPEC_PRESET_ID = 'qwen3.8-27b-dspark';-export const SPEC_MODEL_ROLES = Object.freeze(['model', 'draftModel']);+// `projector` is llama.cpp's `--mmproj` multimodal sidecar — a third weight the+// launcher may load, not a second drafter. It is a full role rather than a+// free-text path field because every other weight the card shows already has+// on-disk status, a Download button, progress frames, a remove path and orphan+// GC; a projector outside that would be the one file the user had to fetch by+// hand, with its `.partial` invisible to the sweep (#7611).+export const SPEC_MODEL_ROLES = Object.freeze(['model', 'draftModel', 'projector']);++// What each role is called in a user-facing message. Server-side counterpart of+// the card's own `ROLE_LABELS`; keep the two in step.+export const SPEC_ROLE_LABELS = Object.freeze({+ model: 'base model',+ draftModel: 'drafter',+ projector: 'vision projector',+});export const findSpecDecodePreset = (id) =>SPEC_DECODE_PRESETS.find((preset) => preset.id === id) || null;diff --git a/server/services/llamaServerManager.js b/server/services/llamaServerManager.jsindex d268356eb7..8839542432 100644--- a/server/services/llamaServerManager.js+++ b/server/services/llamaServerManager.js@@ -369,6 +369,10 @@ function parseConfigFromArgs(args) {if (!model) return null;const draftModel = getArg('--model-draft') || getArg('--spec-draft-model') || getArg('-md');+ // Absent means the recovered process is running text-only — a pre-#7611+ // PortOS could not emit this flag at all, so every launch line it left behind+ // reads back as no projector, which is the truth about that process.+ const projector = getArg('--mmproj');// Absent means the process is running WITHOUT speculative decoding — don't// invent a type the launch line never carried.const specType = getArg('--spec-type');@@ -386,6 +390,7 @@ function parseConfigFromArgs(args) {return {model,draftModel,+ projector,specType,port,host,@@ -563,6 +568,9 @@ export async function startLlamaServer(options = {}) {const {model,draftModel,+ // llama.cpp's multimodal projector (`--mmproj`). Optional and independent of+ // speculative decoding: a vision-capable GGUF loads text-only without it.+ projector,specType = 'draft-dflash',port = PORTS.LLAMA_SERVER,host = '127.0.0.1',@@ -609,6 +617,12 @@ export async function startLlamaServer(options = {}) {const configuredDraftPath = typeof draftModel === 'string' && draftModel.trim()? draftModel.trim(): null;+ // Unlike the drafter, the projector is resolved against nothing — no spec type+ // turns vision on or off, so what the caller set is what goes on the line.+ const projectorPath = typeof projector === 'string' && projector.trim()+ ? projector.trim()+ : null;+ if (projectorPath) await assertModelFileExists('The vision projector', projectorPath);// `--spec-type` is a comma-separated LIST, and only its `draft-*` entries want// a drafter GGUF — every `ngram-*` implementation speculates off the tokens@@ -640,6 +654,7 @@ export async function startLlamaServer(options = {}) {const args = ['-m', expandHome(model.trim())];if (draftPath) args.push('--model-draft', expandHome(draftPath));+ if (projectorPath) args.push('--mmproj', expandHome(projectorPath));if (effectiveSpecTypes.length > 0) args.push('--spec-type', effectiveSpecTypes.join(','));if (port) args.push('--port', String(port));if (host) args.push('--host', host);@@ -702,6 +717,9 @@ export async function startLlamaServer(options = {}) {// The drafter actually on the launch line, so the status card reports what// is running rather than what the form happened to be holding.draftModel: draftPath,+ // Same reason: `null` here means the running process is text-only, which is+ // what the card says rather than echoing an unused form field.+ projector: projectorPath,// The types actually on the launch line, so the status card reports what is// running rather than what was asked for.specType: effectiveSpecTypes.join(','),@@ -725,7 +743,7 @@ export async function startLlamaServer(options = {}) {await execPm2(['delete', LLAMA_APP]).catch(() => {});clearJlistCache();- console.log(`🦙 llama-server starting on ${host}:${port} (model ${model}${draftPath ? `, drafter ${draftPath}` : ''})`);+ console.log(`🦙 llama-server starting on ${host}:${port} (model ${model}${draftPath ? `, drafter ${draftPath}` : ''}${projectorPath ? `, projector ${projectorPath}` : ''})`);await execPm2(['start', binaryPath,'--name', LLAMA_APP,diff --git a/server/services/llamaServerManager.test.js b/server/services/llamaServerManager.test.jsindex 2aa128a1ad..3c87844498 100644--- a/server/services/llamaServerManager.test.js+++ b/server/services/llamaServerManager.test.js@@ -75,6 +75,7 @@ describe('llamaServerManager', () => {let modelDir;let modelPath;let draftPath;+ let projectorPath;let homebrewBinaryPath;let homebrewPrefix;let pm2State = null;@@ -90,8 +91,10 @@ describe('llamaServerManager', () => {modelDir = await mkdtemp(join(tmpdir(), 'portos-llama-'));modelPath = join(modelDir, 'model.gguf');draftPath = join(modelDir, 'draft.gguf');+ projectorPath = join(modelDir, 'mmproj.gguf');await writeFile(modelPath, 'gguf');await writeFile(draftPath, 'gguf');+ await writeFile(projectorPath, 'gguf');const homebrewRoot = join(modelDir, 'homebrew');const cellarRoot = join(homebrewRoot, 'Cellar', 'llama.cpp', 'build-100');homebrewPrefix = join(homebrewRoot, 'opt', 'llama.cpp');@@ -336,6 +339,45 @@ describe('llamaServerManager', () => {expect(status.config.parallel).toBe(1);});+ // The whole point of #7611: a vision-capable GGUF loads text-only unless+ // llama.cpp is handed its projector sidecar. Both halves are asserted here —+ // the flag lands when a projector is set, and the line is UNCHANGED when one+ // is not, because every existing launch must keep producing the same argv.+ it('puts --mmproj on the launch line for a projector, and nothing at all without one', async () => {+ vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue('/usr/local/bin/llama-server');++ await startLlamaServer({ model: modelPath, specType: 'none', projector: projectorPath });+ const withProjector = execPm2Calls.find((c) => c[0] === 'start').slice(8);+ expect(withProjector.slice(0, 4)).toEqual(['-m', modelPath, '--mmproj', projectorPath]);+ const running = await getLlamaServerStatus();+ expect(running.config.projector).toBe(projectorPath);++ await stopLlamaServer();+ execPm2Calls = [];+ await startLlamaServer({ model: modelPath, specType: 'none' });+ const withoutProjector = execPm2Calls.find((c) => c[0] === 'start').slice(8);+ expect(withoutProjector).not.toContain('--mmproj');+ expect(withoutProjector).toEqual(withProjector.filter((a) => a !== '--mmproj' && a !== projectorPath));+ expect((await getLlamaServerStatus()).config.projector).toBeNull();+ });++ // Vision is orthogonal to speculative decoding — no spec type turns it on or+ // off — so the projector survives the resolution that drops an unused drafter.+ it('keeps the projector when an ngram spec type drops the drafter', async () => {+ vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue('/usr/local/bin/llama-server');++ await startLlamaServer({+ model: modelPath,+ draftModel: draftPath,+ projector: projectorPath,+ specType: 'ngram-map-k',+ });++ const startCall = execPm2Calls.find((c) => c[0] === 'start');+ expect(startCall).not.toContain('--model-draft');+ expect(startCall[startCall.indexOf('--mmproj') + 1]).toBe(projectorPath);+ });+it('starts an ngram spec type with no drafter model at all', async () => {// `ngram-*` implementations draft from the tokens already in context, so a// drafter GGUF is not just optional — there is nothing to download.@@ -447,6 +489,11 @@ describe('llamaServerManager', () => {await expect(startLlamaServer({ model: modelPath, draftModel: join(modelDir, 'absent.gguf') })).rejects.toThrow(/drafter model was not found/i);+ // Same gate for the projector: an `--mmproj` llama-server cannot open is a+ // failed launch, so it is refused here rather than in a server log (#7611).+ await expect(startLlamaServer({ model: modelPath, projector: join(modelDir, 'absent.gguf') })).rejects.toThrow(+ /vision projector was not found/i+ );// The weights are a separate multi-gigabyte download; spawning anyway just// buries that in a server log.expect(execPm2Calls.filter((c) => c[0] === 'start')).toHaveLength(0);@@ -482,7 +529,7 @@ describe('llamaServerManager', () => {name: LLAMA_APP,status: 'online',pid: 98765,- args: ['-m', modelPath, '--model-draft', draftPath, '--port', '8090', '--host', '127.0.0.1', '--parallel', '4'],+ args: ['-m', modelPath, '--model-draft', draftPath, '--mmproj', projectorPath, '--port', '8090', '--host', '127.0.0.1', '--parallel', '4'],};const status = await getLlamaServerStatus();@@ -492,6 +539,10 @@ describe('llamaServerManager', () => {expect(status.endpoint).toBe('http://127.0.0.1:8090/v1');expect(status.config?.model).toBe(modelPath);expect(status.config?.draftModel).toBe(draftPath);+ // Recovered from argv too, so the status card describes a running vision+ // launch correctly — and so a relaunch replays the same line rather than+ // silently demoting the daemon to text-only.+ expect(status.config?.projector).toBe(projectorPath);expect(status.config?.parallel).toBe(4);});diff --git a/server/services/specDecodeModels.js b/server/services/specDecodeModels.jsindex 9d730c4540..f3cfa889ea 100644--- a/server/services/specDecodeModels.js+++ b/server/services/specDecodeModels.js@@ -32,6 +32,7 @@ import { getHfToken } from './hfToken.js';import {SPEC_DECODE_PRESETS,SPEC_MODEL_ROLES,+ SPEC_ROLE_LABELS,findSpecDecodePreset,hfSearchUrl,specDecodeSource,@@ -61,7 +62,7 @@ const fileStat = async (path) => {return stats?.isFile() ? stats : null;};-/** State of one preset role (base or drafter) for the UI. */+/** State of one preset role (base, drafter or vision projector) for the UI. */const describeEntry = async (presetId, role) => {const entry = findSpecDecodePreset(presetId)?.[role];if (!entry?.path) return null;@@ -91,8 +92,12 @@ export async function getSpecDecodePresetStatus() {id: preset.id,label: preset.label,specType: preset.specType,- model: await describeEntry(preset.id, 'model'),- draftModel: await describeEntry(preset.id, 'draftModel'),+ // Keyed off the role list so a role added to the vocabulary is reported+ // without a fourth hand-written line here — `describeEntry` already returns+ // null for a preset that declares no weight for it.+ ...Object.fromEntries(await Promise.all(+ SPEC_MODEL_ROLES.map(async (role) => [role, await describeEntry(preset.id, role)]),+ )),})));}@@ -108,7 +113,7 @@ const normalize = (text) => String(text).toLowerCase().replace(/[^a-z0-9]/g, '')* launcher's existence check and then fail at load time — the exact confusion* this whole module exists to remove.*/-export function pickGgufSibling(model, { file, quant, repo }) {+export function pickGgufSibling(model, { file, quant, repo, role = 'model' }) {const all = modelSiblingFilenames(model).filter((name) => /\.gguf$/i.test(name));if (!all.length) {throw new ServerError(`Hugging Face repo ${repo} publishes no .gguf file`, { status: 422, code: 'SPEC_NO_GGUF' });@@ -127,15 +132,21 @@ export function pickGgufSibling(model, { file, quant, repo }) {{ status: 422, code: 'SPEC_FILE_MISSING' },);}+ // The projector role and every other role want DISJOINT halves of the repo.// A projector ships under the target's own quant tag// (`mmproj-Muse-Glimmer-30B-Q4_K_M.gguf`, 1.4 GB) right beside the 17 GB target,- // so shortest-name-wins below would hand one back — and it would then satisfy- // the launcher's existence check and fail at load. Only an explicit `file` may- // name one, which is why this filter sits after the exact-match branch.- const ggufs = all.filter((name) => !isProjectorName(name));+ // so for a language-weight role shortest-name-wins below would hand one back —+ // and it would then satisfy the launcher's existence check and fail at load.+ // For the `projector` role the same test inverts: the language packs are the+ // files that must not be selected. Either way an explicit `file` outranks this,+ // which is why the filter sits after the exact-match branch.+ const wantsProjector = role === 'projector';+ const ggufs = all.filter((name) => isProjectorName(name) === wantsProjector);if (!ggufs.length) {throw new ServerError(- `Hugging Face repo ${repo} publishes only projector (mmproj) sidecars, not a loadable model`,+ wantsProjector+ ? `Hugging Face repo ${repo} publishes no projector (mmproj) sidecar — this model has no vision tower to load`+ : `Hugging Face repo ${repo} publishes only projector (mmproj) sidecars, not a loadable model`,{ status: 422, code: 'SPEC_NO_GGUF' },);}@@ -191,13 +202,13 @@ const siblingFor = (model, filename) => {// stream for hours, while metadata headers/body and the size fallback must settle.const METADATA_FETCH_TIMEOUT_MS = 10_000;-const resolveSpecDownloadPlan = async ({ source, destPath, token, signal }) => {+const resolveSpecDownloadPlan = async ({ source, role, destPath, token, signal }) => {const headers = buildHfAuthHeaders(token);const { file, url, meta } = await withAbortTimeout(METADATA_FETCH_TIMEOUT_MS, async (deadline) => {const boundedSignal = anyAbortSignal([signal, deadline]);try {const model = await fetchHuggingfaceModel(source.repo, { token, signal: boundedSignal });- const selectedFile = pickGgufSibling(model, { file: source.file, quant: source.quant, repo: source.repo });+ const selectedFile = pickGgufSibling(model, { file: source.file, quant: source.quant, repo: source.repo, role });const selectedUrl = buildHfResolveUrl(source.repo, 'main', selectedFile);let selectedMeta = siblingDownloadMeta(siblingFor(model, selectedFile));if (!selectedMeta.bytes) {@@ -232,7 +243,7 @@ export async function downloadSpecDecodeModel({ presetId, role, onProgress = ()const source = specDecodeSource(presetId, role);if (!source) {throw new ServerError(- `No Hugging Face source is registered for that preset's ${role === 'model' ? 'base model' : 'drafter'} — download it manually and point the field at the file.`,+ `No Hugging Face source is registered for that preset's ${SPEC_ROLE_LABELS[role]} — download it manually and point the field at the file.`,{ status: 400, code: 'SPEC_NO_SOURCE' },);}@@ -261,6 +272,7 @@ export async function downloadSpecDecodeModel({ presetId, role, onProgress = ()onProgress({ event: 'start', presetId, role, path: source.path, message: `Resolving ${source.repo} on Hugging Face…` });const plan = await resolveSpecDownloadPlan({source,+ role,destPath,token,signal: slot.signal,@@ -310,7 +322,7 @@ export async function previewSpecDecodeDownload({ presetId, role }) {const source = specDecodeSource(presetId, role);if (!source) {throw new ServerError(- `No Hugging Face source is registered for that preset's ${role === 'model' ? 'base model' : 'drafter'} — download it manually and point the field at the file.`,+ `No Hugging Face source is registered for that preset's ${SPEC_ROLE_LABELS[role]} — download it manually and point the field at the file.`,{ status: 400, code: 'SPEC_NO_SOURCE' },);}@@ -330,7 +342,7 @@ export async function previewSpecDecodeDownload({ presetId, role }) {};}const token = await getHfToken();- const plan = await resolveSpecDownloadPlan({ source, destPath, token });+ const plan = await resolveSpecDownloadPlan({ source, role, destPath, token });return {kind: 'spec-decode',file: plan.file,diff --git a/server/services/specDecodeModels.test.js b/server/services/specDecodeModels.test.jsindex 3a31622d6e..f5d487366f 100644--- a/server/services/specDecodeModels.test.js+++ b/server/services/specDecodeModels.test.js@@ -129,6 +129,51 @@ describe('pickGgufSibling', () => {expect(pickGgufSibling(model, { quant: entry.quant, repo: entry.repo })).toBe('Ternary-Bonsai-2-27B-PQ2_0.gguf');});++ // The `projector` role inverts the projector filter, so the SAME sibling list+ // resolves to opposite halves of the repo depending on the role. Asserted+ // against the real Ternary Bonsai list — two projectors beside three language+ // packs — because the regression this catches is the two selections colliding,+ // not either one in isolation (#7611).+ //+ // The quant hint alone is what proves the invert: the preset's `file` pin+ // short-circuits at the exact-match branch ABOVE the filter, so a pinned pick+ // would resolve to a projector even with the filter still hard-coded the old+ // way. Both are asserted — the pin because it is what the preset ships, the+ // hint because it is what actually reaches the clause under test.+ it('selects a projector sibling for the projector role, by pin and by quant hint', () => {+ const preset = specDecodePresets.findSpecDecodePreset('ternary-bonsai-2-27b');+ const model = siblings(+ 'Ternary-Bonsai-2-27B-F16.gguf',+ 'Ternary-Bonsai-2-27B-PQ2_0.gguf',+ 'Ternary-Bonsai-2-27B-PTQ1_0.gguf',+ 'Ternary-Bonsai-2-27B-mmproj-BF16.gguf',+ 'Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf',+ );+ expect(pickGgufSibling(model, { ...preset.projector, role: 'projector' }))+ .toBe('Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf');+ expect(pickGgufSibling(model, { quant: 'Q8_0', repo: preset.projector.repo, role: 'projector' }))+ .toBe('Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf');+ // …while the same hint under the model role still cannot see a projector at+ // all: `Q8_0` is carried only by the two sidecars here, so there is nothing+ // left for it to match among the language packs.+ expect(() => pickGgufSibling(model, { quant: 'Q8_0', repo: preset.model.repo, role: 'model' }))+ .toThrow(/no Q8_0 build/i);+ });++ it('refuses a projector-role pick with no projector in the repo', () => {+ const model = siblings('model-Q4_K_M.gguf', 'model-Q8_0.gguf');+ expect(() => pickGgufSibling(model, { quant: 'Q8_0', repo: 'o/r', role: 'projector' }))+ .toThrow(/no projector/i);+ });++ // Every non-projector role shares the base model's filter, so the drafter is+ // protected from a same-quant projector by the same clause.+ it('keeps a projector out of a drafter-role pick', () => {+ const model = siblings('mmproj-model-Q4_K_M.gguf', 'drafter-model-Q4_K_M.gguf');+ expect(pickGgufSibling(model, { quant: 'Q4_K_M', repo: 'o/r', role: 'draftModel' }))+ .toBe('drafter-model-Q4_K_M.gguf');+ });});describe('getSpecDecodePresetStatus', () => {@@ -157,6 +202,15 @@ describe('getSpecDecodePresetStatus', () => {expect(bonsai.specType).toBe('none');expect(bonsai.model.downloadable).toBe(true);expect(bonsai.draftModel).toBeNull();+ // The projector role is reported beside the other two, so the card renders a+ // third weights row with its own Download button rather than leaving the+ // vision tower as the one file the user must fetch by hand (#7611).+ expect(bonsai.projector.path).toMatch(/mmproj-Q8_0\.gguf$/);+ expect(bonsai.projector.role).toBe('projector');+ expect(bonsai.projector.downloadable).toBe(true);+ // A text-only preset reports no projector at all, which is what keeps the+ // row out of every other preset's card.+ expect(recommended.projector).toBeNull();expect(fetchSpy).not.toHaveBeenCalled();});});