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
fix(ui): surface where the OpenCode OrcaRouter API key goes
Adam Eivy1258589440e8
diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsxindex 3b74d166db..239811ae6b 100644--- a/client/src/pages/AIProviders.jsx+++ b/client/src/pages/AIProviders.jsx@@ -3,7 +3,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, supportsModelRefresh, isGrokBuildCli, isLocalEndpoint, effectiveModelContextWindow, isRunnerAllowedCommand, effortLevelsForProvider, isOllamaBackedProvider } from '../utils/providers';+import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, configuredDefaultIn, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, supportsModelRefresh, isGrokBuildCli, isLocalEndpoint, effectiveModelContextWindow, isRunnerAllowedCommand, effortLevelsForProvider, isOllamaBackedProvider, isOrcaRouterBackedProvider } from '../utils/providers';import useLocalModels from '../hooks/useLocalModels';import BrailleSpinner from '../components/BrailleSpinner';import EmptyState from '../components/EmptyState';@@ -41,7 +41,30 @@ function GrokUploadWarning({ className = '' }) {<pre className="mt-1.5 whitespace-pre rounded bg-port-bg/60 px-2 py-1.5 font-mono text-[11px] text-port-warning">{`[harness]disable_codebase_upload = true`}</pre></div>- );+ );+}++// The OpenCode OrcaRouter wrappers (opencode-orcarouter / -tui) keep no key of+// their own — at spawn time the server copies the key from the sibling+// `orcarouter` API provider. This answers "where do I put the API key?" from the+// card/form: it's on the API provider, not here.+function OrcaRouterKeyHint({ sibling, className = '' }) {+ const hasKey = Boolean(sibling?.hasApiKey);+ return (+ <div className={`text-xs rounded-md border border-port-border bg-port-bg/60 px-2.5 py-2 leading-relaxed ${className}`}>+ <span className="text-gray-300">+ API key is inherited from the <code className="font-mono">OrcaRouter</code> API provider+ {" "}at run time — this wrapper has no key field of its own.+ </span>+ <div className="mt-1">+ {hasKey ? (+ <span className="text-port-success">OrcaRouter key: set</span>+ ) : (+ <span className="text-port-warning">OrcaRouter key: not set — Edit the OrcaRouter API provider to paste one</span>+ )}+ </div>+ </div>+ );}export default function AIProviders() {@@ -705,9 +728,16 @@ export default function AIProviders() {)}</div>- {isGrokBuildCli(provider) && <GrokUploadWarning className="mt-2" />}+ {isGrokBuildCli(provider) && <GrokUploadWarning className="mt-2" />}++ {isOrcaRouterBackedProvider(provider) && (+ <OrcaRouterKeyHint+ sibling={providers.find(p => p.id === 'orcarouter')}+ className="mt-2"+ />+ )}- {testResults[provider.id] && !testResults[provider.id].testing && (+ {testResults[provider.id] && !testResults[provider.id].testing && (<div className={`mt-2 text-sm ${testResults[provider.id].success ? 'text-port-success' : 'text-port-error'}`}>{testResults[provider.id].success? `✓ Available${testResults[provider.id].version ? ` (${testResults[provider.id].version})` : ''}`@@ -1586,7 +1616,14 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [], runnerAllo<span className="text-sm text-gray-400">Enabled</span></label>- {isGrokBuildCli({ type: formData.type, command: formData.command }) && <GrokUploadWarning />}+ {isGrokBuildCli({ type: formData.type, command: formData.command }) && <GrokUploadWarning />}++ {isOrcaRouterBackedProvider(provider) && (+ <OrcaRouterKeyHint+ sibling={allProviders.find(p => p.id === 'orcarouter')}+ />+ )}+<div className="flex justify-end gap-3 pt-4"><buttondiff --git a/client/src/pages/AIProviders.test.jsx b/client/src/pages/AIProviders.test.jsxindex 21ff2e27e5..fb4ab586d8 100644--- a/client/src/pages/AIProviders.test.jsx+++ b/client/src/pages/AIProviders.test.jsx@@ -388,5 +388,81 @@ describe('Local num_ctx field', () => {await screen.findByLabelText('Planning Window');expect(screen.queryByLabelText('Local num_ctx')).toBeNull();- });+ });+});++describe('OpenCode OrcaRouter key hint', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ api.getApps.mockResolvedValue([]);+ api.getRuns.mockResolvedValue({ runs: [] });+ api.getProviderStatuses.mockResolvedValue({ providers: {} });+ api.getOpenCodeInstallStatus.mockResolvedValue({ installed: true, npmAvailable: true });+ });++ // The OpenCode wrapper carries no key of its own — the card must point the+ // user at the sibling `orcarouter` API provider, not a key field that's absent.+ it('points a keyless OpenCode wrapper at the sibling OrcaRouter API key', async () => {+ api.getProviders.mockResolvedValue({+ providers: [+ {+ id: 'opencode-orcarouter',+ name: 'OpenCode OrcaRouter',+ type: 'cli',+ command: 'opencode',+ enabled: true,+ orcarouterBacked: true,+ models: ['orcarouter/auto'],+ defaultModel: 'orcarouter/auto',+ },+ { id: 'orcarouter', name: 'OrcaRouter', type: 'api', enabled: false, hasApiKey: false },+ ],+ activeProvider: 'opencode-orcarouter',+ });++ renderPage();++ const hint = await screen.findByText(/API key is inherited from/);+ expect(hint).toBeInTheDocument();+ expect(screen.getByText(/OrcaRouter key: not set/)).toBeInTheDocument();+ });++ it('reports the inherited key as set when the sibling API provider has one', async () => {+ api.getProviders.mockResolvedValue({+ providers: [+ {+ id: 'opencode-orcarouter-tui',+ name: 'OpenCode OrcaRouter TUI',+ type: 'tui',+ command: 'opencode',+ enabled: true,+ orcarouterBacked: true,+ models: ['orcarouter/auto'],+ defaultModel: 'orcarouter/auto',+ },+ { id: 'orcarouter', name: 'OrcaRouter', type: 'api', enabled: false, hasApiKey: true },+ ],+ activeProvider: 'opencode-orcarouter-tui',+ });++ renderPage();++ expect(await screen.findByText(/API key is inherited from/)).toBeInTheDocument();+ expect(screen.getByText('OrcaRouter key: set')).toBeInTheDocument();+ });++ // A non-orcarouter-backed provider must never see the inheritance hint.+ it('does not show the hint for a non-orcarouter-backed provider', async () => {+ api.getProviders.mockResolvedValue({+ providers: [+ { id: 'orca', name: 'My Orca', type: 'cli', command: 'claude', enabled: true, models: [] },+ ],+ activeProvider: 'orca',+ });++ renderPage();++ expect(await screen.findByText('My Orca')).toBeInTheDocument();+ expect(screen.queryByText(/API key is inherited from/)).not.toBeInTheDocument();+ });});diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex 9739e0a6c4..5d340d41dd 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`, `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`. |+| `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`. || `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 353ebe7471..e6584fb07b 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -824,6 +824,21 @@ export const isOllamaBackedProvider = (provider) => {return /:11434\b/.test(base) || /ollama/i.test(base);};+/**+* True when a provider is an OpenCode wrapper that front-ends the OrcaRouter+* gateway (the shipped `opencode-orcarouter` / `opencode-orcarouter-tui`+* presets, or any renamed wrapper carrying the `orcarouterBacked` marker).+*+* These wrappers deliberately carry NO key of their own: at spawn time the+* server attaches the key from the sibling `orcarouter` API provider+* (`server/lib/aiToolkit/providers.js` `withOrcaRouterApiKey`), so the one place+* a user actually pastes the key is the `orcarouter` API provider, not this+* form. MIRROR of the `orcarouterBacked` marker the server keys on — keep in+* lockstep with `server/lib/providerModels.js#getOpencodeLocalProviderNamespace`.+* @param {{id?:string,orcarouterBacked?:boolean}} provider+*/+export const isOrcaRouterBackedProvider = (provider) => provider?.orcarouterBacked === true;+/*** Check if a provider is the Grok Build CLI/TUI (the `grok` command harness).* Mirrors the Grok detection in `knownProviderContextWindow`: matches the shippeddiff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 0d684fbc28..661ea72b55 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -33,6 +33,7 @@ import {isApiProvider,isProcessProvider,isOllamaBackedProvider,+ isOrcaRouterBackedProvider,isGrokBuildCli,isKimiProvider,isCodexProvider,@@ -430,6 +431,19 @@ describe('provider type predicates', () => {expect(isProcessProvider(api)).toBe(false);});+ it('isOrcaRouterBackedProvider matches only the orcarouterBacked marker', () => {+ expect(isOrcaRouterBackedProvider({ id: 'opencode-orcarouter', orcarouterBacked: true })).toBe(true);+ expect(isOrcaRouterBackedProvider({ id: 'opencode-orcarouter-tui', orcarouterBacked: true })).toBe(true);+ // A renamed wrapper that keeps the marker still inherits the sibling key.+ expect(isOrcaRouterBackedProvider({ id: 'my-orca', orcarouterBacked: true })).toBe(true);+ // The sibling API provider itself is NOT orcarouter-backed (it owns the key).+ expect(isOrcaRouterBackedProvider({ id: 'orcarouter', type: 'api' })).toBe(false);+ // An ollama-backed OpenCode wrapper shares the form shape but not the marker.+ expect(isOrcaRouterBackedProvider({ id: 'opencode-ollama', ollamaBacked: true })).toBe(false);+ expect(isOrcaRouterBackedProvider(null)).toBe(false);+ expect(isOrcaRouterBackedProvider(undefined)).toBe(false);+ });+it('isOllamaBackedProvider matches the marker or an Ollama base URL', () => {// explicit marker (Claude Ollama CLI + TUI samples carry this)expect(isOllamaBackedProvider({ type: 'tui', ollamaBacked: true })).toBe(true);