python-codex 0.2.7__py3-none-any.whl → 0.3.0__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.
Files changed (84) hide show
  1. pycodex/__init__.py +14 -14
  2. pycodex/agent.py +465 -499
  3. pycodex/bootstrap.py +417 -0
  4. pycodex/cli.py +236 -510
  5. pycodex/compat.py +19 -5
  6. pycodex/context.py +222 -212
  7. pycodex/doctor.py +52 -48
  8. pycodex/events.py +857 -0
  9. pycodex/feishu_card.py +217 -163
  10. pycodex/feishu_link.py +43 -83
  11. pycodex/model.py +324 -253
  12. pycodex/model_metadata.py +19 -7
  13. pycodex/portable.py +76 -45
  14. pycodex/portable_server.py +32 -24
  15. pycodex/prompts/models.json +245 -983
  16. pycodex/protocol.py +177 -137
  17. pycodex/runtime.py +579 -176
  18. pycodex/runtime_services.py +204 -157
  19. pycodex/tools/__init__.py +1 -1
  20. pycodex/tools/apply_patch_tool.py +69 -48
  21. pycodex/tools/base_tool.py +89 -42
  22. pycodex/tools/clock_tool.py +58 -25
  23. pycodex/tools/close_agent_tool.py +2 -2
  24. pycodex/tools/code_mode_manager.py +77 -64
  25. pycodex/tools/exec_command_tool.py +26 -11
  26. pycodex/tools/exec_tool.py +4 -4
  27. pycodex/tools/grep_files_tool.py +12 -10
  28. pycodex/tools/ipython_tool.py +10 -13
  29. pycodex/tools/list_dir_tool.py +13 -9
  30. pycodex/tools/read_file_tool.py +29 -17
  31. pycodex/tools/request_permissions_tool.py +15 -5
  32. pycodex/tools/request_user_input_tool.py +13 -104
  33. pycodex/tools/resume_agent_tool.py +2 -2
  34. pycodex/tools/send_input_tool.py +11 -8
  35. pycodex/tools/shell_command_tool.py +7 -5
  36. pycodex/tools/shell_tool.py +7 -5
  37. pycodex/tools/spawn_agent_tool.py +7 -4
  38. pycodex/tools/unified_exec_manager.py +102 -69
  39. pycodex/tools/update_plan_tool.py +8 -5
  40. pycodex/tools/view_image_tool.py +7 -5
  41. pycodex/tools/wait_agent_tool.py +27 -4
  42. pycodex/tools/wait_tool.py +5 -4
  43. pycodex/tools/web_search_tool.py +4 -2
  44. pycodex/tools/write_stdin_tool.py +12 -11
  45. pycodex/utils/__init__.py +2 -17
  46. pycodex/utils/compactor.py +41 -72
  47. pycodex/utils/debug.py +2 -2
  48. pycodex/utils/dotenv.py +6 -7
  49. pycodex/utils/event_helpers.py +190 -0
  50. pycodex/utils/get_env.py +27 -70
  51. pycodex/{image_utils.py → utils/image_utils.py} +8 -11
  52. pycodex/utils/random_ids.py +1 -2
  53. pycodex/utils/session_persist.py +217 -163
  54. pycodex/utils/truncation.py +21 -45
  55. python_codex-0.3.0.dist-info/METADATA +704 -0
  56. python_codex-0.3.0.dist-info/RECORD +90 -0
  57. responses_server/__init__.py +1 -5
  58. responses_server/__main__.py +0 -1
  59. responses_server/app.py +36 -31
  60. responses_server/config.py +23 -23
  61. responses_server/messages_api.py +51 -53
  62. responses_server/payload_processors.py +25 -20
  63. responses_server/server.py +11 -11
  64. responses_server/session_store.py +14 -11
  65. responses_server/stream_router.py +101 -98
  66. responses_server/tools/custom_adapter.py +17 -16
  67. responses_server/tools/web_search.py +39 -36
  68. responses_server/trajectory_dump.py +36 -14
  69. workspace_server/__main__.py +0 -1
  70. workspace_server/app.py +461 -375
  71. workspace_server/workspace.html +852 -228
  72. workspace_server/workspaces.html +94 -95
  73. workspace_server/workspaces.py +137 -79
  74. pycodex/collaboration.py +0 -20
  75. pycodex/interactive_session.py +0 -415
  76. pycodex/prompts/collaboration_default.md +0 -11
  77. pycodex/prompts/collaboration_plan.md +0 -128
  78. pycodex/utils/toolcall_visualize.py +0 -713
  79. pycodex/utils/visualize.py +0 -560
  80. python_codex-0.2.7.dist-info/METADATA +0 -455
  81. python_codex-0.2.7.dist-info/RECORD +0 -93
  82. {python_codex-0.2.7.dist-info → python_codex-0.3.0.dist-info}/WHEEL +0 -0
  83. {python_codex-0.2.7.dist-info → python_codex-0.3.0.dist-info}/entry_points.txt +0 -0
  84. {python_codex-0.2.7.dist-info → python_codex-0.3.0.dist-info}/licenses/LICENSE +0 -0
@@ -13,12 +13,11 @@ Expected behavior:
13
13
  import base64
14
14
  import io
15
15
  import mimetypes
16
+ import typing
16
17
  from pathlib import Path
17
18
 
18
19
  from PIL import Image
19
20
 
20
- import typing
21
-
22
21
  MAX_DIMENSION = 2048
23
22
 
24
23
  _PRESERVABLE_MIME_TYPES = ("image/png", "image/jpeg", "image/webp")
@@ -29,9 +28,9 @@ class ImageProcessingError(RuntimeError):
29
28
 
30
29
 
31
30
  def load_image_data_url(
32
- path: 'Path',
33
- resize_to_fit: 'bool' = True,
34
- ) -> 'str':
31
+ path: "Path",
32
+ resize_to_fit: "bool" = True,
33
+ ) -> "str":
35
34
  mime_type, _ = mimetypes.guess_type(path.name)
36
35
  if not mime_type or not mime_type.startswith("image/"):
37
36
  raise ImageProcessingError(
@@ -46,9 +45,9 @@ def load_image_data_url(
46
45
 
47
46
 
48
47
  def _resize_to_fit(
49
- mime_type: 'str',
50
- image_bytes: 'bytes',
51
- ) -> 'typing.Tuple[str, bytes]':
48
+ mime_type: "str",
49
+ image_bytes: "bytes",
50
+ ) -> "typing.Tuple[str, bytes]":
52
51
  with Image.open(io.BytesIO(image_bytes)) as image:
53
52
  width, height = image.size
54
53
  if width <= MAX_DIMENSION and height <= MAX_DIMENSION:
@@ -60,9 +59,7 @@ def _resize_to_fit(
60
59
  max(1, int(height * scale)),
61
60
  )
62
61
  resized = image.resize(target_size, Image.BILINEAR)
63
- target_mime = (
64
- mime_type if mime_type in _PRESERVABLE_MIME_TYPES else "image/png"
65
- )
62
+ target_mime = mime_type if mime_type in _PRESERVABLE_MIME_TYPES else "image/png"
66
63
  if target_mime == "image/jpeg":
67
64
  resized = resized.convert("RGB")
68
65
  save_format, save_kwargs = "JPEG", {"quality": 85}
@@ -1,10 +1,9 @@
1
-
2
1
  import random
3
2
  import time
4
3
  import uuid
5
4
 
6
5
 
7
- def uuid7_string() -> 'str':
6
+ def uuid7_string() -> "str":
8
7
  timestamp_ms = int(time.time() * 1000) & ((1 << 48) - 1)
9
8
  rand_a = random.getrandbits(12)
10
9
  rand_b = random.getrandbits(62)