Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(codex): add global bypass flag and update sandboxPolicy format

cyh012741f05a62
diff --git a/config/v2_compat.py b/config/v2_compat.py
index 0f4ae43a5..b5e2713b8 100644
--- a/config/v2_compat.py
+++ b/config/v2_compat.py
@@ -24,6 +24,7 @@ class CodexCompatConfig:
binary: str
extra_args: list[str]
default_model: Optional[str] = None
+ dangerously_bypass_approvals_and_sandbox: bool = True
@dataclass
@@ -74,6 +75,7 @@ def to_app_config(v2: V2Config) -> AppCompatConfig:
binary=v2.agents.codex.cli_path,
extra_args=[],
default_model=v2.agents.codex.default_model,
+ dangerously_bypass_approvals_and_sandbox=v2.agents.codex.dangerously_bypass_approvals_and_sandbox,
)
opencode = None
if v2.agents.opencode.enabled:
diff --git a/config/v2_config.py b/config/v2_config.py
index b923a94e2..835765442 100644
--- a/config/v2_config.py
+++ b/config/v2_config.py
@@ -123,6 +123,7 @@ class CodexConfig:
enabled: bool = True
cli_path: str = "codex"
default_model: Optional[str] = None
+ dangerously_bypass_approvals_and_sandbox: bool = True
@dataclass
diff --git a/modules/agents/codex/agent.py b/modules/agents/codex/agent.py
index af4ccc626..44d28532b 100644
--- a/modules/agents/codex/agent.py
+++ b/modules/agents/codex/agent.py
@@ -237,6 +237,11 @@ class CodexAgent(BaseAgent):
binary=self.codex_config.binary,
cwd=cwd,
extra_args=list(self.codex_config.extra_args),
+ dangerously_bypass_approvals_and_sandbox=getattr(
+ self.codex_config,
+ "dangerously_bypass_approvals_and_sandbox",
+ False,
+ ),
)
# Wire up callbacks
@@ -346,7 +351,7 @@ class CodexAgent(BaseAgent):
"threadId": thread_id,
"input": input_items,
"approvalPolicy": "never",
- "sandbox": "danger-full-access",
+ "sandboxPolicy": {"type": "dangerFullAccess"},
}
if effective_model:
turn_params["model"] = effective_model
diff --git a/modules/agents/codex/transport.py b/modules/agents/codex/transport.py
index eb13d6396..557479f8d 100644
--- a/modules/agents/codex/transport.py
+++ b/modules/agents/codex/transport.py
@@ -27,10 +27,12 @@ class CodexTransport:
binary: str,
cwd: str,
extra_args: list[str] | None = None,
+ dangerously_bypass_approvals_and_sandbox: bool = False,
) -> None:
self._binary = binary
self._cwd = cwd
self._extra_args = extra_args or []
+ self._dangerously_bypass_approvals_and_sandbox = dangerously_bypass_approvals_and_sandbox
self._process: Optional[Process] = None
self._request_id: int = 0
self._pending: dict[int | str, asyncio.Future[dict[str, Any]]] = {}
@@ -57,7 +59,10 @@ class CodexTransport:
logger.warning("CodexTransport.start() called but process is already running")
return
- cmd = [self._binary, "app-server"] + self._extra_args
+ cmd = [self._binary]
+ if self._dangerously_bypass_approvals_and_sandbox:
+ cmd.append("--dangerously-bypass-approvals-and-sandbox")
+ cmd += ["app-server"] + self._extra_args
logger.info("Launching Codex app-server: %s (cwd=%s)", " ".join(cmd), self._cwd)
if not os.path.exists(self._cwd):
diff --git a/tests/test_codex_agent.py b/tests/test_codex_agent.py
index 08a28488c..770ecc415 100644
--- a/tests/test_codex_agent.py
+++ b/tests/test_codex_agent.py
@@ -294,5 +294,137 @@ class CodexAgentHandleMessageTests(unittest.IsolatedAsyncioTestCase):
self.assertIsNone(resolved)
+class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):
+ async def test_start_thread_requests_danger_full_access(self):
+ agent = object.__new__(CodexAgent)
+ agent.controller = SimpleNamespace(config=SimpleNamespace(platform="slack", reply_enhancements=False))
+ agent._session_mgr = SimpleNamespace(set_thread_id=Mock())
+ agent.sessions = SimpleNamespace(set_agent_session_mapping=Mock())
+ request = SimpleNamespace(
+ working_path="/tmp/work",
+ context=SimpleNamespace(platform="slack", platform_specific={}),
+ base_session_id="session-1",
+ session_key="channel-1",
+ )
+
+ transport = SimpleNamespace(send_request=AsyncMock(return_value={"thread": {"id": "thread-1"}}))
+
+ thread_id = await agent._start_thread(transport, request)
+
+ self.assertEqual(thread_id, "thread-1")
+ transport.send_request.assert_awaited_once_with(
+ "thread/start",
+ {
+ "cwd": "/tmp/work",
+ "approvalPolicy": "never",
+ "sandbox": "danger-full-access",
+ },
+ )
+
+ async def test_start_turn_uses_sandbox_policy_object(self):
+ agent = object.__new__(CodexAgent)
+ agent.settings_manager = SimpleNamespace(get_channel_settings=lambda session_key: None)
+ agent.codex_config = SimpleNamespace(default_model=None)
+ agent._build_input = Mock(return_value=[{"type": "text", "text": "hello"}])
+ agent._turn_registry = SimpleNamespace(
+ begin_turn_start=Mock(),
+ get_bootstrapped_turn_id=Mock(return_value=None),
+ finalize_turn_start_response=Mock(return_value=SimpleNamespace()),
+ )
+ request = SimpleNamespace(
+ session_key="channel-1",
+ base_session_id="session-1",
+ composite_session_id="slack:C1:T1",
+ )
+ transport = SimpleNamespace(send_request=AsyncMock(return_value={"turn": {"id": "turn-1"}}))
+
+ thread_id = await agent._start_turn(transport, request, "thread-1")
+
+ self.assertEqual(thread_id, "thread-1")
+ transport.send_request.assert_awaited_once_with(
+ "turn/start",
+ {
+ "threadId": "thread-1",
+ "input": [{"type": "text", "text": "hello"}],
+ "approvalPolicy": "never",
+ "sandboxPolicy": {"type": "dangerFullAccess"},
+ },
+ )
+
+
+class CodexTransportCommandTests(unittest.IsolatedAsyncioTestCase):
+ async def test_transport_starts_app_server_with_global_bypass_flag(self):
+ import importlib.util
+ from pathlib import Path
+
+ transport_path = Path(__file__).resolve().parents[1] / "modules/agents/codex/transport.py"
+ spec = importlib.util.spec_from_file_location("test_codex_transport_module", transport_path)
+ assert spec is not None and spec.loader is not None
+ transport_module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(transport_module)
+ Transport = transport_module.CodexTransport
+
+ writes = []
+ created_cmd = {}
+
+ class _FakeStdin:
+ def __init__(self):
+ self._closing = False
+
+ def write(self, data):
+ writes.append(data.decode())
+
+ async def drain(self):
+ return None
+
+ def is_closing(self):
+ return self._closing
+
+ def close(self):
+ self._closing = True
+
+ class _FakeStdout:
+ def __init__(self):
+ self._lines = [b'{"jsonrpc":"2.0","id":1,"result":{}}\n', b""]
+
+ async def readline(self):
+ return self._lines.pop(0)
+
+ class _FakeStderr:
+ async def readline(self):
+ return b""
+
+ class _FakeProcess:
+ def __init__(self):
+ self.stdin = _FakeStdin()
+ self.stdout = _FakeStdout()
+ self.stderr = _FakeStderr()
+ self.pid = 123
+ self.returncode = None
+
+ async def wait(self):
+ self.returncode = 0
+ return 0
+
+ async def fake_create_subprocess_exec(*cmd, **kwargs):
+ created_cmd["cmd"] = list(cmd)
+ return _FakeProcess()
+
+ transport_module.asyncio.create_subprocess_exec = fake_create_subprocess_exec
+
+ transport = Transport(
+ binary="codex",
+ cwd="/tmp/work",
+ dangerously_bypass_approvals_and_sandbox=True,
+ )
+ await transport.start()
+ await transport.stop()
+
+ self.assertEqual(
+ created_cmd["cmd"],
+ ["codex", "--dangerously-bypass-approvals-and-sandbox", "app-server"],
+ )
+
+
if __name__ == "__main__":
unittest.main()