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
detect vision-capable Ollama models via /api/show in the LoRA caption picker
[._.]/ Adam Eivy9cc45094d590
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex e3ac3b27f9..48e2a04b0d 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -12,6 +12,8 @@## Fixed+- **LoRA caption-model picker now sees vision-capable Ollama models whose name lacks a `vl`/`vision` token** — The picker showed "none installed" even with a vision model like the `qwen3.6:35b` MoE installed, because Ollama's `/api/tags` carries no vision flag and the id heuristic only matches names containing a `vl`/`vision`/known-family token. Ollama *does* report `capabilities: ["…","vision",…]` via `/api/show`, but PortOS only consulted that for LM Studio. `listVisionModels` now enriches each Ollama model the id heuristic doesn't already catch with its `/api/show` capabilities (cached per model, busted on delete), so capability-tagged vision models surface in the picker — and, through the same path, in the captioner's auto-pick and explicit-model validation. (`server/services/ollamaManager.js`, `server/services/localLlm.js`)+- **TUI agents no longer leave the prompt sitting unsent in the input box** — CoS agents that run inside a terminal-UI provider (Claude Code, Codex) bracketed-paste their task prompt and then send a single Enter to submit it. On a large multi-line prompt that one `\r` could arrive while the TUI was still reflowing the paste and get swallowed — so the prompt sat typed-but-unsubmitted, the agent did no work, idled out after 3 minutes, and was (wrongly) recorded as a successful run. You'd see it only by opening the Shell tab and hitting Enter yourself. The submit Enter now fires a few times spaced ~700ms apart so one lands after the paste settles; re-sending is safe because once the prompt submits the input box is empty and a bare Enter is a no-op. Applies to both the long-running agent path and the one-shot TUI runner. (`server/lib/tuiHandshake.js`, `server/services/agentTuiSpawning.js`, `server/lib/tuiPromptRunner.js`)- **`calendarSync` test no longer depends on the developer's machine state** — the "throws 401 when Google OAuth is not configured" test read the REAL Google credentials/tokens off disk, so on a machine with OAuth configured it failed with a `GaxiosError` (400 invalid_grant) instead of the pinned 401. The auth client is now mocked to the not-configured state. (`server/services/calendarSync.test.js`)diff --git a/server/services/localLlm.js b/server/services/localLlm.jsindex 97ca7ecc59..dd674ea19b 100644--- a/server/services/localLlm.js+++ b/server/services/localLlm.js@@ -552,9 +552,12 @@ function normalizeModels(backend, models) {id: m.id, name: m.name, size: m.size ?? null,params: m.params || null, quantization: m.quantization || null, family: m.family || null,contextLength: m.contextLength ?? null,- // Ollama's /api/tags doesn't tag vision capability, so this is the id- // heuristic only (no explicit metadata to prefer).- vision: isVisionModel(m.id)+ // Ollama's /api/tags doesn't tag vision capability, but /api/show does —+ // when the model has been enriched with a `capabilities` array (status+ // path, or the listVisionModels enrichment below) prefer it; otherwise+ // fall back to the id heuristic. Passing the object lets a vision-capable+ // MoE like `qwen3.6:35b` (no `vl`/`vision` token in its id) resolve true.+ vision: isVisionModel(Array.isArray(m.capabilities) ? { id: m.id, capabilities: m.capabilities } : m.id)}))}return models.map((m) => ({@@ -646,10 +649,20 @@ export async function listVisionModels() {listModels('ollama').catch(() => []),listModels('lmstudio').catch(() => [])])+ // Ollama's /api/tags carries no vision flag, so the normalized `vision` above+ // is id-regex only — it misses vision-capable models whose id has no+ // `vl`/`vision` token (e.g. the `qwen3.6:35b` MoE). For each not already+ // matched, consult /api/show capabilities (cached per model) so they surface+ // in the picker. Models the id heuristic already caught skip the round-trip.+ const ollamaVision = await Promise.all(ollama.map(async (m) => {+ if (m.vision) return m+ const capabilities = await ollamaManager.getModelCapabilities(m.id).catch(() => [])+ return { ...m, vision: isVisionModel({ id: m.id, capabilities }) }+ }))const tag = (backend, models) => models.filter((m) => m.vision).map((m) => ({ providerId: PROVIDER_ID[backend], backend, id: m.id, name: m.name || m.id, vision: true }))- return [...tag('ollama', ollama), ...tag('lmstudio', lmstudio)]+ return [...tag('ollama', ollamaVision), ...tag('lmstudio', lmstudio)]}// ---- install / delete --------------------------------------------------------diff --git a/server/services/localLlm.test.js b/server/services/localLlm.test.jsindex 81d3078d7a..1c65ffd315 100644--- a/server/services/localLlm.test.js+++ b/server/services/localLlm.test.js@@ -19,6 +19,7 @@ vi.mock('../lib/fileUtils.js', async () => {const mocks = vi.hoisted(() => ({ollama: {getInstalledModels: vi.fn(async () => []),+ getModelCapabilities: vi.fn(async () => []),pullModel: vi.fn(async (id) => ({ success: true, modelId: id })),deleteModel: vi.fn(async (id) => ({ success: true, modelId: id })),getStatus: vi.fn(async () => ({ available: true, baseUrl: 'x', version: '1', modelCount: 0, models: [] })),@@ -300,4 +301,32 @@ describe('localLlm', () => {}});});++ describe('listVisionModels', () => {+ it('detects a vision-capable Ollama model whose id lacks a vl/vision token via /api/show capabilities', async () => {+ mocks.ollama.getInstalledModels.mockResolvedValueOnce([+ { id: 'qwen3.6:35b', name: 'qwen3.6:35b', family: 'qwen35moe' },+ { id: 'gemma4:31b', name: 'gemma4:31b', family: 'gemma4' },+ ]);+ mocks.ollama.getModelCapabilities.mockImplementation(async (id) =>+ id === 'qwen3.6:35b' ? ['completion', 'vision', 'tools'] : ['completion']);++ const models = await svc.listVisionModels();+ expect(models).toEqual([+ { providerId: 'ollama', backend: 'ollama', id: 'qwen3.6:35b', name: 'qwen3.6:35b', vision: true },+ ]);+ // The text-only gemma was excluded even though /api/show was consulted.+ expect(mocks.ollama.getModelCapabilities).toHaveBeenCalledWith('gemma4:31b');+ });++ it('skips the /api/show round-trip when the id already matches the vision heuristic', async () => {+ mocks.ollama.getInstalledModels.mockResolvedValueOnce([+ { id: 'qwen2.5-vl:7b', name: 'qwen2.5-vl:7b', family: 'qwen2vl' },+ ]);++ const models = await svc.listVisionModels();+ expect(models.map((m) => m.id)).toEqual(['qwen2.5-vl:7b']);+ expect(mocks.ollama.getModelCapabilities).not.toHaveBeenCalled();+ });+ });});diff --git a/server/services/ollamaManager.js b/server/services/ollamaManager.jsindex f05e59b1bb..bf78125d53 100644--- a/server/services/ollamaManager.js+++ b/server/services/ollamaManager.js@@ -421,48 +421,66 @@ async function getVersion() {return data?.version || null}-// A model's native context length is immutable for a given build, but Ollama's-// /api/tags listing doesn't include it — only /api/show does (one POST per-// model). Cache name → contextLength so enriching the model list on every-// status poll doesn't re-hit /api/show. Busted alongside installedModels on-// delete (a deleted name shouldn't linger), but a re-pull of the same name-// yields the same value so we don't bust on pull.-const modelContextCache = new Map() // name -> number|null+// A model's native context length and capability set are immutable for a given+// build, but Ollama's /api/tags listing carries neither — only /api/show does+// (one POST per model). Cache name → { contextLength, capabilities } so+// enriching the model list on every status poll doesn't re-hit /api/show.+// Busted alongside installedModels on delete (a deleted name shouldn't linger),+// but a re-pull of the same name yields the same details so we don't bust on pull.+const modelDetailsCache = new Map() // name -> { contextLength: number|null, capabilities: string[] }/**- * Fetch a model's native maximum context length (in tokens) via /api/show.- * Ollama nests it under `model_info["<arch>.context_length"]`; the arch prefix- * varies by family so we scan for the suffix. Cached; returns null when the- * daemon doesn't report it.+ * Fetch a model's native details (max context length + capability set) via+ * /api/show. Ollama nests context under `model_info["<arch>.context_length"]`+ * (the arch prefix varies by family so we scan for the suffix) and reports a+ * top-level `capabilities` array (`["completion","vision","tools",…]`). Cached;+ * returns nulls/empty when the daemon doesn't report a field.* @param {string} name- * @returns {Promise<number|null>}+ * @returns {Promise<{ contextLength: number|null, capabilities: string[] }>}*/-async function getModelContextLength(name) {- if (!name) return null- if (modelContextCache.has(name)) return modelContextCache.get(name)+async function getModelDetails(name) {+ const miss = { contextLength: null, capabilities: [] }+ if (!name) return miss+ if (modelDetailsCache.has(name)) return modelDetailsCache.get(name)// /api/show documents the id under `model`; current Ollama also accepts the// legacy `name`, so send both (extra fields are ignored) for cross-version safety.const data = await ollamaRequest('/api/show', { method: 'POST', body: JSON.stringify({ model: name, name }) }).catch(() => null)- // A transient /api/show failure must NOT be cached as a permanent null —- // that would pin the model with no context label until restart. Only cache- // when the daemon actually answered; a present-but-no-context_length response- // legitimately caches null ("daemon doesn't report it"). Mirrors the- // null-vs-empty sentinel rule used by the installed-model caches.- if (!data) return null- let ctx = null+ // A transient /api/show failure must NOT be cached — that would pin the model+ // with no context label / wrong vision flag until restart. Only cache when the+ // daemon actually answered; a present-but-missing field legitimately caches+ // its empty default. Mirrors the null-vs-empty sentinel rule used by the+ // installed-model caches.+ if (!data) return miss+ let contextLength = nullfor (const [key, value] of Object.entries(data.model_info || {})) {- if (key.endsWith('.context_length') && Number.isFinite(value)) { ctx = value; break }+ if (key.endsWith('.context_length') && Number.isFinite(value)) { contextLength = value; break }}- modelContextCache.set(name, ctx)- return ctx+ const details = {+ contextLength,+ capabilities: Array.isArray(data.capabilities) ? data.capabilities : []+ }+ modelDetailsCache.set(name, details)+ return details}-/** Add `contextLength` to each model (parallel, cached). */-async function enrichWithContextLength(models) {- return Promise.all(models.map(async (m) => ({- ...m,- contextLength: await getModelContextLength(m.id || m.name)- })))+/**+ * A model's capability set (`["completion","vision","tools",…]`) from /api/show.+ * Lets vision detection see capabilities that the /api/tags id can't reveal —+ * e.g. a vision-capable MoE like `qwen3.6:35b` whose id has no `vl`/`vision`+ * token. Cached; returns `[]` when the daemon doesn't report capabilities.+ * @param {string} name+ * @returns {Promise<string[]>}+ */+async function getModelCapabilities(name) {+ return (await getModelDetails(name)).capabilities+}++/** Add `contextLength` + `capabilities` to each model (parallel, cached). */+async function enrichWithModelDetails(models) {+ return Promise.all(models.map(async (m) => {+ const { contextLength, capabilities } = await getModelDetails(m.id || m.name)+ return { ...m, contextLength, capabilities }+ }))}/**@@ -776,7 +794,7 @@ async function deleteModel(modelId) {return { success: false, error: result._err, modelId }}installedModels = null- modelContextCache.delete(modelId)+ modelDetailsCache.delete(modelId)console.log(`🗑️ Ollama deleted: ${modelId}`)return { success: true, modelId }}@@ -894,9 +912,10 @@ function getBaseUrl() {async function getStatus(forceRefresh = false) {const available = await checkOllamaAvailable(forceRefresh)const baseModels = available ? await getInstalledModels(true) : []- // Enrich with native context length (cached /api/show per model) so the- // model cards + selector dropdowns can show each model's window.- const models = available ? await enrichWithContextLength(baseModels) : baseModels+ // Enrich with native context length + capabilities (cached /api/show per+ // model) so the model cards + selector dropdowns can show each model's window+ // and so vision-capable models are detected from their reported capabilities.+ const models = available ? await enrichWithModelDetails(baseModels) : baseModelsconst service = await getServiceStatus().catch(() => ({ supported: false, manager: null, running: false, runAtStartup: false, status: null }))return {available,@@ -912,6 +931,7 @@ async function getStatus(forceRefresh = false) {export {getInstalledModels,+ getModelCapabilities,getLoadedModels,unloadModel,pullModel,