optio-codex 0.4.7__tar.gz → 0.4.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. {optio_codex-0.4.7 → optio_codex-0.4.9}/PKG-INFO +3 -3
  2. {optio_codex-0.4.7 → optio_codex-0.4.9}/pyproject.toml +3 -3
  3. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/host_actions.py +2 -1
  4. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/session.py +7 -3
  5. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex.egg-info/PKG-INFO +3 -3
  6. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex.egg-info/SOURCES.txt +2 -0
  7. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex.egg-info/requires.txt +2 -2
  8. optio_codex-0.4.9/tests/test_deliverable_metadata_wiring.py +65 -0
  9. optio_codex-0.4.9/tests/test_engine_venv.py +121 -0
  10. {optio_codex-0.4.7 → optio_codex-0.4.9}/README.md +0 -0
  11. {optio_codex-0.4.7 → optio_codex-0.4.9}/setup.cfg +0 -0
  12. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/__init__.py +0 -0
  13. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/account.py +0 -0
  14. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/conversation.py +0 -0
  15. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/conversation_listener.py +0 -0
  16. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/cred_watcher.py +0 -0
  17. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/fs_allowlist.py +0 -0
  18. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/info.py +0 -0
  19. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/models.py +0 -0
  20. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/prompt.py +0 -0
  21. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/rollout.py +0 -0
  22. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/seed_manifest.py +0 -0
  23. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/snapshots.py +0 -0
  24. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/todos.py +0 -0
  25. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/types.py +0 -0
  26. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex/verify.py +0 -0
  27. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex.egg-info/dependency_links.txt +0 -0
  28. {optio_codex-0.4.7 → optio_codex-0.4.9}/src/optio_codex.egg-info/top_level.txt +0 -0
  29. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_account.py +0 -0
  30. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_agent_info.py +0 -0
  31. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_auto_start_prompt.py +0 -0
  32. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_await_codex_gone.py +0 -0
  33. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_claustrum.py +0 -0
  34. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_codex_cache.py +0 -0
  35. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_config.py +0 -0
  36. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_config_hooks.py +0 -0
  37. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_conversation.py +0 -0
  38. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_conversation_controls.py +0 -0
  39. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_conversation_listener.py +0 -0
  40. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_cred_watcher.py +0 -0
  41. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_file_download.py +0 -0
  42. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_file_upload.py +0 -0
  43. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_fs_allowlist.py +0 -0
  44. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_host_actions.py +0 -0
  45. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_import.py +0 -0
  46. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_input_wiring.py +0 -0
  47. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_kill_ttyd_by_socket.py +0 -0
  48. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_models.py +0 -0
  49. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_prompt.py +0 -0
  50. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_real_codex_conversation.py +0 -0
  51. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_real_codex_seed_resume.py +0 -0
  52. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_real_codex_session.py +0 -0
  53. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_rollout.py +0 -0
  54. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_sandbox_enforce.py +0 -0
  55. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_seed_manifest.py +0 -0
  56. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_session_conversation.py +0 -0
  57. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_session_lease.py +0 -0
  58. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_session_local.py +0 -0
  59. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_session_remote.py +0 -0
  60. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_session_resume.py +0 -0
  61. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_session_sandbox.py +0 -0
  62. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_session_seed.py +0 -0
  63. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_snapshots.py +0 -0
  64. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_teardown_session_tree.py +0 -0
  65. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_todos.py +0 -0
  66. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_verify.py +0 -0
  67. {optio_codex-0.4.7 → optio_codex-0.4.9}/tests/test_workdir_trust.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: optio-codex
3
- Version: 0.4.7
3
+ Version: 0.4.9
4
4
  Summary: Run OpenAI Codex as an optio task; local subprocess; ttyd-served TUI iframe.
5
5
  Author-email: Kristof Csillag <kristof.csillag@deai-labs.com>
6
6
  License-Expression: Apache-2.0
@@ -20,9 +20,9 @@ Classifier: Topic :: Software Development :: Code Generators
20
20
  Classifier: Framework :: AsyncIO
21
21
  Requires-Python: >=3.11
22
22
  Description-Content-Type: text/markdown
23
- Requires-Dist: optio-core<0.7,>=0.6
23
+ Requires-Dist: optio-core<0.8,>=0.7
24
24
  Requires-Dist: optio-host<0.5,>=0.4
25
- Requires-Dist: optio-agents<0.8,>=0.7
25
+ Requires-Dist: optio-agents<0.9,>=0.8
26
26
  Requires-Dist: asyncssh>=2.14
27
27
  Requires-Dist: aiohttp>=3.9
28
28
  Provides-Extra: dev
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "optio-codex"
7
- version = "0.4.7"
7
+ version = "0.4.9"
8
8
  description = "Run OpenAI Codex as an optio task; local subprocess; ttyd-served TUI iframe."
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -26,9 +26,9 @@ classifiers = [
26
26
  "Framework :: AsyncIO",
27
27
  ]
28
28
  dependencies = [
29
- "optio-core>=0.6,<0.7",
29
+ "optio-core>=0.7,<0.8",
30
30
  "optio-host>=0.4,<0.5",
31
- "optio-agents>=0.7,<0.8",
31
+ "optio-agents>=0.8,<0.9",
32
32
  "asyncssh>=2.14",
33
33
  "aiohttp>=3.9",
34
34
  ]
@@ -16,6 +16,7 @@ from optio_agents import RESUME_NOTICE, SYSTEM_MESSAGE_PREFIX
16
16
  from optio_agents import claustrum
17
17
  from optio_agents import pane_surfacing
18
18
  from optio_agents import tmux_input as _tmux_input
19
+ from optio_agents.session_env import session_base_path
19
20
  from optio_host.host import proc_wait
20
21
 
21
22
  if TYPE_CHECKING:
@@ -593,7 +594,7 @@ def _codex_isolation_env(host: "Host") -> dict[str, str]:
593
594
  explicitly (the worker's PATH plus the per-task ``.local/bin``) or a
594
595
  missing interpreter/bash would break the probe."""
595
596
  iso = _isolation_env(host.workdir)
596
- base_path = os.environ.get("PATH", "/usr/local/bin:/usr/bin:/bin")
597
+ base_path = session_base_path()
597
598
  return {**iso, "PATH": f"{iso['HOME']}/.local/bin:{base_path}"}
598
599
 
599
600
 
@@ -14,12 +14,15 @@ from typing import AsyncIterator
14
14
  from optio_core.context import ProcessContext
15
15
  from optio_core.models import BasicAuth, TaskInstance
16
16
 
17
- from optio_agents import HookContext, RESUME_NOTICE, SYSTEM_MESSAGE_PREFIX, get_protocol
17
+ from optio_agents import (
18
+ HookContext, RESUME_NOTICE, SYSTEM_MESSAGE_PREFIX, agent_entries, get_protocol,
19
+ )
18
20
  from optio_agents import seeds as _seeds
19
21
  from optio_agents.fs_grants import fs_isolation_dirs
20
22
  from optio_agents.input_listener import serialized, start_input_listener
21
23
  from optio_agents.protocol.session import _SessionFailed, run_log_protocol_session
22
24
  from optio_agents.session_controls import filter_controls
25
+ from optio_agents.session_env import session_env_remove
23
26
  from optio_agents.account import EMPTY, accounts_to_metadata
24
27
  from optio_agents.todos import TodoTracker
25
28
  from optio_agents.uploads import materialize, upload_url_token
@@ -387,7 +390,7 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
387
390
  codex_flags=codex_flags,
388
391
  claustrum_wrap=claustrum_wrap,
389
392
  ready_timeout_s=READY_TIMEOUT_S,
390
- env_remove=config.scrub_env,
393
+ env_remove=session_env_remove(config.scrub_env),
391
394
  )
392
395
  launched_handle = handle
393
396
  tmux_path = tmux_path_local
@@ -480,7 +483,7 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
480
483
  ctx.report_progress(None, f"Launching {AGENT_INFO.name} (conversation)…")
481
484
  handle = await host.launch_subprocess(
482
485
  cmd, env=env, cwd=host.workdir,
483
- env_remove=config.scrub_env, stdin=True, merge_stderr=False,
486
+ env_remove=session_env_remove(config.scrub_env), stdin=True, merge_stderr=False,
484
487
  )
485
488
  launched_handle = handle
486
489
  conversation.attach(handle)
@@ -702,6 +705,7 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
702
705
  protocol=protocol,
703
706
  agent_sender=_agent_sender,
704
707
  keywords=config.host_protocol,
708
+ deliverable_metadata=lambda: agent_entries(config, AGENT_INFO),
705
709
  )
706
710
  except _SessionFailed as fail:
707
711
  raise RuntimeError(str(fail)) from None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: optio-codex
3
- Version: 0.4.7
3
+ Version: 0.4.9
4
4
  Summary: Run OpenAI Codex as an optio task; local subprocess; ttyd-served TUI iframe.
5
5
  Author-email: Kristof Csillag <kristof.csillag@deai-labs.com>
6
6
  License-Expression: Apache-2.0
@@ -20,9 +20,9 @@ Classifier: Topic :: Software Development :: Code Generators
20
20
  Classifier: Framework :: AsyncIO
21
21
  Requires-Python: >=3.11
22
22
  Description-Content-Type: text/markdown
23
- Requires-Dist: optio-core<0.7,>=0.6
23
+ Requires-Dist: optio-core<0.8,>=0.7
24
24
  Requires-Dist: optio-host<0.5,>=0.4
25
- Requires-Dist: optio-agents<0.8,>=0.7
25
+ Requires-Dist: optio-agents<0.9,>=0.8
26
26
  Requires-Dist: asyncssh>=2.14
27
27
  Requires-Dist: aiohttp>=3.9
28
28
  Provides-Extra: dev
@@ -34,6 +34,8 @@ tests/test_conversation.py
34
34
  tests/test_conversation_controls.py
35
35
  tests/test_conversation_listener.py
36
36
  tests/test_cred_watcher.py
37
+ tests/test_deliverable_metadata_wiring.py
38
+ tests/test_engine_venv.py
37
39
  tests/test_file_download.py
38
40
  tests/test_file_upload.py
39
41
  tests/test_fs_allowlist.py
@@ -1,6 +1,6 @@
1
- optio-core<0.7,>=0.6
1
+ optio-core<0.8,>=0.7
2
2
  optio-host<0.5,>=0.4
3
- optio-agents<0.8,>=0.7
3
+ optio-agents<0.9,>=0.8
4
4
  asyncssh>=2.14
5
5
  aiohttp>=3.9
6
6
 
@@ -0,0 +1,65 @@
1
+ """Deliverable metadata wiring: the driver gets the base entries.
2
+
3
+ ``run_codex_session`` must hand ``run_log_protocol_session`` a
4
+ ``deliverable_metadata`` provider that returns the agent type and the agent's
5
+ name. Pure wiring test: ``_build_host``, ``get_protocol`` and
6
+ ``run_log_protocol_session`` are stubbed so nothing is spawned and no MongoDB is
7
+ needed. With the driver stubbed, the outer shell awaits only ``host.connect``
8
+ and, in its ``finally``, ``host.cleanup_taskdir`` and ``host.disconnect``.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from unittest.mock import patch
14
+
15
+ from optio_agents import KEY_AGENT_NAME, KEY_AGENT_TYPE, SOURCE_CONFIG
16
+ from optio_agents.deliverable_meta import entry
17
+ from optio_codex import CodexTaskConfig
18
+ from optio_codex import session as codex_session
19
+ from optio_codex.info import AGENT_INFO
20
+
21
+
22
+ class _FakeHost:
23
+ async def connect(self):
24
+ pass
25
+
26
+ async def disconnect(self):
27
+ pass
28
+
29
+ async def cleanup_taskdir(self, aggressive=False):
30
+ pass
31
+
32
+
33
+ class _FakeCtx:
34
+ process_id = "p"
35
+
36
+ def should_continue(self):
37
+ return True
38
+
39
+
40
+ async def _capture_wiring(config):
41
+ """Run run_codex_session with stubs; return (protocol_kwargs, run_kwargs)."""
42
+ captured: dict = {}
43
+
44
+ def _fake_get_protocol(**kwargs):
45
+ captured["protocol"] = kwargs
46
+ return object() # opaque; run_log is stubbed so it is never inspected
47
+
48
+ async def _fake_run_log(host, ctx, **kwargs):
49
+ captured["run"] = kwargs
50
+
51
+ with patch.object(codex_session, "_build_host", lambda c, pid: _FakeHost()), \
52
+ patch.object(codex_session, "get_protocol", _fake_get_protocol), \
53
+ patch.object(codex_session, "run_log_protocol_session", _fake_run_log):
54
+ await codex_session.run_codex_session(_FakeCtx(), config)
55
+ return captured["protocol"], captured["run"]
56
+
57
+
58
+ async def test_the_driver_gets_the_base_deliverable_entries(): # RF5
59
+ config = CodexTaskConfig(consumer_instructions="x", delivery_type="audit")
60
+ _proto, run = await _capture_wiring(config)
61
+ assert run["deliverable_metadata"]() == [
62
+ entry(KEY_AGENT_TYPE, config.agent_type, SOURCE_CONFIG),
63
+ entry(KEY_AGENT_NAME, AGENT_INFO.name, SOURCE_CONFIG),
64
+ ]
65
+ assert config.agent_type == AGENT_INFO.slug
@@ -0,0 +1,121 @@
1
+ """Agent sessions never inherit the engine's virtualenv (optio_agents.session_env).
2
+
3
+ The engine is made to look like it runs from a venv (sys.prefix /
4
+ sys.base_prefix / VIRTUAL_ENV monkeypatched, the venv's bin leading PATH). The
5
+ real session runs up to codex's launch; that launch is recorded and replaced by
6
+ ``/usr/bin/env`` under the same env and env_remove, so the test reads the
7
+ environment LocalHost really builds for the child, then the session stops.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ import sys
14
+
15
+ import pytest
16
+
17
+ from optio_host.host import LocalHost, proc_wait
18
+
19
+ from optio_codex import CodexTaskConfig, create_codex_task
20
+
21
+ _LAUNCH = LocalHost.launch_subprocess
22
+
23
+
24
+ class _Launched(Exception):
25
+ """Raised in place of the agent launch once it is recorded."""
26
+
27
+
28
+ @pytest.fixture
29
+ def engine_venv(tmp_path, monkeypatch) -> str:
30
+ venv = tmp_path / "engine-venv"
31
+ (venv / "bin").mkdir(parents=True)
32
+ monkeypatch.setattr(sys, "prefix", str(venv))
33
+ monkeypatch.setattr(sys, "base_prefix", "/opt/base-python")
34
+ monkeypatch.setenv("VIRTUAL_ENV", str(venv))
35
+ monkeypatch.setenv("PYTHONPATH", os.pathsep.join(
36
+ p for p in (str(venv / "lib"), os.environ.get("PYTHONPATH")) if p))
37
+ monkeypatch.setenv("PATH", f"{venv}/bin:{os.environ['PATH']}")
38
+ return f"{venv}/bin"
39
+
40
+
41
+ async def _child_env(host, kw) -> dict[str, str]:
42
+ probe = await _LAUNCH(host, "/usr/bin/env", env=kw.get("env"), env_remove=kw.get("env_remove"))
43
+ out = b"".join([chunk async for chunk in probe.stdout])
44
+ await proc_wait(probe)
45
+ env: dict[str, str] = {}
46
+ for line in out.decode("utf-8", "replace").splitlines():
47
+ name, sep, value = line.partition("=")
48
+ if sep and name.isidentifier():
49
+ env.setdefault(name, value)
50
+ return env
51
+
52
+
53
+ def _capture_launch(monkeypatch, is_agent) -> dict:
54
+ seen: dict = {}
55
+
56
+ async def _launch(self, command, **kw):
57
+ if seen or not is_agent(command):
58
+ return await _LAUNCH(self, command, **kw)
59
+ seen["command"] = command
60
+ seen["env"] = await _child_env(self, kw)
61
+ raise _Launched(command)
62
+
63
+ monkeypatch.setattr(LocalHost, "launch_subprocess", _launch)
64
+ return seen
65
+
66
+
67
+ async def _run(ctx, shim_install_dir, **kw) -> None:
68
+ task = create_codex_task(
69
+ process_id="codex-engine-venv", name="venv",
70
+ config=CodexTaskConfig(
71
+ consumer_instructions="do it",
72
+ install_dir=str(shim_install_dir),
73
+ ttyd_install_dir=str(shim_install_dir),
74
+ delivery_type="audit",
75
+ supports_resume=False,
76
+ **kw,
77
+ ),
78
+ )
79
+ try:
80
+ await task.execute(ctx)
81
+ except Exception: # noqa: BLE001 - the recorded launch stops the session
82
+ pass
83
+
84
+
85
+ async def test_the_tmux_launch_inherits_no_engine_venv(
86
+ engine_venv, shim_install_dir, task_root, ctx_and_captures, monkeypatch,
87
+ ):
88
+ ctx, *_ = ctx_and_captures
89
+ seen = _capture_launch(monkeypatch, lambda cmd: "new-session" in cmd)
90
+ await _run(ctx, shim_install_dir)
91
+
92
+ assert seen, "codex was never launched"
93
+ # codex's PATH is exported on its command line; the venv is nowhere in it.
94
+ assert "PATH=" in seen["command"]
95
+ assert engine_venv not in seen["command"]
96
+ # The tmux server (which holds codex) starts without the engine's Python.
97
+ assert not {"VIRTUAL_ENV", "PYTHONPATH"} & set(seen["env"])
98
+
99
+
100
+ async def test_the_conversation_launch_inherits_no_engine_venv(
101
+ engine_venv, shim_install_dir, task_root, ctx_and_captures, monkeypatch,
102
+ ):
103
+ ctx, *_ = ctx_and_captures
104
+ seen = _capture_launch(monkeypatch, lambda cmd: "app-server" in cmd)
105
+ await _run(ctx, shim_install_dir, mode="conversation", auto_start=False)
106
+
107
+ assert seen, "codex was never launched"
108
+ path = seen["env"]["PATH"].split(":")
109
+ assert engine_venv not in path and "/usr/bin" in path
110
+ assert not {"VIRTUAL_ENV", "PYTHONPATH"} & set(seen["env"])
111
+
112
+
113
+ def test_the_probe_path_leaves_out_the_engine_venv(engine_venv):
114
+ from optio_codex import host_actions
115
+
116
+ class _Host:
117
+ workdir = "/w"
118
+
119
+ path = host_actions._codex_isolation_env(_Host())["PATH"].split(":")
120
+ assert path[0] == "/w/home/.local/bin"
121
+ assert engine_venv not in path and "/usr/bin" in path
File without changes
File without changes