Skip to content

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

address review (codex): keyless LAN/tailnet endpoints are configured, not broken

[._.]/ Adam Eivy09d70a17f8a8
diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsx
index 5fe40fecf8..a9d0065102 100644
--- a/client/src/pages/AIProviders.jsx
+++ b/client/src/pages/AIProviders.jsx
@@ -338,8 +338,10 @@ export default function AIProviders() {
const readinessById = Object.fromEntries(providers.map(p => [p.id, providerReadiness(p, {
runtime: runtimeById[p.id],
status: statuses[p.id],
- // `null` when the sibling isn't in the list at all — unknown, not missing.
- orcaRouterKeySet: byId.orcarouter ? Boolean(byId.orcarouter.hasApiKey) : null,
+ // `providers` is the authoritative list, so a sibling that is absent from
+ // it was deleted — the wrapper has no key to inherit, which is `false`,
+ // not "unknown". (Nothing here runs before the list loads.)
+ orcaRouterKeySet: Boolean(byId.orcarouter?.hasApiKey),
})]));
// The default provider floats to the top of whichever section it sits in, so
// "which one runs by default" stays a one-glance answer after grouping.
diff --git a/client/src/pages/AIProviders.test.jsx b/client/src/pages/AIProviders.test.jsx
index 8aa1a36f28..6362e2a5aa 100644
--- a/client/src/pages/AIProviders.test.jsx
+++ b/client/src/pages/AIProviders.test.jsx
@@ -632,6 +632,27 @@ describe('readiness grouping', () => {
expect(screen.queryByRole('button', { name: new RegExp('^Disabled') })).not.toBeInTheDocument();
});
+ // The provider list is authoritative: no sibling means the wrapper has no key
+ // to inherit at spawn time, which is a missing prerequisite, not "unknown".
+ it('files an OrcaRouter wrapper whose sibling was deleted under Needs setup', async () => {
+ api.getProviders.mockResolvedValue({
+ providers: [{
+ id: 'opencode-orcarouter',
+ name: 'OpenCode OrcaRouter',
+ type: 'cli',
+ command: 'opencode',
+ enabled: true,
+ orcarouterBacked: true,
+ }],
+ activeProvider: null,
+ });
+
+ renderPage();
+
+ expect(await screen.findByText('NEEDS SETUP')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: new RegExp('^Needs setup') })).toBeInTheDocument();
+ });
+
it('badges an enabled-but-benched provider with its reason', async () => {
api.getProviders.mockResolvedValue({
providers: [{ id: 'claude', name: 'Claude', type: 'cli', command: 'claude', enabled: true }],
diff --git a/client/src/utils/README.md b/client/src/utils/README.md
index 9ac896b5cb..b0fe4a0452 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`. And `providerReadiness(provider, { runtime, status, orcaRouterKeySet })` + `PROVIDER_READINESS` — 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. 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. And `providerReadiness(provider, { runtime, status, orcaRouterKeySet })` + `PROVIDER_READINESS` — 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. 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 / resilience
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index db5c4d53f1..67f17d57ed 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -678,6 +678,42 @@ const LOCAL_ENDPOINT_RE = /^(https?:\/\/)?(localhost|127\.0\.0\.1|0\.0\.0\.0|\[?
export const isLocalEndpoint = (endpoint) =>
typeof endpoint === 'string' && LOCAL_ENDPOINT_RE.test(endpoint.trim());
+// Hosts inside the trust boundary, where an unauthenticated OpenAI-compatible
+// server is a normal setup rather than a misconfiguration: RFC1918 LAN ranges,
+// link-local, and the Tailscale CGNAT range 100.64.0.0/10 (PortOS is a
+// tailnet-first product — an API provider pointed at another machine's Ollama
+// is a first-class configuration, not an edge case).
+const PRIVATE_IP_RE = /^(?:10\.|192\.168\.|172\.(?:1[6-9]|2\d|3[01])\.|169\.254\.|100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7])\.)/;
+
+/**
+ * Is this endpoint inside the private network — loopback, a LAN/tailnet address,
+ * a `.local`/`.ts.net`/`.internal` name, or a bare single-label host?
+ *
+ * Used to decide whether a missing API key is actually a missing prerequisite.
+ * The server only attaches an `Authorization` header when a key is stored, so a
+ * keyless call to a private OpenAI-compatible server (LM Studio on the desk
+ * machine, Ollama on a tailnet peer) works exactly as configured — reporting it
+ * as "needs setup" would be a false alarm on a supported deployment. A public
+ * endpoint with no key stays flagged: that one really is misconfigured.
+ *
+ * A host that cannot be parsed reads as NOT private, keeping the stricter of
+ * the two answers for input we don't understand.
+ */
+export const isPrivateNetworkEndpoint = (endpoint) => {
+ if (isLocalEndpoint(endpoint)) return true;
+ if (typeof endpoint !== 'string' || !endpoint.trim()) return false;
+ const trimmed = endpoint.trim();
+ // A scheme-less endpoint ("192.168.1.5:1234/v1") is still a host — give the
+ // parser one so it doesn't read the leading segment as a scheme.
+ const candidate = /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ? trimmed : `http://${trimmed}`;
+ if (!URL.canParse(candidate)) return false;
+ const host = new URL(candidate).hostname.toLowerCase().replace(/^\[|\]$/g, '');
+ if (PRIVATE_IP_RE.test(host)) return true;
+ if (/\.(local|internal|lan|home\.arpa|ts\.net)$/.test(host)) return true;
+ // A single-label host resolves only inside the local network (`http://nas:11434`).
+ return !host.includes('.') && !host.includes(':');
+};
+
export const isLikelyLargeContextProvider = (provider) => {
if (isProcessProvider(provider)) return true;
return isApiProvider(provider) && !isLocalEndpoint(provider.endpoint);
@@ -911,8 +947,12 @@ export const PROVIDER_READINESS = Object.freeze({
* means the provider is benched after a failure.
* orcaRouterKeySet — whether the sibling `orcarouter` API provider holds the
* key an OpenCode OrcaRouter wrapper inherits at spawn
- * time. `null` = unknown (sibling not in the list), and
- * like `runtime` must not be reported as missing.
+ * time. `false` covers BOTH "sibling has no key" and
+ * "sibling was deleted" — the server injects the key only
+ * when that provider exists and holds one, so either way
+ * the wrapper cannot authenticate. `null` is for a caller
+ * that genuinely cannot tell (no provider list yet) and,
+ * like `runtime`, is never reported as missing.
*
* `blocked` outranks `disabled`: a provider whose CLI isn't installed can't be
* enabled at all, so it belongs in the "needs setup" bucket whichever way its
@@ -927,9 +967,11 @@ export const providerReadiness = (provider, { runtime = null, status = null, orc
if (runtime && runtime.installed === false) {
missing.push({ code: 'runtime', label: `${runtime.label || 'Runtime'} is not installed` });
}
- // API providers auth solely via the stored key. A local endpoint (Ollama, LM
- // Studio) needs none, so its absence is not a missing prerequisite there.
- if (isApiProvider(provider) && provider?.hasApiKey !== true && !isLocalEndpoint(provider?.endpoint)) {
+ // API providers auth solely via the stored key — but only an endpoint outside
+ // the private network actually needs one. The server attaches `Authorization`
+ // only when a key is stored, so a keyless call to loopback, a LAN box, or a
+ // tailnet peer running LM Studio / Ollama works exactly as configured.
+ if (isApiProvider(provider) && provider?.hasApiKey !== true && !isPrivateNetworkEndpoint(provider?.endpoint)) {
missing.push({ code: 'apiKey', label: 'API key is not set' });
}
// The OpenCode OrcaRouter wrappers carry no key of their own — theirs lives
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index 29d717426e..326e423528 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -34,6 +34,7 @@ import {
isProcessProvider,
providerRuntimeKey,
providerReadiness,
+ isPrivateNetworkEndpoint,
PROVIDER_READINESS,
isOllamaBackedProvider,
isOrcaRouterBackedProvider,
@@ -1213,6 +1214,25 @@ describe('providerReadiness', () => {
.toBe(PROVIDER_READINESS.READY);
});
+ // A LAN box or a tailnet peer running LM Studio / Ollama serves keylessly, and
+ // PortOS is a tailnet-first product — flagging those as unconfigured would be
+ // a false alarm on a supported deployment.
+ it.each([
+ ['http://192.168.1.50:1234/v1'],
+ ['http://10.0.0.4:11434/v1'],
+ ['http://100.101.102.103:11434/v1'],
+ ['http://desk-machine.ts.net:1234/v1'],
+ ['http://nas:11434/v1'],
+ ])('does not demand a key from the private-network endpoint %s', (endpoint) => {
+ expect(providerReadiness({ id: 'lan', type: 'api', endpoint, enabled: true }).state)
+ .toBe(PROVIDER_READINESS.READY);
+ });
+
+ it('still demands a key from a public endpoint', () => {
+ expect(providerReadiness({ id: 'cloud', type: 'api', endpoint: 'https://api.example.com/v1', enabled: true }).state)
+ .toBe(PROVIDER_READINESS.BLOCKED);
+ });
+
it('blocks an OrcaRouter wrapper when the sibling API provider holds no key', () => {
const wrapper = cli({ id: 'opencode-orcarouter', orcarouterBacked: true });
expect(providerReadiness(wrapper, { orcaRouterKeySet: false }).missing)
@@ -1250,4 +1270,34 @@ describe('providerReadiness', () => {
});
});
+describe('isPrivateNetworkEndpoint', () => {
+ it.each([
+ 'http://localhost:11434/v1',
+ 'http://127.0.0.1:1234',
+ '192.168.1.5:1234/v1',
+ 'http://172.16.4.4:11434',
+ 'http://172.31.255.1:11434',
+ 'http://100.64.0.1:11434',
+ 'http://host.local:1234',
+ 'http://box.internal/v1',
+ 'http://ollama',
+ ])('treats %s as inside the private network', (endpoint) => {
+ expect(isPrivateNetworkEndpoint(endpoint)).toBe(true);
+ });
+
+ it.each([
+ 'https://api.example.com/v1',
+ 'https://example.com:8443/v1',
+ // 172.32 is outside RFC1918 (which stops at 172.31), and 100.128 is above
+ // the Tailscale CGNAT range — both are public space.
+ 'http://172.32.0.1:11434',
+ 'http://100.128.0.1:11434',
+ 'http://9.9.9.9/v1',
+ '',
+ null,
+ ])('treats %s as public', (endpoint) => {
+ expect(isPrivateNetworkEndpoint(endpoint)).toBe(false);
+ });
+});
+
// @vitest-environment node