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: name the right source when a provider CLI rejects its config
[._.]/ Adam Eivy30fd372f903a
diff --git a/server/lib/README.md b/server/lib/README.mdindex 7ee3fbe130..c48e93e3bf 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -122,7 +122,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `videoFinishProfiles.js` | Draft → delivery ("Finish") relationships between video models (#3696). `VIDEO_FINISH_PROFILES` declares each fast draft entry id → `{ shippedRepo, finishModelId }`, only for pairs that share a runtime, base repo and supported modes (the same weights at a different step budget), so re-rendering the draft's seed reproduces its composition instead of re-rolling it. `applyVideoFinishProfiles(list)` is the load-time backfill (twin of migration 238) with the usual preservation guards (existing key wins, custom id skipped, forked `repo` skipped); `validateFinishProfileGraph(list)` returns the graph problems (missing / self-referencing / chained target, runtime / repo / supportedModes mismatch) and `sanitizeFinishProfiles(list)` warns + strips them at load so a typo can never surface a Finish button targeting nothing. `finishTargetForModel(model, availableModels)` resolves the delivery entry scoped to what this install can run. || `videoModeProfiles.js` | The shipped `supportedModes` fact per video runtime (#3737), so "which modes does this model support?" has one answer on the registry entry instead of 25+ `runtime === '…'` comparisons. `VIDEO_RUNTIME_MODES` maps each runtime to the base semantic modes its helper's argv can actually render (`mlx_video`/`ltx2` text+image+fflf+extend, `wan22` text+image, `minimax_h3` / `minimax_h3_cuda` text+image+fflf off one shared array — also the mode ceiling in `videoGen/modeContract.js` — `hunyuan` text only, replacing the legacy unread `mode: 't2v'` field); `VIDEO_BASE_MODES` is the fallback for an unknown (user-added or peer-synced) runtime, deliberately the full base set so a custom model doesn't vanish from every picker. `resolveVideoSupportedModes(entry)` (declared non-empty list always wins) and `applyVideoSupportedModes(list)` — the read-time decoration `mediaModels.js#getVideoModels` applies, so the derived list never lands in `data/media-models.json` where it would read back as a *declared* list no later correction could reach. a2v and the IC-LoRA remix ids are NOT enumerated here: they're ltx2 pipeline capabilities, gated by runtime (`A2V_REQUIRES_LTX2` / `IC_LORA_REQUIRES_LTX2`). || `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. |-| `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, model-flag scan helpers incl. `stripBrokenModelFlags`, `isCodexProvider`, `isKimiProvider`, `isAntigravityProvider`) plus reasoning-effort helpers for the claude/codex/agy CLIs (`CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `ANTIGRAVITY_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 — `hasEffortFlag`, and `buildEffortArgs` — the one emitter of `--effort <level>` / `-c model_reasoning_effort=<level>`) plus codex startup-arg helpers (`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). |+| `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, model-flag scan helpers incl. `stripBrokenModelFlags`, `isCodexProvider`, `isKimiProvider`, `isAntigravityProvider`) plus reasoning-effort helpers for the claude/codex/agy CLIs (`CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `ANTIGRAVITY_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 — `hasEffortFlag`, and `buildEffortArgs` — the one emitter of `--effort <level>` / `-c model_reasoning_effort=<level>`) 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. || `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. || `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. || `usageRange.js` | `resolveUsageRange({ period, from, to })` — pure period→inclusive-YYYY-MM-DD range resolution for the usage cost report (explicit dates win; `all` unbounded; default 7d). |diff --git a/server/lib/providerModels.js b/server/lib/providerModels.jsindex b85b3bfd4e..1530a2b127 100644--- a/server/lib/providerModels.js+++ b/server/lib/providerModels.js@@ -335,6 +335,12 @@ export function resolveCliEffort(effort, provider, model = null) {return EFFORT_RANK[below.length ? below[below.length - 1] : supported[0]];}+// Codex's config key (set via `-c <key>=<value>`) that carries the reasoning+// effort. Named for the same reason as CODEX_UPDATE_CHECK_KEY below: the string+// is matched in one place, emitted in another, and read back by the error+// analyzer when a config rejection has to be blamed on PortOS or on the user.+export const CODEX_EFFORT_KEY = 'model_reasoning_effort';+/*** True when the user has already baked an effort override into the provider's* args — claude's `--effort <level>` / `--effort=<level>` or a codex@@ -352,7 +358,7 @@ export function hasEffortFlag(args) {const next = args[i + 1];return typeof next === 'string' && next.length > 0 && !next.startsWith('-');}- return a.startsWith('model_reasoning_effort=');+ return a.startsWith(`${CODEX_EFFORT_KEY}=`);});}@@ -373,7 +379,7 @@ export function buildEffortArgs(effort, provider, existingArgs = [], model = nulconst effectiveEffort = resolveCliEffort(effort, provider, model);if (!effectiveEffort || hasEffortFlag(existingArgs)) return [];return isCodexProvider(provider)- ? ['-c', `model_reasoning_effort=${effectiveEffort}`]+ ? ['-c', `${CODEX_EFFORT_KEY}=${effectiveEffort}`]: ['--effort', effectiveEffort];}@@ -424,6 +430,33 @@ export function buildCodexStartupArgs(existingArgs = []) {return ['-c', `${CODEX_UPDATE_CHECK_KEY}=false`];}+/**+ * Every CLI config key PortOS itself injects as a `-c <key>=<value>` override.+ * Exhaustive by construction — `buildEffortArgs` and `buildCodexStartupArgs`+ * above are the only two builders that emit `-c`, and both key off the+ * constants listed here.+ *+ * Read by the `cli-config-invalid` error analyzer (`agentErrorAnalysis.js`) to+ * answer the only question that matters when a CLI refuses to start: did PortOS+ * hand it that value, or was it already sitting in the user's own config file?+ * Getting this wrong sends the user grepping PortOS source for a key PortOS+ * never emits — the 2026-08-18 `service_tier` incident, where a newer install+ * of the same CLI had written a variant the CLI on PATH rejects into the shared+ * config file.+ */+export const PORTOS_CLI_CONFIG_KEYS = Object.freeze([CODEX_EFFORT_KEY, CODEX_UPDATE_CHECK_KEY]);++/**+ * True when `key` is a config key PortOS supplies via `-c` (see+ * PORTOS_CLI_CONFIG_KEYS). Null-safe; comparison is exact, so a lookalike key+ * from the user's config file is correctly reported as not-ours.+ * @param {unknown} key+ * @returns {boolean}+ */+export function isPortosSuppliedConfigKey(key) {+ return typeof key === 'string' && PORTOS_CLI_CONFIG_KEYS.includes(key.trim());+}+/*** True when a provider command points at the OpenCode binary — matching the bare* `opencode` on PATH OR an absolute/relative path to it (`/opt/homebrew/bin/opencode`,diff --git a/server/lib/providerModels.test.js b/server/lib/providerModels.test.jsindex 0b7da9ee6b..4c9210ba2e 100644--- a/server/lib/providerModels.test.js+++ b/server/lib/providerModels.test.js@@ -32,7 +32,10 @@ import {resolveCliEffort,hasEffortFlag,buildEffortArgs,+ CODEX_EFFORT_KEY,CODEX_UPDATE_CHECK_KEY,+ PORTOS_CLI_CONFIG_KEYS,+ isPortosSuppliedConfigKey,hasCodexUpdateCheckConfig,buildCodexStartupArgs,isCodexProvider,@@ -516,6 +519,35 @@ describe('providerModels', () => {});});+ // The `cli-config-invalid` analyzer asks this to decide whether a rejected+ // config key came from a PortOS `-c` override or from the user's own CLI+ // config file, and it names a different fix for each — so an emitter added+ // without a row here would be blamed on the user (incident 2026-08-18).+ describe('isPortosSuppliedConfigKey / PORTOS_CLI_CONFIG_KEYS', () => {+ it('covers exactly the keys the -c builders emit', () => {+ expect([...PORTOS_CLI_CONFIG_KEYS].sort()).toEqual([CODEX_EFFORT_KEY, CODEX_UPDATE_CHECK_KEY].sort());+ // Guard against a third emitter appearing without a row: both builders+ // that produce `-c` are asserted to use a listed key.+ const emitted = [+ ...buildEffortArgs('high', { command: 'codex' }),+ ...buildCodexStartupArgs()+ ].filter((a) => a.includes('='));+ expect(emitted.length).toBeGreaterThan(0);+ for (const pair of emitted) expect(isPortosSuppliedConfigKey(pair.split('=')[0])).toBe(true);+ });++ it('is false for keys that only ever live in the user config file', () => {+ // Real 2026-08-18 rejection: written by a newer install of the same CLI.+ expect(isPortosSuppliedConfigKey('service_tier')).toBe(false);+ expect(isPortosSuppliedConfigKey('notify')).toBe(false);+ // Lookalikes must not pass — the fix text hinges on an exact match.+ expect(isPortosSuppliedConfigKey('model_reasoning_effort_override')).toBe(false);+ expect(isPortosSuppliedConfigKey('')).toBe(false);+ expect(isPortosSuppliedConfigKey(null)).toBe(false);+ expect(isPortosSuppliedConfigKey(42)).toBe(false);+ });+ });+describe('isConfiguredDefaultModel', () => {it('matches every configured-default sentinel', () => {expect(isConfiguredDefaultModel(CODEX_CONFIGURED_DEFAULT)).toBe(true);diff --git a/server/services/agentErrorAnalysis.js b/server/services/agentErrorAnalysis.jsindex ee018c449d..6eb76164ed 100644--- a/server/services/agentErrorAnalysis.js+++ b/server/services/agentErrorAnalysis.js@@ -24,6 +24,7 @@ import {} from '../lib/investigationTasks.js';import { investigationCircuitOpen, noteInvestigationFiled, readAllTasksFlat, recentInvestigationCreations } from './investigationTaskProducer.js';import { PRIMARY_CHECKOUT_MUTATED_CATEGORY, PRIMARY_CHECKOUT_MUTATED_ESCALATION, PRIMARY_CHECKOUT_MUTATED_REASON } from '../lib/primaryCheckoutGuard.js';+import { isPortosSuppliedConfigKey } from '../lib/providerModels.js';// Max retries before blocking a taskexport const MAX_TASK_RETRIES = 3;@@ -31,6 +32,11 @@ export const MAX_TASK_RETRIES = 3;// Longest redacted failure snippet folded into a human-facing investigation body.const SNIPPET_MAX_CHARS = 240;+// Longest accepted-values list echoed back in a `cli-config-invalid` fix. Codex+// enumerates every variant it accepts ("expected one of `minimal`, `low`, …"),+// which is useful at a glance and unreadable at full length.+const CONFIG_EXPECTED_MAX_CHARS = 120;+// Machine-identity / network / PII fragments stripped before a captured failure// snippet (or any interpolated free text) lands in a human-facing — and possibly// federated — investigation task body. See the "Sensitive Data & Privacy" section@@ -123,8 +129,17 @@ export const ERROR_PATTERNS = [// accept, sitting in the global config). Deliberately does NOT echo the// matched path — it embeds the OS username (see Sensitive Data & Privacy in// CLAUDE.md).+ //+ // The rejected key can come from either side, and the fix text says which+ // (see `extract`): PortOS injects only PORTOS_CLI_CONFIG_KEYS via `-c`, so+ // any other key is already in the user's own config file. Second real+ // incident, 2026-08-18: the Codex desktop app wrote `service_tier =+ // "default"` into the shared `~/.codex/config.toml`, and the older+ // `codex` on PATH — the one PortOS spawns — accepts only `fast` or `flex`.+ // Blaming a PortOS override there burns an investigation cycle in the wrong+ // repo.{- pattern: /(?:error loading )?config\.toml(?::\d+:\d+)?:\s*unknown (variant|field) `([^`]+)`(?:[\s\S]{0,200}?in `([^`]+)`)?/i,+ pattern: /(?:error loading )?config\.toml(?::\d+:\d+)?:\s*unknown (variant|field) `([^`]+)`(?:,\s*expected ([^\n]+))?(?:[\s\S]{0,200}?in `([^`]+)`)?/i,category: 'cli-config-invalid',actionable: true,origin: 'runner', // fully structured — the CLI's own config-load rejection@@ -132,13 +147,37 @@ export const ERROR_PATTERNS = [extract: (match) => {const kind = match[1].toLowerCase();const value = match[2];- const key = match[3] || null;+ // The CLI already printed the values it WILL accept ("expected `fast` or+ // `flex`"). Fold them into the fix so it is directly actionable, instead+ // of "its own error message lists them" — which sends the reader back to+ // a log the escalation card never shows. Redacted like every other+ // free-text capture (this body can federate) and capped, since some keys+ // enumerate a long ladder.+ const expected =+ redactFailureSnippet(match[3] || '')+ .replace(/[.,;]+$/, '')+ .slice(0, CONFIG_EXPECTED_MAX_CHARS) || null;+ const key = match[4] || null;const keyRef = key ? `\`${key}\`` : 'the rejected key';+ const accepts = expected ? ` This CLI version expects ${expected}.` : '';+ // Provenance is the whole fix here. PortOS emits exactly two `-c` config+ // keys (PORTOS_CLI_CONFIG_KEYS); anything else was already sitting in the+ // user's own config file — commonly written there by a NEWER install of+ // the same CLI sharing that file. Real incident 2026-08-18: the Codex+ // desktop app wrote `service_tier = "default"` into `~/.codex/config.toml`+ // and the older `codex` on PATH rejects that variant. Naming the wrong+ // source costs a whole investigation cycle, so say which one it is.+ const source = !key+ ? `Look first in the CLI's own config file — for codex that is \`~/.codex/config.toml\` — then in the \`-c <key>=<value>\` overrides PortOS builds in server/lib/providerModels.js.`+ : isPortosSuppliedConfigKey(key)+ ? `PortOS supplies ${keyRef} itself as a \`-c <key>=<value>\` override, so the accepted values belong in that provider's ladder in server/lib/providerModels.js — editing the CLI config file will not help.`+ : `PortOS never supplies ${keyRef}, so it is already in the CLI's own config file — for codex that is \`~/.codex/config.toml\`. Edit or delete that line, or upgrade this CLI to a version that accepts the value; a second, newer install of the same CLI sharing one config file is the usual source.`;return {message: `Provider CLI rejected its config: unknown ${kind} "${value}"${key ? ` for ${key}` : ''}`,- suggestedFix: `The CLI failed while LOADING its config, before the prompt was read, so every retry dies identically. Set ${keyRef} to a value this CLI version accepts (its own error message lists them) in the CLI's config file — for codex that is \`~/.codex/config.toml\`. If PortOS supplied the value as a \`-c <key>=<value>\` override instead, it is out of the provider's ladder in server/lib/providerModels.js.`,+ suggestedFix: `The CLI failed while LOADING its config, before the prompt was read, so every retry dies identically. Set ${keyRef} to a value this CLI version accepts.${accepts} ${source}`,rejectedConfigKey: key,- rejectedConfigValue: value+ rejectedConfigValue: value,+ rejectedConfigExpected: expected};}},diff --git a/server/services/agentErrorAnalysis.test.js b/server/services/agentErrorAnalysis.test.jsindex 39e4d29f7e..ae0caa712a 100644--- a/server/services/agentErrorAnalysis.test.js+++ b/server/services/agentErrorAnalysis.test.js@@ -150,6 +150,56 @@ describe('analyzeAgentFailure — ERROR_PATTERNS classification', () => {expect(decision.metadataUpdates.blockedCategory).toBe('cli-config-invalid');});+ // Real incident 2026-08-18: the Codex desktop app wrote `service_tier =+ // "default"` into the shared `~/.codex/config.toml`, and the older `codex` on+ // PATH — the binary PortOS spawns — accepts only `fast` or `flex`. Every+ // codex agent on the machine died at config load. The first pass at this fix+ // text told the reader to check "the provider's ladder in providerModels.js",+ // which for a key PortOS never emits is a dead end: the analysis has to name+ // the CLI's own config file as the source.+ it('blames the user config for a key PortOS never supplies', () => {+ const line = 'Error loading config.toml: unknown variant `default`, expected `fast` or `flex`\nin `service_tier`';+ const analysis = analyzeAgentFailure(withLead(line), { id: 't' }, 'gpt-5.6-luna');+ expect(analysis.category).toBe('cli-config-invalid');+ expect(analysis.rejectedConfigKey).toBe('service_tier');+ expect(analysis.rejectedConfigValue).toBe('default');+ expect(analysis.suggestedFix).toContain('PortOS never supplies `service_tier`');+ expect(analysis.suggestedFix).toContain('~/.codex/config.toml');+ // Pointing at PortOS source for a key PortOS does not emit is the failure+ // mode this test exists to prevent.+ expect(analysis.suggestedFix).not.toContain('providerModels.js');+ });++ // The mirror case: `model_reasoning_effort` IS a PortOS `-c` override, so the+ // fix belongs in the effort ladder and editing the CLI config would be undone+ // on the next spawn.+ it('blames the PortOS override for a key PortOS does supply', () => {+ const line = 'Error loading config.toml: unknown variant `max`, expected one of `low`, `high`\nin `model_reasoning_effort`';+ const analysis = analyzeAgentFailure(withLead(line), { id: 't' }, 'gpt-5.6-sol');+ expect(analysis.suggestedFix).toContain('providerModels.js');+ expect(analysis.suggestedFix).not.toContain('PortOS never supplies');+ });++ // The CLI enumerates what it WILL accept; the escalation card shows the fix+ // text, not the raw log, so the accepted values have to ride along with it.+ it('echoes the accepted values the CLI listed', () => {+ const line = 'Error loading config.toml: unknown variant `default`, expected `fast` or `flex`\nin `service_tier`';+ const analysis = analyzeAgentFailure(withLead(line), { id: 't' }, 'gpt-5.6-luna');+ expect(analysis.rejectedConfigExpected).toBe('`fast` or `flex`');+ expect(analysis.suggestedFix).toContain('expects `fast` or `flex`');+ });++ // No `expected` clause (and no `in \`key\`` line) — the fix degrades to naming+ // both possible sources rather than interpolating an empty list.+ it('omits the accepted-values clause when the CLI did not list any', () => {+ const line = 'Error loading config.toml: unknown field `mystery_setting` while parsing the provider table';+ const analysis = analyzeAgentFailure(withLead(line), { id: 't' }, 'x');+ expect(analysis.category).toBe('cli-config-invalid');+ expect(analysis.rejectedConfigExpected).toBeNull();+ expect(analysis.suggestedFix).not.toContain('This CLI version expects');+ expect(analysis.suggestedFix).toContain('Look first in');+ });+it('classifies a config file that fails to load at all', () => {const analysis = analyzeAgentFailure(withLead('Error loading config.toml: expected a value after the equals sign'), { id: 't' }, 'x');expect(analysis.category).toBe('cli-config-invalid');