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
stop probing this machine when a provider points at another machine's server
Adam Eivy43fb519e3e77
diff --git a/client/src/components/providers/ProviderCard.jsx b/client/src/components/providers/ProviderCard.jsxindex 3733817db3..ba71d393e4 100644--- a/client/src/components/providers/ProviderCard.jsx+++ b/client/src/components/providers/ProviderCard.jsx@@ -16,8 +16,8 @@ import {effectiveModelContextWindow,isApiProvider,isGrokBuildCli,- isLocalEndpoint,isOrcaRouterBackedProvider,+ isPrivateNetworkEndpoint,isProcessProvider,isRunnerAllowedCommand,isTuiProvider,@@ -205,8 +205,13 @@ export default function ProviderCard({{isApiProvider(provider) && (provider.hasApiKey ? (<p className="text-xs">API key: <span className="text-port-success">set</span></p>- ) : isLocalEndpoint(provider.endpoint) ? (- <p className="text-xs">API key: <span className="text-gray-500">none (local endpoint)</span></p>+ ) : isPrivateNetworkEndpoint(provider.endpoint) ? (+ /* Same rule as `providerCardState`'s apiKey prerequisite — a+ keyless call to a private OpenAI-compatible server (loopback,+ the LAN box, a tailnet peer) is a supported setup, so the two+ must not disagree: a card badged READY used to carry an+ orange "API key: not set" line for exactly those endpoints. */+ <p className="text-xs">API key: <span className="text-gray-500">none (private network endpoint)</span></p>) : (<p className="text-xs">API key: <span className="text-port-warning">not set — Edit this provider to paste one</span></p>)diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsxindex 5054f2f957..376e4e77fa 100644--- a/client/src/pages/AIProviders.jsx+++ b/client/src/pages/AIProviders.jsx@@ -4,7 +4,7 @@ import { AlertTriangle } from 'lucide-react';import toast from '../components/ui/Toast';import * as api from '../services/api';import socket from '../services/socket';-import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, configuredDefaultIn, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, isGrokBuildCli, isLocalEndpoint, effectiveModelContextWindow, isRunnerAllowedCommand, effortLevelsForProvider, isOllamaBackedProvider, isOrcaRouterBackedProvider, providerRuntimeKey, providerCardState, PROVIDER_CARD_STATE } from '../utils/providers';+import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, configuredDefaultIn, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, isGrokBuildCli, isLocalEndpoint, isLocalInstanceProvider, effectiveModelContextWindow, isRunnerAllowedCommand, effortLevelsForProvider, isOllamaBackedProvider, isOrcaRouterBackedProvider, providerRuntimeKey, providerCardState, PROVIDER_CARD_STATE } from '../utils/providers';import useLocalModels from '../hooks/useLocalModels';import { useAutoRefetch } from '../hooks/useAutoRefetch';import BrailleSpinner from '../components/BrailleSpinner';@@ -333,8 +333,15 @@ export default function AIProviders() {// The install widget's data for one card: a CLI provider's binary comes from// the server's runtime table; an API provider fronted by a local app takes the// local-LLM status, which counts an installed app with no CLI shim on PATH.+ //+ // Only when the endpoint is on THIS machine: `localBackendForProvider` matches+ // by name and port, so an API provider pointed at another box's LM Studio also+ // resolves to `lmstudio` — and reporting this host's install state for it says+ // nothing true about that server, which is somebody else's to run.const runtimeForProvider = useCallback((provider) => {- const backend = isApiProvider(provider) ? localBackendForProvider(provider) : null;+ const backend = isApiProvider(provider) && isLocalInstanceProvider(provider)+ ? localBackendForProvider(provider)+ : null;if (!backend) return runtimes[providerRuntimeKey(provider)] || null;// The readiness checklist covers this same backend in more detail, and knows// the difference between "not installed" and "installed but not started".diff --git a/client/src/pages/AIProviders.test.jsx b/client/src/pages/AIProviders.test.jsxindex 1f44d35261..d8e71a98bf 100644--- a/client/src/pages/AIProviders.test.jsx+++ b/client/src/pages/AIProviders.test.jsx@@ -298,6 +298,64 @@ describe('local-daemon readiness on the provider card', () => {});});+describe('an API provider pointed at another machine', () => {+ // `localBackendForProvider` matches by NAME and port, so a provider named+ // "LM Studio <peer>" resolved to the `lmstudio` backend and collected THIS+ // host's install state — a card badged READY carried "LM Studio not+ // installed / Install LM Studio" for a server running on someone else's box.+ beforeEach(() => {+ vi.clearAllMocks();+ api.getApps.mockResolvedValue([]);+ api.getProviderStatuses.mockResolvedValue({ providers: {} });+ api.getProviderRuntimes.mockResolvedValue({ runtimes: {} });+ api.getProviderReadiness.mockResolvedValue({ readiness: {} });+ // LM Studio is genuinely absent from THIS machine.+ localModels.value = { ctxById: {}, installed: { ollama: false, lmstudio: false } };+ api.getProviders.mockResolvedValue({+ providers: [{+ id: 'lmstudio-peer',+ name: 'LM Studio peer',+ type: 'api',+ enabled: true,+ endpoint: 'http://192.168.1.50:1234/v1',+ models: ['qwen/qwen3.5-35b-a3b'],+ defaultModel: 'qwen/qwen3.5-35b-a3b',+ }],+ activeProvider: null,+ });+ });++ it('offers no local install for it, and does not demand an API key', async () => {+ renderPage();++ expect(await screen.findByText('LM Studio peer')).toBeInTheDocument();+ expect(screen.queryByText(/LM Studio not installed/)).not.toBeInTheDocument();+ expect(screen.queryByText(/Install LM Studio/)).not.toBeInTheDocument();+ // A keyless call to a private-network endpoint is a supported setup, so the+ // card must not contradict the READY badge it is wearing.+ expect(screen.getByText(/none \(private network endpoint\)/)).toBeInTheDocument();+ expect(screen.queryByText(/not set — Edit this provider/)).not.toBeInTheDocument();+ });++ it('still offers the local install for the same backend on THIS machine', async () => {+ api.getProviders.mockResolvedValue({+ providers: [{+ id: 'lmstudio',+ name: 'LM Studio',+ type: 'api',+ enabled: true,+ endpoint: 'http://localhost:1234/v1',+ models: [],+ }],+ activeProvider: null,+ });++ renderPage();++ expect(await screen.findByText(/LM Studio not installed/)).toBeInTheDocument();+ });+});+describe('handleAddSample error handling', () => {beforeEach(() => {vi.clearAllMocks();diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex fbbc4c6d20..5ac4219810 100644--- a/client/src/utils/README.md+++ b/client/src/utils/README.md@@ -41,7 +41,7 @@ grep -i "what you want to do" client/src/utils/README.md| `urlNormalize` | `isUrl` detection, `normalizeUrl` (optional git/`requireDot` modes), `isHttpUrl` (explicit http(s) only — safe-href check), and `tiktokVideoId` / `tiktokEmbedSrc` (host-anchored TikTok video-id extraction + its Embed Player URL, so a reference embeds without loading TikTok's embed.js). || `platform` | `isMac` detection and `modKey` (⌘/Ctrl) for keyboard-shortcut display. || `navWorkingSet` | Recent/pinned nav persistence (`recordVisit`, `togglePin`, `isPinned`) plus `resolveRecentNavEntries` for mapping stored deep links back to their longest matching nav-manifest entry. |-| `providers` | AI-provider type predicates and helpers (`isCliProvider`, `isApiProvider`, `isCodexProvider`, `isAntigravityProvider`, `isOrcaRouterBackedProvider` (the OpenCode wrapper that inherits its API key from the sibling `orcarouter` API provider at spawn time), `filterSelectableModels`, `resolveCliEffort` (mirror — what a stored effort actually runs as, so the picker can name a clamped level), `configuredDefaultIn` — the sentinel a provider's catalog carries, so a picker can render an option matching a sentinel-valued tier instead of a blank select — `getProviderTimeout`, `resolveEffectiveProvider` — the provider a record actually runs on (its pin, else the active provider) plus whether it fell back, so a "Default" option can name what it resolves to — `resolveSeriesRunLlm` (mirror of server `seriesLlmOverride.js`: which provider/model a Pipeline **series** run resolves to — per-run override → `series.llm` → active provider) and `providerModelLabel` (the one "Provider / model" phrasing), configured-default sentinels, and the claude/codex/agy thinking-effort levels — `effortLevelsForProvider`, mirror of server `providerModels.js`). Also `isRunnerAllowedCommand(command, allowedCommands)` — would the CoS Agent Runner (`/spawn`, `/spawn-tui`) accept this command? Mirrors only the *normalization* in `server/cos-runner/allowedCommands.js` (the list itself arrives as `runnerAllowedCommands` on `GET /api/providers`, because the allowlist is an exec boundary and stays hand-curated server-side); returns `null` for "list not fetched / field blank" so a failed fetch never renders a warning. Pinned by `server/cos-runner/allowedCommands.parity.test.js`. `isPrivateNetworkEndpoint(endpoint)` — loopback, RFC1918/tailnet address, or a `.local`/`.ts.net`/single-label host, i.e. somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key. And `providerCardState(provider, { runtime, status, orcaRouterKeySet })` + `PROVIDER_CARD_STATE` — is a provider ready to run, benched, blocked on a missing prerequisite (CLI not installed / API key absent), or simply switched off? Presentation-only (the server routes on `enabled && available` alone); `null` inputs mean "not probed", never "missing". Drives the AI Providers page card colors and grouping — distinct from `ProviderReadiness`/`GET /api/providers/readiness`, which probes the local daemon behind a provider. And `providerRuntimeKey(provider)` — the key a provider's runtime is published under by `GET /api/providers/runtimes`, so a card can show its CLI install status (bare binary name for a cli/tui provider, provider id for an API provider fronted by a local app); the runtime table itself stays server-side. |+| `providers` | AI-provider type predicates and helpers (`isCliProvider`, `isApiProvider`, `isCodexProvider`, `isAntigravityProvider`, `isOrcaRouterBackedProvider` (the OpenCode wrapper that inherits its API key from the sibling `orcarouter` API provider at spawn time), `filterSelectableModels`, `resolveCliEffort` (mirror — what a stored effort actually runs as, so the picker can name a clamped level), `configuredDefaultIn` — the sentinel a provider's catalog carries, so a picker can render an option matching a sentinel-valued tier instead of a blank select — `getProviderTimeout`, `resolveEffectiveProvider` — the provider a record actually runs on (its pin, else the active provider) plus whether it fell back, so a "Default" option can name what it resolves to — `resolveSeriesRunLlm` (mirror of server `seriesLlmOverride.js`: which provider/model a Pipeline **series** run resolves to — per-run override → `series.llm` → active provider) and `providerModelLabel` (the one "Provider / model" phrasing), configured-default sentinels, and the claude/codex/agy thinking-effort levels — `effortLevelsForProvider`, mirror of server `providerModels.js`). Also `isRunnerAllowedCommand(command, allowedCommands)` — would the CoS Agent Runner (`/spawn`, `/spawn-tui`) accept this command? Mirrors only the *normalization* in `server/cos-runner/allowedCommands.js` (the list itself arrives as `runnerAllowedCommands` on `GET /api/providers`, because the allowlist is an exec boundary and stays hand-curated server-side); returns `null` for "list not fetched / field blank" so a failed fetch never renders a warning. Pinned by `server/cos-runner/allowedCommands.parity.test.js`. `isPrivateNetworkEndpoint(endpoint)` — loopback, RFC1918/tailnet address, or a `.local`/`.ts.net`/single-label host, i.e. somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key. `isLocalInstanceProvider(provider)` — the narrower question, mirroring server `localProviderRuntime.js#isLocalInstanceEndpoint`: does this provider talk to a daemon on THIS machine (loopback, or no endpoint at all)? Gate anything that explains a provider by inspecting the host PortOS runs on — install state, "start it from Settings → Local LLM" — since `localBackendForProvider` matches by NAME and would otherwise claim a peer's LM Studio. And `providerCardState(provider, { runtime, status, orcaRouterKeySet })` + `PROVIDER_CARD_STATE` — is a provider ready to run, benched, blocked on a missing prerequisite (CLI not installed / API key absent), or simply switched off? Presentation-only (the server routes on `enabled && available` alone); `null` inputs mean "not probed", never "missing". Drives the AI Providers page card colors and grouping — distinct from `ProviderReadiness`/`GET /api/providers/readiness`, which probes the local daemon behind a provider. And `providerRuntimeKey(provider)` — the key a provider's runtime is published under by `GET /api/providers/runtimes`, so a card can show its CLI install status (bare binary name for a cli/tui provider, provider id for an API provider fronted by a local app); the runtime table itself stays server-side. || `layeredIntelligenceReasons` | Canonical gloss for the Layered Intelligence loop's run-outcome reason tokens, shared by the on-demand toast and the durable "Last run" line (`formatLiReason`, `liReasonTone`, `LI_NEUTRAL_REASONS`). |## Module loading / resiliencediff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex 4132a0a351..aa5da2816c 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -722,6 +722,29 @@ export const isPrivateNetworkEndpoint = (endpoint) => {return !host.includes('.') && !host.includes(':');};+/**+ * Does this provider talk to a daemon on THIS machine?+ *+ * Client mirror of `isLocalInstanceEndpoint` in+ * server/lib/localProviderRuntime.js, and the guard for anything that explains+ * a provider by inspecting the machine PortOS runs on — "is `lms` installed+ * here?", "start it from Settings → Local LLM". A provider named for LM Studio+ * but pointed at another box on the tailnet matches+ * {@link localBackendForProvider} by NAME, so without this it collected this+ * machine's install state and offered to start a server it does not own.+ *+ * A blank endpoint reads as local, unlike the server's copy: the record simply+ * hasn't named one, and every default it can fall back to is a loopback URL.+ *+ * @param {{endpoint?:string}} provider+ * @returns {boolean}+ */+export const isLocalInstanceProvider = (provider) => {+ const endpoint = provider?.endpoint;+ if (typeof endpoint !== 'string' || endpoint.trim() === '') return true;+ return isLocalEndpoint(endpoint);+};+export const isLikelyLargeContextProvider = (provider) => {if (isProcessProvider(provider)) return true;return isApiProvider(provider) && !isLocalEndpoint(provider.endpoint);diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex d9daa352f5..67e76f12fc 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -52,6 +52,7 @@ import {isConfiguredDefaultModel,configuredDefaultIn,isLocalEndpoint,+ isLocalInstanceProvider,enabledApiProviderFilter,providerTypeClass,getProviderTimeout,@@ -494,6 +495,24 @@ describe('isLocalEndpoint', () => {});});+describe('isLocalInstanceProvider', () => {+ it('accepts a loopback endpoint and a record that names none', () => {+ expect(isLocalInstanceProvider({ endpoint: 'http://localhost:1234/v1' })).toBe(true);+ expect(isLocalInstanceProvider({ endpoint: 'http://127.0.0.1:11434' })).toBe(true);+ // No endpoint = the stock local default every backend manager targets.+ expect(isLocalInstanceProvider({ id: 'lmstudio' })).toBe(true);+ expect(isLocalInstanceProvider({ endpoint: ' ' })).toBe(true);+ });++ it('rejects another machine, however local the provider is NAMED', () => {+ // This is the case that put "Install LM Studio" on a card for a server+ // running on a different box.+ expect(isLocalInstanceProvider({ name: 'LM Studio peer', endpoint: 'http://192.168.1.50:1234/v1' })).toBe(false);+ expect(isLocalInstanceProvider({ id: 'ollama', endpoint: 'http://10.0.0.4:11434/v1' })).toBe(false);+ expect(isLocalInstanceProvider({ endpoint: 'https://api.openai.com/v1' })).toBe(false);+ });+});+describe('isGrokBuildCli', () => {it('matches the shipped grok-cli / grok-tui samples', () => {expect(isGrokBuildCli({ id: 'grok-cli', type: 'cli', command: 'grok' })).toBe(true);diff --git a/server/lib/README.md b/server/lib/README.mdindex 696268f626..c33068d7b4 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -132,7 +132,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, matches }` for claude/codex/agy/grok), `PROVIDER_FAMILY_IDS`, `familyLabel`, `familyForProvider(config)` → family id or null (local-runtime wrappers and API-only providers belong to none). The pure half of the registry `services/providerUsage.js` attaches quota `fetch`ers to, so cost attribution and route validation can ask "which plan is this provider on?" without importing the PTY-scrape graph. Distinct from `providerVendors.js`, which is argv-shaped and includes vendors with no subscription quota. || `providerTranscriptUsage.js` | Parsers for the real per-message token counts the coding CLIs write to disk (0 tokens to read) — `parseClaudeTranscript` (`~/.claude/projects/<cwd-slug>/*.jsonl`), `parseCodexRollout` (`~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl`), `claudeProjectSlug`, `totalTranscriptTokens`. Both de-duplicate a format hazard that otherwise inflates counts badly: Claude repeats one response across several lines sharing a `message.id`, and Codex's `total_token_usage` is cumulative and repeated. Each parser returns per-model buckets (`byModel`) plus the message keys it counted (`countedKeys`), and accepts an `exclude` set — that is what stops two overlapping PortOS runs from both billing the same messages. Tolerant of truncated (mid-write) files; consumed by `services/usageReconciler.js`. || `opencodeConfig.js` | OpenCode config builder — `buildOpencodeEnvVars(provider, model)` builds dynamic `OPENCODE_CONFIG_CONTENT` declaring bare model ids under the selected local provider (`ollama` or `mtplx`) for marked OpenCode providers. Fixes --model rejection. |-| `localProviderRuntime.js` | Which LOCAL daemon a provider talks to, and where — `LOCAL_RUNTIMES` (llama.cpp / Ollama / LM Studio / MTPLX: label, binary, canonical base URL read from `opencodeConfig.js` rather than re-typed, manage/docs links, model-download hint), `localBackendForProvider` + `localEndpointPort` + `isLocalInstanceHost` (moved here from `services/localModelHealing.js`, which re-exports them, so the healing path and the readiness checklist classify a provider identically — loopback/bind-all only, so a LAN/Tailscale peer on port 11434 is NOT claimed as a local daemon), `localRuntimeKind(provider)` (the `*Backed` markers first, then that classifier; `orcarouter` excluded as a remote API), `localRuntimeForProvider(provider)` → the row with the endpoint the provider ITSELF configures (`OPENCODE_CONFIG_CONTENT`'s `baseURL`, `ANTHROPIC_BASE_URL`, or `endpoint`), then the `OLLAMA_URL`/`OLLAMA_HOST`/`LM_STUDIO_URL` override the backend managers read, then the canonical default — plus `normalizeOpenAiBaseUrl`. Pure; the probing half is `services/providerReadiness.js`. |+| `localProviderRuntime.js` | Which LOCAL daemon a provider talks to, and where — `LOCAL_RUNTIMES` (llama.cpp / Ollama / LM Studio / MTPLX: label, binary, canonical base URL read from `opencodeConfig.js` rather than re-typed, manage/docs links, model-download hint), `localBackendForProvider` + `localEndpointPort` + `isLocalInstanceHost` (moved here from `services/localModelHealing.js`, which re-exports them, so the healing path and the readiness checklist classify a provider identically — loopback/bind-all only, so a LAN/Tailscale peer on port 11434 is NOT claimed as a local daemon), `localRuntimeKind(provider)` (the `*Backed` markers first, then that classifier; `orcarouter` excluded as a remote API), `localRuntimeForProvider(provider)` → the row with the endpoint the provider ITSELF configures (`OPENCODE_CONFIG_CONTENT`'s `baseURL`, `ANTHROPIC_BASE_URL`, or `endpoint`), then the `OLLAMA_URL`/`OLLAMA_HOST`/`LM_STUDIO_URL` override the backend managers read, then the canonical default — and `null` when that resolved endpoint fails `isLocalInstanceEndpoint` (an API provider on another machine has no local daemon to check, whatever its name says) — plus `normalizeOpenAiBaseUrl`. Pure; the probing half is `services/providerReadiness.js`. || `openAiModelsProbe.js` | `probeOpenAiModels(baseUrl, { timeoutMs })` → `{ reachable, models, error }` — the one `GET {base}/models` probe for the local OpenAI-compatible daemons, shared by `services/providerReadiness.js` and `services/llamaServerManager.js`. Distinguishes unreachable from reachable-but-unlistable (`models: null`) from up-with-nothing-loaded (`[]`), names the real transport failure via `describeFetchError` (undici reports every one as a bare `fetch failed`), and cancels an unread body on a non-OK response. Consolidated after the two copies drifted — one passed its timeout as a `timeout` key inside the fetch init object, where it is not an option, silently running a 500ms poll loop on the 15s default. || `cliChildEnv.js` | The one place the AI-CLI child environment is composed, replacing the hand-rolled copy every spawn site carried — which made each env-level fix an N-file sweep (#3194). `buildCliChildEnv({ baseEnv, before, provider, model, cwd, extra, guard })` returns a COMPLETE env for `spawn`: layers `baseEnv → before → Ollama-Claude defaults → provider.envVars → buildOpencodeEnvVars → extra`, pins `PWD` to `cwd`, strips `CLAUDECODE`, and (with `guard: true`) prepends the pm2 guard shim onto the final `PATH`. The Ollama-Claude layer raises Claude Code's default output ceiling to 65,536 tokens so a thinking-capable local model cannot finish its reasoning past the stock 32K ceiling and die before its final tool call; an explicit provider env value wins. `composeProviderEnv({ before, provider, model, extra })` returns just the ordered provider layers, for sites that build a DELTA someone else bases and spawns (the CoS runner payload, a shell-session overlay). The two slots are not interchangeable: `before` sits UNDER `provider.envVars` (forgeTokenEnv/claudeSettingsEnv, so a provider override still wins), `extra` sits OVER it (TERM/COLORTERM for a PTY). `cliChildEnv.test.js` asserts the composed order per call site and **discovers** any new site that hand-rolls the tuple instead of calling these — so the call-site list stays in the test, not in prose here. || `cliProviderArgs.js` | Per-CLI argv conventions (`buildCliArgs`) for stdin prompt delivery — dependency-light extraction from runner.js so out-of-process callers (autofixer) can import it. |diff --git a/server/lib/localProviderRuntime.js b/server/lib/localProviderRuntime.jsindex 259a18d020..489f2691b3 100644--- a/server/lib/localProviderRuntime.js+++ b/server/lib/localProviderRuntime.js@@ -50,18 +50,41 @@ export function isLocalInstanceHost(hostname) {/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h);}+/** Parse a provider endpoint (with any `/v1` suffix stripped) into a URL, or null. */+function parseEndpoint(endpoint) {+ const cleaned = String(endpoint || '').replace(/\/v\d+\/?$/, '').replace(/\/+$/, '');+ try {+ return new URL(cleaned);+ } catch { return null; }+}++/**+ * Does this endpoint point at a daemon running on THIS machine?+ *+ * The distinction decides whether PortOS may inspect the host it is running on+ * to explain the endpoint. An endpoint on a LAN/tailnet box is an EXTERNAL API+ * server: whether `lms` is on this machine's PATH, or this machine's LM Studio+ * app is installed, says nothing about it — so those checks must not run, and+ * their answers must never be reported as that provider's requirements.+ *+ * An unparseable/blank endpoint is NOT local: callers resolve their own local+ * default before asking, so anything still unparseable here is a typo, and+ * guessing "local" would put this machine's install state on a remote card.+ */+export function isLocalInstanceEndpoint(endpoint) {+ const url = parseEndpoint(endpoint);+ return url ? isLocalInstanceHost(url.hostname) : false;+}+/*** The port of a provider endpoint when it points at THIS machine's local* instance (any loopback / bind-all host spelling); null otherwise — so a* LAN/Tailscale peer on the same port is NOT mistaken for a local backend.*/export function localEndpointPort(endpoint) {- const cleaned = String(endpoint || '').replace(/\/v1\/?$/, '').replace(/\/+$/, '');- try {- const u = new URL(cleaned);- if (!isLocalInstanceHost(u.hostname)) return null;- return u.port || (u.protocol === 'https:' ? '443' : '80');- } catch { return null; }+ const u = parseEndpoint(endpoint);+ if (!u || !isLocalInstanceHost(u.hostname)) return null;+ return u.port || (u.protocol === 'https:' ? '443' : '80');}// MIRROR of `isOllamaProvider` in services/ollamaManager.js — keep in lockstep.@@ -226,6 +249,15 @@ export function localRuntimeForProvider(provider) {|| normalizeOpenAiBaseUrl(envBaseUrl(kind))|| runtime.defaultBaseUrl;+ // A provider whose endpoint lives on ANOTHER machine has no local runtime,+ // however local its name/id looks. An `LM Studio <box>` provider pointed+ // at a LAN host still matched `lmstudio` by NAME, and the card answered+ // "LM Studio installed — `lms` is on PortOS's PATH" and "start it from+ // Settings → Local LLM" about a server PortOS neither runs nor can start.+ // An external API endpoint is assumed to be set up by whoever runs it; the+ // only honest report here is none.+ if (!isLocalInstanceEndpoint(endpoint)) return null;+const { id, ...row } = runtime;return { ...row, kind: id, endpoint };}diff --git a/server/lib/localProviderRuntime.test.js b/server/lib/localProviderRuntime.test.jsindex 2d703fd247..81fc8d434c 100644--- a/server/lib/localProviderRuntime.test.js+++ b/server/lib/localProviderRuntime.test.js@@ -1,6 +1,7 @@import { describe, it, expect, vi, afterEach } from 'vitest';import {LOCAL_RUNTIMES,+ isLocalInstanceEndpoint,localBackendForProvider,localRuntimeForProvider,localRuntimeKind,@@ -32,6 +33,25 @@ describe('normalizeOpenAiBaseUrl', () => {});});+describe('isLocalInstanceEndpoint', () => {+ it('accepts every loopback / bind-all spelling, with or without a version segment', () => {+ expect(isLocalInstanceEndpoint('http://localhost:1234/v1')).toBe(true);+ expect(isLocalInstanceEndpoint('http://127.0.0.1:11434')).toBe(true);+ expect(isLocalInstanceEndpoint('http://127.5.5.5:8080/v1/')).toBe(true);+ expect(isLocalInstanceEndpoint('http://0.0.0.0:1234/v1')).toBe(true);+ expect(isLocalInstanceEndpoint('http://[::1]:1234/v1')).toBe(true);+ });++ it('rejects another machine, a public API, and anything unparseable', () => {+ expect(isLocalInstanceEndpoint('http://192.0.2.10:1234/v1')).toBe(false);+ expect(isLocalInstanceEndpoint('http://nas.example.com:11434/v1')).toBe(false);+ expect(isLocalInstanceEndpoint('https://api.openai.com/v1')).toBe(false);+ expect(isLocalInstanceEndpoint('localhost:1234')).toBe(false); // no scheme — not a URL+ expect(isLocalInstanceEndpoint('')).toBe(false);+ expect(isLocalInstanceEndpoint(null)).toBe(false);+ });+});+describe('localRuntimeKind', () => {it('reads the explicit backing markers first', () => {expect(localRuntimeKind({ command: 'opencode', llamaBacked: true })).toBe('llama');@@ -125,6 +145,36 @@ describe('localRuntimeForProvider', () => {expect(localRuntimeForProvider({ command: 'claude', type: 'cli' })).toBeNull();});+ it('returns null for an API provider whose endpoint lives on ANOTHER machine', () => {+ // The name matches `lmstudio`, so the card used to report THIS host's+ // install state — "`lms` is on PortOS's PATH", "start LM Studio from+ // Settings → Local LLM" — for a server PortOS neither runs nor can start.+ expect(localRuntimeForProvider({+ type: 'api',+ id: 'lmstudio-peer',+ name: 'LM Studio peer',+ endpoint: 'http://192.0.2.10:1234/v1',+ })).toBeNull();+ // Same for the authoritative `*Backed` markers and for an OpenCode config+ // that points its namespace at a peer.+ expect(localRuntimeForProvider({+ command: 'claude',+ ollamaBacked: true,+ envVars: { ANTHROPIC_BASE_URL: 'http://192.0.2.10:11434' },+ })).toBeNull();+ expect(localRuntimeForProvider({+ command: 'opencode',+ llamaBacked: true,+ envVars: { OPENCODE_CONFIG_CONTENT: opencodeConfig('llama', 'http://192.0.2.10:8080/v1') },+ })).toBeNull();+ });++ it('returns null when the env override the managers read points off-box', () => {+ // OLLAMA_HOST on another machine means no local daemon to install here.+ vi.stubEnv('OLLAMA_HOST', '192.0.2.10:11434');+ expect(localRuntimeForProvider({ command: 'opencode', ollamaBacked: true, envVars: {} })).toBeNull();+ });+it('takes the canonical default from the OpenCode provider table, not a second copy', () => {// These are the base URLs a spawned OpenCode actually talks to; probing a// hand-typed duplicate would eventually check a port nothing is on.diff --git a/server/services/providerReadiness.js b/server/services/providerReadiness.jsindex 5e5c688908..3a1cc5f8fe 100644--- a/server/services/providerReadiness.js+++ b/server/services/providerReadiness.js@@ -24,7 +24,10 @@** Checks are reported in fix order, each with what to do about it. Only* local-daemon providers get a report at all (`localProviderRuntime.js` decides- * which those are); everything else returns `null` and renders nothing.+ * which those are); everything else returns `null` and renders nothing. That+ * deliberately excludes a provider pointed at ANOTHER machine's OpenAI-compatible+ * server — an external endpoint is somebody else's install to run, so PortOS+ * neither probes this host for it nor offers to start it here.** No LLM call is ever made here — `GET /v1/models` is a listing, so this is safe* to poll from a settings page under the no-cold-bootstrap policy in CLAUDE.md.diff --git a/server/services/providerReadiness.test.js b/server/services/providerReadiness.test.jsindex a9856fbd8c..74d2a67f80 100644--- a/server/services/providerReadiness.test.js+++ b/server/services/providerReadiness.test.js@@ -31,6 +31,32 @@ describe('getProviderReadiness', () => {expect(readiness).toBeNull();});+ it('reports nothing — and probes nothing — for an API provider on another machine', async () => {+ // `LM Studio <peer>` matches the `lmstudio` runtime by NAME, so the card+ // used to answer "`lms` is on PortOS's PATH" and "start LM Studio from+ // Settings → Local LLM" about a server running on someone else's box. An+ // external endpoint is assumed to be set up by whoever runs it.+ let probed = 0;+ let pathScans = 0;+ const readiness = await getProviderReadiness(+ {+ id: 'lmstudio-peer',+ name: 'LM Studio peer',+ type: 'api',+ endpoint: 'http://192.0.2.10:1234/v1',+ defaultModel: 'qwen/qwen3.5-35b-a3b',+ },+ {+ findCommand: () => { pathScans += 1; return '/opt/homebrew/bin/lms'; },+ probe: async () => { probed += 1; return { reachable: false, models: null, error: 'timed out' }; },+ isAppInstalled: () => true,+ },+ );+ expect(readiness).toBeNull();+ expect(probed).toBe(0);+ expect(pathScans).toBe(0);+ });+it('reports ready when the binary, the server, and the model all check out', async () => {const readiness = await getProviderReadiness(llamaProvider(), {findCommand: () => '/opt/homebrew/bin/llama-server',