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
feat: per-provider Codex authentication mode (ChatGPT subscription vs API key)
[._.]/ Adam Eivye6af9e72acb0
diff --git a/client/src/components/providers/ProviderForm.jsx b/client/src/components/providers/ProviderForm.jsxindex 211e8b17e3..e59d8987b0 100644--- a/client/src/components/providers/ProviderForm.jsx+++ b/client/src/components/providers/ProviderForm.jsx@@ -74,6 +74,7 @@ export default function ProviderForm({ provider, daemonReadiness = null, onCloseapiKey: '',allowCustomEndpoint: provider?.allowCustomEndpoint === true,ignoreUserConfig: provider?.ignoreUserConfig === true,+ codexAuthMode: provider?.codexAuthMode || '',lowPriorityOnUsageLimit: provider?.lowPriorityOnUsageLimit === true,// The FULL advertised catalog, never the model-access-scoped `models` the// payload carries. This textarea is saved verbatim, so seeding it from the@@ -480,7 +481,12 @@ export default function ProviderForm({ provider, daemonReadiness = null, onClose}// `--ignore-user-config` is a Codex flag. Never stamp it onto a record// running another vendor's binary, where it would be a stored lie.- if (!isCodexProvider({ ...provider, ...data, id: provider?.id })) delete data.ignoreUserConfig;+ if (!isCodexProvider({ ...provider, ...data, id: provider?.id })) {+ delete data.ignoreUserConfig;+ delete data.codexAuthMode;+ } else {+ data.codexAuthMode = data.codexAuthMode || null;+ }// `/low-priority` is a Claude TUI-only command. Do not persist a dormant// toggle on a CLI/headless or another vendor's provider record.if (formData.type !== 'tui' || !isClaudeCommandProvider({ ...provider, ...data, id: provider?.id })) {@@ -976,6 +982,25 @@ export default function ProviderForm({ provider, daemonReadiness = null, onClose</FormField>)}+ {isCodexProvider({ ...provider, ...formData, id: provider?.id }) && isProcessProvider(formData) && (+ <FormField label="Codex authentication">+ <select+ id="codexAuthMode"+ value={formData.codexAuthMode}+ onChange={(e) => setFormData(prev => ({ ...prev, codexAuthMode: e.target.value }))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white"+ >+ <option value="">Codex default (its own login state)</option>+ <option value="chatgpt">ChatGPT subscription</option>+ <option value="api">API key (API billing)</option>+ </select>+ <span className="text-xs text-gray-500 mt-1 block">+ Pins Codex to one login method (<code>forced_login_method</code>). Some models are only+ available to one method; ChatGPT subscription and API-key access are billed separately.+ </span>+ </FormField>+ )}+<label className="flex items-center gap-2"><inputtype="checkbox"diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex 0d7b1495e7..66f5233b99 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -10,6 +10,10 @@ This is a model-access rejection, not evidence that login failed. Run`codex login status` in the same environment as PortOS to confirm the activeauthentication method. PortOS lets Codex own its credentials and token refresh.+To pin which login method PortOS uses, set **Codex authentication** on the Codex provider+(AI Providers → edit): *ChatGPT subscription* or *API key*. It passes+`-c forced_login_method=...` to Codex; leave it on the default to let Codex decide.+Choose a supported model in the task or provider settings, or clear the task'smodel override to use its configured default (check that default too). PortOS'sshipped model catalog can include models unavailable to your account; refreshingdiff --git a/server/lib/aiToolkit/internal/providerModes.js b/server/lib/aiToolkit/internal/providerModes.jsindex c5a7903c66..bfd01d0ad7 100644--- a/server/lib/aiToolkit/internal/providerModes.js+++ b/server/lib/aiToolkit/internal/providerModes.js@@ -43,6 +43,7 @@ export const MODE_SHARED_SETTINGS_KEYS = Object.freeze(['modelHardwareRequirements','secretEnvVars','ignoreUserConfig',+ 'codexAuthMode','numCtx','temperature','topP',diff --git a/server/lib/aiToolkit/internal/providerServiceState.js b/server/lib/aiToolkit/internal/providerServiceState.jsindex ea9202b038..efad3eb03e 100644--- a/server/lib/aiToolkit/internal/providerServiceState.js+++ b/server/lib/aiToolkit/internal/providerServiceState.js@@ -329,6 +329,7 @@ export function createProviderServiceState(config = {}) {...(modelAccess ? { modelAccess } : {}),...(providerData.allowCustomEndpoint === true ? { allowCustomEndpoint: true } : {}),...(providerData.ignoreUserConfig === true ? { ignoreUserConfig: true } : {}),+ ...(providerData.codexAuthMode === 'chatgpt' || providerData.codexAuthMode === 'api' ? { codexAuthMode: providerData.codexAuthMode } : {}),...(providerData.credentialBootstrap?.command ? { credentialBootstrap: providerData.credentialBootstrap } : {}),envVars: providerData.envVars || {},secretEnvVars: providerData.secretEnvVars || [],diff --git a/server/lib/aiToolkit/validation.js b/server/lib/aiToolkit/validation.jsindex a871fd0d03..9ede39facd 100644--- a/server/lib/aiToolkit/validation.js+++ b/server/lib/aiToolkit/validation.js@@ -224,6 +224,10 @@ export const providerSchema = z.object({// one an existing install already relies on, and an override that silently// turned itself on would be its own surprise.ignoreUserConfig: z.boolean().optional(),+ // Codex authentication method pin (`forced_login_method`): 'chatgpt' = the+ // ChatGPT subscription, 'api' = API-key billing. Absent/null = Codex decides+ // from its own login state. Some models are available to only one method.+ codexAuthMode: z.enum(['chatgpt', 'api']).nullable().optional(),// A CLI/TUI provider whose harness auth is provisioned by an external CLI at// spawn time (e.g. a short-lived token for a proxy) rather than a static// `apiKey` PortOS stores. PortOS spawns `command`(+`args`) in front of thediff --git a/server/lib/codex.js b/server/lib/codex.jsindex e99b73dd3c..7f04f3caa4 100644--- a/server/lib/codex.js+++ b/server/lib/codex.js@@ -77,6 +77,7 @@ export function ensureCodexTuiArgs(args, provider = null) {if (provider?.ignoreUserConfig === true && !args.includes('--ignore-user-config')) {prefix.push('--ignore-user-config');}+ prefix.push(...buildCodexAuthModeArgs(provider, args));prefix.push(...buildCodexStartupArgs(args));// The local backing, on the same posture-flag step both TUI spawn paths// share — an interactive `codex-ollama` session without it silently reaches@@ -97,6 +98,26 @@ export function ensureCodexTuiArgs(args, provider = null) {* @param {string[]} [existingArgs]* @returns {string[]}*/+export const CODEX_AUTH_MODES = Object.freeze(['chatgpt', 'api']);++/**+ * `["-c", "forced_login_method=\"<mode>\""]` when the provider pins Codex to+ * one authentication method, else `[]` (Codex picks from its own login state).+ *+ * ChatGPT-subscription access and API-key access are separate auth and billing+ * modes, and some models are only available to one of them. Skipped when the+ * argv already sets the key, so a hand-typed `-c forced_login_method=…` wins.+ * @param {object|null|undefined} provider+ * @param {string[]} [existingArgs]+ * @returns {string[]}+ */+export function buildCodexAuthModeArgs(provider, existingArgs = []) {+ const mode = provider?.codexAuthMode;+ if (!CODEX_AUTH_MODES.includes(mode)) return [];+ if (existingArgs.some((arg) => typeof arg === 'string' && arg.includes('forced_login_method'))) return [];+ return ['-c', `forced_login_method="${mode}"`];+}+export function buildCodexOssArgs(provider, existingArgs = []) {const localProvider = codexOssLocalProvider(provider);if (!localProvider) return [];diff --git a/server/lib/providerVendors.codexIgnoreUserConfig.test.js b/server/lib/providerVendors.codexIgnoreUserConfig.test.jsindex ea6d77d095..8cc8fea8ea 100644--- a/server/lib/providerVendors.codexIgnoreUserConfig.test.js+++ b/server/lib/providerVendors.codexIgnoreUserConfig.test.js@@ -48,3 +48,27 @@ describe('codex --ignore-user-config pin', () => {expect(buildVendorSpawnConfig(claude, {}).args).not.toContain('--ignore-user-config');});});++describe('codex forced_login_method pin (codexAuthMode)', () => {+ const pin = (provider, mode) => ({ ...provider, codexAuthMode: mode });+ const pair = (mode) => ['-c', `forced_login_method="${mode}"`];+ const has = (args, mode) => args.join('\u0000').includes(pair(mode).join('\u0000'));++ it('is absent unless the provider pins a mode', () => {+ expect(buildVendorCliArgs(codexCli, [], {}).join(' ')).not.toContain('forced_login_method');+ expect(buildVendorSpawnConfig(codexCli, {}).args.join(' ')).not.toContain('forced_login_method');+ expect(applyCommandDefaults('codex', [], codexTui).join(' ')).not.toContain('forced_login_method');+ expect(buildVendorCliArgs(pin(codexCli, 'bogus'), [], {}).join(' ')).not.toContain('forced_login_method');+ });++ it('reaches every codex spawn path', () => {+ expect(has(buildVendorCliArgs(pin(codexCli, 'chatgpt'), [], {}), 'chatgpt')).toBe(true);+ expect(has(buildVendorSpawnConfig(pin(codexCli, 'api'), {}).args, 'api')).toBe(true);+ expect(has(applyCommandDefaults('codex', [], pin(codexTui, 'chatgpt')), 'chatgpt')).toBe(true);+ });++ it('does not override a forced_login_method the user already typed', () => {+ const args = buildVendorCliArgs(pin(codexCli, 'api'), ['-c', 'forced_login_method="chatgpt"'], {});+ expect(args.filter((arg) => arg.includes('forced_login_method'))).toHaveLength(1);+ });+});diff --git a/server/lib/providerVendors.js b/server/lib/providerVendors.jsindex 50fab1c813..f793c8460e 100644--- a/server/lib/providerVendors.js+++ b/server/lib/providerVendors.js@@ -86,6 +86,7 @@ import {CODEX_COMMAND,CODEX_CLI_ID,buildCodexOssArgs,+ buildCodexAuthModeArgs,} from './codex.js';import {ANTIGRAVITY_COMMAND,@@ -287,6 +288,7 @@ function codexCliArgs(baseArgs, { model, effort, provider }) {const hasExec = baseArgs.includes('exec');const args = hasExec ? [...baseArgs] : [...baseArgs, 'exec'];args.push(...codexIgnoreUserConfigArgs(provider, args));+ args.push(...buildCodexAuthModeArgs(provider, baseArgs));args.push(...buildCodexStartupArgs(baseArgs));// The local-model backing, when the record carries a runtime marker codex can// serve. Emitted from the marker rather than from provider args so a wrapper@@ -308,6 +310,7 @@ function codexSpawnArgs(provider, { effectiveModel, effort, maxConcurrentThreads'exec','--dangerously-bypass-approvals-and-sandbox',...codexIgnoreUserConfigArgs(provider),+ ...buildCodexAuthModeArgs(provider),...buildCodexStartupArgs(),...buildCodexOssArgs(provider),...buildCodexAgentThreadArgs(maxConcurrentThreads),