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: align provider controls with the Claude launch harness (#6605)
[._.]/ Adam Eivy7af8a24d3171
diff --git a/client/src/components/cos/AgentJobProviderFields.jsx b/client/src/components/cos/AgentJobProviderFields.jsxindex 368887c298..d70dfd172a 100644--- a/client/src/components/cos/AgentJobProviderFields.jsx+++ b/client/src/components/cos/AgentJobProviderFields.jsx@@ -1,5 +1,5 @@import {- AGENT_HARNESS_PROVIDER_TYPES,+ isProcessProvider,effortAwareModelOptions,filterRunnableProviders,resolveEffectiveProvider,@@ -14,7 +14,7 @@ import ProviderModelSelector from '../ProviderModelSelector.jsx';export const hasRunnableAgentProvider = (providers, providerId, activeProviderId) => {const selectableProviders = filterRunnableProviders(providers, providerId);const { provider } = resolveEffectiveProvider(selectableProviders, providerId, activeProviderId);- return AGENT_HARNESS_PROVIDER_TYPES.includes(provider?.type);+ return isProcessProvider(provider);};/**@@ -46,8 +46,8 @@ export default function AgentJobProviderFields({const effectiveProviderId = usingActive ? (activeProviderId || undefined) : undefined;const patchWithActiveProvider = (patch) =>data.providerId || !activeProviderId ? patch : { providerId: activeProviderId, ...patch };- const canInheritActiveProvider = AGENT_HARNESS_PROVIDER_TYPES.includes(- selectableProviders.find(provider => provider.id === activeProviderId)?.type+ const canInheritActiveProvider = isProcessProvider(+ selectableProviders.find(provider => provider.id === activeProviderId));return (diff --git a/client/src/components/providers/ProviderForm.test.jsx b/client/src/components/providers/ProviderForm.test.jsxindex 1f8602ce8b..6669933678 100644--- a/client/src/components/providers/ProviderForm.test.jsx+++ b/client/src/components/providers/ProviderForm.test.jsx@@ -92,4 +92,10 @@ describe('ProviderForm', () => {await waitFor(() => expect(api.createProvider).toHaveBeenCalledWith(expect.objectContaining({ ultraModel: 'frontier-model' })));});+ it('explains the Claude credential path for a blank-command SGLang harness', () => {+ renderForm({ provider: { id: 'example-local', name: 'Example Local', type: 'tui', command: '', sglangBacked: true } });+ expect(screen.getByText('ANTHROPIC_AUTH_TOKEN')).toBeInTheDocument();+ expect(screen.queryByText(/It rides both the spawned OpenCode provider/)).not.toBeInTheDocument();+ });+});diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex 1dce9ae3e7..2c52697d25 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` (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. |+| `providerTypes` | What KIND of provider a record is: `PROVIDER_TYPES` (re-exported from `server/lib/aiToolkit/constants.js`) with `isCliProvider` / `isTuiProvider` / `isApiProvider` / `isProcessProvider` and `isClaudeHarnessProvider` (re-exported from `server/lib/providerTypes.js`, with legacy alias `isClaudeCommandProvider`), `isLaunchableTuiProvider` (a TUI provider carrying the server-resolved `tuiCommandLine`, i.e. one a human can start at a shell prompt — shared by the Providers card's "Launch in Shell" button and the Shell page's launch menu so the two can't disagree), `enabledApiProviderFilter`, `enabledProcessProviderFilter` (the coding/CLI-TUI-only counterpart, for a manual Claim/Replan/Resolve/Review "Run with" picker), `providerTypeClass`; the vendor-harness predicates keyed on the shipped ids plus `commandBasename` so a path-configured or renamed binary still qualifies (`isCodexProvider`, `isCodexSubscriptionProvider` — subscription readiness is keyed on the `codex` command, never an editable id — `isAntigravityProvider`, `isCursorProvider`, `isKimiProvider`, `isGrokProvider`, `isGrokBuildCli`, `isClaudeCommandProvider`, `isOpencodeLocalProvider`); and the structural backend markers a wrapper carries (`localRuntimeNamespace`, `isOllamaBackedProvider`). Everything with a server twin is re-exported from the pure leaves `server/lib/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/providerSelection.js b/client/src/utils/providerSelection.jsindex e93cefce83..10cb87e301 100644--- a/client/src/utils/providerSelection.js+++ b/client/src/utils/providerSelection.js@@ -15,7 +15,7 @@*/import { isLocalInstanceProvider, localBackendForProvider } from './providerEndpoints.js';-import { AGENT_HARNESS_PROVIDER_TYPES, isApiProvider } from './providerTypes.js';+import { isProcessProvider, isApiProvider } from './providerTypes.js';import { isHardwareCompatible } from './systemCapabilities.js';import { CALLER_MODE_POLICIES } from '../../../server/lib/callerModePolicy.js';@@ -149,7 +149,7 @@ export const filterRunnableProviders = (providers, selectedProviderIds = []) =>(Array.isArray(selectedProviderIds) ? selectedProviderIds : [selectedProviderIds]).filter(Boolean));return (Array.isArray(providers) ? providers : []).filter(provider =>- AGENT_HARNESS_PROVIDER_TYPES.includes(provider?.type) || preservedIds.has(provider?.id)+ isProcessProvider(provider) || preservedIds.has(provider?.id));};diff --git a/client/src/utils/providerTypes.js b/client/src/utils/providerTypes.jsindex d70e598097..5de90c46a4 100644--- a/client/src/utils/providerTypes.js+++ b/client/src/utils/providerTypes.js@@ -9,15 +9,15 @@* 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.+ * here: launchability and picker filters, the Grok process composition, and+ * the Tailwind chip classes.** Re-exported by `./providers.js` for existing `utils/providers` imports.*/+import { isTuiProvider, isApiProvider, isProcessProvider } from '../../../server/lib/providerTypes.js';import { PROVIDER_TYPES } from '../../../server/lib/aiToolkit/constants.js';-import { commandBasename, isGrokProvider } from '../../../server/lib/providerModels.js';+import { 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`,@@ -35,18 +35,14 @@ export {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.-export const AGENT_HARNESS_PROVIDER_TYPES = Object.freeze([- PROVIDER_TYPES.CLI,- PROVIDER_TYPES.TUI-]);--/**- * Check if a provider is a TUI-backed agent provider. Mirror of- * `isTuiProvider` in server/services/agentCliSpawning.js.- */-export const isTuiProvider = (provider) => provider?.type === PROVIDER_TYPES.TUI;+export {+ isCliProvider,+ isTuiProvider,+ isApiProvider,+ isProcessProvider,+ isClaudeHarnessProvider,+ isClaudeHarnessProvider as isClaudeCommandProvider,+} from '../../../server/lib/providerTypes.js';/*** Can a human launch this provider at a shell prompt?@@ -63,18 +59,6 @@ export const isTuiProvider = (provider) => provider?.type === PROVIDER_TYPES.TUI*/export const isLaunchableTuiProvider = (provider) => isTuiProvider(provider) && Boolean(provider?.tuiCommandLine);-/**- * Check if a provider is a one-shot CLI agent provider.- */-export const isCliProvider = (provider) => provider?.type === PROVIDER_TYPES.CLI;--/**- * Check if a provider is an HTTP-API provider (e.g. OpenAI, Anthropic, LM Studio),- * as opposed to a process-backed CLI/TUI agent. Use this anywhere you'd write- * `provider.type === PROVIDER_TYPES.API` against a saved provider.- */-export const isApiProvider = (provider) => provider?.type === PROVIDER_TYPES.API;-/*** Stable, module-scoped filter for `useProviderModels({ filter })` and other* call sites that need "enabled HTTP-API providers only". Hoisted so the@@ -82,12 +66,6 @@ export const isApiProvider = (provider) => provider?.type === PROVIDER_TYPES.API*/export const enabledApiProviderFilter = (provider) => Boolean(provider?.enabled) && isApiProvider(provider);-/**- * Check if a provider is process-backed (cli or tui), as opposed to an- * HTTP-API provider. Use this for "shows a Command + args" config predicates.- */-export const isProcessProvider = (provider) => isCliProvider(provider) || isTuiProvider(provider);-/*** Stable, module-scoped filter for `useProviderModels({ filter })` on a manual* dispatch picker (a Claim/Replan/Resolve/Review "Run with" control) — only@@ -97,26 +75,6 @@ export const isProcessProvider = (provider) => isCliProvider(provider) || isTuiP*/export const enabledProcessProviderFilter = (provider) => Boolean(provider?.enabled) && isProcessProvider(provider);-/**- * True when a provider launches the Claude Code binary, whatever backend it is- * pointed at (`claude-code`, `claude-ollama`, `claude-sglang`, or any renamed- * record whose command resolves to `claude`).- *- * 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.- *- * 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):* a PROCESS provider `isGrokProvider` recognizes — the shipped `grok-cli` /diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 442e7bafb8..6a501e284e 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -4,6 +4,7 @@// the 69 `utils/providers` importers notices. The declaring modules re-export// their shared tables from `server/lib`, so what is pinned here is the// client-side behaviour built on top of them.+import * as serverProviderTypes from '../../../server/lib/providerTypes.js';import { describe, it, expect } from 'vitest';import {ANTIGRAVITY_CONFIGURED_DEFAULT,@@ -208,38 +209,39 @@ describe('effortLevelsForProvider', () => {// (server/lib/aiToolkit/internal/generationOptions.js) for HTTP runs.describe('generationControlsFor', () => {it.each([- ['OpenCode llama TUI', { id: 'opencode-llama-tui', command: 'opencode', llamaBacked: true }, { temperature: true, topP: true, thinking: true }],- ['OpenCode MTPLX', { id: 'opencode-mtplx', command: 'opencode', mtplxBacked: true }, { temperature: true, topP: true, thinking: true }],+ ['OpenCode llama TUI', { id: 'opencode-llama-tui', type: 'tui', command: 'opencode', llamaBacked: true }, { temperature: true, topP: true, thinking: true }],+ ['OpenCode MTPLX', { id: 'opencode-mtplx', type: 'tui', command: 'opencode', mtplxBacked: true }, { temperature: true, topP: true, thinking: true }],// vLLM routes the thinking toggle through the chat template like the other// two. Both sides were written before `vllmBacked` existed, so the editor// hid the whole block while the server discarded every control anyway// (#4765).- ['OpenCode vLLM TUI', { id: 'opencode-vllm-tui', command: 'opencode', vllmBacked: true }, { temperature: true, topP: true, thinking: true }],+ ['OpenCode vLLM TUI', { id: 'opencode-vllm-tui', type: 'tui', command: 'opencode', vllmBacked: true }, { temperature: true, topP: true, thinking: true }],// SGLang takes the same chat-template thinking toggle, and shipped with the// controls wired from day one so it never repeated vLLM's hole.- ['OpenCode SGLang TUI', { id: 'opencode-sglang-tui', command: 'opencode', sglangBacked: true }, { temperature: true, topP: true, thinking: true }],+ ['OpenCode SGLang TUI', { id: 'opencode-sglang-tui', type: 'tui', command: 'opencode', sglangBacked: true }, { temperature: true, topP: true, thinking: true }],// A Claude harness on Ollama is forwarded only MAX_THINKING_TOKENS// (server/lib/cliChildEnv.js) — it owns its own sampling.- ['Claude Ollama TUI', { id: 'claude-ollama-tui', command: 'claude', ollamaBacked: true }, { temperature: false, topP: false, thinking: true }],+ ['Claude Ollama TUI', { id: 'claude-ollama-tui', type: 'tui', command: 'claude', ollamaBacked: true }, { temperature: false, topP: false, thinking: true }],+ ['blank Claude command', { id: 'claude-ollama', type: 'tui', command: '', ollamaBacked: true }, { temperature: false, topP: false, thinking: true }],// ...but a Claude harness on ANY OTHER local backend gets no control at all.// MAX_THINKING_TOKENS is the harness's only thinking lever, and it means// "off" solely on Ollama; SGLang takes `chat_template_kwargs.enable_thinking`,// which the Anthropic wire cannot carry, so the toggle would pin a value// nothing reads. Sampling was never forwardable on a Claude harness either,// which would have left the block rendering one inert select.- ['Claude SGLang TUI', { id: 'claude-sglang-tui', command: 'claude', sglangBacked: true }, null],+ ['Claude SGLang TUI', { id: 'claude-sglang-tui', type: 'tui', command: 'claude', sglangBacked: true }, null],// LM Studio forwards temperature/top_p like any OpenAI-compatible endpoint,// but reasoning is a property of the LOADED model instance there — no// per-request field carries it, so the toggle would pin a value nothing// reads (THINKING_STYLE.lmstudio is null on the server).- ['OpenCode LM Studio', { id: 'opencode-lmstudio', command: 'opencode', lmstudioBacked: true }, { temperature: true, topP: true, thinking: false }],+ ['OpenCode LM Studio', { id: 'opencode-lmstudio', type: 'tui', command: 'opencode', lmstudioBacked: true }, { temperature: true, topP: true, thinking: false }],['native Ollama API', { id: 'ollama', type: 'api', endpoint: 'http://localhost:11434/v1' }, { temperature: true, topP: true, thinking: true }],// OrcaRouter proxies cloud models that own their own reasoning switch.- ['OpenCode OrcaRouter', { id: 'opencode-orcarouter', command: 'opencode', orcarouterBacked: true }, { temperature: true, topP: true, thinking: false }],+ ['OpenCode OrcaRouter', { id: 'opencode-orcarouter', type: 'tui', command: 'opencode', orcarouterBacked: true }, { temperature: true, topP: true, thinking: false }],// Same posture for every gateway: upstream models own their reasoning switch.- ['OpenCode OpenRouter', { id: 'opencode-openrouter', command: 'opencode', gatewayBacked: 'openrouter' }, { temperature: true, topP: true, thinking: false }],+ ['OpenCode OpenRouter', { id: 'opencode-openrouter', type: 'tui', command: 'opencode', gatewayBacked: 'openrouter' }, { temperature: true, topP: true, thinking: false }],['cloud API provider', { id: 'anthropic', type: 'api', endpoint: 'https://api.anthropic.com/v1' }, null],- ['vendor CLI', { id: 'claude-code', command: 'claude' }, null],+ ['vendor CLI', { id: 'claude-code', type: 'cli', command: 'claude' }, null],])('%s', (_label, provider, expected) => {expect(generationControlsFor(provider)).toEqual(expected);});@@ -570,7 +572,7 @@ describe('configuredDefaultIn', () => {// 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]+ const shared = [serverProviderModels, serverProviderTypes, 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', () => {@@ -578,6 +580,9 @@ describe('providerTypes re-exports the server predicates', () => {'PROVIDER_TYPES','commandBasename','isAntigravityProvider',+ 'isApiProvider',+ 'isClaudeHarnessProvider',+ 'isCliProvider','isCodexProvider','isCodexSubscriptionProvider','isCursorProvider',@@ -585,10 +590,16 @@ describe('providerTypes re-exports the server predicates', () => {'isKimiProvider','isOllamaBackedProvider','isOpencodeLocalProvider',+ 'isProcessProvider',+ 'isTuiProvider','localRuntimeNamespace',]);});+ it('keeps the legacy Claude command alias on the type-gated server export', () => {+ expect(providerTypes.isClaudeCommandProvider).toBe(serverProviderTypes.isClaudeHarnessProvider);+ });+it.each(shared)('%s is the server export itself', (name, leaf) => {expect(providerTypes[name]).toBe(leaf[name]);});diff --git a/server/lib/README.md b/server/lib/README.mdindex 47cc9c55e8..21494f5d62 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -609,3 +609,5 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and| `creativeDirectorVideoReview.js` | `retainVideoCuts` preserves rendered cut references on invalidation. Video checkpoint fingerprints, owner-only review actions, feedback, and targeted revision invalidation. || `creativeDirectorVideoCompiler.js` | `compileVideoArtifact` and `validateVideoShot` — pure timed-shot/source-reference compilation and pinned-backend compatibility shared by Creative Director project mutations and Video execution preflight. Storage, history and approval remain with their existing owners. |++| `providerTypes.js` | Pure shared `isCliProvider`, `isTuiProvider`, `isApiProvider`, `isProcessProvider`, and type-gated `isClaudeHarnessProvider` predicates. |diff --git a/server/lib/grok.js b/server/lib/grok.jsindex 246ba6f3c6..88aa424b69 100644--- a/server/lib/grok.js+++ b/server/lib/grok.js@@ -21,6 +21,7 @@* standalone autofixer process.*/+import { isCliProvider, isTuiProvider } from './providerTypes.js';import os from 'os';import { writeFileSync, unlinkSync } from 'fs';import { join } from 'path';@@ -56,13 +57,13 @@ export function isGrokCommand(command) {/** True for the CLI (headless) Grok provider. */export function isGrokCliProvider(provider) {return provider?.id === GROK_CLI_ID- || (provider?.type === 'cli' && isGrokCommand(provider?.command));+ || (isCliProvider(provider) && isGrokCommand(provider?.command));}/** True for the TUI (interactive) Grok provider. */export function isGrokTuiProvider(provider) {return provider?.id === GROK_TUI_ID- || (provider?.type === 'tui' && isGrokCommand(provider?.command));+ || (isTuiProvider(provider) && isGrokCommand(provider?.command));}// A prompt source already declared (single-turn prompt, prompt file, or JSONdiff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.jsindex cf2d0b3c3d..971493181e 100644--- a/server/lib/importScoping.test.js+++ b/server/lib/importScoping.test.js@@ -381,3 +381,12 @@ it('keeps Video compilation independent of project storage and execution', () =>expect(closure.has(abs('services/creativeDirector/videoExecution.js'))).toBe(false);expect(closure.has(abs('lib/validation.js'))).toBe(false);});++describe('shared provider type leaf', () => {+ it('keeps provider models independent of the type leaf and browser-safe', () => {+ expect(reaches('lib/providerModels.js', 'lib/providerTypes.js')).toBe(false);+ const closure = staticImportClosure(abs('lib/providerTypes.js'));+ expect(closure.packages.size).toBe(0);+ expect(reaches('lib/providerTypes.js', 'lib/providerModels.js')).toBe(true);+ });+});diff --git a/server/lib/index.js b/server/lib/index.jsindex 5bc9d471c3..666b00609c 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -589,3 +589,4 @@ export * from './requestOrigin.js';export * from './cosFederationPolicy.js';export * from './creativeDirectorVideoReview.js';export * from './creativeDirectorVideoCompiler.js';+export * from './providerTypes.js';diff --git a/server/lib/kimi.js b/server/lib/kimi.jsindex fa08b87f4d..b4a77a2e6a 100644--- a/server/lib/kimi.js+++ b/server/lib/kimi.js@@ -44,6 +44,7 @@* parses kimi's stdout programmatically today, so `text` stays the default.*/+import { isCliProvider, isTuiProvider } from './providerTypes.js';import { argvHasFlag, commandBasename, hasModelFlag } from './providerModels.js';const NOOP_CLEANUP = () => {};@@ -81,13 +82,13 @@ export function isKimiCommand(command) {/** True for the CLI (headless) Kimi provider. */export function isKimiCliProvider(provider) {return provider?.id === KIMI_CLI_ID- || (provider?.type === 'cli' && isKimiCommand(provider?.command));+ || (isCliProvider(provider) && isKimiCommand(provider?.command));}/** True for the TUI (interactive) Kimi provider. */export function isKimiTuiProvider(provider) {return provider?.id === KIMI_TUI_ID- || (provider?.type === 'tui' && isKimiCommand(provider?.command));+ || (isTuiProvider(provider) && isKimiCommand(provider?.command));}/**diff --git a/server/lib/providerFamilies.js b/server/lib/providerFamilies.jsindex a6215fd8b1..7b4ec21dbd 100644--- a/server/lib/providerFamilies.js+++ b/server/lib/providerFamilies.js@@ -1,4 +1,5 @@-import { commandBasename, isClaudeCommand } from './providerModels.js';+import { isClaudeHarnessProvider } from './providerTypes.js';+import { commandBasename } from './providerModels.js';import { isGrokCommand } from './grok.js';/**@@ -26,7 +27,7 @@ export const PROVIDER_FAMILIES = [id: 'claude',label: 'Claude Code',idPattern: /claude/i,- matches: (p) => (p.type === 'cli' || p.type === 'tui') && isClaudeCommand(p.command)+ matches: isClaudeHarnessProvider},{id: 'codex',diff --git a/server/lib/providerPrerequisites.js b/server/lib/providerPrerequisites.jsindex cb1f7b6324..02feabd002 100644--- a/server/lib/providerPrerequisites.js+++ b/server/lib/providerPrerequisites.js@@ -35,6 +35,7 @@* process environment that will ultimately run the provider.*/+import { isProcessProvider } from './providerTypes.js';import { PROVIDER_TYPES } from './aiToolkit/constants.js';import { CODEX_ACCOUNT_STATUS, isCodexSubscriptionProvider } from './codexAccount.js';import { isLocalInstanceHost } from './localProviderRuntime.js';@@ -135,10 +136,6 @@ export const isPrivateNetworkEndpoint = (endpoint) => {return !host.includes('.') && !host.includes(':');};-/** True for a process-backed provider (cli/tui), which needs its binary on PATH. */-const isProcessProvider = (provider) =>- provider?.type === PROVIDER_TYPES.CLI || provider?.type === PROVIDER_TYPES.TUI;-/*** The key a CLI/TUI provider's runtime is published under in the runtimes map* from `services/providerRuntimeInstaller.js`, or `null` when that map hasdiff --git a/server/lib/providerTypes.js b/server/lib/providerTypes.jsnew file mode 100644index 0000000000..07efbffc6c--- /dev/null+++ b/server/lib/providerTypes.js@@ -0,0 +1,11 @@+import { PROVIDER_TYPES } from './aiToolkit/constants.js';+import { isClaudeCommand } from './providerModels.js';++/** Provider record types, shared by server dispatch and browser controls. */+export const isCliProvider = (provider) => provider?.type === PROVIDER_TYPES.CLI;+export const isTuiProvider = (provider) => provider?.type === PROVIDER_TYPES.TUI;+export const isApiProvider = (provider) => provider?.type === PROVIDER_TYPES.API;+export const isProcessProvider = (provider) => isCliProvider(provider) || isTuiProvider(provider);++/** Blank process commands default to Claude; API records never launch a harness. */+export const isClaudeHarnessProvider = (provider) => isProcessProvider(provider) && isClaudeCommand(provider?.command);diff --git a/server/lib/providerVendors.js b/server/lib/providerVendors.jsindex df910394cc..cef704ae33 100644--- a/server/lib/providerVendors.js+++ b/server/lib/providerVendors.js@@ -57,6 +57,7 @@* constant lives in providerModels.js beside its siblings.*/+import { isProcessProvider } from './providerTypes.js';import {resolveCliModel,resolveCliEffort,@@ -145,17 +146,6 @@ function defaultSpawnArgs(cliArgsFn, fallbackCommand) {});}-/**- * A provider record that names a local binary PortOS can spawn. A TUI record of- * a vendor (`codex-tui`, `grok-tui`, …) is spawned through that vendor's- * headless public-review recipe exactly like its CLI sibling, so the user's- * enabled TUI providers are legal stage choices. The one exception is a recipe- * supplying `tuiSpawnArgs` (see `supportsTuiPublicReviewPosture`), which the- * sandboxed-actions stage may run as an attachable session so an operator can- * watch and steer it. API/custom providers have no binary and no recipe.- */-const isDirectBinaryProvider = (provider) => provider?.type === PROVIDER_TYPES.CLI || provider?.type === PROVIDER_TYPES.TUI;-// ─── codex ──────────────────────────────────────────────────────────────────// The opt-in that pins a Codex run to the account PortOS believes it is using.@@ -317,7 +307,7 @@ const CODEX = {// Read-only filesystem access still exposes tools; it is not no-tool.[PUBLIC_REVIEW_ACTIONS_POSTURE]: {spawnArgs: codexPublicReviewActionsSpawnArgs,- matchProvider: (provider) => isDirectBinaryProvider(provider) && isCodexCommand(provider?.command),+ matchProvider: (provider) => isProcessProvider(provider) && isCodexCommand(provider?.command),},},};@@ -344,7 +334,7 @@ const ANTIGRAVITY = {// Plan mode is not an explicit empty-tool contract.[PUBLIC_REVIEW_ACTIONS_POSTURE]: {spawnArgs: antigravityPublicReviewActionsSpawnArgs,- matchProvider: (provider) => isDirectBinaryProvider(provider) && isAntigravityCommand(provider?.command),+ matchProvider: (provider) => isProcessProvider(provider) && isAntigravityCommand(provider?.command),},},};@@ -385,7 +375,7 @@ function opencodeCliArgs(baseArgs, { model, provider }) {* unrepresentable.* - **a spawnable binary**, as for every other vendor.*/-const matchOpencodeBinary = (provider) => isDirectBinaryProvider(provider) && isOpencodeCommand(provider?.command);+const matchOpencodeBinary = (provider) => isProcessProvider(provider) && isOpencodeCommand(provider?.command);const isLocalOpencodeProvider = (provider) => matchOpencodeBinary(provider)&& ['ollama', 'lmstudio'].includes(localRuntimeNamespace(provider))@@ -480,11 +470,11 @@ const GROK = {publicReview: {[PUBLIC_REVIEW_NO_TOOL_POSTURE]: {spawnArgs: grokPublicReviewSpawnArgs,- matchProvider: (provider) => isDirectBinaryProvider(provider) && isGrokCommand(provider?.command),+ matchProvider: (provider) => isProcessProvider(provider) && isGrokCommand(provider?.command),},[PUBLIC_REVIEW_ACTIONS_POSTURE]: {spawnArgs: grokPublicReviewActionsSpawnArgs,- matchProvider: (provider) => isDirectBinaryProvider(provider) && isGrokCommand(provider?.command),+ matchProvider: (provider) => isProcessProvider(provider) && isGrokCommand(provider?.command),},},};@@ -563,7 +553,7 @@ const PI = {spawnArgs: defaultSpawnArgs(piCliArgs, PI_COMMAND),publicReview: {[PUBLIC_REVIEW_NO_TOOL_POSTURE]: {- matchProvider: (provider) => isDirectBinaryProvider(provider) && isPiCommand(provider?.command),+ matchProvider: (provider) => isProcessProvider(provider) && isPiCommand(provider?.command),spawnArgs: (provider, { effectiveModel, effort } = {}) => ({command: provider.command,args: ensurePiHeadlessArgs([@@ -730,7 +720,7 @@ function claudePublicReviewArgs(postureArgs, provider, {};}-const matchClaudeBinary = (provider) => isDirectBinaryProvider(provider) && isClaudeCommand(provider?.command);+const matchClaudeBinary = (provider) => isProcessProvider(provider) && isClaudeCommand(provider?.command);const CLAUDE = {id: 'claude',@@ -918,7 +908,7 @@ export function buildVendorSpawnConfig(provider, ctx) {* API/custom providers have no maintained recipe: a generic read-only prompt* is not enforcement, so they fail closed. A TUI record IS eligible — the* stage spawns its binary through the vendor's enforced recipe, headless unless- * that recipe also supplies `tuiSpawnArgs` (see `isDirectBinaryProvider` and+ * that recipe also supplies `tuiSpawnArgs` (see `isProcessProvider` and* `supportsTuiPublicReviewPosture`).*/export function publicReviewPosturesForProvider(provider) {@@ -939,7 +929,7 @@ export function enforcedPublicReviewPosturesForProvider(provider) {// still falls through to the vendor's ordinary argv and the schedule UI keeps// reporting that choice as worktree-only rather than OS-sandboxed.const enforcesPublicReviewPosture = (provider, posture) => (- isDirectBinaryProvider(provider) && Boolean(publicReviewRecipe(provider, posture)?.spawnArgs)+ isProcessProvider(provider) && Boolean(publicReviewRecipe(provider, posture)?.spawnArgs));/**diff --git a/server/services/agentCliSpawning.js b/server/services/agentCliSpawning.jsindex ab429dcd87..0f3e48ac7a 100644--- a/server/services/agentCliSpawning.js+++ b/server/services/agentCliSpawning.js@@ -297,7 +297,7 @@ export const isClaudeCliProvider = (provider) =>* Antigravity, etc. that run in a PTY). Used by callers that need to branch* between headless CLI/API runs and TUI shell sessions.*/-export const isTuiProvider = (provider) => provider?.type === PROVIDER_TYPES.TUI;+export { isTuiProvider } from '../lib/providerTypes.js';/*** Read env vars from ~/.claude/settings.json to inject into Claude CLI spawns.diff --git a/server/services/agentProviderResolution.js b/server/services/agentProviderResolution.jsindex b3ce2afb2c..43ef3483aa 100644--- a/server/services/agentProviderResolution.js+++ b/server/services/agentProviderResolution.js@@ -1,3 +1,4 @@+import { isProcessProvider } from '../lib/providerTypes.js';import { isPrivateSecurityTask, PRIVATE_SECURITY_DELIVERY } from '../lib/privateSecurityPolicy.js';import { supportsPublicReviewProvider } from '../lib/providerVendors.js';/**@@ -43,7 +44,7 @@ export async function resolveAgentProviderAndModel(task) {if (!project) return { ok: false, permanent: true, error: 'Video production is paused or changed. Review and Resume from the project.' };const choice = project.videoExecution.choices[marker.kind === 'evaluate' ? 'evaluation' : marker.kind];const provider = choice?.providerId ? await getProviderById(choice.providerId) : null;- if (!provider || provider.enabled === false || provider.type === 'api' || !await isProviderAvailable(provider.id)) {+ if (!provider || provider.enabled === false || !isProcessProvider(provider) || !await isProviderAvailable(provider.id)) {return { ok: false, permanent: true, error: 'The reviewed Video agent provider is unavailable. Change Models or Settings and Resume.' };}return { ok: true, provider, selectedModel: choice.model, modelSelection: { model: choice.model, tier: 'user-specified', reason: 'Reviewed Video production choice' } };diff --git a/server/services/persistentMindTaskCapability.js b/server/services/persistentMindTaskCapability.jsindex 4abf865dd4..db26905505 100644--- a/server/services/persistentMindTaskCapability.js+++ b/server/services/persistentMindTaskCapability.js@@ -7,6 +7,7 @@* and outcome in the mind trajectory, and only then queues an internal task.*/+import { isProcessProvider } from '../lib/providerTypes.js';import {PERSISTENT_MIND_TASK_LIMITS,isPersistentMindTaskModelAllowed,@@ -47,7 +48,7 @@ const appTrackerCache = new Map();const isRunnableApp = (app) => typeof app?.repoPath === 'string' && app.repoPath.trim().length > 0;const isRunnableAgentProvider = (provider) => provider?.enabled !== false- && (provider?.type === 'cli' || provider?.type === 'tui');+ && isProcessProvider(provider);const boundedProviderCandidates = (providers) => providers.filter((provider) => isRunnableAgentProvider(provider)diff --git a/server/services/providerUsage.js b/server/services/providerUsage.jsindex 08538d6e65..3a784385f8 100644--- a/server/services/providerUsage.js+++ b/server/services/providerUsage.js@@ -1,3 +1,4 @@+import { isProcessProvider } from '../lib/providerTypes.js';import { readdir } from 'fs/promises';import { join } from 'path';import { getAllProviders } from './providers.js';@@ -520,7 +521,7 @@ export function parseGrokUsage(text, { now = Date.now(), timezone } = {}) {* args are one-shot/headless flags that would break the interactive `/usage`.*/function pickScrapeProvider(providers, binary) {- const cliTui = (providers || []).filter((p) => p?.type === 'cli' || p?.type === 'tui');+ const cliTui = (providers || []).filter(isProcessProvider);const byBinary = (list) => list.find((p) => commandBasename(p.command) === binary) || list[0];const tui = cliTui.filter((p) => p.type === 'tui');const cli = cliTui.filter((p) => p.type === 'cli');diff --git a/server/services/scheduledHandlers/providerPick.js b/server/services/scheduledHandlers/providerPick.jsindex cdfbf0aaa7..c9b588e0b5 100644--- a/server/services/scheduledHandlers/providerPick.js+++ b/server/services/scheduledHandlers/providerPick.js@@ -8,6 +8,7 @@* programmatic job's probe load exactly that.*/+import { isProcessProvider } from '../../lib/providerTypes.js';import { getAllProviders } from '../providers.js';import { commandBasename } from '../../lib/providerModels.js';@@ -41,7 +42,7 @@ import { commandBasename } from '../../lib/providerModels.js';export function providerForFamily(providers, { familyId, providerId, prefer = 'tui' }) {const available = (providers || []).filter((provider) =>provider?.enabled && provider.ollamaBacked !== true && provider.lmstudioBacked !== true && provider.mtplxBacked !== true && provider.llamaBacked !== true && provider.vllmBacked !== true && provider.sglangBacked !== true- && (provider.type === 'cli' || provider.type === 'tui'));+ && isProcessProvider(provider));if (providerId) return available.find((provider) => provider.id === providerId) || null;const inFamily = available.filter((provider) => matchesFamily(provider, familyId));return inFamily.find((provider) => provider.type === prefer) || inFamily[0] || null;diff --git a/server/services/stageRunner.js b/server/services/stageRunner.jsindex f39a4747ba..d5754a1e5a 100644--- a/server/services/stageRunner.js+++ b/server/services/stageRunner.js@@ -14,6 +14,7 @@* every stage call lands in `data/runs/<runId>/` for replay.*/+import { isProcessProvider } from '../lib/providerTypes.js';import { ServerError } from '../lib/errorHandler.js';import { findBalancedBlocks, tryParseWithRepair } from '../lib/jsonExtract.js';import { resolveEffectiveModel, runPromptThroughProvider, DEFAULT_TIMEOUT_MS, isLocalEndpoint } from './promptRunner.js';@@ -191,7 +192,7 @@ export { isLocalEndpoint };// non-local API providers are cloud. Local backends (ollama/lmstudio on// localhost) are the only genuinely small-window case.const isLikelyLargeContextProvider = (provider) => {- if (provider?.type === 'cli' || provider?.type === 'tui') return true;+ if (isProcessProvider(provider)) return true;if (provider?.type === 'api') return !isLocalEndpoint(provider.endpoint);return false;};