PEP-171: Codex agents start without the removed --full-auto — no approvals, no sandbox by default (like bypassPermissions); mock-codex refuses --full-auto like Codex 0.169

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Асель 2026-11-16 18:27:30 +05:00
parent a05d163a14
commit bcecf9b334
3 changed files with 17 additions and 2 deletions

View File

@ -67,8 +67,11 @@ function claudeCommand(c: LaunchContext): string[] {
/**
* Codex has no Claude-style hooks: Peppa only learns about completed turns through the
* `notify` callback, and about crashes, stalls and limits through the watchdog.
* Permission prompts can't be routed to the PM, so it runs in --full-auto by default.
* Permission prompts can't be routed to the PM: like Claude's bypassPermissions (PEP-171 — Codex
* 0.169 removed --full-auto) it runs with no approvals and no sandbox, unless PEPPA_CODEX_MODE says otherwise.
*/
export const CODEX_DEFAULT_MODE = "--sandbox danger-full-access --ask-for-approval never";
function codexCommand(c: LaunchContext): string[] {
const toml = (v: unknown) => JSON.stringify(v);
return [
@ -76,7 +79,7 @@ function codexCommand(c: LaunchContext): string[] {
"--no-alt-screen",
"--cd",
c.cwd,
...(c.permissionMode ?? process.env.PEPPA_CODEX_MODE ?? "--full-auto").split(" ").filter(Boolean),
...(c.permissionMode ?? process.env.PEPPA_CODEX_MODE ?? CODEX_DEFAULT_MODE).split(" ").filter(Boolean),
...(c.model ? ["--model", c.model] : []),
// Codex knows low/medium/high (xhigh/max → high).
...(c.effort ? ["-c", `model_reasoning_effort=${toml(["xhigh", "max"].includes(c.effort) ? "high" : c.effort)}`] : []),

View File

@ -70,6 +70,11 @@ function parseArgs(): Args {
return a;
}
// PEP-171: Codex 0.169 removed --full-auto — the real CLI refuses it and exits with 2.
if (provider === "codex" && argv.includes("--full-auto")) {
process.stderr.write("error: unexpected argument '--full-auto' found\n\n tip: to pass '--full-auto' as a value, use '-- --full-auto'\n\nUsage: codex [OPTIONS] [PROMPT]\n");
process.exit(2);
}
const args = parseArgs();
// OpenCode: rules (instructions) and the peppa MCP server come from the generated config.
if (provider === "opencode" && process.env.OPENCODE_CONFIG && existsSync(process.env.OPENCODE_CONFIG)) {

View File

@ -181,3 +181,10 @@ describe("Codex", () => {
await runner.stopSession(db, sid);
});
});
describe("PEP-171: запуск Codex без удалённого флага", () => {
test("по умолчанию — без подтверждений и песочницы, флага --full-auto нет", () => {
assert.equal(runner.CODEX_DEFAULT_MODE, "--sandbox danger-full-access --ask-for-approval never");
assert.ok(!runner.CODEX_DEFAULT_MODE.includes("--full-auto"));
});
});