optio-codex 0.4.4__tar.gz → 0.4.6__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 (65) hide show
  1. {optio_codex-0.4.4 → optio_codex-0.4.6}/PKG-INFO +3 -3
  2. {optio_codex-0.4.4 → optio_codex-0.4.6}/pyproject.toml +3 -3
  3. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/conversation.py +9 -1
  4. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/conversation_listener.py +8 -0
  5. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/host_actions.py +3 -1
  6. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/models.py +5 -2
  7. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/session.py +19 -4
  8. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/types.py +31 -10
  9. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex.egg-info/PKG-INFO +3 -3
  10. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex.egg-info/SOURCES.txt +1 -0
  11. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex.egg-info/requires.txt +2 -2
  12. optio_codex-0.4.6/tests/test_auto_start_prompt.py +14 -0
  13. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_config.py +21 -0
  14. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_config_hooks.py +6 -1
  15. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_conversation.py +15 -0
  16. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_conversation_listener.py +43 -0
  17. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_models.py +11 -0
  18. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_session_conversation.py +100 -0
  19. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_session_local.py +8 -0
  20. {optio_codex-0.4.4 → optio_codex-0.4.6}/README.md +0 -0
  21. {optio_codex-0.4.4 → optio_codex-0.4.6}/setup.cfg +0 -0
  22. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/__init__.py +0 -0
  23. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/account.py +0 -0
  24. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/cred_watcher.py +0 -0
  25. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/fs_allowlist.py +0 -0
  26. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/info.py +0 -0
  27. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/prompt.py +0 -0
  28. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/rollout.py +0 -0
  29. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/seed_manifest.py +0 -0
  30. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/snapshots.py +0 -0
  31. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/todos.py +0 -0
  32. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex/verify.py +0 -0
  33. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex.egg-info/dependency_links.txt +0 -0
  34. {optio_codex-0.4.4 → optio_codex-0.4.6}/src/optio_codex.egg-info/top_level.txt +0 -0
  35. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_account.py +0 -0
  36. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_agent_info.py +0 -0
  37. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_await_codex_gone.py +0 -0
  38. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_claustrum.py +0 -0
  39. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_codex_cache.py +0 -0
  40. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_conversation_controls.py +0 -0
  41. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_cred_watcher.py +0 -0
  42. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_file_download.py +0 -0
  43. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_file_upload.py +0 -0
  44. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_fs_allowlist.py +0 -0
  45. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_host_actions.py +0 -0
  46. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_import.py +0 -0
  47. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_input_wiring.py +0 -0
  48. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_kill_ttyd_by_socket.py +0 -0
  49. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_prompt.py +0 -0
  50. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_real_codex_conversation.py +0 -0
  51. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_real_codex_seed_resume.py +0 -0
  52. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_real_codex_session.py +0 -0
  53. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_rollout.py +0 -0
  54. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_sandbox_enforce.py +0 -0
  55. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_seed_manifest.py +0 -0
  56. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_session_lease.py +0 -0
  57. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_session_remote.py +0 -0
  58. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_session_resume.py +0 -0
  59. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_session_sandbox.py +0 -0
  60. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_session_seed.py +0 -0
  61. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_snapshots.py +0 -0
  62. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_teardown_session_tree.py +0 -0
  63. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_todos.py +0 -0
  64. {optio_codex-0.4.4 → optio_codex-0.4.6}/tests/test_verify.py +0 -0
  65. {optio_codex-0.4.4 → optio_codex-0.4.6}/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.4
3
+ Version: 0.4.6
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.6,>=0.5
23
+ Requires-Dist: optio-core<0.7,>=0.6
24
24
  Requires-Dist: optio-host<0.4,>=0.3
25
- Requires-Dist: optio-agents<0.7,>=0.6
25
+ Requires-Dist: optio-agents<0.8,>=0.7
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.4"
7
+ version = "0.4.6"
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.5,<0.6",
29
+ "optio-core>=0.6,<0.7",
30
30
  "optio-host>=0.3,<0.4",
31
- "optio-agents>=0.6,<0.7",
31
+ "optio-agents>=0.7,<0.8",
32
32
  "asyncssh>=2.14",
33
33
  "aiohttp>=3.9",
34
34
  ]
@@ -100,6 +100,7 @@ from optio_agents.conversation import (
100
100
  PermissionDecision,
101
101
  PermissionRequest,
102
102
  )
103
+ from optio_agents.session_controls import filter_controls
103
104
  from optio_codex import models as codex_models
104
105
  from optio_codex import rollout as codex_rollout
105
106
  from optio_codex.info import AGENT_INFO
@@ -128,8 +129,13 @@ class CodexConversation:
128
129
  reasoning_effort: str | None = None,
129
130
  sandbox: str = "workspace-write",
130
131
  resume_thread_id: str | None = None,
132
+ session_controls: "list[str] | None" = None,
131
133
  ) -> None:
132
134
  self._cwd = cwd
135
+ # The task's session_controls allowlist (None: every control): the
136
+ # controls snapshot re-emitted on a model switch is narrowed to it, so
137
+ # a control hidden from the widget does not reappear.
138
+ self._session_controls = session_controls
133
139
  self._agent_label = agent_label
134
140
  # When False, requestApproval is answered with a defensive deny
135
141
  # instead of being queued for a handler.
@@ -613,7 +619,9 @@ class CodexConversation:
613
619
  )
614
620
  await self._emit_event({
615
621
  "type": "x-optio-control-update",
616
- "controls": [c.to_dict() for c in controls],
622
+ "controls": filter_controls(
623
+ [c.to_dict() for c in controls], self._session_controls,
624
+ ),
617
625
  })
618
626
 
619
627
  async def close(self) -> None:
@@ -35,6 +35,7 @@ from typing import Awaitable, Callable
35
35
  from aiohttp import web
36
36
 
37
37
  from optio_agents.conversation import ConversationClosed, PermissionDecision
38
+ from optio_agents.session_controls import control_allowed
38
39
 
39
40
  from optio_codex import rollout as _rollout
40
41
 
@@ -72,8 +73,13 @@ class ConversationListener:
72
73
  max_download_bytes: int = 10_000_000,
73
74
  host=None,
74
75
  codex_home: str | None = None,
76
+ allowed_controls: "list[str] | None" = None,
75
77
  ) -> None:
76
78
  self._conversation = conversation
79
+ # The task's session_controls allowlist (None: every control): /control
80
+ # refuses any other id, so a control hidden from the widget cannot be
81
+ # set by posting here directly.
82
+ self._allowed_controls = allowed_controls
77
83
  self._password = password
78
84
  self._download_reader = download_reader
79
85
  self._max_download_bytes = max_download_bytes
@@ -303,6 +309,8 @@ class ConversationListener:
303
309
  cid = payload.get("id")
304
310
  if not isinstance(cid, str) or not cid:
305
311
  return web.json_response({"ok": False, "reason": "bad-id"}, status=400)
312
+ if not control_allowed(cid, self._allowed_controls):
313
+ return web.json_response({"ok": False, "reason": "not-allowed"}, status=403)
306
314
  value = payload.get("value")
307
315
  try:
308
316
  await self._conversation.set_control(cid, value)
@@ -800,7 +800,9 @@ def build_codex_flags(
800
800
  return out
801
801
 
802
802
 
803
- AUTO_START_PROMPT = "Read AGENTS.md and execute the task it describes"
803
+ # A harness message (System: prefix), like the resume notice: the agent is
804
+ # not handed a turn that reads as the human typing.
805
+ AUTO_START_PROMPT = f"{SYSTEM_MESSAGE_PREFIX}Read AGENTS.md and execute the task it describes"
804
806
 
805
807
 
806
808
  def build_auto_start_args(
@@ -68,7 +68,7 @@ def parse_model_list(result: "dict | None") -> dict:
68
68
  if not isinstance(mid, str) or not mid or m.get("hidden"):
69
69
  continue
70
70
  efforts = m.get("supportedReasoningEfforts")
71
- out.append({
71
+ entry = {
72
72
  "id": mid,
73
73
  "label": m.get("displayName") or mid,
74
74
  "disabled": False,
@@ -77,7 +77,10 @@ def parse_model_list(result: "dict | None") -> dict:
77
77
  if isinstance(e, dict) and isinstance(e.get("reasoningEffort"), str)
78
78
  ] if isinstance(efforts, list) else [],
79
79
  "defaultEffort": m.get("defaultReasoningEffort"),
80
- })
80
+ }
81
+ if isinstance(m.get("description"), str) and m["description"]:
82
+ entry["description"] = m["description"]
83
+ out.append(entry)
81
84
  if m.get("isDefault"):
82
85
  default = mid
83
86
  if not out:
@@ -19,6 +19,7 @@ from optio_agents import seeds as _seeds
19
19
  from optio_agents.fs_grants import fs_isolation_dirs
20
20
  from optio_agents.input_listener import serialized, start_input_listener
21
21
  from optio_agents.protocol.session import _SessionFailed, run_log_protocol_session
22
+ from optio_agents.session_controls import filter_controls
22
23
  from optio_agents.account import EMPTY, accounts_to_metadata
23
24
  from optio_agents.todos import TodoTracker
24
25
  from optio_agents.uploads import materialize, upload_url_token
@@ -308,6 +309,8 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
308
309
  supports_resume=config.supports_resume,
309
310
  file_download=config.file_download,
310
311
  fs_isolation_dirs=fs_isolation_dirs(config, host.workdir),
312
+ # Every resume sends the System: resume notice.
313
+ check_resume_log_every_message=False,
311
314
  ),
312
315
  )
313
316
  else:
@@ -363,8 +366,8 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
363
366
  # PUSH resume awareness (Gap 1): a System: notice positional appended
364
367
  # after `resume <id>` + flags so the resumed TUI session gets a "you
365
368
  # have been resumed" turn (mutually exclusive with the fresh-launch
366
- # kickoff above). Parity with claudecode/opencode/grok; resume.log
367
- # stays the pull-based backstop.
369
+ # kickoff above). Parity with claudecode/opencode/grok. AGENTS.md
370
+ # tells codex to wait for this notice, not to poll resume.log.
368
371
  *host_actions.build_resume_notice_args(resuming=resuming),
369
372
  ]
370
373
  launch_env = {
@@ -457,6 +460,8 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
457
460
  # instead of starting a fresh one. resume_session_id is the codex
458
461
  # thread id recorded in the restored snapshot.
459
462
  resume_thread_id=resume_session_id if resuming else None,
463
+ # Narrows the controls snapshot re-emitted on a model switch.
464
+ session_controls=config.session_controls,
460
465
  )
461
466
  # Stage 9: Landlock-confine the app-server process tree (None when
462
467
  # fs_isolation is off).
@@ -536,6 +541,9 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
536
541
  # a fresh viewer attach replays before the live tail — so a long
537
542
  # session stays scrollable to its start past the bounded buffer.
538
543
  codex_home=host_actions._isolation_env(host.workdir)["CODEX_HOME"],
544
+ # Only the controls the widget shows may be set: none when the
545
+ # controls bar is off, else the session_controls allowlist.
546
+ allowed_controls=config.settable_controls,
539
547
  )
540
548
  # In-process aiohttp app: binds directly on the widget-tunnel
541
549
  # interface, no host tunnel needed.
@@ -567,9 +575,13 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
567
575
  "protocol": "codex",
568
576
  "toolVerbosity": config.tool_verbosity,
569
577
  "thinkingVerbosity": config.thinking_verbosity,
578
+ # The welcome card atop the transcript (None: no card).
579
+ "welcome": config.welcome_widget_data,
570
580
  "showSessionControls": config.show_session_controls,
571
581
  "nativeSpinner": config.native_spinner,
572
- "controls": [c.to_dict() for c in controls],
582
+ "controls": filter_controls(
583
+ [c.to_dict() for c in controls], config.session_controls,
584
+ ),
573
585
  "showFileUpload": config.show_file_upload,
574
586
  "maxUploadBytes": config.max_upload_bytes,
575
587
  "fileDownload": config.file_download,
@@ -615,7 +627,8 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
615
627
  # Kickoff prompt as the first turn (headless: no positional prompt
616
628
  # path). Suppressed on resume — re-kicking would duplicate the task.
617
629
  # On resume, PUSH a System: resume notice instead so the resumed thread
618
- # notices promptly (parity; resume.log stays the pull-based backstop).
630
+ # notices promptly (parity; AGENTS.md says to wait for it, not to
631
+ # poll resume.log).
619
632
  if config.auto_start and not resuming:
620
633
  await conversation.send(host_actions.AUTO_START_PROMPT)
621
634
  elif resuming:
@@ -910,6 +923,8 @@ async def _maybe_refresh_on_resume(
910
923
  supports_resume=new_config.supports_resume,
911
924
  file_download=new_config.file_download,
912
925
  fs_isolation_dirs=fs_isolation_dirs(new_config, host.workdir),
926
+ # Every resume sends the System: resume notice.
927
+ check_resume_log_every_message=False,
913
928
  )
914
929
  try:
915
930
  existing = await hook_ctx.read_text_from_host("AGENTS.md", silent=True)
@@ -33,7 +33,15 @@ from optio_agents import (
33
33
  TOOL_VERBOSITIES,
34
34
  ToolVerbosity,
35
35
  )
36
- from optio_agents.config_types import BlobCryptoConfigMixin, ClaustrumConfigMixin
36
+ from optio_agents.config_types import (
37
+ BlobCryptoConfigMixin,
38
+ ClaustrumConfigMixin,
39
+ ResumeConfigMixin,
40
+ SessionControlsConfigMixin,
41
+ WelcomeConfigMixin,
42
+ )
43
+ from optio_agents.custom_controls import CustomControlsConfigMixin
44
+ from optio_agents.mcp import McpConfigMixin
37
45
  from optio_agents.protocol.session import (
38
46
  CallerMessageCallback,
39
47
  DeliverableCallback,
@@ -93,15 +101,20 @@ def _identity_resume_refresh(config: "CodexTaskConfig") -> "CodexTaskConfig":
93
101
 
94
102
 
95
103
  @dataclass(frozen=True, kw_only=True)
96
- class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
104
+ class CodexTaskConfig(
105
+ ClaustrumConfigMixin, BlobCryptoConfigMixin, SessionControlsConfigMixin, McpConfigMixin,
106
+ CustomControlsConfigMixin, ResumeConfigMixin,
107
+ WelcomeConfigMixin,
108
+ ):
97
109
  """Configuration for one optio-codex task instance.
98
110
 
99
111
  Inherits the claustrum filesystem-isolation triad (``fs_isolation`` /
100
112
  ``extra_allowed_dirs`` / ``delivery_type``) from ``ClaustrumConfigMixin``
101
113
  and the at-rest blob-crypto quartet (``session_blob_encrypt/decrypt`` /
102
- ``seed_blob_encrypt/decrypt``) from ``BlobCryptoConfigMixin``; those
103
- fields stay top-level here (callers write ``fs_isolation=`` /
104
- ``session_blob_encrypt=`` verbatim). Frozen because the mixins are frozen;
114
+ ``seed_blob_encrypt/decrypt``) from ``BlobCryptoConfigMixin``, and the
115
+ session-controls pair (``show_session_controls`` / ``session_controls``)
116
+ from ``SessionControlsConfigMixin``; those fields stay top-level here
117
+ (callers write ``fs_isolation=`` / ``session_blob_encrypt=`` verbatim). Frozen because the mixins are frozen;
105
118
  ``kw_only`` because the mixins contribute defaulted fields ahead of the
106
119
  required ``consumer_instructions``.
107
120
  """
@@ -168,7 +181,7 @@ class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
168
181
 
169
182
  # When True, a fresh launch kicks off the first turn itself — iframe mode
170
183
  # types a trailing positional prompt, conversation mode sends the
171
- # AUTO_START_PROMPT ("Read AGENTS.md and execute the task it describes").
184
+ # AUTO_START_PROMPT ("System: Read AGENTS.md and execute the task it describes").
172
185
  # This is for UNATTENDED task execution; a task must opt in. Defaults to
173
186
  # False (parity with claudecode/grok/opencode): a conversation/chat task
174
187
  # must NOT auto-fire a kickoff, or codex starts an agentic loop on launch
@@ -222,10 +235,12 @@ class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
222
235
  thinking_verbosity: ThinkingVerbosity = "hidden"
223
236
 
224
237
  # --- conversation frontend parity (Stage 7) -------------------------
225
- # Show the session controls (the model picker is the id="model" control).
226
- # Codex switches the model INLINE: the chosen model rides the next
227
- # turn/start and sticks — no process restart.
228
- show_session_controls: bool = False
238
+ # show_session_controls / session_controls come from
239
+ # SessionControlsConfigMixin. Codex's controls: "model" (the picker) and
240
+ # "reasoning_effort" (only for a model with graded reasoning), both
241
+ # switched INLINE: the chosen value rides the next turn/start and sticks —
242
+ # no process restart. The bar requires mode="conversation" and
243
+ # conversation_ui=True.
229
244
  # Replace the generic working-spinner with codex's on-brand native
230
245
  # spinner in the conversation widget. Requires mode="conversation" and
231
246
  # conversation_ui=True.
@@ -297,6 +312,12 @@ class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
297
312
  def __post_init__(self) -> None:
298
313
  self._validate_claustrum()
299
314
  self._validate_blob_crypto()
315
+ self._validate_session_controls()
316
+ self._validate_welcome()
317
+ # This engine cannot hand MCP servers to its agent yet: refuse mcp_servers.
318
+ self._validate_mcp(supported=False, agent=self.agent_type)
319
+ # Nor can it apply custom session controls: refuse a non-empty custom_controls.
320
+ self._validate_custom_controls(supported=False, agent=self.agent_type)
300
321
  if self.mode not in _VALID_MODES:
301
322
  raise ValueError(
302
323
  f"CodexTaskConfig.mode={self.mode!r} is not one of "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: optio-codex
3
- Version: 0.4.4
3
+ Version: 0.4.6
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.6,>=0.5
23
+ Requires-Dist: optio-core<0.7,>=0.6
24
24
  Requires-Dist: optio-host<0.4,>=0.3
25
- Requires-Dist: optio-agents<0.7,>=0.6
25
+ Requires-Dist: optio-agents<0.8,>=0.7
26
26
  Requires-Dist: asyncssh>=2.14
27
27
  Requires-Dist: aiohttp>=3.9
28
28
  Provides-Extra: dev
@@ -24,6 +24,7 @@ src/optio_codex.egg-info/requires.txt
24
24
  src/optio_codex.egg-info/top_level.txt
25
25
  tests/test_account.py
26
26
  tests/test_agent_info.py
27
+ tests/test_auto_start_prompt.py
27
28
  tests/test_await_codex_gone.py
28
29
  tests/test_claustrum.py
29
30
  tests/test_codex_cache.py
@@ -1,6 +1,6 @@
1
- optio-core<0.6,>=0.5
1
+ optio-core<0.7,>=0.6
2
2
  optio-host<0.4,>=0.3
3
- optio-agents<0.7,>=0.6
3
+ optio-agents<0.8,>=0.7
4
4
  asyncssh>=2.14
5
5
  aiohttp>=3.9
6
6
 
@@ -0,0 +1,14 @@
1
+ """The auto-start kickoff is a harness message, not a human one."""
2
+
3
+ from optio_agents.context import SYSTEM_MESSAGE_PREFIX
4
+ from optio_codex.host_actions import AUTO_START_PROMPT
5
+
6
+
7
+ def test_auto_start_prompt_is_a_system_message():
8
+ # The kickoff comes from the harness: it carries the System: prefix every
9
+ # harness message has, so the agent (told that the human may not be
10
+ # present) is not given a turn that reads as the human typing, and the
11
+ # conversation widget renders it as a System row, not a user bubble.
12
+ assert AUTO_START_PROMPT == (
13
+ f"{SYSTEM_MESSAGE_PREFIX}Read AGENTS.md and execute the task it describes"
14
+ )
@@ -148,6 +148,27 @@ def test_upload_download_byte_limits_default():
148
148
  assert cfg.max_download_bytes == 10_000_000
149
149
 
150
150
 
151
+ # --- session controls (shared SessionControlsConfigMixin) -------------------
152
+
153
+
154
+ def test_the_controls_settings_come_from_the_shared_mixin():
155
+ from optio_agents.config_types import SessionControlsConfigMixin
156
+
157
+ assert issubclass(CodexTaskConfig, SessionControlsConfigMixin)
158
+ ui = dict(mode="conversation", conversation_ui=True)
159
+ # None (the default) offers every control.
160
+ assert _cfg(**ui, show_session_controls=True).session_controls is None
161
+ narrowed = _cfg(**ui, show_session_controls=True, session_controls=["model"])
162
+ assert narrowed.settable_controls == ["model"]
163
+ # The bar off: /control may change nothing.
164
+ assert _cfg(**ui).settable_controls == []
165
+
166
+
167
+ def test_session_controls_needs_show_session_controls():
168
+ with pytest.raises(ValueError, match="session_controls"):
169
+ _cfg(mode="conversation", conversation_ui=True, session_controls=["model"])
170
+
171
+
151
172
  # --- Stage 8: filesystem-isolation config reconciliation --------------------
152
173
 
153
174
 
@@ -15,7 +15,7 @@ from unittest.mock import AsyncMock, MagicMock
15
15
 
16
16
  import pytest
17
17
 
18
- from optio_agents import get_protocol
18
+ from optio_agents import RESUME_NOTICE, SYSTEM_MESSAGE_PREFIX, get_protocol
19
19
  from optio_agents.fs_grants import fs_isolation_dirs
20
20
  from optio_codex.prompt import compose_agents_md
21
21
  from optio_codex.types import CodexTaskConfig
@@ -271,6 +271,7 @@ async def test_maybe_refresh_identity_unchanged_is_noop():
271
271
  supports_resume=cfg.supports_resume,
272
272
  file_download=cfg.file_download,
273
273
  fs_isolation_dirs=fs_isolation_dirs(cfg, workdir),
274
+ check_resume_log_every_message=False, # as the fresh start writes it
274
275
  )
275
276
  host, hook, written = _resume_fakes(existing, workdir=workdir)
276
277
 
@@ -301,6 +302,10 @@ async def test_maybe_refresh_mutating_hook_rewrites_agents_md():
301
302
  refreshed = await _maybe_refresh_on_resume(host, hook, cfg, protocol)
302
303
  assert refreshed == ["AGENTS.md"]
303
304
  assert "UPDATED INSTRUCTIONS" in written["AGENTS.md"]
305
+ # Every resume sends the System: resume notice, so the refreshed file
306
+ # says to wait for it rather than read resume.log before each message.
307
+ assert "At the start of every new incoming user message" not in written["AGENTS.md"]
308
+ assert f"`{SYSTEM_MESSAGE_PREFIX}{RESUME_NOTICE}` message on your input channel" in written["AGENTS.md"]
304
309
 
305
310
 
306
311
  async def test_maybe_refresh_none_hook_is_noop():
@@ -716,6 +716,21 @@ async def test_set_control_model_drops_effort_for_non_graded_model():
716
716
  assert c._requested_effort is None # disarmed
717
717
 
718
718
 
719
+ @pytest.mark.asyncio
720
+ async def test_set_control_model_reemit_is_narrowed_by_the_allowlist():
721
+ # session_controls=["model"] hides the effort slider: the snapshot
722
+ # re-emitted on a switch to a graded model must not bring it back.
723
+ c = CodexConversation(cwd="/w", session_controls=["model"])
724
+ c.thread_id = "t1"
725
+ c.model_list = _GRADED_MODEL_LIST
726
+ events: list = []
727
+ c.on_event(events.append)
728
+ await c.set_control("model", "gpt-5.5") # graded: effort would show
729
+ update = next(e for e in events if e.get("type") == "x-optio-control-update")
730
+ assert [ctl["id"] for ctl in update["controls"]] == ["model"]
731
+ assert update["controls"][0]["value"] == "gpt-5.5"
732
+
733
+
719
734
  @pytest.mark.asyncio
720
735
  async def test_turn_start_error_response_unwinds_pending(convo):
721
736
  c, handle = convo
@@ -311,6 +311,49 @@ async def test_control_route_forwards_to_conversation(listener):
311
311
  assert r.status == 409
312
312
 
313
313
 
314
+ async def _post_control(conv, body, *, allowed):
315
+ lst = ConversationListener(conv, password="pw", allowed_controls=allowed)
316
+ port = await lst.start("127.0.0.1")
317
+ try:
318
+ async with aiohttp.ClientSession() as s:
319
+ async with s.post(f"http://127.0.0.1:{port}/control", json=body,
320
+ headers=_auth("pw")) as r:
321
+ return r.status, await r.json()
322
+ finally:
323
+ await lst.stop()
324
+
325
+
326
+ async def test_control_route_refuses_an_id_outside_the_allowlist():
327
+ # A control session_controls hides from the widget cannot be set by
328
+ # posting its id here directly either.
329
+ conv = FakeConversation()
330
+ status, body = await _post_control(
331
+ conv, {"id": "model", "value": "gpt-5.4-mini"}, allowed=["reasoning_effort"],
332
+ )
333
+ assert status == 403 and body["reason"] == "not-allowed"
334
+ assert conv.control_changes == []
335
+
336
+
337
+ async def test_control_route_refuses_every_id_while_the_bar_is_off():
338
+ # The session passes config.settable_controls: [] while
339
+ # show_session_controls is off.
340
+ conv = FakeConversation()
341
+ status, body = await _post_control(
342
+ conv, {"id": "model", "value": "gpt-5.4-mini"}, allowed=[],
343
+ )
344
+ assert status == 403 and body["reason"] == "not-allowed"
345
+ assert conv.control_changes == []
346
+
347
+
348
+ async def test_control_route_passes_an_allowed_id_through():
349
+ conv = FakeConversation()
350
+ status, body = await _post_control(
351
+ conv, {"id": "reasoning_effort", "value": "high"}, allowed=["reasoning_effort"],
352
+ )
353
+ assert status == 200 and body == {"ok": True}
354
+ assert conv.control_changes == [("reasoning_effort", "high")]
355
+
356
+
314
357
  async def test_permission_roundtrip_by_jsonrpc_id(listener):
315
358
  # PermissionRequest.raw is the full requestApproval JSON-RPC object; the
316
359
  # listener correlates the operator's answer by its `id`.
@@ -141,3 +141,14 @@ def test_fallback_contents():
141
141
  ids = [m["id"] for m in FALLBACK_MODELS["models"]]
142
142
  assert ids == ["gpt-5.5", "gpt-5.4-mini"]
143
143
  assert FALLBACK_MODELS["default"] == "gpt-5.5"
144
+
145
+
146
+
147
+ def test_parse_model_list_keeps_a_models_description():
148
+ from optio_codex.models import parse_model_list
149
+ out = parse_model_list({"data": [
150
+ {"id": "gpt-x", "displayName": "GPT X", "description": "Optimized for coding"},
151
+ {"id": "gpt-y", "displayName": "GPT Y"},
152
+ ]})
153
+ assert out["models"][0]["description"] == "Optimized for coding"
154
+ assert out["models"][1].get("description") is None
@@ -10,13 +10,17 @@ responder when argv contains ``app-server`` (no tmux/ttyd in this mode).
10
10
  from __future__ import annotations
11
11
 
12
12
  import asyncio
13
+ import base64
14
+ import json
13
15
  import pathlib
14
16
  import time as _time
15
17
 
18
+ import aiohttp
16
19
  import pytest
17
20
 
18
21
  from optio_core.lifecycle import Optio
19
22
 
23
+ from optio_agents import WelcomeCard
20
24
  from optio_codex import CodexTaskConfig, create_codex_task
21
25
 
22
26
 
@@ -59,6 +63,46 @@ async def _wait_widget_data(optio: Optio, process_id: str, timeout: float = 60.0
59
63
  raise AssertionError(f"{process_id} never set widgetData in {timeout}s")
60
64
 
61
65
 
66
+ async def _wait_widget_upstream(optio: Optio, process_id: str, timeout: float = 60.0) -> dict:
67
+ """Poll the process doc until widgetUpstream is set; return it."""
68
+ end = _time.monotonic() + timeout
69
+ while _time.monotonic() < end:
70
+ proc = await optio.get_process(process_id)
71
+ if proc is not None and proc.get("widgetUpstream"):
72
+ return proc["widgetUpstream"]
73
+ await asyncio.sleep(0.05)
74
+ raise AssertionError(f"{process_id} never set widgetUpstream in {timeout}s")
75
+
76
+
77
+ def _basic(password: str) -> dict:
78
+ token = base64.b64encode(f"optio:{password}".encode()).decode()
79
+ return {"Authorization": f"Basic {token}"}
80
+
81
+
82
+ async def _read_until(resp, predicate, timeout: float = 60.0) -> dict:
83
+ """Parse SSE data frames from an open aiohttp response until one satisfies
84
+ ``predicate``; return it. Keep-alive comment frames carry no data line."""
85
+ buf = b""
86
+
87
+ async def _go():
88
+ nonlocal buf
89
+ while True:
90
+ chunk = await resp.content.read(1024)
91
+ if not chunk:
92
+ raise AssertionError("SSE stream ended before a match")
93
+ buf += chunk
94
+ while b"\n\n" in buf:
95
+ frame, buf = buf.split(b"\n\n", 1)
96
+ data = [l[5:] for l in frame.split(b"\n") if l.startswith(b"data:")]
97
+ if not data:
98
+ continue
99
+ event = json.loads(b"".join(data).strip())
100
+ if predicate(event):
101
+ return event
102
+
103
+ return await asyncio.wait_for(_go(), timeout)
104
+
105
+
62
106
  def _conversation_config(shim_install_dir: pathlib.Path, **kw) -> CodexTaskConfig:
63
107
  base = dict(
64
108
  consumer_instructions="Converse with the test.",
@@ -218,6 +262,11 @@ async def test_conversation_ui_publishes_widget(shim_install_dir, task_root, mon
218
262
  config=_conversation_config(
219
263
  shim_install_dir, conversation_ui=True,
220
264
  show_session_controls=True, tool_verbosity="verbose",
265
+ # A language-map title (published unresolved) and a minimum height.
266
+ welcome=WelcomeCard(
267
+ title={"en": "Hello", "hu": "Szia"}, description="Try **this**.",
268
+ icon="img/w.png", min_height=200,
269
+ ),
221
270
  ),
222
271
  )
223
272
  assert task.ui_widget == "conversation"
@@ -244,6 +293,11 @@ async def test_conversation_ui_publishes_widget(shim_install_dir, task_root, mon
244
293
  assert wd.get("toolVerbosity") == "verbose"
245
294
  assert wd.get("showSessionControls") is True
246
295
  assert wd.get("nativeSpinner") is False
296
+ # The welcome card, its icon rooted at the web app.
297
+ assert wd.get("welcome") == {
298
+ "title": {"en": "Hello", "hu": "Szia"}, "description": "Try **this**.",
299
+ "icon": "/img/w.png", "minHeight": 200,
300
+ }
247
301
  # The model picker is now the generic id="model" SessionControl.
248
302
  controls = wd.get("controls", [])
249
303
  model_ctrl = next((c for c in controls if c.get("id") == "model"), None)
@@ -258,6 +312,52 @@ async def test_conversation_ui_publishes_widget(shim_install_dir, task_root, mon
258
312
  await optio.shutdown(grace_seconds=1.0)
259
313
 
260
314
 
315
+ @pytest.mark.asyncio
316
+ async def test_conversation_ui_session_controls_allowlist(shim_install_dir, task_root, mongo_db):
317
+ """session_controls=["model"]: widgetData offers only the model picker (the
318
+ fake's default model is graded, so the effort slider would be there too),
319
+ /control refuses the hidden reasoning_effort, and the snapshot re-emitted
320
+ on a model switch stays narrowed."""
321
+ optio = await _make_optio(mongo_db, "cxconvallow")
322
+ try:
323
+ task = create_codex_task(
324
+ process_id="cx-conv-allow",
325
+ name="Conversation controls allowlist",
326
+ config=_conversation_config(
327
+ shim_install_dir, conversation_ui=True,
328
+ show_session_controls=True, session_controls=["model"],
329
+ ),
330
+ )
331
+ await optio.adhoc_define(task)
332
+ conv = await optio.launch_and_await_result(
333
+ "cx-conv-allow", session_id=None, timeout=60,
334
+ )
335
+ wd = await _wait_widget_data(optio, "cx-conv-allow")
336
+ assert [c["id"] for c in wd["controls"]] == ["model"]
337
+
338
+ upstream = await _wait_widget_upstream(optio, "cx-conv-allow")
339
+ url, headers = upstream["url"], _basic(upstream["innerAuth"]["password"])
340
+ async with aiohttp.ClientSession() as session:
341
+ async with session.post(f"{url}/control", headers=headers, json={
342
+ "id": "reasoning_effort", "value": "high"}) as r:
343
+ assert r.status == 403
344
+ assert (await r.json())["reason"] == "not-allowed"
345
+ async with session.get(f"{url}/events", headers=headers) as events:
346
+ async with session.post(f"{url}/control", headers=headers, json={
347
+ "id": "model", "value": "gpt-5.4-mini"}) as r:
348
+ assert r.status == 200
349
+ upd = await _read_until(
350
+ events, lambda e: e.get("type") == "x-optio-control-update",
351
+ )
352
+ assert [c["id"] for c in upd["controls"]] == ["model"]
353
+ assert upd["controls"][0]["value"] == "gpt-5.4-mini"
354
+
355
+ await conv.close()
356
+ await _wait_terminal(optio, "cx-conv-allow")
357
+ finally:
358
+ await optio.shutdown(grace_seconds=1.0)
359
+
360
+
261
361
  @pytest.mark.asyncio
262
362
  async def test_conversation_ui_file_upload_materialize(
263
363
  shim_install_dir, task_root, mongo_db,
@@ -9,11 +9,15 @@ import shutil
9
9
 
10
10
  import pytest
11
11
 
12
+ from optio_agents import RESUME_NOTICE, SYSTEM_MESSAGE_PREFIX
12
13
  from optio_codex import (
13
14
  CodexTaskConfig,
14
15
  create_codex_task,
15
16
  )
16
17
 
18
+ _POLL_RULE = "At the start of every new incoming user message"
19
+ _NOTICE_RULE = f"`{SYSTEM_MESSAGE_PREFIX}{RESUME_NOTICE}` message on your input channel"
20
+
17
21
 
18
22
  @pytest.mark.asyncio
19
23
  async def test_local_happy_path_done_in_optio_log(
@@ -61,6 +65,10 @@ async def test_local_happy_path_done_in_optio_log(
61
65
  assert observed["per_task_codex"] is True
62
66
  assert observed["resume_log"].count("\n") == 1 # exactly one launch line
63
67
  assert "## Resumes" in observed["agents_md"]
68
+ # Every resume sends the System: resume notice (both modes), so the
69
+ # agent waits for it instead of reading resume.log before each message.
70
+ assert _POLL_RULE not in observed["agents_md"]
71
+ assert _NOTICE_RULE in observed["agents_md"]
64
72
  assert captures.widget_upstream
65
73
  assert captures.widget_data
66
74
 
File without changes
File without changes