Skip to content

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

fix(runner): use provider-specific CLI args for Codex and Gemini

Adam Eivy3e942b5db849
diff --git a/.changelog/v0.12.x.md b/.changelog/v0.12.x.md
index 3a28e9939a..ff64e02eba 100644
--- a/.changelog/v0.12.x.md
+++ b/.changelog/v0.12.x.md
@@ -197,6 +197,10 @@ This release adds branch management and automated release workflow capabilities
## Fixes
+### Codex CLI Provider — Wrong Argument Convention
+- **Fix**: The CLI runner hardcoded `-p -` (Claude's "print, read from stdin" flag) for all CLI providers, but Codex CLI interprets `-p` as `--profile`, causing `Error loading configuration: config profile '-' not found` and immediate exit code 1
+- **Solution**: Added `buildCliArgs()` function that constructs provider-specific arguments — Codex uses `exec --model <model> -` (stdin marker), Gemini uses bare args, and Claude retains `-p -`
+
### Managed App Port Conflict — ENV Leak & Detection
- **Fix**: When PortOS started managed apps via `startFromEcosystem()`, the PortOS server's own `PORT=5554` env var leaked into child processes. Apps with `process.env.PORT || fallback` in their ecosystem configs would bind to 5554 instead of their intended port, crashing portos-server on restart.
- **Fix**: Port detection regex in `parseEcosystemConfig()` couldn't parse `process.env.PORT || 4420` expressions — it only captured `process.env.PORT` and failed to resolve it. Now extracts the `|| fallback` value.
diff --git a/server/services/runner.js b/server/services/runner.js
index 5d8b3414bb..bfe4ec29f1 100644
--- a/server/services/runner.js
+++ b/server/services/runner.js
@@ -22,6 +22,32 @@ export async function createRun(options) {
return result;
}
+/**
+ * Build CLI args based on provider type.
+ * Each CLI provider has different conventions for stdin input and model selection.
+ */
+function buildCliArgs(provider) {
+ const providerId = provider?.id || '';
+
+ // Codex CLI: `codex exec -` reads prompt from stdin, --model for model
+ if (providerId === 'codex') {
+ const args = [...(provider.args || []), 'exec'];
+ if (provider.defaultModel) {
+ args.push('--model', provider.defaultModel);
+ }
+ args.push('-'); // stdin marker
+ return args;
+ }
+
+ // Gemini CLI: prompt is piped via stdin directly
+ if (providerId === 'gemini-cli') {
+ return [...(provider.args || [])];
+ }
+
+ // Default (Claude Code CLI): -p - means "read prompt from stdin"
+ return [...(provider.args || []), '-p', '-'];
+}
+
/**
* Override executeCliRun to fix shell security issue
* This removes 'shell: true' which causes DEP0190 warning and potential security issues
@@ -38,8 +64,8 @@ export async function executeCliRun(runId, provider, prompt, workspacePath, onDa
const startTime = Date.now();
let output = '';
- // Build command with args - prompt passed via stdin to avoid argv limits
- const args = [...(provider.args || []), '-p', '-'];
+ // Build provider-specific args for stdin-based prompt delivery
+ const args = buildCliArgs(provider);
console.log(`🚀 Executing CLI: ${provider.command} (${prompt.length} chars via stdin)`);
const childProcess = spawn(provider.command, args, {