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
re-export the provider predicates from server/lib instead of copying them into client/src/utils/providerTypes.js
[._.]/ Adam Eivy68cac2f77704
diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex b2ecd4e2e2..1dce9ae3e7 100644--- a/client/src/utils/README.md+++ b/client/src/utils/README.md@@ -54,7 +54,7 @@ is where each shared table is re-exported from its `server/lib` leaf.| Module | Purpose ||---|---|| `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` (mirror of `server/lib/aiToolkit/constants.js`) with `isCliProvider` / `isTuiProvider` / `isApiProvider` / `isProcessProvider`, `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`). Mirror of the same predicates in `server/lib/providerModels.js`. |+| `providerTypes` | What KIND of provider a record is: `PROVIDER_TYPES` (re-exported from `server/lib/aiToolkit/constants.js`) with `isCliProvider` / `isTuiProvider` / `isApiProvider` / `isProcessProvider`, `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/providerModels.js`, `server/lib/aiToolkit/constants.js` and `server/lib/aiToolkit/internal/ollamaBacked.js`, never copied. || `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`. || `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). |diff --git a/client/src/utils/providerTypes.js b/client/src/utils/providerTypes.jsindex 56aea9d99e..d70e598097 100644--- a/client/src/utils/providerTypes.js+++ b/client/src/utils/providerTypes.js@@ -5,124 +5,35 @@* `kimi`/`cursor-agent`/`grok`/`claude` still qualifies), and the structural* backend markers (`ollamaBacked`, `lmstudioBacked`, …) a wrapper record carries.*- * Browser MIRROR of the predicates in `server/lib/providerModels.js` (the- * `isXProvider` family, `commandBasename`, `localRuntimeNamespace`),- * `server/lib/aiToolkit/constants.js#PROVIDER_TYPES` and- * `server/lib/aiToolkit/providers.js#isOllamaBackedProvider` — keep in lockstep.- * Every other provider helper module builds on these; this one imports only- * the gateway registry.+ * Everything with a server twin is RE-EXPORTED from the pure server leaves+ * below rather than copied, so the browser and the server classify a record+ * with the same function and a vendor added on one side cannot be missing on+ * the other. Only helpers with no browser-importable server twin are declared+ * here: the type predicates a sanitized inventory still answers (their server+ * copies live under `services/` — #6605 gives them a pure-leaf home), the+ * launchability and picker filters, and the Tailwind chip classes.** Re-exported by `./providers.js` for existing `utils/providers` imports.*/-import { isGatewayBackedProvider } from './providerGateways.js';--// Copy of server/lib/providerModels.js#commandBasename (the predicates in this-// file are the one provider table still copied rather than re-exported — see-// the header). Strip the directory + a Windows `.exe` suffix so a-// path-configured command (/opt/homebrew/bin/grok) matches the bare vendor name.-// Keep in lockstep with the server helper (only `.exe` is stripped, not `.cmd`).-export const commandBasename = (command) =>- typeof command === 'string' && command !== ''- ? command.split(/[\\/]/).pop().toLowerCase().replace(/\.exe$/, '')- : '';--/**- * True when a provider is codex-flavored — the shipped `codex`/`codex-tui` ids- * or any provider whose launch command basename is `codex` (path/exe tolerant).- * MIRROR of `isCodexProvider` in server/lib/providerModels.js — keep in lockstep.- * @param {{id?:string, command?:string}|null|undefined} provider- * @returns {boolean}- */-export const isCodexProvider = (provider) => {- const id = String(provider?.id || '').toLowerCase();- return id === 'codex' || id === 'codex-tui' || commandBasename(provider?.command) === 'codex';-};--/**- * True when a provider is Grok-Build-flavored. MIRROR of `isGrokProvider` in- * server/lib/providerModels.js — the shipped `grok-cli`/`grok-tui` ids or a- * `grok` command basename. The bare `grok` id is the HTTP API provider, which- * has no CLI flag to carry an effort level, and is excluded.- * @param {{id?:string, command?:string}|null|undefined} provider- * @returns {boolean}- */-export const isGrokProvider = (provider) => {- const id = String(provider?.id || '').toLowerCase();- return id === 'grok-cli' || id === 'grok-tui' || commandBasename(provider?.command) === 'grok';-};--/**- * True when a CLI/TUI record uses Codex's ChatGPT subscription. This mirrors- * server/lib/codexAccount.js: the command, not an editable provider id, owns- * the account contract.- * @param {{type?:string, command?:string}|null|undefined} provider- * @returns {boolean}- */-export const isCodexSubscriptionProvider = (provider) =>- (provider?.type === 'cli' || provider?.type === 'tui')- && commandBasename(provider?.command) === 'codex'- // A local-runtime-backed codex record (`codex --oss --local-provider ollama`)- // generates its tokens on this machine and authenticates against nothing, so- // it must not be painted "No ChatGPT account is signed in" — or parked in- // UNKNOWN waiting on an account read that will never matter.- && localRuntimeNamespace(provider) === null;--/**- * True when a provider is Kimi-Code-flavored — the shipped `kimi-cli`/`kimi-tui`- * ids or any provider whose launch command basename is `kimi` (path/exe tolerant).- * MIRROR of `isKimiProvider` in server/lib/providerModels.js — keep in lockstep.- * @param {{id?:string, command?:string}|null|undefined} provider- * @returns {boolean}- */-export const isKimiProvider = (provider) => {- const id = String(provider?.id || '').toLowerCase();- return id === 'kimi-cli' || id === 'kimi-tui' || commandBasename(provider?.command) === 'kimi';-};--/**- * True when a provider is Antigravity-flavored — the shipped- * `antigravity-cli`/`antigravity-tui` ids or any provider whose launch command- * basename is `agy`/`antigravity` (path/exe tolerant). MIRROR of- * `isAntigravityProvider` in server/lib/providerModels.js — keep in lockstep.- * @param {{id?:string, command?:string}|null|undefined} provider- * @returns {boolean}- */-export const isAntigravityProvider = (provider) => {- if (!provider) return false;- const id = String(provider.id || '').toLowerCase();- if (id === 'antigravity-cli' || id === 'antigravity-tui') return true;- const base = commandBasename(provider.command);- return base === 'agy' || base === 'antigravity';-};--/**- * True when a provider is Cursor-Agent-flavored — the shipped- * `cursor-cli`/`cursor-tui` ids or any provider whose launch command basename is- * `cursor-agent` (never a bare `cursor`, which is the GUI editor). MIRROR of- * `isCursorProvider` in server/lib/providerModels.js — keep in lockstep.- * @param {{id?:string, command?:string}|null|undefined} provider- * @returns {boolean}- */-export const isCursorProvider = (provider) => {- if (!provider) return false;- const id = String(provider.id || '').toLowerCase();- return id === 'cursor-cli' || id === 'cursor-tui' || commandBasename(provider.command) === 'cursor-agent';-};--/**- * Provider-type enum mirrored from server/lib/aiToolkit/constants.js#PROVIDER_TYPES.- * The aiToolkit directory is kept self-contained (no imports out to other PortOS- * modules) so the client cannot import the server copy directly — keep these two- * in lockstep when adding a type. The provider type predicates below and the- * Tailwind chip helper read from this object, so a string literal only needs to- * appear once per side.- */-export const PROVIDER_TYPES = Object.freeze({- CLI: 'cli',- TUI: 'tui',- API: 'api'-});+import { PROVIDER_TYPES } from '../../../server/lib/aiToolkit/constants.js';+import { commandBasename, isGrokProvider } from '../../../server/lib/providerModels.js';++export { PROVIDER_TYPES } from '../../../server/lib/aiToolkit/constants.js';+// The public `aiToolkit/providers.js` barrel reaches `fs` and `child_process`,+// so the browser takes the dependency-free leaf that barrel itself re-exports.+export { isOllamaBackedProvider } from '../../../server/lib/aiToolkit/internal/ollamaBacked.js';+export {+ commandBasename,+ isAntigravityProvider,+ isCodexProvider,+ isCodexSubscriptionProvider,+ isCursorProvider,+ isGrokProvider,+ isKimiProvider,+ isOpencodeLocalProvider,+ localRuntimeNamespace,+} from '../../../server/lib/providerModels.js';// Agent jobs need the CLI/TUI file-writing harnesses. Keep this allowlist in// lockstep with the api-provider rejection in server/services/agentProviderResolution.js.@@ -131,21 +42,6 @@ export const AGENT_HARNESS_PROVIDER_TYPES = Object.freeze([PROVIDER_TYPES.TUI]);-/**- * True when an OpenCode process provider runs against one of the local- * OpenAI-compatible backends (Ollama / LM Studio / MTPLX / llama.cpp / vLLM) or- * a hosted gateway (OrcaRouter / OpenRouter)- * rather than a vendor cloud model. MIRROR of `isOpencodeProvider(p) &&- * getOpencodeLocalProviderNamespace(p)` in server/lib/providerModels.js, which- * is exactly what gates the effort ladder there — so a backend marker missing- * here hides the effort picker for a provider the server would happily forward- * `reasoningEffort` for (#4765).- */-export const isOpencodeLocalProvider = (provider) =>- (['opencode', 'opencode-tui'].includes(String(provider?.id || '').toLowerCase())- || commandBasename(provider?.command) === 'opencode')- && (localRuntimeNamespace(provider) !== null || isGatewayBackedProvider(provider));-/*** Check if a provider is a TUI-backed agent provider. Mirror of* `isTuiProvider` in server/services/agentCliSpawning.js.@@ -201,46 +97,6 @@ export const isProcessProvider = (provider) => isCliProvider(provider) || isTuiP*/export const enabledProcessProviderFilter = (provider) => Boolean(provider?.enabled) && isProcessProvider(provider);-/**- * Whether `provider` is served by an Ollama daemon rather than its nominal- * cloud/CLI backend: the built-in `ollama` API provider itself (id match), an- * `api`-type provider whose `endpoint` points at Ollama, or the Claude-Ollama- * CLI/TUI pattern — a `claude` process carrying the `ollamaBacked` marker or an- * `ANTHROPIC_BASE_URL` pointed at Ollama, which runs the Claude Code harness but- * generates tokens locally, so its model list is refreshed from Ollama- * (including the TUI variant, which the server refreshes via the- * `type==='tui' && ollamaBacked` branch). MIRROR of `isOllamaBackedProvider` in- * server/lib/aiToolkit/providers.js.- * @param {{id?:string,endpoint?:string,ollamaBacked?:boolean,envVars?:Record<string,string>}} provider- */-export const isOllamaBackedProvider = (provider) => {- if (provider?.id === 'ollama') return true;- if (provider?.ollamaBacked === true) return true;- const base = String(provider?.envVars?.ANTHROPIC_BASE_URL || provider?.endpoint || '');- return /:11434\b/.test(base) || /ollama/i.test(base);-};--/**- * The LOCAL daemon namespace a provider is marked with, or null. Structural- * markers only — a hosted gateway is an OpenCode namespace and a remote API, so- * it is deliberately NOT one of these.- *- * MIRROR of `localRuntimeNamespace` in server/lib/providerModels.js — keep in- * lockstep. The order matters: a malformed record carrying two markers keeps its- * legacy Ollama outcome on both sides.- * @param {{ollamaBacked?:boolean,mtplxBacked?:boolean,llamaBacked?:boolean,vllmBacked?:boolean,sglangBacked?:boolean}|null|undefined} provider- * @returns {'ollama'|'mtplx'|'llama'|'vllm'|'sglang'|null}- */-export const localRuntimeNamespace = (provider) => {- if (provider?.ollamaBacked === true) return 'ollama';- if (provider?.lmstudioBacked === true) return 'lmstudio';- if (provider?.mtplxBacked === true) return 'mtplx';- if (provider?.llamaBacked === true) return 'llama';- if (provider?.vllmBacked === true) return 'vllm';- if (provider?.sglangBacked === true) return 'sglang';- return null;-};-/*** True when a provider launches the Claude Code binary, whatever backend it is* pointed at (`claude-code`, `claude-ollama`, `claude-sglang`, or any renamed@@ -249,22 +105,26 @@ export const localRuntimeNamespace = (provider) => {* The harness — not the backend — is what decides which knobs are forwardable:* Claude Code owns its own sampling and speaks the Anthropic wire, so a control* that reaches an OpenCode wrapper through `agent.build` has no route here.- * MIRROR of `isClaudeCommand` in server/lib/providerModels.js.+ *+ * Not the server's `isClaudeCommand`: that counts a BLANK command as Claude+ * because the spawners default one to `claude`, which is right for a process+ * record and wrong for the `api` records this also classifies — they carry no+ * command at all, and `generationControlsFor` would strip the sampling controls+ * off the native Ollama API provider. The type-gated form the server uses lives+ * in `providerFamilies.js`, which is not browser-safe, so this stays+ * command-only until the type predicates have a pure-leaf home.* @param {{command?:string}|null|undefined} provider*/export const isClaudeCommandProvider = (provider) => commandBasename(provider?.command) === 'claude';/**- * Check if a provider is the Grok Build CLI/TUI (the `grok` command harness).- * Matches the shipped `grok-cli` / `grok-tui` samples or any process provider- * whose command basename is `grok`; the plain Grok API provider is excluded.- * Reviewer-model discovery uses this for custom Grok process providers too.+ * Check if a provider is the Grok Build CLI/TUI (the `grok` command harness):+ * a PROCESS provider `isGrokProvider` recognizes — the shipped `grok-cli` /+ * `grok-tui` samples or any process provider whose command basename is `grok`.+ * The plain Grok API provider is excluded on both counts. Reviewer-model+ * discovery uses this for custom Grok process providers too.*/-export const isGrokBuildCli = (provider) => {- if (!isProcessProvider(provider)) return false;- const id = String(provider?.id || '').toLowerCase();- return id === 'grok-cli' || id === 'grok-tui' || commandBasename(provider?.command) === 'grok';-};+export const isGrokBuildCli = (provider) => isProcessProvider(provider) && isGrokProvider(provider);/*** Tailwind chip classes for the provider type badge ('cli' / 'tui' / 'api').@@ -276,12 +136,3 @@ export const providerTypeClass = (type) => {if (type === PROVIDER_TYPES.TUI) return 'bg-emerald-500/20 text-emerald-400';return 'bg-purple-500/20 text-purple-400';};--// ----------------------------------------------------------------------------// AI Assignments option helpers — shared by the global AI Assignments table-// (settings/AiAssignmentsTab.jsx) and per-record override drawers (e.g. the-// Creative Director Models drawer). All three consume the `getAiAssignments`-// payload shape (`{ providers, assignments }`), where an assignment `entry` may-// carry `providerTypes` (which provider kinds are eligible) and optional-// pre-baked `providerOptions` / `modelOptions` overrides for runtime call sites.-// ---------------------------------------------------------------------------diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex bfe9c4832a..442e7bafb8 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -94,17 +94,15 @@ import {effortSurvivingModel,seedModelEffort,} from './providers.js';-import { PROVIDER_TYPES as SERVER_PROVIDER_TYPES } from '../../../server/lib/aiToolkit/constants.js';import SHIPPED_PROVIDERS from '../../../data.reference/providers.json';// The server's own payload decorator, so the shipped-catalog walk below tests// the REAL derivation instead of a hand transcription of it (#3620). Pure and// dependency-free — it imports nothing outside the vendored aiToolkit.import { withRefreshCapabilityList } from '../../../server/lib/aiToolkit/internal/modelFetchers.js';-import {- effortLevelsForProvider as serverEffortLevelsForProvider,- isAntigravityProvider as serverIsAntigravityProvider,- resolveCliEffort as serverResolveCliEffort,-} from '../../../server/lib/providerModels.js';+import * as providerTypes from './providerTypes.js';+import * as serverProviderModels from '../../../server/lib/providerModels.js';+import * as serverOllamaBacked from '../../../server/lib/aiToolkit/internal/ollamaBacked.js';+import * as serverToolkitConstants from '../../../server/lib/aiToolkit/constants.js';// The client resolves its own ladder and clamps through the server's// clampEffortToLadder; the server's resolveCliEffort decides what the CLI@@ -140,16 +138,16 @@ describe('resolveCliEffort', () => {['null yields no flag', null, CLAUDE, null],])('%s', (_label, effort, provider, expected) => {expect(resolveCliEffort(effort, provider)).toBe(expected);- expect(serverResolveCliEffort(effort, provider)).toBe(expected);+ expect(serverProviderModels.resolveCliEffort(effort, provider)).toBe(expected);});it('passes Ultra through for Sol and Terra but clamps it for Luna', () => {for (const model of ['gpt-5.6', 'gpt-5.6-sol', 'gpt-5.6-terra']) {expect(resolveCliEffort('ultra', CODEX, model)).toBe('ultra');- expect(serverResolveCliEffort('ultra', CODEX, model)).toBe('ultra');+ expect(serverProviderModels.resolveCliEffort('ultra', CODEX, model)).toBe('ultra');}expect(resolveCliEffort('ultra', CODEX, 'gpt-5.6-luna')).toBe('max');- expect(serverResolveCliEffort('ultra', CODEX, 'gpt-5.6-luna')).toBe('max');+ expect(serverProviderModels.resolveCliEffort('ultra', CODEX, 'gpt-5.6-luna')).toBe('max');});});@@ -184,7 +182,7 @@ describe('effortLevelsForProvider', () => {it.each(CASES)('%s', (_label, provider, expected) => {expect(effortLevelsForProvider(provider)).toEqual(expected);- expect(serverEffortLevelsForProvider(provider)).toEqual(expected);+ expect(serverProviderModels.effortLevelsForProvider(provider)).toEqual(expected);});// Codex's ladder is model-gated in BOTH directions: the gpt-6 family adds@@ -199,7 +197,7 @@ describe('effortLevelsForProvider', () => {])('codex ladder for %s', (model, expected) => {const codex = { id: 'codex', command: 'codex' };expect(effortLevelsForProvider(codex, model)).toEqual(expected);- expect(serverEffortLevelsForProvider(codex, model)).toEqual(expected);+ expect(serverProviderModels.effortLevelsForProvider(codex, model)).toEqual(expected);});});@@ -327,11 +325,11 @@ describe('Antigravity base-model split', () => {['claude-sonnet-4-6', null],]) {expect(effortLevelsForProvider(agy, model)).toEqual(expected);- expect(serverEffortLevelsForProvider(agy, model)).toEqual(expected);+ expect(serverProviderModels.effortLevelsForProvider(agy, model)).toEqual(expected);}// Clamping follows the narrowed ladder, so agy never sees an invalid pair.expect(resolveCliEffort('medium', agy, 'gemini-3.1-pro')).toBe('low');- expect(serverResolveCliEffort('medium', agy, 'gemini-3.1-pro')).toBe('low');+ expect(serverProviderModels.resolveCliEffort('medium', agy, 'gemini-3.1-pro')).toBe('low');});it('rewrites only Antigravity model lists', () => {@@ -565,16 +563,34 @@ describe('configuredDefaultIn', () => {});});-describe('isAntigravityProvider (server mirror)', () => {- it.each([- [{ id: 'antigravity-cli' }, true],- [{ id: 'antigravity-tui' }, true],- [{ id: 'custom', command: 'agy.exe' }, true],- [{ id: 'claude-code', command: 'claude' }, false],- [null, false],- ])('%o → %s', (provider, expected) => {- expect(isAntigravityProvider(provider)).toBe(expected);- expect(serverIsAntigravityProvider(provider)).toBe(expected);+// The vendor predicates and backend markers the browser classifies a record+// with are the server's own functions — identity, not behavioral parity, is the+// contract. A copy that answers the same today is exactly what let every vendor+// addition (kimi, cursor, the grok effort flag) land the same predicate twice.+// Every name the client module shares with a server leaf must be that leaf's+// export, so a local declaration that shadows a server name fails here too.+describe('providerTypes re-exports the server predicates', () => {+ const shared = [serverProviderModels, serverOllamaBacked, serverToolkitConstants]+ .flatMap((leaf) => Object.keys(leaf).filter((name) => name in providerTypes).map((name) => [name, leaf]));++ it('shares exactly the re-exported names with the server leaves', () => {+ expect(shared.map(([name]) => name).sort()).toEqual([+ 'PROVIDER_TYPES',+ 'commandBasename',+ 'isAntigravityProvider',+ 'isCodexProvider',+ 'isCodexSubscriptionProvider',+ 'isCursorProvider',+ 'isGrokProvider',+ 'isKimiProvider',+ 'isOllamaBackedProvider',+ 'isOpencodeLocalProvider',+ 'localRuntimeNamespace',+ ]);+ });++ it.each(shared)('%s is the server export itself', (name, leaf) => {+ expect(providerTypes[name]).toBe(leaf[name]);});});@@ -583,16 +599,8 @@ describe('PROVIDER_TYPES', () => {expect(PROVIDER_TYPES).toEqual({ CLI: 'cli', TUI: 'tui', API: 'api' });});- // The client mirror exists because aiToolkit is server-only (the directory is- // kept self-contained for upstream sync hygiene). A drift here would let one- // side read a provider type the other doesn't recognize.- it('matches the server-side enum (mirror must stay in lockstep)', () => {- expect({ ...PROVIDER_TYPES }).toEqual({ ...SERVER_PROVIDER_TYPES });- });-it('is frozen so callers cannot mutate the shared enum', () => {expect(Object.isFrozen(PROVIDER_TYPES)).toBe(true);- expect(Object.isFrozen(SERVER_PROVIDER_TYPES)).toBe(true);});});@@ -1183,7 +1191,7 @@ describe('knownProviderContextWindow', () => {});});-describe('isKimiProvider (mirror of server providerModels)', () => {+describe('isKimiProvider (re-exported from server providerModels)', () => {it('matches the shipped ids and a path/exe command, rejects others', () => {expect(isKimiProvider({ id: 'kimi-cli' })).toBe(true);expect(isKimiProvider({ id: 'kimi-tui' })).toBe(true);@@ -1667,7 +1675,8 @@ describe('credentialSource', () => {// and authenticates against nothing, so the account is not one of its// prerequisites — without this the card claims "No ChatGPT account is signed// in" and, worse, parks in UNKNOWN awaiting a read that never matters.- // MIRROR of server/lib/codexAccount.js#isCodexSubscriptionProvider.+ // The server's own isCodexSubscriptionProvider (server/lib/providerModels.js),+ // re-exported — one rule for the card and the prerequisite router.const local = SHIPPED_PROVIDERS.providers['codex-ollama'];expect(local.ollamaBacked).toBe(true);expect(isCodexSubscriptionProvider(local)).toBe(false);diff --git a/server/lib/README.md b/server/lib/README.mdindex c3bd107cc1..47cc9c55e8 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -193,7 +193,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `videoStreamingMode.js` | Block-streaming request vocabulary for LTX-2/2.5 MLX local video renders (#6499) — `VIDEO_STREAMING_MODES` (`auto` \| `resident` \| `stream`), `DEFAULT_VIDEO_STREAMING_MODE` (`'auto'`), `VIDEO_STREAMING_MODE_OPTIONS` (label + description for the picker), `isDefaultVideoStreamingMode` / `isKnownVideoStreamingMode` / `videoStreamingModeLabel` / `videoStreamingModeFromRecord`. This module carries only the REQUEST-side enum — `scripts/generate_ltx2.py#resolve_streaming_policy()` inspects the pinned pipeline's actual constructor and this machine's physical RAM to decide whether `auto` streams, and an explicit `stream` request the pinned pipeline cannot honor (Extend) is a refusal there, not a downgrade here. Pure, mirrored to `client/src/lib/videoStreamingMode.js`. || `videoTextEncoders.js` | Swappable prompt conditioners for local video runtimes. MiniMax H3 reads the *unnormalized* hidden state after Qwen3-VL language layer 49 (layers 50-63, the final norm and `lm_head` are never evaluated), so any checkpoint carrying the same embedding + layers 0-49 + vision tower is a drop-in conditioner — swapping it changes how the model reads a prompt without touching the diffusion weights. `TEXT_ENCODERS_BY_RUNTIME` declares the shipped options per runtime (pinned repo/revision plus an explicit `files` LIST — one repackaged safetensors, or just the shards of an upstream checkpoint that carry parameters the loader actually builds; in code rather than the media-models registry so a stale `data/media-models.json` can't name a file the runner can't map); `videoTextEncoderOptions(model)` returns the TRUE list stock-first (it deliberately does NOT collapse a one-entry runtime to `[]` — that is a presentation rule, and folding it in here would change what the server believes a model supports and empty the "offers …" list in the error; `TextEncoderPicker` owns the hide-when-there-is-no-real-choice check), `isStockTextEncoder(id)` makes absence and the `stock` sentinel the same request, `resolveVideoTextEncoder(model, id)` returns `null` for the stock choice or throws `VIDEO_TEXT_ENCODER_UNSUPPORTED` (with the non-throwing `supportsVideoTextEncoder` + `videoTextEncoderUnsupportedError` split out so the request path can reject before staging uploads), and `downloadableVideoTextEncoders()` (deduped by id — the table is keyed by RUNTIME, so one conditioner can be offered by two) / `downloadableVideoTextEncoder(id)` feed the `/api/video-gen/text-encoders/:id/(download\|repair)` lane. Two loader-mechanics fields exist because a ComfyUI-packaged conditioner is namespaced differently from the HF checkpoint the MLX port matches: `keyPrefixMap` (`model.` → `model.language_model.`, `visual.` → `model.visual.`) is applied to every checkpoint key by `scripts/generate_minimax_h3.py` BEFORE the pinned loader sees it — no fork of the pinned runtime — and `finalNormKey` names where the runner synthesizes a ones-filled `norm.weight` for a checkpoint published without one (correct upstream, since H3 reads the state *before* the norm, but the pinned loader refuses to load with any parameter missing). Both are absent for an UPSTREAM Qwen3-VL-32B checkpoint, which already uses the loader namespace and ships its own norm. A candidate must BE Qwen3-VL-32B (the shim reuses upstream's config/tokenizer/processor) — a different Qwen generation is not a substitute however close its conditioning width looks; see docs/features/video-text-encoders.md. `publicTextEncoderOption(entry)` is the client projection and deliberately drops both, so the UI can't reimplement the remap. The `ltx25` table (#4320) uses a third mechanic, `configOverrides`, because an LTX-2.5 pack's OWN Gemma 4 tower wins over `--gemma` inside the pinned fork: the substitution is a standalone shim directory whose generated `config.json` is the substitute's own with these keys merged over it (only ever the `model_type` label a unified checkpoint gets wrong — never `text_config`/`quantization`), and a candidate must BE Gemma 4 12B at 48 layers / hidden 3840 / vocab 262144 / `k_eq_v`. `verified` gates a substitute out of BOTH lanes (picker AND download) until it has been A/B-rendered against its runtime's stock conditioner — required on every non-built-in entry and fail-closed on absence, so a new entry is unreachable until someone states a verdict; both ltx25 substitutes are `verified: false` today. `declaredVideoTextEncoders()` is the UNFILTERED table for shape/invariant checks only — never the render or download path, and `videoTextEncoderRuntimes()` enumerates the table's runtime keys so parity/shape tests cover every runtime rather than the one that happened to exist when they were written. || `pi.js` | Pi command identity, headless/TUI arguments, and positional prompt delivery. |-| `providerModels.js` | Provider model resolution sentinels + helpers (`CODEX_CONFIGURED_DEFAULT` / `ANTIGRAVITY_CONFIGURED_DEFAULT` / `GROK_CONFIGURED_DEFAULT` / `KIMI_CONFIGURED_DEFAULT`, `resolveCliModel`, `filterSelectableModels`, Bedrock/OpenCode model mappers, `localRuntimeNamespace(provider)` — the OpenCode namespace only when it names a LOCAL daemon, i.e. the composed "namespace and not a hosted gateway" test that `cliChildEnv.js`, `localProviderRuntime.js` and `providerVendors.js` all key on, `CODEX_OSS_LOCAL_PROVIDERS` / `CODEX_OSS_MIN_VERSION` / `codexOssLocalProvider` / `codexUnsupportedLocalRuntime` — the codex half of that same axis: which local runtimes Codex's `--local-provider` can serve, and which marked runtime it cannot, kept here beside the namespace they wrap so `providerPrerequisites.js` classifies a codex record without importing `codex.js` (the argv emitter, `buildCodexOssArgs`, stays there), `OPENCODE_PUBLIC_REVIEW_AGENT` — the read-only OpenCode agent a no-tool public-review stage runs as, kept in this leaf because `providerVendors.js` must not import `opencodeConfig.js`, `parseOpencodeConfigContent` — the shared "is this stored OPENCODE_CONFIG_CONTENT usable?" read — plus `opencodeConfigIsLocalOnly` / `opencodeProviderIsLocalOnly`, the ONE locality rule `providerVendors.js` (gate eligibility) and `cliChildEnv.js` (public-review env allowlist) must not disagree about: if eligibility says yes where the allowlist strips the config, the stage spawns against the user's own ~/.config/opencode with tools intact while still reporting an enforced tool-free gate, `normalizeClaudeModelId` / `resolveClaudeCliModel` — the Claude-argv chokepoint that rewrites a dotted first-party version (`claude-fable-5.1`) to the dashed id Claude Code actually serves before the Bedrock mapping runs, model-flag scan helpers incl. `stripBrokenModelFlags`, `isCodexProvider`, `isKimiProvider`, `isAntigravityProvider`, `isCursorProvider`) plus reasoning-effort helpers for the claude/codex/agy/cursor CLIs (`CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `ANTIGRAVITY_EFFORT_LEVELS` / `CURSOR_EFFORT_LEVELS` / `EFFORT_LEVELS`, `effortLevelsForProvider`, `resolveCliEffort` — clamps an out-of-range effort to the nearest level the target CLI accepts rather than dropping it, so a value saved against a wider ladder survives a provider switch — `clampEffortToLadder` (that clamp over an explicit ladder; the client's own `resolveCliEffort` runs its published-field ladder through it), `hasEffortFlag`, `buildEffortArgs` — the one emitter of `--effort <level>` / `-c model_reasoning_effort=<level>`, and deliberately silent for cursor — and `foldCursorEffortIntoModel`, which carries a cursor level inside `--model` as Cursor’s own variant syntax (`gpt-5[effort=max]`) because `cursor-agent` has no `--effort` flag) plus codex startup-arg helpers (`CODEX_EFFORT_KEY`, `CODEX_UPDATE_CHECK_KEY`, `hasCodexUpdateCheckConfig`, `buildCodexStartupArgs` — the one emitter of `-c check_for_update_on_startup=false`, spread by every codex spawn builder to disable the blocking startup update modal) plus `PORTOS_CLI_CONFIG_KEYS` / `isPortosSuppliedConfigKey` — the exhaustive list of `-c <key>=<value>` config keys PortOS injects, read by the `cli-config-invalid` error analyzer to tell a rejected PortOS override apart from a bad line in the user's own CLI config file. |+| `providerModels.js` | Provider model resolution sentinels + helpers (`CODEX_CONFIGURED_DEFAULT` / `ANTIGRAVITY_CONFIGURED_DEFAULT` / `GROK_CONFIGURED_DEFAULT` / `KIMI_CONFIGURED_DEFAULT`, `resolveCliModel`, `filterSelectableModels`, Bedrock/OpenCode model mappers, `localRuntimeNamespace(provider)` — the OpenCode namespace only when it names a LOCAL daemon, i.e. the composed "namespace and not a hosted gateway" test that `cliChildEnv.js`, `localProviderRuntime.js` and `providerVendors.js` all key on, `CODEX_OSS_LOCAL_PROVIDERS` / `CODEX_OSS_MIN_VERSION` / `codexOssLocalProvider` / `codexUnsupportedLocalRuntime` — the codex half of that same axis: which local runtimes Codex's `--local-provider` can serve, and which marked runtime it cannot, kept here beside the namespace they wrap so `providerPrerequisites.js` classifies a codex record without importing `codex.js` (the argv emitter, `buildCodexOssArgs`, stays there), `OPENCODE_PUBLIC_REVIEW_AGENT` — the read-only OpenCode agent a no-tool public-review stage runs as, kept in this leaf because `providerVendors.js` must not import `opencodeConfig.js`, `parseOpencodeConfigContent` — the shared "is this stored OPENCODE_CONFIG_CONTENT usable?" read — plus `opencodeConfigIsLocalOnly` / `opencodeProviderIsLocalOnly`, the ONE locality rule `providerVendors.js` (gate eligibility) and `cliChildEnv.js` (public-review env allowlist) must not disagree about: if eligibility says yes where the allowlist strips the config, the stage spawns against the user's own ~/.config/opencode with tools intact while still reporting an enforced tool-free gate, `normalizeClaudeModelId` / `resolveClaudeCliModel` — the Claude-argv chokepoint that rewrites a dotted first-party version (`claude-fable-5.1`) to the dashed id Claude Code actually serves before the Bedrock mapping runs, model-flag scan helpers incl. `stripBrokenModelFlags`, `isCodexProvider`, `isKimiProvider`, `isAntigravityProvider`, `isCursorProvider`) plus reasoning-effort helpers for the claude/codex/agy/cursor CLIs (`CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `ANTIGRAVITY_EFFORT_LEVELS` / `CURSOR_EFFORT_LEVELS` / `EFFORT_LEVELS`, `effortLevelsForProvider`, `resolveCliEffort` — clamps an out-of-range effort to the nearest level the target CLI accepts rather than dropping it, so a value saved against a wider ladder survives a provider switch — `clampEffortToLadder` (that clamp over an explicit ladder; the client's own `resolveCliEffort` runs its published-field ladder through it), `hasEffortFlag`, `buildEffortArgs` — the one emitter of `--effort <level>` / `-c model_reasoning_effort=<level>`, and deliberately silent for cursor — and `foldCursorEffortIntoModel`, which carries a cursor level inside `--model` as Cursor’s own variant syntax (`gpt-5[effort=max]`) because `cursor-agent` has no `--effort` flag) plus codex startup-arg helpers (`CODEX_EFFORT_KEY`, `CODEX_UPDATE_CHECK_KEY`, `hasCodexUpdateCheckConfig`, `buildCodexStartupArgs` — the one emitter of `-c check_for_update_on_startup=false`, spread by every codex spawn builder to disable the blocking startup update modal) plus `PORTOS_CLI_CONFIG_KEYS` / `isPortosSuppliedConfigKey` — the exhaustive list of `-c <key>=<value>` config keys PortOS injects, read by the `cli-config-invalid` error analyzer to tell a rejected PortOS override apart from a bad line in the user's own CLI config file.; `isOpencodeLocalProvider` (the OpenCode-on-a-local-backend-or-gateway gate behind the OpenCode effort ladder) and `isCodexSubscriptionProvider` (the ChatGPT-subscription readiness key, housed here so the browser re-export skips `codexAccount.js`'s protocol tables) || `providerVendors.js` | `PROVIDER_VENDORS` — one row per coding-agent CLI/TUI vendor (claude/codex/antigravity/opencode/grok/kimi/cursor, plus a deliberately-incomplete legacy `gemini-cli` row), consumed by every dispatch site that used to hand-roll its own vendor if-chain across ~8 branches in 5 files (#3618): `applyCommandDefaults`/`prepareCliPrompt` (re-exported from `tuiHandshake.js`/`cliProviderArgs.js`), `buildVendorCliArgs`/`buildVendorSpawnConfig` (consumed by `cliProviderArgs.js#buildCliArgs` / `agentCliSpawning.js#buildCliSpawnConfig`), `inferTuiCommand` (re-exported from `tuiHandshake.js`), and `injectTuiModelAndEffort` — the shared antigravity-validates-the-pair-vs-everyone-else `--model`/`--effort` injection used by both `tuiHandshake.js#buildTuiInvocation` and `agentTuiSpawning.js#buildTuiSpawnConfig`, replacing a second copy of that split that had already drifted once before this file existed. Doesn't rewrite any vendor's argv-building logic — that stays in `antigravity.js`/`grok.js`/`kimi.js`/`cursor.js`/`codex.js`. Dependency-light on purpose, mirroring those files. || `modelCapabilityTests.js` | Catalog + scoring for the CAPABILITY tests on `/models/performance` (run by `services/modelCapabilityTests.js`): `CAPABILITY_TESTS` (sandbox repair / image analysis / story outline / fiction scene / rhetoric evaluator, each gated on the capability badges the install catalog already shows), `applicabilityFor` + `applicableTests` (`applicable` / `not-applicable` / `unknown` — an UNCLAIMED capability is never a failure, and `null` capabilities mean the runtime reported none, which is distinct from `[]`), `scoreKeywords` + `VISION_FIXTURE_KEYWORDS` (required vs bonus terms, word-boundary matched with a negation guard so "no dog" doesn't score a dog), `scoreStoryBeats` + `HEROS_JOURNEY_BEATS` (coverage AND ordering, judged only over the beats present), `scoreSandboxRepair` (verdict from observed disk facts — editing the test instead of the module fails outright), `formatAgentEvent` (one agent stream frame → a transcript line), `rollUpVerdict`, and the verbatim `CAPABILITY_TEST_PROMPTS` / `SANDBOX_TASK_PROMPT` the consent gate shows. Pure, so any stored transcript can be re-scored with no provider call. || `modelPricing.js` | Per-model API billing rates for the /devtools/usage cost estimates — `resolveModelRates(providerId, model)` (exact → family regex → provider default → blended fallback, with a `matched` tier; also derives `cacheReadPer1M`/`cacheWritePer1M` from the input rate via per-family multipliers), `isFreeProvider` (ollama/lmstudio/`ollamaBacked`/localhost = free), `estimateCostUsd(tokensIn, tokensOut, rates, cache?)` — `tokensIn` is UNCACHED input; cache tiers are priced separately via the optional 4th arg — and `PRICING_AS_OF`. Informational only (PortOS runs on subscriptions); still excludes batch/long-context tiers. |@@ -247,7 +247,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `reactorVideoClip.js` | The reactor.inc `fast-h3` clip contract, dependency-free so the route schema, the FableLoom prompt compiler and the VideoGen picker all read one copy — `REACTOR_MAX_PROMPT_LENGTH` (800; the API rejects a longer prompt rather than truncating it), `REACTOR_MIN_CLIP_SECONDS` / `REACTOR_MAX_CLIP_SECONDS` (5.167–14.375, i.e. 124–345 frames at the `REACTOR_CLIP_FPS` 24 it delivers), `REACTOR_MAX_CLIP_ID_LENGTH`, and the picker list `REACTOR_CLIP_LENGTHS` + `REACTOR_DEFAULT_CLIP_LENGTH` + `reactorClipLengthLabel()` (the two exact endpoints plus every whole second between them, since the accepted range is continuous but starts and ends off a round number). Also the CANVAS contract `set_canvas` accepts: `REACTOR_CANVASES` (`16:9` 1344×768, `4:3` 1024×768, `1:1` 768×768, `9:16` 768×1344 — every one a 768px short edge, so the aspect string is the whole choice), `REACTOR_ASPECTS`, `REACTOR_DEFAULT_ASPECT`, `reactorCanvas(aspect)` and `nearestReactorAspect(width, height)` (closest canvas in log-ratio space; anything unmeasurable answers the default rather than deriving one). Mirrored to `client/src/lib/reactorVideoClip.js`, parity pinned by `reactorVideoClip.test.js`. || `kimi.js` | Moonshot AI Kimi Code (`kimi`) provider helpers — id constants (`KIMI_CLI_ID`/`KIMI_TUI_ID`), `isKimiCommand`/`isKimiCliProvider`/`isKimiTuiProvider` predicates, `ensureKimiHeadlessArgs` (model flag only — non-interactive mode is implicit in `--prompt`, and kimi has no `--print`/`--afk` and refuses approval flags alongside `--prompt`) / `ensureKimiTuiArgs` (`--yolo`) argv builders (model selection uses the `KIMI_CONFIGURED_DEFAULT` sentinel in `providerModels.js` so PortOS omits `--model` like Grok/Antigravity), and `prepareKimiPrompt` (delivers the prompt as the `--prompt <value>` argv, not stdin). || `runners.js` | Image-runner family constants (`RUNNER_FAMILIES`, `loraCompatKey`), video LoRA families, MiniMax H3 runtime predicates, and the shared `AUDIO_TO_VIDEO_RUNTIMES` / `isAudioToVideoRuntime` capability gate (LTX plus H3 Ref2VA). Mirrored to `client/src/lib/runnerFamilies.js`. |-| `codexAccount.js` | The ChatGPT-subscription half of the Codex providers (#5589), pure. The fixed `codex app-server` invocation, the `account/*` method + notification names, `CODEX_ACCOUNT_STATUS` (`runtime-missing` / `unknown` / `signed-out` / `login-pending` / `ready` / `quota-exhausted` / `reauth-required`) and `CODEX_ERROR_CODES`, `isCodexSubscriptionProvider` (keyed on the `codex` COMMAND, so a renamed clone still resolves), the `normalizeCodexAccount` / `normalizeCodexRateLimits` / `normalizeCodexLoginStart` payload normalizers, `redactCodexPayload` (every log/error/response path runs through it, so "PortOS never writes down a Codex token" is one function rather than a rule per call site), and `deriveCodexAccountStatus`. Sentinels are load-bearing: `runtimeInstalled: null` = NOT PROBED, `accountFetched: false` ≠ signed out, `rateLimits: null` (failed fetch) ≠ a fetched window with nothing to report. The process half is `services/codexAppServer.js`. |+| `codexAccount.js` | The ChatGPT-subscription half of the Codex providers (#5589), pure. The fixed `codex app-server` invocation, the `account/*` method + notification names, `CODEX_ACCOUNT_STATUS` (`runtime-missing` / `unknown` / `signed-out` / `login-pending` / `ready` / `quota-exhausted` / `reauth-required`) and `CODEX_ERROR_CODES`, `isCodexSubscriptionProvider` (re-exported from `providerModels.js`; keyed on the `codex` COMMAND, so a renamed clone still resolves), the `normalizeCodexAccount` / `normalizeCodexRateLimits` / `normalizeCodexLoginStart` payload normalizers, `redactCodexPayload` (every log/error/response path runs through it, so "PortOS never writes down a Codex token" is one function rather than a rule per call site), and `deriveCodexAccountStatus`. Sentinels are load-bearing: `runtimeInstalled: null` = NOT PROBED, `accountFetched: false` ≠ signed out, `rateLimits: null` (failed fetch) ≠ a fetched window with nothing to report. The process half is `services/codexAppServer.js`. || `codexTurn.js` | The INFERENCE half of the Codex ChatGPT-subscription provider (#5590), pure. The `thread/start` / `turn/start` / `turn/interrupt` / `model/list` method names and the turn notifications, `CODEX_TEXT_TRANSPORT` plus `providerDeclaresCodexTextTransport` (advertises, reusing `codexAccount.isCodexSubscriptionProvider` so the two halves cannot drift) vs `isCodexTextTransportEnabled` (requires both the explicit opt-in and the Providers-UI read-risk acknowledgement), the `CODEX_TEXT_THREAD_CONFIG` safety envelope a generic text call runs under (empty throwaway cwd, no writes, no network, fail-closed approvals, no MCP servers, no web search — Codex can still read local files by absolute path; see the module docstring), `normalizeCodexModels` / `normalizeCodexTokenUsage` / `resolveCodexEffort`, the `createTurnAccumulator` → `applyCodexTurnEvent` → `finalizeCodexTurn` projection (a non-`completed` turn yields an error, NEVER the partial text), and `classifyCodexTurnError` / `classifyCodexTransportError`, which fold both failure shapes onto the shared `ERROR_CATEGORIES` the cooldown policy reads. `models: null` = never fetched, `[]` = fetched-and-empty. The process half is `services/codexAppServer.js`. || `codexUserConfig.js` | READ-ONLY probe of the user's own `~/.codex/config.toml` (honoring `CODEX_HOME`), so PortOS can SAY when a third-party bridge has re-pointed Codex model routing away from the account its cards report on. `parseCodexRoutingOverride` (pure) reports which of the top-level `openai_base_url` / `model_provider` / `model_catalog_json` keys are assigned and the base URL they name — top-level ONLY, since the same key inside a `[table]` is per-provider configuration and must not trip the badge. `readCodexRoutingOverride` adds a short TTL cache and the load-bearing sentinel: `null` = could not read (never paint that as "not overridden"), an ABSENT file = a definite `overridden: false`. PortOS never writes this file, and `baseUrl` is machine-local — render it, never log or federate it. || `codexAssistantExtract.js` | Strip Codex CLI banner + echoed metadata from session transcript. |diff --git a/server/lib/codexAccount.js b/server/lib/codexAccount.jsindex cada7fec94..3fed83646f 100644--- a/server/lib/codexAccount.js+++ b/server/lib/codexAccount.js@@ -32,8 +32,6 @@* with no limit window in flight is never mistaken for a broken fetch.*/-import { commandBasename, localRuntimeNamespace } from './providerModels.js';-/*** The one invocation PortOS is allowed to spawn. Fixed argv, never assembled* from a provider record or a request: the app-server is a protocol endpoint,@@ -92,28 +90,11 @@ export const CODEX_ERROR_CODES = Object.freeze({});/**- * Which provider records this account state belongs to.- *- * Keyed on the COMMAND, not the id: a user who cloned `codex` into- * `codex-review` still runs the same binary against the same ChatGPT sign-in,- * and hard-coding two ids would leave that card blank. API providers are- * excluded — an OpenAI API-key provider authenticates with its own stored key- * and has nothing to do with a subscription.+ * Which provider records this account state belongs to — the command-keyed,+ * local-runtime-excluding rule. Declared in `providerModels.js`, the pure leaf+ * the browser re-exports, so this module's protocol tables stay server-only.*/-export const isCodexSubscriptionProvider = (provider) => {- if (provider?.type !== 'cli' && provider?.type !== 'tui') return false;- const command = typeof provider?.command === 'string' ? provider.command.trim() : '';- if (command === '') return false;- if (commandBasename(command) !== CODEX_APP_SERVER_COMMAND) return false;- // A local-runtime-backed codex record (`codex --oss --local-provider ollama`)- // generates its tokens on this machine and authenticates against nothing, so- // the ChatGPT account is not one of its prerequisites. Without this it would- // paint "No ChatGPT account is signed in" on a provider that needs no account- // — and the card would sit in UNKNOWN until an account read that will never- // matter answers. MIRROR of `isCodexSubscriptionProvider` in- // client/src/utils/providerTypes.js.- return localRuntimeNamespace(provider) === null;-};+export { isCodexSubscriptionProvider } from './providerModels.js';/*** Keys whose VALUES may carry a credential. Matched case-insensitively as adiff --git a/server/lib/providerModels.js b/server/lib/providerModels.jsindex 90a1bc9f1d..165f3f0175 100644--- a/server/lib/providerModels.js+++ b/server/lib/providerModels.js@@ -4,11 +4,13 @@* Pure leaf (no Node built-ins, nothing outside server/lib), so the browser* imports it: client/src/utils/providerModels.js re-exports the sentinels,* effort ladders and the Antigravity split, and delegates its own ladder- * resolution to `effortLevelsForProvider` / `clampEffortToLadder`. The- * `isXProvider` predicates are still copied in client/src/utils/providerTypes.js- * — keep those in sync. One caveat the purity guard cannot see: the Bedrock /- * Claude-argv resolvers below default to `process.env`, so they are server-only- * — never call them from the browser (they tree-shake out unless something does).+ * resolution to `effortLevelsForProvider` / `clampEffortToLadder`;+ * client/src/utils/providerTypes.js re-exports the `isXProvider` predicates,+ * `commandBasename`, `localRuntimeNamespace`, `isOpencodeLocalProvider` and+ * `isCodexSubscriptionProvider`. One caveat the purity guard+ * cannot see: the Bedrock / Claude-argv resolvers below default to+ * `process.env`, so they are server-only — never call them from the browser+ * (they tree-shake out unless something does).*/import { gatewayIdForProvider, isGatewayNamespace } from './providerGateways.js';@@ -259,6 +261,37 @@ export function isCodexProvider(provider) {return id === 'codex' || id === 'codex-tui' || commandBasename(provider?.command) === 'codex';}+/**+ * True when a CLI/TUI record runs on Codex's ChatGPT subscription — what the+ * account half of the Codex providers (`codexAccount.js`, #5589) keys its+ * readiness on.+ *+ * Keyed on the COMMAND, not the id: a user who cloned `codex` into+ * `codex-review` still runs the same binary against the same ChatGPT sign-in,+ * and hard-coding two ids would leave that card blank. API providers are+ * excluded — an OpenAI API-key provider authenticates with its own stored key+ * and has nothing to do with a subscription. So is a local-runtime-backed codex+ * record (`codex --oss --local-provider ollama`): it generates its tokens on+ * this machine and authenticates against nothing, and without that exclusion+ * the card would paint "No ChatGPT account is signed in" on a provider that+ * needs no account and sit in UNKNOWN until an account read that will never+ * matter answers.+ *+ * Lives here rather than in `codexAccount.js` so the browser, which re-exports+ * it through client/src/utils/providerTypes.js, does not also carry that+ * module's frozen protocol tables — top-level `Object.freeze` calls the bundler+ * cannot shake.+ * @param {{type?:string, command?:string}|null|undefined} provider+ * @returns {boolean}+ */+export function isCodexSubscriptionProvider(provider) {+ if (provider?.type !== 'cli' && provider?.type !== 'tui') return false;+ const command = typeof provider?.command === 'string' ? provider.command.trim() : '';+ if (command === '') return false;+ if (commandBasename(command) !== 'codex') return false;+ return localRuntimeNamespace(provider) === null;+}+/*** True when a provider is Grok-Build-flavored — the shipped `grok-cli`/`grok-tui`* ids or any provider whose launch command basename is `grok`. Same posture as@@ -309,7 +342,7 @@ export function isOpencodeProvider(provider) {* True when a provider is Kimi-Code-flavored — the shipped `kimi-cli`/`kimi-tui`* ids or any provider whose launch command basename is `kimi` (path/exe tolerant).* The single home for the kimi signature, same posture as `isCodexProvider`.- * Mirrored in client/src/utils/providerTypes.js — keep in lockstep.+ * Re-exported by client/src/utils/providerTypes.js, so it stays browser-safe.* @param {{id?:string, command?:string}|null|undefined} provider* @returns {boolean}*/@@ -324,8 +357,8 @@ export function isKimiProvider(provider) {* basename is `agy`/`antigravity` (path/exe tolerant). The provider-shaped* companion to `isAntigravityCommand` in antigravity.js; lives here (rather* than there) so `effortLevelsForProvider` can key on it without this- * dependency-light module importing a sibling. Mirrored in- * client/src/utils/providerTypes.js — keep in lockstep.+ * dependency-light module importing a sibling. Re-exported by+ * client/src/utils/providerTypes.js, so it stays browser-safe.* @param {{id?:string, command?:string}|null|undefined} provider* @returns {boolean}*/@@ -348,7 +381,7 @@ export function isAntigravityProvider(provider) {** Deliberately never matches a bare `cursor` command: that is Cursor's GUI* editor launcher, not the agent binary (see cursor.js).- * Mirrored in client/src/utils/providerTypes.js — keep in lockstep.+ * Re-exported by client/src/utils/providerTypes.js, so it stays browser-safe.* @param {{id?:string, command?:string}|null|undefined} provider* @returns {boolean}*/@@ -412,7 +445,7 @@ export function foldCursorEffortIntoModel(model, effort) {*/export function effortLevelsForProvider(provider, model = null) {if (!provider) return null;- if (isOpencodeProvider(provider) && getOpencodeLocalProviderNamespace(provider)) return OPENCODE_LOCAL_EFFORT_LEVELS;+ if (isOpencodeLocalProvider(provider)) return OPENCODE_LOCAL_EFFORT_LEVELS;if (isCodexProvider(provider)) return codexEffortLevelsForModel(model);if (isAntigravityProvider(provider)) {const perModel = model ? antigravityModelEffortLevels(model, provider.models) : null;@@ -754,6 +787,19 @@ export function localRuntimeNamespace(provider) {return namespace && !isGatewayNamespace(namespace) ? namespace : null;}+/**+ * True when an OpenCode process provider runs against a local OpenAI-compatible+ * backend or a hosted gateway — any namespace `getOpencodeLocalProviderNamespace`+ * resolves — rather than a vendor cloud model. This is the gate on the OpenCode+ * effort ladder, and the browser re-exports it so the effort picker and the run+ * agree on which records get one (#4765).+ * @param {object|null|undefined} provider+ * @returns {boolean}+ */+export function isOpencodeLocalProvider(provider) {+ return isOpencodeProvider(provider) && getOpencodeLocalProviderNamespace(provider) !== null;+}+/*** The Codex CLI's own `--local-provider` values, mapped from PortOS's* local-runtime marker axis (`localRuntimeNamespace` in providerModels.js).