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
refactor: resolve the Codex record through one predicate, not two
[._.]/ Adam Eivy7cd1da01dc68
diff --git a/server/lib/README.md b/server/lib/README.mdindex 1a72433959..7d5c9cdccf 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| `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`. |-| `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) vs `isCodexTextTransportEnabled` (the explicit opt-in that actually permits routing), the `CODEX_TEXT_THREAD_CONFIG` safety envelope a generic text call runs under (empty throwaway cwd, read-only no-network sandbox, fail-closed approvals, no MCP servers, no web search), `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`. |+| `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` (the explicit opt-in that actually permits routing), the `CODEX_TEXT_THREAD_CONFIG` safety envelope a generic text call runs under (empty throwaway cwd, read-only no-network sandbox, fail-closed approvals, no MCP servers, no web search), `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`. || `codexAssistantExtract.js` | Strip Codex CLI banner + echoed metadata from session transcript. || `codexCliOutput.js` | Network/system error patterns for `agentErrorAnalysis.js`. || `contextBudget.js` | Context-window budgeter for editorial passes. `estimateTokens`/`estimateTokensFromChars` (chars/4), `usableInputTokens`, `manuscriptContentBudgetChars` (single-block content cap floored at a manuscript minimum so a standalone stage trims to fit a small window instead of overflowing a fixed 48–60K floor, #1488), `planManuscriptPass({ contextWindow, sections })` → `{ mode: 'whole' \| 'chunked', chunks }`. Also `fitContextToManuscriptFloor`/`capContextOverhead`/`trimContextToBudget` — trim a re-sent context block (scene map, character arcs, …) so a large reverse outline on a small window can't starve the manuscript chunk below a budget floor (#1459). Decides whole-manuscript vs chunked given a model's window. |diff --git a/server/lib/codexTurn.js b/server/lib/codexTurn.jsindex c64487018a..e36f1a6bdf 100644--- a/server/lib/codexTurn.js+++ b/server/lib/codexTurn.js@@ -30,8 +30,7 @@*/import { ERROR_CATEGORIES } from './aiToolkit/errorDetection.js';-import { commandBasename } from './providerModels.js';-import { CODEX_APP_SERVER_COMMAND, CODEX_ERROR_CODES } from './codexAccount.js';+import { CODEX_ERROR_CODES, isCodexSubscriptionProvider } from './codexAccount.js';/*** The value a provider record carries to advertise that it can serve generic@@ -100,12 +99,12 @@ export const CODEX_TURN_ERROR_CODES = Object.freeze({* shipped seed advertises it so the Providers page has something to offer,* while the capability stays off until the user turns it on.*/-export const providerDeclaresCodexTextTransport = (provider) => {- if (provider?.textTransport !== CODEX_TEXT_TRANSPORT) return false;- if (provider.type !== 'cli' && provider.type !== 'tui') return false;- const command = typeof provider.command === 'string' ? provider.command.trim() : '';- return command !== '' && commandBasename(command) === CODEX_APP_SERVER_COMMAND;-};+export const providerDeclaresCodexTextTransport = (provider) =>+ provider?.textTransport === CODEX_TEXT_TRANSPORT+ // "Which record IS the Codex subscription" is one question with one answer,+ // keyed on the COMMAND so a renamed clone still resolves. Reused rather than+ // restated so the account side and the inference side can never drift.+ && isCodexSubscriptionProvider(provider);/*** May PortOS actually route a text call here?