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: add NVIDIA NIM free-endpoint gateway and comparison coverage
Adam Eivy997008d85653
diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex ecbfe45739..c34b9e6d31 100644--- a/client/src/utils/README.md+++ b/client/src/utils/README.md@@ -55,7 +55,7 @@ is where each shared table is re-exported from its `server/lib` leaf.|---|---|| `providers` | Compatibility facade re-exporting every helper from the nine modules below, so existing `../utils/providers` imports keep working. New code imports the declaring module. || `providerTypes` | What KIND of provider a record is: `PROVIDER_TYPES` (re-exported from `server/lib/aiToolkit/constants.js`) with `isCliProvider` / `isTuiProvider` / `isApiProvider` / `isProcessProvider` and `isClaudeHarnessProvider` (re-exported from `server/lib/providerTypes.js`, with legacy alias `isClaudeCommandProvider`), `isLaunchableTuiProvider` (a TUI provider carrying the server-resolved `tuiCommandLine`, i.e. one a human can start at a shell prompt — shared by the Providers card's "Launch in Shell" button and the Shell page's launch menu so the two can't disagree), `enabledApiProviderFilter`, `enabledProcessProviderFilter` (the coding/CLI-TUI-only counterpart, for a manual Claim/Replan/Resolve/Review "Run with" picker), `providerTypeClass`; the vendor-harness predicates keyed on the shipped ids plus `commandBasename` so a path-configured or renamed binary still qualifies (`isCodexProvider`, `isCodexSubscriptionProvider` — subscription readiness is keyed on the `codex` command, never an editable id — `isAntigravityProvider`, `isCursorProvider`, `isKimiProvider`, `isGrokProvider`, `isGrokBuildCli`, `isClaudeCommandProvider`, `isOpencodeLocalProvider`); and the structural backend markers a wrapper carries (`localRuntimeNamespace`, `isOllamaBackedProvider`). Everything with a server twin is re-exported from the pure leaves `server/lib/providerTypes.js`, `server/lib/providerModels.js`, `server/lib/aiToolkit/constants.js` and `server/lib/aiToolkit/internal/ollamaBacked.js`, never copied — `isGrokBuildCli` moved there in #7339 so the shared reviewer→provider matcher table keys on the same predicate the browser does. |-| `providerGateways` | `PROVIDER_GATEWAYS` / `gatewayForProvider` / `isGatewayBackedProvider` — the hosted OpenAI-compatible gateways (`orcarouter`, `openrouter`) an OpenCode CLI/TUI wrapper can front-end, inheriting its API key at spawn time from the sibling API provider whose id equals the gateway id. Reads the generic `gatewayBacked` marker and, forever, the legacy per-gateway boolean. All three are re-exported from the pure leaf `server/lib/providerGateways.js`. |+| `providerGateways` | `PROVIDER_GATEWAYS` / `gatewayForProvider` / `isGatewayBackedProvider` — the hosted OpenAI-compatible gateways (`orcarouter`, `openrouter`, `nvidia-nim`) an OpenCode CLI/TUI wrapper can front-end, inheriting its API key at spawn time from the sibling API provider whose id equals the gateway id. Reads the generic `gatewayBacked` marker and, forever, the legacy per-gateway boolean. All three are re-exported from the pure leaf `server/lib/providerGateways.js`. || `providerHarnesses` | `harnessLabel(harnessId)` — the display name for an agent program PortOS drives (Claude Code, OpenCode, Codex, …), used by the connection-management UI, where `null` means Direct API and an unknown id renders verbatim rather than disappearing. Read through `harnessById` from the pure leaf `server/lib/providerHarnesses.js`, so a harness added to the registry is named here without a second edit. || `providerEndpoints` | WHERE a provider's endpoint points. `isLocalEndpoint` (loopback), `isPrivateNetworkEndpoint` (RFC1918 / tailnet address, or a `.local` / `.ts.net` / single-label host — somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key), `isLocalInstanceProvider` (talks to a daemon on THIS machine; mirror of `server/lib/localProviderRuntime.js#isLocalInstanceEndpoint` — gate anything that explains a provider by inspecting the host PortOS runs on), `isFleetProvider` / `isFleetHostConfigured` (another machine inside the private network), and `localBackendForProvider` (`'ollama'` / `'lmstudio'` / `null` by id, endpoint or name — it matches by NAME, so pair it with `isLocalInstanceProvider` before claiming this machine's install state). || `providerModels` | Which MODEL and EFFORT a run resolves to, and what a picker may list. The configured-default sentinels (`CODEX_CONFIGURED_DEFAULT` …, `isConfiguredDefaultModel`, `configuredDefaultIn` — so a picker can render an option matching a sentinel-valued tier instead of a blank select) and `filterSelectableModels`; the per-CLI effort ladders, `effortLevelsForProvider`, `resolveCliEffort` (what a stored effort actually runs as, so the picker can name a clamped level), `effortSurvivingModel` and `seedModelEffort`; the Antigravity base-model ↔ effort-suffix split (`splitAntigravityModel`, `antigravityBaseModels`, `antigravityModelEffortLevels`, `withStaleAntigravityPin`); the account-aware option list (`providerModelList`, `resolveProviderModelOptions`, `effortAwareModelOptions`, `MODEL_SOURCE` — the one place a Codex-subscription account catalog enters a picker); `effectiveModelFor`; `mergeModelLists` / `mergeProviderUpdate`; and `generationControlsFor` (which temperature / top-p / thinking controls a provider forwards at all). The sentinels, effort ladders and the Antigravity split are re-exported from the pure leaf `server/lib/providerModels.js`; `effortLevelsForProvider` / `resolveCliEffort` delegate to the server's and add the ladder a sanitized provider inventory publishes, clamped through the server's `clampEffortToLadder`. The generation-control tables still mirror `server/lib/opencodeConfig.js`. |diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex d8886cece5..cbc9cbdca4 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -240,6 +240,7 @@ describe('generationControlsFor', () => {['OpenCode OrcaRouter', { id: 'opencode-orcarouter', type: 'tui', command: 'opencode', orcarouterBacked: true }, { temperature: true, topP: true, thinking: false }],// Same posture for every gateway: upstream models own their reasoning switch.['OpenCode OpenRouter', { id: 'opencode-openrouter', type: 'tui', command: 'opencode', gatewayBacked: 'openrouter' }, { temperature: true, topP: true, thinking: false }],+ ['OpenCode NVIDIA NIM', { id: 'opencode-nvidia-nim', type: 'tui', command: 'opencode', gatewayBacked: 'nvidia-nim' }, { temperature: true, topP: true, thinking: false }],['cloud API provider', { id: 'anthropic', type: 'api', endpoint: 'https://api.anthropic.com/v1' }, null],['vendor CLI', { id: 'claude-code', type: 'cli', command: 'claude' }, null],])('%s', (_label, provider, expected) => {@@ -749,11 +750,14 @@ describe('provider type predicates', () => {// The generic marker every new gateway wrapper ships with.expect(gatewayForProvider({ id: 'opencode-openrouter', gatewayBacked: 'openrouter' }).id).toBe('openrouter');expect(gatewayForProvider({ id: 'opencode-openrouter-tui', gatewayBacked: 'openrouter' }).label).toBe('OpenRouter');+ expect(gatewayForProvider({ id: 'opencode-nvidia-nim', gatewayBacked: 'nvidia-nim' }).id).toBe('nvidia-nim');+ expect(gatewayForProvider({ id: 'opencode-nvidia-nim-tui', gatewayBacked: 'nvidia-nim' }).label).toBe('NVIDIA NIM');// A renamed wrapper that keeps the marker still inherits the sibling key.expect(isGatewayBackedProvider({ id: 'my-orca', orcarouterBacked: true })).toBe(true);// The sibling API provider itself is NOT gateway-backed (it owns the key).expect(isGatewayBackedProvider({ id: 'orcarouter', type: 'api' })).toBe(false);expect(isGatewayBackedProvider({ id: 'openrouter', type: 'api' })).toBe(false);+ expect(isGatewayBackedProvider({ id: 'nvidia-nim', type: 'api' })).toBe(false);// An ollama-backed OpenCode wrapper shares the form shape but not the marker.expect(isGatewayBackedProvider({ id: 'opencode-ollama', ollamaBacked: true })).toBe(false);expect(isGatewayBackedProvider({ id: 'x', gatewayBacked: 'not-a-gateway' })).toBe(false);@@ -1339,10 +1343,12 @@ describe('supportsModelRefresh', () => {'claude-sglang', 'claude-sglang-tui', 'codex', 'codex-lmstudio','codex-ollama', 'codex-tui','cursor-cli',- 'cursor-tui', 'grok', 'lmstudio', 'mtplx', 'nvidia-kimi', 'ollama',+ 'cursor-tui', 'grok', 'lmstudio', 'mtplx', 'nvidia-kimi', 'nvidia-nim', 'ollama','opencode-llama-tui','opencode-lmstudio', 'opencode-lmstudio-tui',- 'opencode-mtplx', 'opencode-mtplx-tui', 'opencode-ollama',+ 'opencode-mtplx', 'opencode-mtplx-tui',+ 'opencode-nvidia-nim', 'opencode-nvidia-nim-tui',+ 'opencode-ollama','opencode-ollama-tui', 'opencode-openrouter', 'opencode-openrouter-tui','opencode-orcarouter', 'opencode-orcarouter-tui','opencode-sglang', 'opencode-sglang-tui',@@ -1711,6 +1717,8 @@ describe('credentialSource', () => {.toEqual({ kind: 'inherited', ref: 'orcarouter' });expect(credentialSource({ id: 'opencode-openrouter', type: 'cli', gatewayBacked: 'openrouter' })).toEqual({ kind: 'inherited', ref: 'openrouter' });+ expect(credentialSource({ id: 'opencode-nvidia-nim', type: 'cli', gatewayBacked: 'nvidia-nim' }))+ .toEqual({ kind: 'inherited', ref: 'nvidia-nim' });});it('identifies env credentials from explicit metadata and conventional names', () => {diff --git a/data.reference/model-comparison.json b/data.reference/model-comparison.jsonindex c88b1e7190..18a02e2213 100644--- a/data.reference/model-comparison.json+++ b/data.reference/model-comparison.json@@ -6175,6 +6175,70 @@"quota": null,"notes": "Nemotron 3.5 Lightning Free. Free endpoint listed on 2026-09-06. Pricing is temporary; usage limits and data-use terms apply (https://opencode.ai/docs/zen/). No verified quality or speed measurement for this exact endpoint/effort; do not transfer a similarly named model's scores."},+ {+ "id": "nim-free-2026-09-google-gemma-4-31b-it",+ "provider": "NVIDIA NIM",+ "model": "google/gemma-4-31b-it",+ "effort": "unspecified",+ "configuration": "NVIDIA NIM free endpoint; provider default configuration",+ "billing": "api",+ "benchmark": "Unbenchmarked (pricing only)",+ "quality": null,+ "costPerTask": null,+ "inputPerMillion": {+ "value": 0,+ "source": {+ "url": "https://build.nvidia.com/google/gemma-4-31b-it",+ "retrievedAt": "2026-09-15T00:00:00Z",+ "methodology": "NVIDIA NIM hosted free endpoint google/gemma-4-31b-it at https://integrate.api.nvidia.com/v1. Prototype API listed as a free endpoint on build.nvidia.com; published USD per million input/output tokens is zero. Promotional endpoint pricing, not a measured benchmark task or an unlimited quota guarantee."+ }+ },+ "outputPerMillion": {+ "value": 0,+ "source": {+ "url": "https://build.nvidia.com/google/gemma-4-31b-it",+ "retrievedAt": "2026-09-15T00:00:00Z",+ "methodology": "NVIDIA NIM hosted free endpoint google/gemma-4-31b-it at https://integrate.api.nvidia.com/v1. Prototype API listed as a free endpoint on build.nvidia.com; published USD per million input/output tokens is zero. Promotional endpoint pricing, not a measured benchmark task or an unlimited quota guarantee."+ }+ },+ "reasoningPerMillion": null,+ "responseSeconds": null,+ "tokensPerSecond": null,+ "quota": null,+ "notes": "Gemma 4 31B IT. Free NVIDIA NIM endpoint listed on 2026-09-15. Pricing is temporary; usage limits, trial credits, and NVIDIA data-use terms apply (https://build.nvidia.com/google/gemma-4-31b-it). No verified quality or speed measurement for this exact endpoint/effort; do not transfer a similarly named local or third-party hosting's scores."+ },+ {+ "id": "nim-free-2026-09-poolside-laguna-xs-2.1",+ "provider": "NVIDIA NIM",+ "model": "poolside/laguna-xs-2.1",+ "effort": "unspecified",+ "configuration": "NVIDIA NIM free endpoint; provider default configuration",+ "billing": "api",+ "benchmark": "Unbenchmarked (pricing only)",+ "quality": null,+ "costPerTask": null,+ "inputPerMillion": {+ "value": 0,+ "source": {+ "url": "https://build.nvidia.com/poolside/laguna-xs-2.1",+ "retrievedAt": "2026-09-15T00:00:00Z",+ "methodology": "NVIDIA NIM hosted free endpoint poolside/laguna-xs-2.1 at https://integrate.api.nvidia.com/v1. Prototype API listed as a free endpoint on build.nvidia.com; published USD per million input/output tokens is zero. Promotional endpoint pricing, not a measured benchmark task or an unlimited quota guarantee."+ }+ },+ "outputPerMillion": {+ "value": 0,+ "source": {+ "url": "https://build.nvidia.com/poolside/laguna-xs-2.1",+ "retrievedAt": "2026-09-15T00:00:00Z",+ "methodology": "NVIDIA NIM hosted free endpoint poolside/laguna-xs-2.1 at https://integrate.api.nvidia.com/v1. Prototype API listed as a free endpoint on build.nvidia.com; published USD per million input/output tokens is zero. Promotional endpoint pricing, not a measured benchmark task or an unlimited quota guarantee."+ }+ },+ "reasoningPerMillion": null,+ "responseSeconds": null,+ "tokensPerSecond": null,+ "quota": null,+ "notes": "Laguna XS 2.1. Free NVIDIA NIM endpoint listed on 2026-09-15. Pricing is temporary; usage limits, trial credits, and NVIDIA data-use terms apply (https://build.nvidia.com/poolside/laguna-xs-2.1). No verified quality or speed measurement for this exact endpoint/effort; do not transfer a similarly named OpenRouter or local serving's scores."+ },{"id": "aa-v4.3-google-gemini-3.5-flash-high","provider": "Google",diff --git a/data.reference/providers.json b/data.reference/providers.jsonindex 6a1a3d19a3..58371d2964 100644--- a/data.reference/providers.json+++ b/data.reference/providers.json@@ -580,6 +580,59 @@"tuiPromptDelayMs": 2500,"tuiIdleTimeoutMs": 180000},+ "nvidia-nim": {+ "id": "nvidia-nim",+ "name": "NVIDIA NIM",+ "type": "api",+ "endpoint": "https://integrate.api.nvidia.com/v1",+ "apiKey": "",+ "models": ["google/gemma-4-31b-it", "poolside/laguna-xs-2.1"],+ "defaultModel": "poolside/laguna-xs-2.1",+ "lightModel": "google/gemma-4-31b-it",+ "mediumModel": "poolside/laguna-xs-2.1",+ "heavyModel": "poolside/laguna-xs-2.1",+ "timeout": 300000,+ "enabled": false,+ "envVars": {},+ "secretEnvVars": []+ },+ "opencode-nvidia-nim": {+ "id": "opencode-nvidia-nim",+ "name": "OpenCode NVIDIA NIM",+ "type": "cli",+ "command": "opencode",+ "args": ["run"],+ "endpoint": "https://integrate.api.nvidia.com/v1",+ "models": ["google/gemma-4-31b-it", "poolside/laguna-xs-2.1"],+ "defaultModel": "poolside/laguna-xs-2.1",+ "gatewayBacked": "nvidia-nim",+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"allow\",\"provider\":{\"nvidia-nim\":{\"npm\":\"@ai-sdk/openai-compatible\",\"name\":\"NVIDIA NIM\",\"options\":{\"baseURL\":\"https://integrate.api.nvidia.com/v1\"}}}}"+ },+ "secretEnvVars": [],+ "headlessArgs": []+ },+ "opencode-nvidia-nim-tui": {+ "id": "opencode-nvidia-nim-tui",+ "name": "OpenCode NVIDIA NIM TUI",+ "type": "tui",+ "command": "opencode",+ "args": [],+ "endpoint": "https://integrate.api.nvidia.com/v1",+ "models": ["google/gemma-4-31b-it", "poolside/laguna-xs-2.1"],+ "defaultModel": "poolside/laguna-xs-2.1",+ "gatewayBacked": "nvidia-nim",+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"allow\",\"provider\":{\"nvidia-nim\":{\"npm\":\"@ai-sdk/openai-compatible\",\"name\":\"NVIDIA NIM\",\"options\":{\"baseURL\":\"https://integrate.api.nvidia.com/v1\"}}}}"+ },+ "secretEnvVars": [],+ "tuiPromptDelayMs": 2500,+ "tuiIdleTimeoutMs": 180000+ },"opencode-orcarouter-tui": {"id": "opencode-orcarouter-tui","name": "OpenCode OrcaRouter TUI",diff --git a/docs/MODEL-COMPARISON.md b/docs/MODEL-COMPARISON.mdindex b5d3082c1a..de2ce00cf4 100644--- a/docs/MODEL-COMPARISON.md+++ b/docs/MODEL-COMPARISON.md@@ -72,6 +72,8 @@ The September 6, 2026 snapshot ships eight exact Zen endpoint IDs (the CLI prefiPricing-only rows appear alongside the selected benchmark as explicitly unbenchmarked evidence. Select input price versus output price to plot them, or use scenario cost with zero reasoning tokens to calculate their published input/output charge. A missing quality measurement cannot become a zero score. Migration 356 appends missing shipped Zen IDs to existing catalogs without overwriting locally researched rows; it validates the entire result before writing and refuses malformed/future-version data.+The September 15, 2026 snapshot adds the two NVIDIA NIM free-endpoint IDs currently shipped on the `nvidia-nim` provider and its OpenCode wrappers: `google/gemma-4-31b-it` and `poolside/laguna-xs-2.1`, from the [Gemma 4 31B IT](https://build.nvidia.com/google/gemma-4-31b-it) and [Laguna XS 2.1](https://build.nvidia.com/poolside/laguna-xs-2.1) prototype pages. Each row carries zero published input/output rates, with unknown quota, reasoning-token billing, benchmark task cost, quality and throughput. The free NIM offer is a trial endpoint subject to NVIDIA credits, rate limits, and data-use terms. Name similarity does not prove that an AA-tested or locally served revision matches NIM's serving configuration. Migration 388 appends missing shipped NIM IDs the same way 356 does for Zen.+## Research: skill-specific comparisonsResearch checked September 6, 2026. These are candidate adapters and metrics, not newly imported scores. The current benchmark selector already separates named/versioned evaluations; a future skill selector should narrow that list, never mix unrelated score scales.diff --git a/docs/features/claude-ollama.md b/docs/features/claude-ollama.mdindex c7cfeaa6a9..91f2855ccc 100644--- a/docs/features/claude-ollama.md+++ b/docs/features/claude-ollama.md@@ -17,7 +17,7 @@ PortOS has two provider classes:- **`cli` / `tui`** (claude, codex, agy) — spawned as a child process in the agentworktree. The CLI owns the Read/Write/Edit/Bash **tool harness**, so it can writefiles. CoS agent tasks run only on these.-- **`api`** (Ollama, LM Studio, nvidia-kimi) — an HTTP request that returns **plain+- **`api`** (Ollama, LM Studio, nvidia-nim, nvidia-kimi) — an HTTP request that returns **plaintext**. No harness, no file writes. Great for planning/vision/ask, but a task thatneeds to edit files produces a transcript and writes nothing.diff --git a/scripts/migrations/387-nvidia-nim-providers.js b/scripts/migrations/387-nvidia-nim-providers.jsnew file mode 100644index 0000000000..e8c3ef4acc--- /dev/null+++ b/scripts/migrations/387-nvidia-nim-providers.js@@ -0,0 +1,91 @@+/**+ * Ship disabled NVIDIA NIM API and OpenCode presets to existing installs.+ *+ * NVIDIA NIM (`https://integrate.api.nvidia.com/v1`) is an OpenAI-compatible+ * hosted gateway, the third row of `server/lib/providerGateways.js` after+ * OrcaRouter and OpenRouter. The existing `nvidia-kimi` API record stays a+ * Kimi-only catalog on the same host; these three records are the general+ * free-endpoint catalog (currently Gemma 4 31B IT and Laguna XS 2.1) plus the+ * OpenCode CLI/TUI harness wrappers that front it.+ *+ * OpenCode is the optimal coding harness for this backend: it already speaks+ * OpenAI-compatible gateways, prefixes `vendor/model` ids at spawn, and+ * inherits the sibling API key. Direct API covers PortOS text generation+ * without a file harness. This migration is additive and never contacts NIM+ * or changes the active provider.+ *+ * The wrappers carry the generic `gatewayBacked: 'nvidia-nim'` marker rather+ * than a per-gateway boolean — the legacy `orcarouterBacked` shape stays+ * readable forever for records written before the registry existed, but nothing+ * new is written in it.+ *+ * Kept in lockstep with data.reference/providers.json and+ * server/lib/aiToolkit/defaults/providers.sample.json. Later default changes+ * require a new migration.+ */++import { makeProviderSeedMigration } from './_lib.js';++const NIM_ENDPOINT = 'https://integrate.api.nvidia.com/v1';+const OPENCODE_CONFIG_CONTENT = '{"permission":"allow","provider":{"nvidia-nim":{"npm":"@ai-sdk/openai-compatible","name":"NVIDIA NIM","options":{"baseURL":"https://integrate.api.nvidia.com/v1"}}}}';++const GEMMA = 'google/gemma-4-31b-it';+const LAGUNA = 'poolside/laguna-xs-2.1';+const NIM_MODELS = [GEMMA, LAGUNA];++const NVIDIA_NIM_API = {+ id: 'nvidia-nim',+ name: 'NVIDIA NIM',+ type: 'api',+ endpoint: NIM_ENDPOINT,+ apiKey: '',+ models: NIM_MODELS,+ defaultModel: LAGUNA,+ lightModel: GEMMA,+ mediumModel: LAGUNA,+ heavyModel: LAGUNA,+ timeout: 300000,+ enabled: false,+ envVars: {},+ secretEnvVars: [],+};++const OPENCODE_NVIDIA_NIM_CLI = {+ id: 'opencode-nvidia-nim',+ name: 'OpenCode NVIDIA NIM',+ type: 'cli',+ command: 'opencode',+ args: ['run'],+ endpoint: NIM_ENDPOINT,+ models: NIM_MODELS,+ defaultModel: LAGUNA,+ gatewayBacked: 'nvidia-nim',+ timeout: 600000,+ enabled: false,+ envVars: { OPENCODE_CONFIG_CONTENT },+ secretEnvVars: [],+ headlessArgs: [],+};++const OPENCODE_NVIDIA_NIM_TUI = {+ id: 'opencode-nvidia-nim-tui',+ name: 'OpenCode NVIDIA NIM TUI',+ type: 'tui',+ command: 'opencode',+ args: [],+ endpoint: NIM_ENDPOINT,+ models: NIM_MODELS,+ defaultModel: LAGUNA,+ gatewayBacked: 'nvidia-nim',+ timeout: 600000,+ enabled: false,+ envVars: { OPENCODE_CONFIG_CONTENT },+ secretEnvVars: [],+ tuiPromptDelayMs: 2500,+ tuiIdleTimeoutMs: 180000,+};++export default makeProviderSeedMigration({+ label: 'NVIDIA NIM',+ defs: [NVIDIA_NIM_API, OPENCODE_NVIDIA_NIM_CLI, OPENCODE_NVIDIA_NIM_TUI],+});diff --git a/scripts/migrations/387-nvidia-nim-providers.test.js b/scripts/migrations/387-nvidia-nim-providers.test.jsnew file mode 100644index 0000000000..61b65ba17b--- /dev/null+++ b/scripts/migrations/387-nvidia-nim-providers.test.js@@ -0,0 +1,80 @@+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 './387-nvidia-nim-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 387 — NVIDIA NIM providers', () => {+ let rootDir;+ let providersPath;++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-387-'));+ mkdirSync(join(rootDir, 'data'), { recursive: true });+ providersPath = join(rootDir, 'data/providers.json');+ });++ afterEach(() => rmSync(rootDir, { recursive: true, force: true }));++ it('adds disabled presets 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);+ const api = out.providers['nvidia-nim'];+ const cli = out.providers['opencode-nvidia-nim'];+ const tui = out.providers['opencode-nvidia-nim-tui'];++ expect(api).toMatchObject({+ endpoint: 'https://integrate.api.nvidia.com/v1',+ apiKey: '',+ models: ['google/gemma-4-31b-it', 'poolside/laguna-xs-2.1'],+ defaultModel: 'poolside/laguna-xs-2.1',+ lightModel: 'google/gemma-4-31b-it',+ enabled: false,+ });+ expect(cli).toMatchObject({ type: 'cli', gatewayBacked: 'nvidia-nim', enabled: false });+ expect(tui).toMatchObject({ type: 'tui', gatewayBacked: 'nvidia-nim', enabled: false, tuiIdleTimeoutMs: 180000 });+ // The wrappers stay keyless on disk — the key is attached to the+ // execution-time copy from the sibling API record (`withGatewayApiKey`).+ expect(JSON.parse(cli.envVars.OPENCODE_CONFIG_CONTENT).provider['nvidia-nim'].options.apiKey).toBeUndefined();+ expect(JSON.parse(tui.envVars.OPENCODE_CONFIG_CONTENT).provider['nvidia-nim'].options.apiKey).toBeUndefined();+ expect(out.activeProvider).toBe('claude-code');+ });++ it('preserves an existing NVIDIA NIM API key and custom provider', async () => {+ const existing = { id: 'nvidia-nim', name: 'My NIM', type: 'api', apiKey: 'nvapi-example', enabled: true };+ writeJson(providersPath, { providers: { 'nvidia-nim': existing } });++ await migration.up({ rootDir });+ expect(readJson(providersPath).providers['nvidia-nim']).toEqual(existing);+ });++ it('is a no-op on re-run', async () => {+ writeJson(providersPath, { activeProvider: 'claude-code', providers: {} });++ await migration.up({ rootDir });+ const first = readFileSync(providersPath, 'utf-8');+ await migration.up({ rootDir });+ expect(readFileSync(providersPath, 'utf-8')).toBe(first);+ });++ it('leaves the Kimi-on-NIM catalog untouched', async () => {+ const kimi = { id: 'nvidia-kimi', type: 'api', apiKey: 'nvapi-kimi-example', models: ['moonshotai/kimi-k2.5'] };+ writeJson(providersPath, { providers: { 'nvidia-kimi': kimi } });++ await migration.up({ rootDir });+ expect(readJson(providersPath).providers['nvidia-kimi']).toEqual(kimi);+ expect(readJson(providersPath).providers['nvidia-nim'].models).toEqual([+ 'google/gemma-4-31b-it',+ 'poolside/laguna-xs-2.1',+ ]);+ });+});diff --git a/scripts/migrations/388-nim-comparison-coverage.js b/scripts/migrations/388-nim-comparison-coverage.jsnew file mode 100644index 0000000000..1d10b20fc2--- /dev/null+++ b/scripts/migrations/388-nim-comparison-coverage.js@@ -0,0 +1,24 @@+/** Add shipped NVIDIA NIM free-endpoint evidence without replacing an install's researched observations. */+import { readFile } from 'node:fs/promises';+import { join } from 'node:path';+import { atomicWrite } from '../../server/lib/fileCore.js';+import { modelComparisonImportSchema } from '../../server/lib/validation.js';++export default {+ async up({ rootDir }) {+ const path = join(rootDir, 'data/model-comparison.json');+ const raw = await readFile(path, 'utf8').catch(error => {+ if (error.code !== 'ENOENT') throw error;+ return null;+ });+ if (raw === null) return { added: 0 };+ const current = modelComparisonImportSchema.parse(JSON.parse(raw));+ const seed = modelComparisonImportSchema.parse(JSON.parse(await readFile(join(rootDir, 'data.reference/model-comparison.json'), 'utf8')));+ const ids = new Set(current.observations.map(row => row.id));+ const additions = seed.observations.filter(row => row.id.startsWith('nim-free-2026-09-') && !ids.has(row.id));+ if (!additions.length) return { added: 0 };+ const result = modelComparisonImportSchema.parse({ ...current, observations: [...current.observations, ...additions] });+ await atomicWrite(path, result);+ return { added: additions.length };+ },+};diff --git a/scripts/migrations/388-nim-comparison-coverage.test.js b/scripts/migrations/388-nim-comparison-coverage.test.jsnew file mode 100644index 0000000000..9cfb16f799--- /dev/null+++ b/scripts/migrations/388-nim-comparison-coverage.test.js@@ -0,0 +1,32 @@+import { afterEach, expect, it } from 'vitest';+import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';+import { tmpdir } from 'os';+import { join } from 'path';+import migration from './388-nim-comparison-coverage.js';++let rootDir;+afterEach(async () => { if (rootDir) await rm(rootDir, { recursive: true, force: true }); });+it('upgrades an existing catalog without losing researched evidence and fails closed on future versions', async () => {+ rootDir = await mkdtemp(join(tmpdir(), 'portos-nim-seed-'));+ await mkdir(join(rootDir, 'data'));+ await mkdir(join(rootDir, 'data.reference'));+ const seed = JSON.parse(await readFile(new URL('../../data.reference/model-comparison.json', import.meta.url), 'utf8'));+ await writeFile(join(rootDir, 'data.reference/model-comparison.json'), JSON.stringify(seed));+ expect(await migration.up({ rootDir })).toEqual({ added: 0 });+ const nim = seed.observations.filter(row => row.provider === 'NVIDIA NIM');+ expect(nim).toHaveLength(2);+ expect(nim.map(row => row.model).sort()).toEqual(['google/gemma-4-31b-it', 'poolside/laguna-xs-2.1']);+ expect(nim.every(row => row.quality === null && row.tokensPerSecond === null && row.inputPerMillion.value === 0)).toBe(true);+ const researched = { ...nim[0], notes: 'Example locally researched evidence' };+ const prior = { schemaVersion: 1, observations: [seed.observations[0], researched] };+ const path = join(rootDir, 'data/model-comparison.json');+ await writeFile(path, JSON.stringify(prior));+ expect(await migration.up({ rootDir })).toEqual({ added: 1 });+ const result = JSON.parse(await readFile(path, 'utf8'));+ expect(result.observations.slice(0, 2)).toEqual(prior.observations);+ expect(await migration.up({ rootDir })).toEqual({ added: 0 });+ const future = JSON.stringify({ ...prior, schemaVersion: 99 });+ await writeFile(path, future);+ await expect(migration.up({ rootDir })).rejects.toThrow();+ expect(await readFile(path, 'utf8')).toBe(future);+});diff --git a/server/lib/README.md b/server/lib/README.mdindex 3a72f2a3a3..ce8367ab61 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -221,7 +221,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `providerFamilies.js` | Subscription-quota FAMILY identity — `PROVIDER_FAMILIES` (`{ id, label, idPattern, matches }` for claude/codex/agy/grok), `PROVIDER_FAMILY_IDS`, `familyLabel`, `familyForProvider(config)`, `familyForProviderId(id)` (the weaker id-only classifier a Zod schema can use, null when the id names no family) → 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. || `fleetQuotas.js` | Unifies subscription-quota readings across federated instances — one plan, several machines, each able to read only its own local CLI. `sanitizeQuotaCards` bounds a peer-supplied payload to the wire shape; `mergeFleetQuotaCards(localCards, peerEntries)` folds every peer's reading into this install's cards, taking the FRESHEST reading per limit key (the meters are account-wide, so summing them would multiply one allowance) and SUMMING activity counts (those are per-machine, which is why the provider captions them "does not include other devices"); `fleetNote` writes the caption naming what was combined. `metrics[]` is left local — its values are prose, not addends. Fed by `services/providerQuotaShare.js` (this machine's readings, persisted) and `services/peerUsage.js` (the `usage` sync category that carries them). || `harnessOutput.js` | Parsers for what a coding-agent HARNESS prints about itself: `parseHarnessVersion(stdout)` (the one semver run in a `--version` banner, `null` when unparseable), `compareHarnessVersions(a, b)` (the null-guarding wrapper around `versionUtils.js#compareSemver` — `null` when either side is unparseable, so a version that did not parse never reads as "out of date"), `parseHarnessModels(harnessId, stdout)` + `HARNESS_MODEL_PARSER_IDS` (OpenCode's `provider/model` lines and Grok's bulleted list are parsed here; Antigravity and Cursor DELEGATE to `antigravity.js#parseAntigravityModelList` / `aiToolkit/internal/cursor.js#parseCursorModelList`, which the provider-card refresh has used for far longer), `MAX_MODELS`, and `parseNpmLatestVersion`. Pure: the service layer runs the child and hands the captured stdout here, so the vendor output shapes are pinned by table-driven tests instead of by running six real binaries in CI. Model ids come back in the exact spelling `--model` takes — namespaces kept where the vendor keeps them. Consumed by `services/providerRuntimeInstaller.js` and `services/harnesses.js`. |-| `providerGateways.js` | `PROVIDER_GATEWAYS` — one row per hosted OpenAI-compatible gateway an OpenCode CLI/TUI wrapper can front-end (`orcarouter`, `openrouter`), plus `PROVIDER_GATEWAY_IDS`, `gatewayById`, `isGatewayNamespace(ns)`, `gatewayForProvider(config)` → row or null, and `isGatewayBackedProvider(config)`. Each row's `id` is simultaneously the OpenCode provider namespace, the `gatewayBacked` marker value, and the id of the sibling `api` record that owns the key — so the sibling lookup is `providers[gateway.id]` and an OrcaRouter key can never satisfy an OpenRouter wrapper. Replaces the `orcarouterBacked` boolean + literal `'orcarouter'` that had been hand-copied across ~15 server and client files (namespace resolution, the OpenCode config builder, both zod schemas, the model-fetcher table, the sibling-key attach, the prerequisite check, and the two "not a local runtime" carve-outs in `cliChildEnv.js`/`localProviderRuntime.js`). Reads the legacy per-gateway boolean FOREVER, so stored records are never rewritten. Distinct from a local runtime (`ollamaBacked`, `vllmBacked`, …): remote, always authenticating, and no thinking toggle. Deliberately mirrored in `aiToolkit/internal/gateways.js` (the vendored toolkit may not import out) — `providerGateways.parity.test.js` fails when the two drift; `client/src/utils/providerGateways.js` re-exports this leaf rather than copying it. Dependency-light: imports nothing. |+| `providerGateways.js` | `PROVIDER_GATEWAYS` — one row per hosted OpenAI-compatible gateway an OpenCode CLI/TUI wrapper can front-end (`orcarouter`, `openrouter`, `nvidia-nim`), plus `PROVIDER_GATEWAY_IDS`, `gatewayById`, `isGatewayNamespace(ns)`, `gatewayForProvider(config)` → row or null, and `isGatewayBackedProvider(config)`. Each row's `id` is simultaneously the OpenCode provider namespace, the `gatewayBacked` marker value, and the id of the sibling `api` record that owns the key — so the sibling lookup is `providers[gateway.id]` and an OrcaRouter key can never satisfy an OpenRouter wrapper. Replaces the `orcarouterBacked` boolean + literal `'orcarouter'` that had been hand-copied across ~15 server and client files (namespace resolution, the OpenCode config builder, both zod schemas, the model-fetcher table, the sibling-key attach, the prerequisite check, and the two "not a local runtime" carve-outs in `cliChildEnv.js`/`localProviderRuntime.js`). Reads the legacy per-gateway boolean FOREVER, so stored records are never rewritten. Distinct from a local runtime (`ollamaBacked`, `vllmBacked`, …): remote, always authenticating, and no thinking toggle. Deliberately mirrored in `aiToolkit/internal/gateways.js` (the vendored toolkit may not import out) — `providerGateways.parity.test.js` fails when the two drift; `client/src/utils/providerGateways.js` re-exports this leaf rather than copying it. Dependency-light: imports nothing. || `providerHarnesses.js` | Provider HARNESS identity for the connection graph (#6366) — `PROVIDER_HARNESSES` (one row per agent program PortOS drives: claude/opencode/codex/antigravity/cursor/grok/kimi/pi, each with its supported `modes`, wire `protocol` and the existing `is*Provider` predicate as its matcher), `PROVIDER_HARNESS_IDS`, `harnessById`, `harnessForProvider` (null for an `api` record AND for an unknown harness — use `providerRouteMode` to tell them apart), `harnessSupportsMode`, `ROUTE_MODES`, plus the model-name adapters `toExecutableModelName` / `toCanonicalModelName` (the verified inverse of `prefixOpencodeModel`: a stored alias is canonicalized only when it maps back to the exact stored string, so import never rewrites a saved model by heuristically stripping a prefix). Distinct from `providerVendors.js` (argv-shaped), `providerFamilies.js` (subscription quota) and `providerGateways.js` (hosted backend). Pure leaf — `client/src/utils/providerHarnesses.js` names a binding's harness through `harnessById`. || `providerContextWindows.js` | The context-window ladder for provider/model planning, split out of `services/stageRunner.js` so the browser shares it: the vendor constants (`DEFAULT_LARGE_CONTEXT_WINDOW` / `CODEX_CONTEXT_WINDOW` / `GEMINI_CONTEXT_WINDOW` / `GROK_CONTEXT_WINDOW` / `KIMI_CONTEXT_WINDOW`), `knownModelContextWindow(model)` (the known-model regex table), `knownProviderContextWindow(provider)` (the vendor window for a configured-default CLI/TUI provider) and `catalogModelContextWindow(provider, model)` (the window the provider's own `/models` catalog reported, which outranks the table). `stageRunner.js` builds `effectiveContextWindow` on them; `client/src/utils/providerContextWindows.js` re-exports them for the provider-card budget meter, so the two ends can't resolve a different window. Pure. || `providerConnections.js` | Provider CONNECTION identity for the connection graph (#6366) — `providerConnectionProfile(provider)` reads one record as the backend it describes (`kind`, `protocol`, `transports`, RAW server-only `credentials`, the `owned` field/env split, and `reasons` from `CONNECTION_ISOLATION_REASONS` when the config is dynamic, external, unparsable or endpoint-less). `sameConnectionIdentity` compares real credential values and refuses once any is the `REDACTED_CREDENTIAL` sentinel, so a sanitized record can never merge two connections; `compareBackendEndpoints` is the looser same-daemon test that only ever produces a link SUGGESTION, applying the recognized OpenAI-compatible `/v1` conversion (never DNS resolution, loopback/remote equivalence or arbitrary path trimming). `projectConnectionOwnedFields(provider, connection)` projects a stored backend through the reader's protocol and env-ownership rules for the graph service; `withoutConnectionOwnedFields` / `withConnectionOwnedFields` are the lossless split/materialize pair that keeps a downgraded install runnable from `data/providers.json` alone. Pure: no I/O. |diff --git a/server/lib/aiToolkit/defaults/providers.sample.json b/server/lib/aiToolkit/defaults/providers.sample.jsonindex 37f1294d5a..81d0626cce 100644--- a/server/lib/aiToolkit/defaults/providers.sample.json+++ b/server/lib/aiToolkit/defaults/providers.sample.json@@ -457,6 +457,59 @@"tuiPromptDelayMs": 2500,"tuiIdleTimeoutMs": 180000},+ "nvidia-nim": {+ "id": "nvidia-nim",+ "name": "NVIDIA NIM",+ "type": "api",+ "endpoint": "https://integrate.api.nvidia.com/v1",+ "apiKey": "",+ "models": ["google/gemma-4-31b-it", "poolside/laguna-xs-2.1"],+ "defaultModel": "poolside/laguna-xs-2.1",+ "lightModel": "google/gemma-4-31b-it",+ "mediumModel": "poolside/laguna-xs-2.1",+ "heavyModel": "poolside/laguna-xs-2.1",+ "timeout": 300000,+ "enabled": false,+ "envVars": {},+ "secretEnvVars": []+ },+ "opencode-nvidia-nim": {+ "id": "opencode-nvidia-nim",+ "name": "OpenCode NVIDIA NIM",+ "type": "cli",+ "command": "opencode",+ "args": ["run"],+ "endpoint": "https://integrate.api.nvidia.com/v1",+ "models": ["google/gemma-4-31b-it", "poolside/laguna-xs-2.1"],+ "defaultModel": "poolside/laguna-xs-2.1",+ "gatewayBacked": "nvidia-nim",+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"allow\",\"provider\":{\"nvidia-nim\":{\"npm\":\"@ai-sdk/openai-compatible\",\"name\":\"NVIDIA NIM\",\"options\":{\"baseURL\":\"https://integrate.api.nvidia.com/v1\"}}}}"+ },+ "secretEnvVars": [],+ "headlessArgs": []+ },+ "opencode-nvidia-nim-tui": {+ "id": "opencode-nvidia-nim-tui",+ "name": "OpenCode NVIDIA NIM TUI",+ "type": "tui",+ "command": "opencode",+ "args": [],+ "endpoint": "https://integrate.api.nvidia.com/v1",+ "models": ["google/gemma-4-31b-it", "poolside/laguna-xs-2.1"],+ "defaultModel": "poolside/laguna-xs-2.1",+ "gatewayBacked": "nvidia-nim",+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"allow\",\"provider\":{\"nvidia-nim\":{\"npm\":\"@ai-sdk/openai-compatible\",\"name\":\"NVIDIA NIM\",\"options\":{\"baseURL\":\"https://integrate.api.nvidia.com/v1\"}}}}"+ },+ "secretEnvVars": [],+ "tuiPromptDelayMs": 2500,+ "tuiIdleTimeoutMs": 180000+ },"opencode-orcarouter-tui": {"id": "opencode-orcarouter-tui","name": "OpenCode OrcaRouter TUI",diff --git a/server/lib/aiToolkit/defaults/providersSeedParity.test.js b/server/lib/aiToolkit/defaults/providersSeedParity.test.jsindex 0c0000c7ec..addb67368f 100644--- a/server/lib/aiToolkit/defaults/providersSeedParity.test.js+++ b/server/lib/aiToolkit/defaults/providersSeedParity.test.js@@ -3,7 +3,7 @@* data.reference/providers.json (PortOS's own install seed)* server/lib/aiToolkit/defaults/providers.sample.json (the toolkit's fallback seed)*- * Both files describe the same 23 providers, and `loadProviders()` falls+ * Both files describe the same providers, and `loadProviders()` falls* through to the toolkit sample when the install seed is absent — so a model* bump that updates one and not the other silently gives some fresh installs a* stale tier. That failure then compounds: the provider-bump migrationsdiff --git a/server/lib/aiToolkit/endpointGuard.js b/server/lib/aiToolkit/endpointGuard.jsindex 7a9bd80213..d9499c1b33 100644--- a/server/lib/aiToolkit/endpointGuard.js+++ b/server/lib/aiToolkit/endpointGuard.js@@ -67,7 +67,7 @@ const ALLOWED_PROVIDER_HOSTS = new Set(['api.fireworks.ai','api.cerebras.ai','api.orcarouter.ai',- 'integrate.api.nvidia.com', // NVIDIA NIM (bundled `nvidia-kimi` provider)+ 'integrate.api.nvidia.com', // NVIDIA NIM (bundled `nvidia-nim` / `nvidia-kimi` providers)]);const IPV4_RE = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;diff --git a/server/lib/aiToolkit/internal/gateways.js b/server/lib/aiToolkit/internal/gateways.jsindex a44e6e18be..2413ceb0b8 100644--- a/server/lib/aiToolkit/internal/gateways.js+++ b/server/lib/aiToolkit/internal/gateways.js@@ -1,6 +1,6 @@/*** Hosted OpenAI-compatible gateways an OpenCode CLI/TUI wrapper can front-end- * (OrcaRouter, OpenRouter).+ * (OrcaRouter, OpenRouter, NVIDIA NIM).** A DELIBERATE MIRROR of `server/lib/providerGateways.js`. This directory is* vendored and stays self-contained — no imports out to other PortOS modules@@ -35,6 +35,12 @@ export const PROVIDER_GATEWAYS = Object.freeze([baseURL: 'https://openrouter.ai/api/v1',apiKeyEnv: 'OPENROUTER_API_KEY',}),+ Object.freeze({+ id: 'nvidia-nim',+ label: 'NVIDIA NIM',+ baseURL: 'https://integrate.api.nvidia.com/v1',+ apiKeyEnv: 'NVIDIA_API_KEY',+ }),]);/** Every gateway id. */diff --git a/server/lib/aiToolkit/internal/modelFetchers.js b/server/lib/aiToolkit/internal/modelFetchers.jsindex 9c83a20f59..a69fceec3f 100644--- a/server/lib/aiToolkit/internal/modelFetchers.js+++ b/server/lib/aiToolkit/internal/modelFetchers.js@@ -115,7 +115,7 @@ export const MODEL_FETCHERS = [},{key: 'gateway',- // A gateway-backed OpenCode wrapper (OrcaRouter, OpenRouter — see+ // A gateway-backed OpenCode wrapper (OrcaRouter, OpenRouter, NVIDIA NIM — see// ./gateways.js) probes its sibling API provider's OpenAI-compatible// `/models` endpoint, never `opencode models`. ONE row for every gateway:// they differ only in base URL and key, which the provider record carries.diff --git a/server/lib/aiToolkit/internal/modelFetchers.test.js b/server/lib/aiToolkit/internal/modelFetchers.test.jsindex a6189af874..fe7a4817f2 100644--- a/server/lib/aiToolkit/internal/modelFetchers.test.js+++ b/server/lib/aiToolkit/internal/modelFetchers.test.js@@ -18,7 +18,7 @@ const SHIPPED_REFRESHABLE = ['pi-cli', 'pi-tui','antigravity-cli', 'antigravity-tui', 'cerebras', 'claude-code','claude-code-bedrock', 'claude-ollama', 'claude-ollama-tui', 'cursor-cli',- 'cursor-tui', 'grok', 'lmstudio', 'mtplx', 'nvidia-kimi', 'ollama',+ 'cursor-tui', 'grok', 'lmstudio', 'mtplx', 'nvidia-kimi', 'nvidia-nim', 'ollama','slotstream','opencode-llama-tui','opencode-mtplx', 'opencode-mtplx-tui', 'opencode-ollama', 'opencode-ollama-tui',@@ -26,6 +26,7 @@ const SHIPPED_REFRESHABLE = [// Every hosted gateway refreshes through the same sibling `/models` probe —// one MODEL_FETCHERS row covers all of them (internal/gateways.js).'opencode-openrouter', 'opencode-openrouter-tui', 'openrouter',+ 'opencode-nvidia-nim', 'opencode-nvidia-nim-tui','codex', 'codex-tui',// The local-backed Codex wrapper resolves through the OLLAMA row, not codex's:// `ollamaBacked` sits in the first pass, and the tool-capable local catalog isdiff --git a/server/lib/aiToolkit/validation.js b/server/lib/aiToolkit/validation.jsindex d586db3a65..2aa74d6bf6 100644--- a/server/lib/aiToolkit/validation.js+++ b/server/lib/aiToolkit/validation.js@@ -173,7 +173,7 @@ export const providerSchema = z.object({// parser, and an API key that is optional rather than required.sglangBacked: z.boolean().optional(),// Marks an OpenCode CLI/TUI wrapper for a hosted OpenAI-compatible gateway- // ('orcarouter', 'openrouter' — see internal/gateways.js). Its API key is read+ // ('orcarouter', 'openrouter', 'nvidia-nim' — see internal/gateways.js). Its API key is read// from the sibling API record of the SAME id at spawn/refresh time and is// never stored in this wrapper's config.gatewayBacked: z.string().optional(),diff --git a/server/lib/comparisonModelScope.test.js b/server/lib/comparisonModelScope.test.jsindex da0bd1ac55..3e3a5d9df6 100644--- a/server/lib/comparisonModelScope.test.js+++ b/server/lib/comparisonModelScope.test.js@@ -10,6 +10,8 @@ describe('catalogSlugForProviderModel', () => {expect(catalogSlugForProviderModel('us.anthropic.claude-sonnet-5')).toBe('claude-sonnet-5');expect(catalogSlugForProviderModel('global.anthropic.claude-opus-5[1m]')).toBe('claude-opus-5');expect(catalogSlugForProviderModel('moonshotai/kimi-k2.5')).toBe('kimi-k2.5');+ expect(catalogSlugForProviderModel('google/gemma-4-31b-it')).toBe('gemma-4-31b-it');+ expect(catalogSlugForProviderModel('nvidia-nim/poolside/laguna-xs-2.1')).toBe('laguna-xs-2.1');expect(catalogSlugForProviderModel('opencode/muse-spark-1.3-contributor-free')).toBe('muse-spark-1.3');});diff --git a/server/lib/providerGateways.js b/server/lib/providerGateways.jsindex cae22d5b88..3557737056 100644--- a/server/lib/providerGateways.js+++ b/server/lib/providerGateways.js@@ -1,6 +1,6 @@/*** `PROVIDER_GATEWAYS` — one row per hosted OpenAI-compatible gateway an OpenCode- * CLI/TUI wrapper can front-end (OrcaRouter, OpenRouter).+ * CLI/TUI wrapper can front-end (OrcaRouter, OpenRouter, NVIDIA NIM).** Before this file, OrcaRouter wasn't *a* gateway — it was *the* gateway: the* boolean `orcarouterBacked` and the literal id `'orcarouter'` were hand-copied@@ -65,6 +65,12 @@ export const PROVIDER_GATEWAYS = Object.freeze([baseURL: 'https://openrouter.ai/api/v1',apiKeyEnv: 'OPENROUTER_API_KEY',}),+ Object.freeze({+ id: 'nvidia-nim',+ label: 'NVIDIA NIM',+ baseURL: 'https://integrate.api.nvidia.com/v1',+ apiKeyEnv: 'NVIDIA_API_KEY',+ }),]);/** Every gateway id — the namespace key space `opencodeConfig.js` extends. */diff --git a/server/lib/providerGateways.parity.test.js b/server/lib/providerGateways.parity.test.jsindex c416c6ccea..19afd42ed4 100644--- a/server/lib/providerGateways.parity.test.js+++ b/server/lib/providerGateways.parity.test.js@@ -24,6 +24,7 @@ describe('providerGateways ↔ aiToolkit/internal/gateways parity', () => {const records = [{ gatewayBacked: 'openrouter' },{ gatewayBacked: 'orcarouter' },+ { gatewayBacked: 'nvidia-nim' },{ orcarouterBacked: true },{ ollamaBacked: true },{ gatewayBacked: 'not-a-gateway' },diff --git a/server/lib/providerGateways.test.js b/server/lib/providerGateways.test.jsindex a2ea558dd2..6912ade404 100644--- a/server/lib/providerGateways.test.js+++ b/server/lib/providerGateways.test.js@@ -10,8 +10,8 @@ import {import { getOpencodeLocalProviderNamespace, prefixOpencodeModel } from './providerModels.js';describe('providerGateways', () => {- it('ships both gateways with a complete row', () => {- expect(PROVIDER_GATEWAY_IDS).toEqual(['orcarouter', 'openrouter']);+ it('ships every gateway with a complete row', () => {+ expect(PROVIDER_GATEWAY_IDS).toEqual(['orcarouter', 'openrouter', 'nvidia-nim']);for (const gateway of PROVIDER_GATEWAYS) {expect(gateway.label).toBeTruthy();expect(gateway.baseURL).toMatch(/^https:\/\//);@@ -22,6 +22,7 @@ describe('providerGateways', () => {it('resolves the generic gatewayBacked marker', () => {expect(gatewayIdForProvider({ gatewayBacked: 'openrouter' })).toBe('openrouter');expect(gatewayIdForProvider({ gatewayBacked: 'orcarouter' })).toBe('orcarouter');+ expect(gatewayIdForProvider({ gatewayBacked: 'nvidia-nim' })).toBe('nvidia-nim');});// Records written before the registry existed carry the per-gateway boolean.@@ -49,6 +50,7 @@ describe('providerGateways', () => {it('classifies namespaces', () => {expect(isGatewayNamespace('openrouter')).toBe(true);expect(isGatewayNamespace('orcarouter')).toBe(true);+ expect(isGatewayNamespace('nvidia-nim')).toBe(true);expect(isGatewayNamespace('ollama')).toBe(false);expect(isGatewayNamespace(null)).toBe(false);});@@ -81,6 +83,18 @@ describe('prefixOpencodeModel — gateway namespacing', () => {expect(prefixOpencodeModel(orcarouter, 'orcarouter/auto')).toBe('orcarouter/orcarouter/auto');});+ // NVIDIA NIM ids are already `vendor/model`. OpenCode still splits on the+ // first slash, so the stored id stays bare and spawn prefixes the gateway.+ it('namespaces a vendor-qualified NVIDIA NIM id', () => {+ const nim = { command: 'opencode', gatewayBacked: 'nvidia-nim' };+ expect(prefixOpencodeModel(nim, 'google/gemma-4-31b-it'))+ .toBe('nvidia-nim/google/gemma-4-31b-it');+ expect(prefixOpencodeModel(nim, 'poolside/laguna-xs-2.1'))+ .toBe('nvidia-nim/poolside/laguna-xs-2.1');+ expect(prefixOpencodeModel(nim, 'nvidia-nim/nvidia-nim/google/gemma-4-31b-it'))+ .toBe('nvidia-nim/nvidia-nim/google/gemma-4-31b-it');+ });+// A local runtime keeps the single-prefix rule — its stored ids are bare.it('leaves local-runtime namespacing single-prefixed', () => {const ollama = { command: 'opencode', ollamaBacked: true };diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 2927071865..b9a34566cc 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -535,7 +535,7 @@ export const providerSchema = z.object({// container (Qwen3.8-27B on a Hopper/Blackwell card).sglangBacked: z.boolean().optional(),// Marks an OpenCode CLI/TUI wrapper for a hosted OpenAI-compatible gateway- // ('orcarouter', 'openrouter' — see server/lib/providerGateways.js). The+ // ('orcarouter', 'openrouter', 'nvidia-nim' — see server/lib/providerGateways.js). The// sibling API record whose id equals this value owns the key.gatewayBacked: z.string().optional(),// Legacy per-gateway marker, superseded by `gatewayBacked`. Still accepted and