From 384b9b818b47abf48d34d667715a425ad4b92975 Mon Sep 17 00:00:00 2001 From: Zhengshou Lai Date: Tue, 7 Jul 2026 10:11:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(launcher):=20mycodex=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=90=AF=E7=94=A8=20--dangerously-bypass-approvals-and-sandbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- myagents/launcher.py | 6 +++--- tests/test_cli.py | 16 ++++++++-------- tests/test_entrypoints.py | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/myagents/launcher.py b/myagents/launcher.py index bbe94ee..624dd2a 100644 --- a/myagents/launcher.py +++ b/myagents/launcher.py @@ -46,9 +46,9 @@ _BACKENDS: dict[str, dict] = { "binary": "codex", "env_bin": "CODEX_BIN", "sessions_root": lambda: Path.home() / ".codex" / "sessions", - "session_pattern": "**/*.jsonl", - "default_args": [], - "not_found_msg": ( + "session_pattern": "**/*.jsonl", + "default_args": ["--dangerously-bypass-approvals-and-sandbox"], + "not_found_msg": ( "[red]codex CLI not found in PATH.[/red] Install with " "[cyan]npm install -g @openai/codex[/cyan] or set [cyan]CODEX_BIN[/cyan]." ), diff --git a/tests/test_cli.py b/tests/test_cli.py index 8f60257..fe3d51e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -251,7 +251,7 @@ class TestCodexSubcommand: result = runner.invoke(cli, ["codex"]) assert result.exit_code == 0 mock_run.assert_called_once() - assert mock_run.call_args[0][0] == ["/usr/bin/codex"] + assert mock_run.call_args[0][0] == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox"] def test_missing_binary_error(self) -> None: runner = CliRunner() @@ -294,11 +294,11 @@ class TestCodexPassthrough: def test_resume_subcommand_passes_through(self, tmp_path: Path) -> None: cmd = self._invoke(["resume", "abc123"], tmp_path) - assert cmd == ["/usr/bin/codex", "resume", "abc123"] + assert cmd == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox", "resume", "abc123"] def test_continue_subcommand_passes_through(self, tmp_path: Path) -> None: cmd = self._invoke(["continue"], tmp_path) - assert cmd == ["/usr/bin/codex", "continue"] + assert cmd == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox", "continue"] class TestCodexResumeOptions: @@ -320,23 +320,23 @@ class TestCodexResumeOptions: def test_r_flag_maps_to_resume(self, tmp_path: Path) -> None: cmd = self._invoke(["-r", "abc123"], tmp_path) - assert cmd == ["/usr/bin/codex", "resume", "abc123"] + assert cmd == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox", "resume", "abc123"] def test_resume_flag_maps_to_resume(self, tmp_path: Path) -> None: cmd = self._invoke(["--resume", "abc123"], tmp_path) - assert cmd == ["/usr/bin/codex", "resume", "abc123"] + assert cmd == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox", "resume", "abc123"] def test_continue_flag_maps_to_continue(self, tmp_path: Path) -> None: cmd = self._invoke(["--continue"], tmp_path) - assert cmd == ["/usr/bin/codex", "continue"] + assert cmd == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox", "continue"] def test_last_flag_maps_to_resume_last(self, tmp_path: Path) -> None: cmd = self._invoke(["--last"], tmp_path) - assert cmd == ["/usr/bin/codex", "resume", "--last"] + assert cmd == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox", "resume", "--last"] def test_all_flag_maps_to_resume_all(self, tmp_path: Path) -> None: cmd = self._invoke(["--all"], tmp_path) - assert cmd == ["/usr/bin/codex", "resume", "--all"] + assert cmd == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox", "resume", "--all"] class TestCodexListSessions: diff --git a/tests/test_entrypoints.py b/tests/test_entrypoints.py index 509d3d8..5f30de8 100644 --- a/tests/test_entrypoints.py +++ b/tests/test_entrypoints.py @@ -87,7 +87,7 @@ class TestMycodexEntrypoint: mock_run.return_value = MagicMock(returncode=0) result = runner.invoke(codex_cli, []) assert result.exit_code == 0 - assert mock_run.call_args[0][0] == ["/usr/bin/codex"] + assert mock_run.call_args[0][0] == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox"] def test_version_shows_mycodex(self) -> None: runner = CliRunner() @@ -104,4 +104,4 @@ class TestMycodexEntrypoint: mock_run.return_value = MagicMock(returncode=0) result = runner.invoke(codex_cli, ["--cwd", str(tmp_path), "-r", "abc123"]) assert result.exit_code == 0 - assert mock_run.call_args[0][0] == ["/usr/bin/codex", "resume", "abc123"] + assert mock_run.call_args[0][0] == ["/usr/bin/codex", "--dangerously-bypass-approvals-and-sandbox", "resume", "abc123"]