python-codex 0.7.1__tar.gz → 0.7.2__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 (109) hide show
  1. {python_codex-0.7.1 → python_codex-0.7.2}/PKG-INFO +1 -1
  2. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/shell_command_tool.py +18 -2
  3. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/unified_exec_manager.py +7 -7
  4. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/get_env.py +57 -5
  5. {python_codex-0.7.1 → python_codex-0.7.2}/pyproject.toml +3 -3
  6. {python_codex-0.7.1 → python_codex-0.7.2}/.gitignore +0 -0
  7. {python_codex-0.7.1 → python_codex-0.7.2}/LICENSE +0 -0
  8. {python_codex-0.7.1 → python_codex-0.7.2}/README.md +0 -0
  9. {python_codex-0.7.1 → python_codex-0.7.2}/README_ZH.md +0 -0
  10. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/__init__.py +0 -0
  11. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/__main__.py +0 -0
  12. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/agent.py +0 -0
  13. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/bootstrap.py +0 -0
  14. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/cli.py +0 -0
  15. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/config.py +0 -0
  16. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/context.py +0 -0
  17. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/events.py +0 -0
  18. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/model.py +0 -0
  19. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/multi_agents.py +0 -0
  20. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/portable/__init__.py +0 -0
  21. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/portable/client.py +0 -0
  22. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/portable/protocol.py +0 -0
  23. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/portable/server.py +0 -0
  24. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/default_base_instructions.md +0 -0
  25. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/developer_messages.json +0 -0
  26. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/goals/budget_limit.md +0 -0
  27. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/goals/continuation.md +0 -0
  28. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/models.json +0 -0
  29. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/permissions/approval_policy/never.md +0 -0
  30. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/permissions/approval_policy/on_failure.md +0 -0
  31. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/permissions/approval_policy/on_request.md +0 -0
  32. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/permissions/approval_policy/on_request_rule_request_permission.md +0 -0
  33. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/permissions/approval_policy/unless_trusted.md +0 -0
  34. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/permissions/sandbox_mode/danger_full_access.md +0 -0
  35. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/permissions/sandbox_mode/read_only.md +0 -0
  36. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/prompts/permissions/sandbox_mode/workspace_write.md +0 -0
  37. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/protocol.py +0 -0
  38. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/runtime.py +0 -0
  39. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/__init__.py +0 -0
  40. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/agent_tool_schemas.py +0 -0
  41. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/apply_patch_tool.py +0 -0
  42. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/base_tool.py +0 -0
  43. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/clock_manager.py +0 -0
  44. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/clock_tool.py +0 -0
  45. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/code_mode_manager.py +0 -0
  46. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/exec_command_tool.py +0 -0
  47. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/exec_runtime.py +0 -0
  48. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/exec_tool.py +0 -0
  49. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/followup_task_tool.py +0 -0
  50. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/goal_manager.py +0 -0
  51. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/goal_tool.py +0 -0
  52. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/grep_files_tool.py +0 -0
  53. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/interrupt_agent_tool.py +0 -0
  54. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/list_agents_tool.py +0 -0
  55. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/list_dir_tool.py +0 -0
  56. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/python_tool_schema.py +0 -0
  57. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/read_file_tool.py +0 -0
  58. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/request_permissions_tool.py +0 -0
  59. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/runtime_services.py +0 -0
  60. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/send_message_tool.py +0 -0
  61. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/shell_tool.py +0 -0
  62. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/spawn_agent_tool.py +0 -0
  63. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/update_plan_tool.py +0 -0
  64. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/view_image_tool.py +0 -0
  65. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/wait_agent_tool.py +0 -0
  66. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/wait_tool.py +0 -0
  67. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/web_search_tool.py +0 -0
  68. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/tools/write_stdin_tool.py +0 -0
  69. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/__init__.py +0 -0
  70. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/_aes_gcm/LICENSE +0 -0
  71. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/_aes_gcm/README.md +0 -0
  72. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/_aes_gcm/__init__.py +0 -0
  73. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/_aes_gcm/aes.py +0 -0
  74. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/_aes_gcm/gcm.py +0 -0
  75. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/_aes_gcm/source-sha256.json +0 -0
  76. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/async_bridge.py +0 -0
  77. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/codex_config.py +0 -0
  78. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/compactor.py +0 -0
  79. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/compat.py +0 -0
  80. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/crypto.py +0 -0
  81. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/debug.py +0 -0
  82. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/doctor.py +0 -0
  83. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/dotenv.py +0 -0
  84. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/event_helpers.py +0 -0
  85. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/history.py +0 -0
  86. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/http_headers.py +0 -0
  87. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/image_utils.py +0 -0
  88. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/model_metadata.py +0 -0
  89. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/random_ids.py +0 -0
  90. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/session_persist.py +0 -0
  91. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/skill_catalog.py +0 -0
  92. {python_codex-0.7.1 → python_codex-0.7.2}/pycodex/utils/truncation.py +0 -0
  93. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/__init__.py +0 -0
  94. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/__main__.py +0 -0
  95. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/app.py +0 -0
  96. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/config.py +0 -0
  97. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/gemini_api.py +0 -0
  98. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/messages_api.py +0 -0
  99. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/payload_processors.py +0 -0
  100. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/request_translation.py +0 -0
  101. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/server.py +0 -0
  102. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/session_store.py +0 -0
  103. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/stream_events.py +0 -0
  104. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/stream_router.py +0 -0
  105. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/tools/__init__.py +0 -0
  106. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/tools/custom_adapter.py +0 -0
  107. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/tools/web_search.py +0 -0
  108. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/trajectory_dump.py +0 -0
  109. {python_codex-0.7.1 → python_codex-0.7.2}/responses_server/transport.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-codex
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: A minimal Python extraction of Codex's main agent loop
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.6.2
@@ -12,8 +12,11 @@ Expected behavior:
12
12
  """
13
13
 
14
14
  import asyncio
15
+ import os
16
+ import subprocess
15
17
 
16
18
  from ..protocol import JSONDict, JSONValue
19
+ from ..utils.get_env import build_shell_command
17
20
  from .base_tool import BaseTool, ToolContext
18
21
 
19
22
  DEFAULT_SHELL_TIMEOUT_MS = 10_000
@@ -61,7 +64,10 @@ class ShellCommandTool(BaseTool):
61
64
  login = bool(args.get("login", True))
62
65
  workdir_arg = args.get("workdir")
63
66
  working_directory = context.resolve_path(workdir_arg)
64
- shell_args = ["bash", "-lc" if login else "-c", command]
67
+ if os.name == "nt":
68
+ shell_args = build_shell_command(command, login=login)
69
+ else:
70
+ shell_args = ["bash", "-lc" if login else "-c", command]
65
71
 
66
72
  process = await asyncio.create_subprocess_exec(
67
73
  *shell_args,
@@ -77,7 +83,17 @@ class ShellCommandTool(BaseTool):
77
83
  )
78
84
  timed_out = False
79
85
  except asyncio.TimeoutError:
80
- process.kill()
86
+ if os.name == "nt":
87
+ try:
88
+ subprocess.run(
89
+ ["taskkill", "/F", "/T", "/PID", str(process.pid)],
90
+ stdout=subprocess.DEVNULL,
91
+ stderr=subprocess.DEVNULL,
92
+ )
93
+ except OSError:
94
+ process.kill()
95
+ else:
96
+ process.kill()
81
97
  stdout_bytes, stderr_bytes = await process.communicate()
82
98
  timed_out = True
83
99
 
@@ -26,6 +26,7 @@ from loguru import logger
26
26
 
27
27
  from ..protocol import JSONValue
28
28
  from ..utils.compat import shlex_join, stream_writer_is_closing
29
+ from ..utils.get_env import build_shell_command
29
30
  from ..utils.truncation import (
30
31
  DEFAULT_MAX_OUTPUT_TOKENS,
31
32
  approx_token_count,
@@ -433,13 +434,12 @@ class UnifiedExecManager:
433
434
  shell: "typing.Union[str, None]",
434
435
  login: "bool",
435
436
  ) -> "typing.List[str]":
436
- shell_path = shell or os.environ.get("SHELL") or "/bin/bash"
437
- shell_name = Path(shell_path).name.lower()
438
- if shell_name in {"cmd", "cmd.exe"}:
439
- return [shell_path, "/C", cmd]
440
- if "powershell" in shell_name:
441
- return [shell_path, "-NoProfile", "-Command", cmd]
442
- return [shell_path, "-lc" if login else "-c", cmd]
437
+ return build_shell_command(
438
+ cmd,
439
+ shell=shell,
440
+ login=login,
441
+ default_posix="/bin/bash",
442
+ )
443
443
 
444
444
  def _truncate_output(
445
445
  self, output: "str", max_output_tokens: "typing.Union[int, None]"
@@ -1,16 +1,68 @@
1
1
  import os
2
2
  import platform
3
+ import shutil
3
4
  import subprocess
4
5
  import typing
5
6
  from datetime import datetime
6
- from pathlib import Path
7
+ from pathlib import Path, PureWindowsPath
7
8
 
8
9
 
9
- def get_shell_name() -> "str":
10
- shell_path = os.environ.get("SHELL")
10
+ def resolve_default_shell_path(default_posix: "str" = "/bin/bash") -> "str":
11
+ shell_path = (os.environ.get("SHELL") or "").strip()
11
12
  if shell_path:
12
- return Path(shell_path).name or shell_path
13
- return "bash"
13
+ if os.name != "nt":
14
+ return shell_path
15
+ if not shell_path.startswith("/") or os.path.isfile(shell_path):
16
+ return shell_path
17
+ win_equiv = shutil.which(PureWindowsPath(shell_path).name)
18
+ if win_equiv:
19
+ return win_equiv
20
+ if os.name == "nt":
21
+ for candidate in ("powershell.exe", "powershell", "pwsh.exe", "pwsh"):
22
+ resolved = shutil.which(candidate)
23
+ if resolved:
24
+ return resolved
25
+ return os.environ.get("COMSPEC") or "cmd.exe"
26
+ return default_posix
27
+
28
+
29
+ def build_shell_command(
30
+ cmd: "str",
31
+ shell: "typing.Union[str, None]" = None,
32
+ login: "bool" = True,
33
+ default_posix: "str" = "/bin/bash",
34
+ ) -> "typing.List[str]":
35
+ shell_path = shell or resolve_default_shell_path(default_posix=default_posix)
36
+ shell_name = (
37
+ PureWindowsPath(shell_path).name.lower()
38
+ if os.name == "nt"
39
+ else Path(shell_path).name.lower()
40
+ )
41
+ if shell_name in {"cmd", "cmd.exe"}:
42
+ return [shell_path, "/C", cmd]
43
+ if "powershell" in shell_name or shell_name in {"pwsh", "pwsh.exe"}:
44
+ return [shell_path, "-NoProfile", "-Command", cmd]
45
+ return [shell_path, "-lc" if login else "-c", cmd]
46
+
47
+
48
+ def get_shell_name() -> "str":
49
+ if os.name != "nt":
50
+ shell_path = os.environ.get("SHELL")
51
+ if shell_path:
52
+ return Path(shell_path).name or shell_path
53
+ return "bash"
54
+ resolved = resolve_default_shell_path()
55
+ name = PureWindowsPath(resolved).name or resolved
56
+ lower = name.lower()
57
+ if "powershell" in lower:
58
+ return "powershell"
59
+ if lower in {"pwsh", "pwsh.exe"}:
60
+ return "pwsh"
61
+ if lower in {"cmd", "cmd.exe"}:
62
+ return "cmd"
63
+ if lower.endswith(".exe"):
64
+ return name[:-4]
65
+ return name
14
66
 
15
67
 
16
68
  def get_timezone_name() -> "str":
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-codex"
7
- version = "0.7.1"
7
+ version = "0.7.2"
8
8
  description = "A minimal Python extraction of Codex's main agent loop"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.6.2"
@@ -41,8 +41,8 @@ test = [
41
41
  ]
42
42
  dev = [
43
43
  { include-group = "test" },
44
- "pyagy==0.7.1",
45
- "pycodex-ws==0.7.1",
44
+ "pyagy==0.7.2",
45
+ "pycodex-ws==0.7.2",
46
46
  "black>=22.8.0",
47
47
  "debugpy>=1.8.20; python_version >= '3.8'",
48
48
  "isort>=5.10.1",
File without changes
File without changes
File without changes
File without changes