optio-codex 0.4.3__tar.gz → 0.4.5__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.
- {optio_codex-0.4.3 → optio_codex-0.4.5}/PKG-INFO +2 -2
- {optio_codex-0.4.3 → optio_codex-0.4.5}/pyproject.toml +2 -2
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/conversation.py +9 -1
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/conversation_listener.py +8 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/host_actions.py +3 -1
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/models.py +5 -2
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/session.py +9 -1
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/types.py +18 -10
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex.egg-info/PKG-INFO +2 -2
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex.egg-info/SOURCES.txt +1 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex.egg-info/requires.txt +1 -1
- optio_codex-0.4.5/tests/test_auto_start_prompt.py +14 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_config.py +21 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_conversation.py +15 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_conversation_listener.py +43 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_models.py +11 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_session_conversation.py +89 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/README.md +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/setup.cfg +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/__init__.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/account.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/cred_watcher.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/fs_allowlist.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/info.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/prompt.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/rollout.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/seed_manifest.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/snapshots.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/todos.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex/verify.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex.egg-info/dependency_links.txt +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/src/optio_codex.egg-info/top_level.txt +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_account.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_agent_info.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_await_codex_gone.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_claustrum.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_codex_cache.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_config_hooks.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_conversation_controls.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_cred_watcher.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_file_download.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_file_upload.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_fs_allowlist.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_host_actions.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_import.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_input_wiring.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_kill_ttyd_by_socket.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_prompt.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_real_codex_conversation.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_real_codex_seed_resume.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_real_codex_session.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_rollout.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_sandbox_enforce.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_seed_manifest.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_session_lease.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_session_local.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_session_remote.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_session_resume.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_session_sandbox.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_session_seed.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_snapshots.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_teardown_session_tree.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_todos.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/tests/test_verify.py +0 -0
- {optio_codex-0.4.3 → optio_codex-0.4.5}/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.
|
|
3
|
+
Version: 0.4.5
|
|
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,7 +20,7 @@ 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.
|
|
23
|
+
Requires-Dist: optio-core<0.6,>=0.5
|
|
24
24
|
Requires-Dist: optio-host<0.4,>=0.3
|
|
25
25
|
Requires-Dist: optio-agents<0.7,>=0.6
|
|
26
26
|
Requires-Dist: asyncssh>=2.14
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "optio-codex"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.5"
|
|
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,7 +26,7 @@ classifiers = [
|
|
|
26
26
|
"Framework :: AsyncIO",
|
|
27
27
|
]
|
|
28
28
|
dependencies = [
|
|
29
|
-
"optio-core>=0.
|
|
29
|
+
"optio-core>=0.5,<0.6",
|
|
30
30
|
"optio-host>=0.3,<0.4",
|
|
31
31
|
"optio-agents>=0.6,<0.7",
|
|
32
32
|
"asyncssh>=2.14",
|
|
@@ -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":
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -457,6 +458,8 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
|
|
|
457
458
|
# instead of starting a fresh one. resume_session_id is the codex
|
|
458
459
|
# thread id recorded in the restored snapshot.
|
|
459
460
|
resume_thread_id=resume_session_id if resuming else None,
|
|
461
|
+
# Narrows the controls snapshot re-emitted on a model switch.
|
|
462
|
+
session_controls=config.session_controls,
|
|
460
463
|
)
|
|
461
464
|
# Stage 9: Landlock-confine the app-server process tree (None when
|
|
462
465
|
# fs_isolation is off).
|
|
@@ -536,6 +539,9 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
|
|
|
536
539
|
# a fresh viewer attach replays before the live tail — so a long
|
|
537
540
|
# session stays scrollable to its start past the bounded buffer.
|
|
538
541
|
codex_home=host_actions._isolation_env(host.workdir)["CODEX_HOME"],
|
|
542
|
+
# Only the controls the widget shows may be set: none when the
|
|
543
|
+
# controls bar is off, else the session_controls allowlist.
|
|
544
|
+
allowed_controls=config.settable_controls,
|
|
539
545
|
)
|
|
540
546
|
# In-process aiohttp app: binds directly on the widget-tunnel
|
|
541
547
|
# interface, no host tunnel needed.
|
|
@@ -569,7 +575,9 @@ async def run_codex_session(ctx: ProcessContext, config: CodexTaskConfig) -> Non
|
|
|
569
575
|
"thinkingVerbosity": config.thinking_verbosity,
|
|
570
576
|
"showSessionControls": config.show_session_controls,
|
|
571
577
|
"nativeSpinner": config.native_spinner,
|
|
572
|
-
"controls":
|
|
578
|
+
"controls": filter_controls(
|
|
579
|
+
[c.to_dict() for c in controls], config.session_controls,
|
|
580
|
+
),
|
|
573
581
|
"showFileUpload": config.show_file_upload,
|
|
574
582
|
"maxUploadBytes": config.max_upload_bytes,
|
|
575
583
|
"fileDownload": config.file_download,
|
|
@@ -33,7 +33,11 @@ from optio_agents import (
|
|
|
33
33
|
TOOL_VERBOSITIES,
|
|
34
34
|
ToolVerbosity,
|
|
35
35
|
)
|
|
36
|
-
from optio_agents.config_types import
|
|
36
|
+
from optio_agents.config_types import (
|
|
37
|
+
BlobCryptoConfigMixin,
|
|
38
|
+
ClaustrumConfigMixin,
|
|
39
|
+
SessionControlsConfigMixin,
|
|
40
|
+
)
|
|
37
41
|
from optio_agents.protocol.session import (
|
|
38
42
|
CallerMessageCallback,
|
|
39
43
|
DeliverableCallback,
|
|
@@ -93,15 +97,16 @@ def _identity_resume_refresh(config: "CodexTaskConfig") -> "CodexTaskConfig":
|
|
|
93
97
|
|
|
94
98
|
|
|
95
99
|
@dataclass(frozen=True, kw_only=True)
|
|
96
|
-
class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
|
|
100
|
+
class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin, SessionControlsConfigMixin):
|
|
97
101
|
"""Configuration for one optio-codex task instance.
|
|
98
102
|
|
|
99
103
|
Inherits the claustrum filesystem-isolation triad (``fs_isolation`` /
|
|
100
104
|
``extra_allowed_dirs`` / ``delivery_type``) from ``ClaustrumConfigMixin``
|
|
101
105
|
and the at-rest blob-crypto quartet (``session_blob_encrypt/decrypt`` /
|
|
102
|
-
``seed_blob_encrypt/decrypt``) from ``BlobCryptoConfigMixin
|
|
103
|
-
|
|
104
|
-
``
|
|
106
|
+
``seed_blob_encrypt/decrypt``) from ``BlobCryptoConfigMixin``, and the
|
|
107
|
+
session-controls pair (``show_session_controls`` / ``session_controls``)
|
|
108
|
+
from ``SessionControlsConfigMixin``; those fields stay top-level here
|
|
109
|
+
(callers write ``fs_isolation=`` / ``session_blob_encrypt=`` verbatim). Frozen because the mixins are frozen;
|
|
105
110
|
``kw_only`` because the mixins contribute defaulted fields ahead of the
|
|
106
111
|
required ``consumer_instructions``.
|
|
107
112
|
"""
|
|
@@ -168,7 +173,7 @@ class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
|
|
|
168
173
|
|
|
169
174
|
# When True, a fresh launch kicks off the first turn itself — iframe mode
|
|
170
175
|
# types a trailing positional prompt, conversation mode sends the
|
|
171
|
-
# AUTO_START_PROMPT ("Read AGENTS.md and execute the task it describes").
|
|
176
|
+
# AUTO_START_PROMPT ("System: Read AGENTS.md and execute the task it describes").
|
|
172
177
|
# This is for UNATTENDED task execution; a task must opt in. Defaults to
|
|
173
178
|
# False (parity with claudecode/grok/opencode): a conversation/chat task
|
|
174
179
|
# must NOT auto-fire a kickoff, or codex starts an agentic loop on launch
|
|
@@ -222,10 +227,12 @@ class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
|
|
|
222
227
|
thinking_verbosity: ThinkingVerbosity = "hidden"
|
|
223
228
|
|
|
224
229
|
# --- conversation frontend parity (Stage 7) -------------------------
|
|
225
|
-
#
|
|
226
|
-
# Codex
|
|
227
|
-
#
|
|
228
|
-
|
|
230
|
+
# show_session_controls / session_controls come from
|
|
231
|
+
# SessionControlsConfigMixin. Codex's controls: "model" (the picker) and
|
|
232
|
+
# "reasoning_effort" (only for a model with graded reasoning), both
|
|
233
|
+
# switched INLINE: the chosen value rides the next turn/start and sticks —
|
|
234
|
+
# no process restart. The bar requires mode="conversation" and
|
|
235
|
+
# conversation_ui=True.
|
|
229
236
|
# Replace the generic working-spinner with codex's on-brand native
|
|
230
237
|
# spinner in the conversation widget. Requires mode="conversation" and
|
|
231
238
|
# conversation_ui=True.
|
|
@@ -297,6 +304,7 @@ class CodexTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
|
|
|
297
304
|
def __post_init__(self) -> None:
|
|
298
305
|
self._validate_claustrum()
|
|
299
306
|
self._validate_blob_crypto()
|
|
307
|
+
self._validate_session_controls()
|
|
300
308
|
if self.mode not in _VALID_MODES:
|
|
301
309
|
raise ValueError(
|
|
302
310
|
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.
|
|
3
|
+
Version: 0.4.5
|
|
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,7 +20,7 @@ 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.
|
|
23
|
+
Requires-Dist: optio-core<0.6,>=0.5
|
|
24
24
|
Requires-Dist: optio-host<0.4,>=0.3
|
|
25
25
|
Requires-Dist: optio-agents<0.7,>=0.6
|
|
26
26
|
Requires-Dist: asyncssh>=2.14
|
|
@@ -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
|
|
|
@@ -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,9 +10,12 @@ 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
|
|
@@ -59,6 +62,46 @@ async def _wait_widget_data(optio: Optio, process_id: str, timeout: float = 60.0
|
|
|
59
62
|
raise AssertionError(f"{process_id} never set widgetData in {timeout}s")
|
|
60
63
|
|
|
61
64
|
|
|
65
|
+
async def _wait_widget_upstream(optio: Optio, process_id: str, timeout: float = 60.0) -> dict:
|
|
66
|
+
"""Poll the process doc until widgetUpstream is set; return it."""
|
|
67
|
+
end = _time.monotonic() + timeout
|
|
68
|
+
while _time.monotonic() < end:
|
|
69
|
+
proc = await optio.get_process(process_id)
|
|
70
|
+
if proc is not None and proc.get("widgetUpstream"):
|
|
71
|
+
return proc["widgetUpstream"]
|
|
72
|
+
await asyncio.sleep(0.05)
|
|
73
|
+
raise AssertionError(f"{process_id} never set widgetUpstream in {timeout}s")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _basic(password: str) -> dict:
|
|
77
|
+
token = base64.b64encode(f"optio:{password}".encode()).decode()
|
|
78
|
+
return {"Authorization": f"Basic {token}"}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
async def _read_until(resp, predicate, timeout: float = 60.0) -> dict:
|
|
82
|
+
"""Parse SSE data frames from an open aiohttp response until one satisfies
|
|
83
|
+
``predicate``; return it. Keep-alive comment frames carry no data line."""
|
|
84
|
+
buf = b""
|
|
85
|
+
|
|
86
|
+
async def _go():
|
|
87
|
+
nonlocal buf
|
|
88
|
+
while True:
|
|
89
|
+
chunk = await resp.content.read(1024)
|
|
90
|
+
if not chunk:
|
|
91
|
+
raise AssertionError("SSE stream ended before a match")
|
|
92
|
+
buf += chunk
|
|
93
|
+
while b"\n\n" in buf:
|
|
94
|
+
frame, buf = buf.split(b"\n\n", 1)
|
|
95
|
+
data = [l[5:] for l in frame.split(b"\n") if l.startswith(b"data:")]
|
|
96
|
+
if not data:
|
|
97
|
+
continue
|
|
98
|
+
event = json.loads(b"".join(data).strip())
|
|
99
|
+
if predicate(event):
|
|
100
|
+
return event
|
|
101
|
+
|
|
102
|
+
return await asyncio.wait_for(_go(), timeout)
|
|
103
|
+
|
|
104
|
+
|
|
62
105
|
def _conversation_config(shim_install_dir: pathlib.Path, **kw) -> CodexTaskConfig:
|
|
63
106
|
base = dict(
|
|
64
107
|
consumer_instructions="Converse with the test.",
|
|
@@ -258,6 +301,52 @@ async def test_conversation_ui_publishes_widget(shim_install_dir, task_root, mon
|
|
|
258
301
|
await optio.shutdown(grace_seconds=1.0)
|
|
259
302
|
|
|
260
303
|
|
|
304
|
+
@pytest.mark.asyncio
|
|
305
|
+
async def test_conversation_ui_session_controls_allowlist(shim_install_dir, task_root, mongo_db):
|
|
306
|
+
"""session_controls=["model"]: widgetData offers only the model picker (the
|
|
307
|
+
fake's default model is graded, so the effort slider would be there too),
|
|
308
|
+
/control refuses the hidden reasoning_effort, and the snapshot re-emitted
|
|
309
|
+
on a model switch stays narrowed."""
|
|
310
|
+
optio = await _make_optio(mongo_db, "cxconvallow")
|
|
311
|
+
try:
|
|
312
|
+
task = create_codex_task(
|
|
313
|
+
process_id="cx-conv-allow",
|
|
314
|
+
name="Conversation controls allowlist",
|
|
315
|
+
config=_conversation_config(
|
|
316
|
+
shim_install_dir, conversation_ui=True,
|
|
317
|
+
show_session_controls=True, session_controls=["model"],
|
|
318
|
+
),
|
|
319
|
+
)
|
|
320
|
+
await optio.adhoc_define(task)
|
|
321
|
+
conv = await optio.launch_and_await_result(
|
|
322
|
+
"cx-conv-allow", session_id=None, timeout=60,
|
|
323
|
+
)
|
|
324
|
+
wd = await _wait_widget_data(optio, "cx-conv-allow")
|
|
325
|
+
assert [c["id"] for c in wd["controls"]] == ["model"]
|
|
326
|
+
|
|
327
|
+
upstream = await _wait_widget_upstream(optio, "cx-conv-allow")
|
|
328
|
+
url, headers = upstream["url"], _basic(upstream["innerAuth"]["password"])
|
|
329
|
+
async with aiohttp.ClientSession() as session:
|
|
330
|
+
async with session.post(f"{url}/control", headers=headers, json={
|
|
331
|
+
"id": "reasoning_effort", "value": "high"}) as r:
|
|
332
|
+
assert r.status == 403
|
|
333
|
+
assert (await r.json())["reason"] == "not-allowed"
|
|
334
|
+
async with session.get(f"{url}/events", headers=headers) as events:
|
|
335
|
+
async with session.post(f"{url}/control", headers=headers, json={
|
|
336
|
+
"id": "model", "value": "gpt-5.4-mini"}) as r:
|
|
337
|
+
assert r.status == 200
|
|
338
|
+
upd = await _read_until(
|
|
339
|
+
events, lambda e: e.get("type") == "x-optio-control-update",
|
|
340
|
+
)
|
|
341
|
+
assert [c["id"] for c in upd["controls"]] == ["model"]
|
|
342
|
+
assert upd["controls"][0]["value"] == "gpt-5.4-mini"
|
|
343
|
+
|
|
344
|
+
await conv.close()
|
|
345
|
+
await _wait_terminal(optio, "cx-conv-allow")
|
|
346
|
+
finally:
|
|
347
|
+
await optio.shutdown(grace_seconds=1.0)
|
|
348
|
+
|
|
349
|
+
|
|
261
350
|
@pytest.mark.asyncio
|
|
262
351
|
async def test_conversation_ui_file_upload_materialize(
|
|
263
352
|
shim_install_dir, task_root, mongo_db,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|