python-codex 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- pycodex/__init__.py +5 -1
- pycodex/agent.py +89 -51
- pycodex/cli.py +152 -45
- pycodex/collaboration.py +6 -7
- pycodex/compat.py +99 -0
- pycodex/context.py +110 -87
- pycodex/doctor.py +40 -40
- pycodex/model.py +429 -90
- pycodex/portable.py +33 -33
- pycodex/portable_server.py +22 -21
- pycodex/prompts/models.json +30 -0
- pycodex/protocol.py +84 -86
- pycodex/runtime.py +36 -35
- pycodex/runtime_services.py +69 -69
- pycodex/tools/agent_tool_schemas.py +0 -2
- pycodex/tools/apply_patch_tool.py +45 -46
- pycodex/tools/base_tool.py +35 -36
- pycodex/tools/close_agent_tool.py +2 -4
- pycodex/tools/code_mode_manager.py +61 -61
- pycodex/tools/exec_command_tool.py +5 -6
- pycodex/tools/exec_runtime.js +3 -3
- pycodex/tools/exec_tool.py +2 -4
- pycodex/tools/grep_files_tool.py +10 -11
- pycodex/tools/list_dir_tool.py +8 -9
- pycodex/tools/read_file_tool.py +13 -14
- pycodex/tools/request_permissions_tool.py +2 -4
- pycodex/tools/request_user_input_tool.py +13 -14
- pycodex/tools/resume_agent_tool.py +2 -4
- pycodex/tools/send_input_tool.py +8 -9
- pycodex/tools/shell_command_tool.py +5 -6
- pycodex/tools/shell_tool.py +5 -6
- pycodex/tools/spawn_agent_tool.py +4 -5
- pycodex/tools/unified_exec_manager.py +62 -61
- pycodex/tools/update_plan_tool.py +4 -5
- pycodex/tools/view_image_tool.py +4 -5
- pycodex/tools/wait_agent_tool.py +2 -4
- pycodex/tools/wait_tool.py +4 -5
- pycodex/tools/web_search_tool.py +1 -3
- pycodex/tools/write_stdin_tool.py +4 -5
- pycodex/utils/__init__.py +4 -0
- pycodex/utils/compactor.py +189 -0
- pycodex/utils/dotenv.py +6 -6
- pycodex/utils/get_env.py +37 -33
- pycodex/utils/random_ids.py +1 -2
- pycodex/utils/session_persist.py +483 -0
- pycodex/utils/visualize.py +197 -83
- {python_codex-0.1.2.dist-info → python_codex-0.1.4.dist-info}/METADATA +32 -11
- python_codex-0.1.4.dist-info/RECORD +76 -0
- {python_codex-0.1.2.dist-info → python_codex-0.1.4.dist-info}/WHEEL +1 -1
- responses_server/app.py +32 -20
- responses_server/config.py +17 -17
- responses_server/payload_processors.py +26 -17
- responses_server/server.py +11 -11
- responses_server/session_store.py +10 -10
- responses_server/stream_router.py +83 -64
- responses_server/tools/custom_adapter.py +12 -12
- responses_server/tools/web_search.py +33 -33
- python_codex-0.1.2.dist-info/RECORD +0 -73
- {python_codex-0.1.2.dist-info → python_codex-0.1.4.dist-info}/entry_points.txt +0 -0
- {python_codex-0.1.2.dist-info → python_codex-0.1.4.dist-info}/licenses/LICENSE +0 -0
pycodex/doctor.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
1
|
|
|
3
2
|
import asyncio
|
|
4
3
|
import json
|
|
@@ -14,31 +13,32 @@ import requests
|
|
|
14
13
|
from .model import ResponsesModelClient, ResponsesProviderConfig
|
|
15
14
|
from .protocol import AssistantMessage, Prompt, UserMessage
|
|
16
15
|
from .utils.dotenv import DOTENV_FILENAME, load_codex_dotenv
|
|
16
|
+
import typing
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
@dataclass
|
|
19
|
+
@dataclass
|
|
20
20
|
class DoctorCheck:
|
|
21
|
-
name: str
|
|
22
|
-
ok: bool
|
|
23
|
-
detail: str
|
|
21
|
+
name: 'str'
|
|
22
|
+
ok: 'bool'
|
|
23
|
+
detail: 'str'
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
@dataclass
|
|
26
|
+
@dataclass
|
|
27
27
|
class DoctorReport:
|
|
28
|
-
ok: bool
|
|
29
|
-
config_path: str
|
|
30
|
-
dotenv_path: str
|
|
31
|
-
profile: str
|
|
32
|
-
provider_name: str
|
|
33
|
-
model: str
|
|
34
|
-
base_url: str
|
|
35
|
-
responses_url: str
|
|
36
|
-
api_key_env: str
|
|
37
|
-
api_key_loaded: bool = False
|
|
38
|
-
checks:
|
|
39
|
-
live_output_text: str
|
|
40
|
-
|
|
41
|
-
def to_dict(self) ->
|
|
28
|
+
ok: 'bool'
|
|
29
|
+
config_path: 'str'
|
|
30
|
+
dotenv_path: 'str'
|
|
31
|
+
profile: 'typing.Union[str, None]'
|
|
32
|
+
provider_name: 'typing.Union[str, None]' = None
|
|
33
|
+
model: 'typing.Union[str, None]' = None
|
|
34
|
+
base_url: 'typing.Union[str, None]' = None
|
|
35
|
+
responses_url: 'typing.Union[str, None]' = None
|
|
36
|
+
api_key_env: 'typing.Union[str, None]' = None
|
|
37
|
+
api_key_loaded: 'bool' = False
|
|
38
|
+
checks: 'typing.List[DoctorCheck]' = field(default_factory=list)
|
|
39
|
+
live_output_text: 'typing.Union[str, None]' = None
|
|
40
|
+
|
|
41
|
+
def to_dict(self) -> 'typing.Dict[str, object]':
|
|
42
42
|
return asdict(self)
|
|
43
43
|
|
|
44
44
|
|
|
@@ -79,11 +79,11 @@ def build_doctor_parser():
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
async def collect_doctor_report(
|
|
82
|
-
config_path: str
|
|
83
|
-
profile: str
|
|
84
|
-
timeout_seconds: float = 120.0,
|
|
85
|
-
skip_live: bool = False,
|
|
86
|
-
) -> DoctorReport:
|
|
82
|
+
config_path: 'typing.Union[str, Path]',
|
|
83
|
+
profile: 'typing.Union[str, None]' = None,
|
|
84
|
+
timeout_seconds: 'float' = 120.0,
|
|
85
|
+
skip_live: 'bool' = False,
|
|
86
|
+
) -> 'DoctorReport':
|
|
87
87
|
config_file = Path(config_path).expanduser().resolve()
|
|
88
88
|
dotenv_file = config_file.parent / DOTENV_FILENAME
|
|
89
89
|
report = DoctorReport(
|
|
@@ -227,7 +227,7 @@ async def collect_doctor_report(
|
|
|
227
227
|
return _finalize_report(report)
|
|
228
228
|
|
|
229
229
|
|
|
230
|
-
async def run_doctor_cli(args) -> int:
|
|
230
|
+
async def run_doctor_cli(args) -> 'int':
|
|
231
231
|
report = await collect_doctor_report(
|
|
232
232
|
args.config,
|
|
233
233
|
args.profile,
|
|
@@ -243,7 +243,7 @@ async def run_doctor_cli(args) -> int:
|
|
|
243
243
|
return 0 if report.ok else 1
|
|
244
244
|
|
|
245
245
|
|
|
246
|
-
def format_doctor_report(report: DoctorReport) -> str:
|
|
246
|
+
def format_doctor_report(report: 'DoctorReport') -> 'str':
|
|
247
247
|
lines = [
|
|
248
248
|
f"config: {report.config_path}",
|
|
249
249
|
f"dotenv: {report.dotenv_path}",
|
|
@@ -267,7 +267,7 @@ def format_doctor_report(report: DoctorReport) -> str:
|
|
|
267
267
|
return "\n".join(lines)
|
|
268
268
|
|
|
269
269
|
|
|
270
|
-
def _loaded_api_key(provider_config: ResponsesProviderConfig) -> str:
|
|
270
|
+
def _loaded_api_key(provider_config: 'ResponsesProviderConfig') -> 'str':
|
|
271
271
|
try:
|
|
272
272
|
return provider_config.api_key()
|
|
273
273
|
except Exception:
|
|
@@ -275,11 +275,11 @@ def _loaded_api_key(provider_config: ResponsesProviderConfig) -> str:
|
|
|
275
275
|
|
|
276
276
|
|
|
277
277
|
def _probe_transport(
|
|
278
|
-
scheme: str,
|
|
279
|
-
host: str,
|
|
280
|
-
port: int,
|
|
281
|
-
timeout_seconds: float,
|
|
282
|
-
) ->
|
|
278
|
+
scheme: 'str',
|
|
279
|
+
host: 'str',
|
|
280
|
+
port: 'int',
|
|
281
|
+
timeout_seconds: 'float',
|
|
282
|
+
) -> 'typing.Tuple[bool, str]':
|
|
283
283
|
started = time.perf_counter()
|
|
284
284
|
try:
|
|
285
285
|
with socket.create_connection((host, port), timeout=timeout_seconds) as sock:
|
|
@@ -298,7 +298,7 @@ def _probe_transport(
|
|
|
298
298
|
return True, f"{label} {host}:{port} connected in {elapsed:.2f}s"
|
|
299
299
|
|
|
300
300
|
|
|
301
|
-
def _proxy_detail(proxies:
|
|
301
|
+
def _proxy_detail(proxies: 'typing.Dict[str, str]') -> 'str':
|
|
302
302
|
if not proxies:
|
|
303
303
|
return "not configured"
|
|
304
304
|
return ", ".join(
|
|
@@ -306,7 +306,7 @@ def _proxy_detail(proxies: dict[str, str]) -> str:
|
|
|
306
306
|
)
|
|
307
307
|
|
|
308
308
|
|
|
309
|
-
def _redact_proxy_url(value: str) -> str:
|
|
309
|
+
def _redact_proxy_url(value: 'str') -> 'str':
|
|
310
310
|
parsed = urllib.parse.urlsplit(value)
|
|
311
311
|
if not parsed.scheme or not parsed.netloc:
|
|
312
312
|
return value
|
|
@@ -319,10 +319,10 @@ def _redact_proxy_url(value: str) -> str:
|
|
|
319
319
|
|
|
320
320
|
|
|
321
321
|
async def _run_live_check(
|
|
322
|
-
config_path: Path,
|
|
323
|
-
profile: str
|
|
324
|
-
timeout_seconds: float,
|
|
325
|
-
) ->
|
|
322
|
+
config_path: 'Path',
|
|
323
|
+
profile: 'typing.Union[str, None]',
|
|
324
|
+
timeout_seconds: 'float',
|
|
325
|
+
) -> 'typing.Tuple[bool, str, typing.Union[str, None]]':
|
|
326
326
|
client = ResponsesModelClient.from_codex_config(
|
|
327
327
|
config_path,
|
|
328
328
|
profile,
|
|
@@ -355,6 +355,6 @@ async def _run_live_check(
|
|
|
355
355
|
return True, f"completed in {elapsed:.2f}s", output_text
|
|
356
356
|
|
|
357
357
|
|
|
358
|
-
def _finalize_report(report: DoctorReport) -> DoctorReport:
|
|
358
|
+
def _finalize_report(report: 'DoctorReport') -> 'DoctorReport':
|
|
359
359
|
report.ok = all(check.ok for check in report.checks)
|
|
360
360
|
return report
|