python-codex 0.5.2__py3-none-any.whl → 0.6.1__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 (76) hide show
  1. pycodex/__init__.py +22 -12
  2. pycodex/agent.py +89 -74
  3. pycodex/bootstrap.py +37 -251
  4. pycodex/cli.py +19 -28
  5. pycodex/config.py +36 -0
  6. pycodex/context.py +368 -51
  7. pycodex/events.py +14 -187
  8. pycodex/model.py +197 -95
  9. pycodex/multi_agents.py +401 -0
  10. pycodex/portable/__init__.py +8 -6
  11. pycodex/portable/client.py +24 -39
  12. pycodex/portable/protocol.py +28 -0
  13. pycodex/portable/server.py +3 -3
  14. pycodex/prompts/developer_messages.json +13 -0
  15. pycodex/prompts/goals/budget_limit.md +19 -0
  16. pycodex/prompts/goals/continuation.md +56 -0
  17. pycodex/prompts/models.json +1143 -200
  18. pycodex/protocol.py +81 -15
  19. pycodex/runtime.py +370 -226
  20. pycodex/tools/__init__.py +102 -10
  21. pycodex/tools/agent_tool_schemas.py +0 -38
  22. pycodex/tools/apply_patch_tool.py +17 -34
  23. pycodex/tools/base_tool.py +63 -35
  24. pycodex/tools/clock_manager.py +182 -0
  25. pycodex/tools/clock_tool.py +58 -187
  26. pycodex/tools/code_mode_manager.py +165 -246
  27. pycodex/tools/exec_command_tool.py +0 -18
  28. pycodex/tools/exec_runtime.py +332 -0
  29. pycodex/tools/exec_tool.py +74 -31
  30. pycodex/tools/followup_task_tool.py +44 -0
  31. pycodex/tools/goal_manager.py +205 -0
  32. pycodex/tools/goal_tool.py +126 -0
  33. pycodex/tools/interrupt_agent_tool.py +48 -0
  34. pycodex/tools/list_agents_tool.py +66 -0
  35. pycodex/tools/python_tool_schema.py +141 -0
  36. pycodex/tools/request_permissions_tool.py +1 -0
  37. pycodex/tools/runtime_services.py +122 -450
  38. pycodex/tools/send_message_tool.py +42 -0
  39. pycodex/tools/spawn_agent_tool.py +55 -94
  40. pycodex/tools/unified_exec_manager.py +26 -35
  41. pycodex/tools/wait_agent_tool.py +46 -66
  42. pycodex/tools/wait_tool.py +24 -13
  43. pycodex/tools/web_search_tool.py +1 -0
  44. pycodex/utils/codex_config.py +105 -0
  45. pycodex/utils/compactor.py +4 -0
  46. pycodex/utils/compat.py +43 -2
  47. pycodex/utils/doctor.py +5 -4
  48. pycodex/utils/dotenv.py +0 -7
  49. pycodex/utils/event_helpers.py +143 -13
  50. pycodex/utils/history.py +59 -0
  51. pycodex/utils/session_persist.py +104 -48
  52. python_codex-0.6.1.dist-info/METADATA +201 -0
  53. python_codex-0.6.1.dist-info/RECORD +106 -0
  54. responses_server/__init__.py +2 -0
  55. responses_server/app.py +10 -7
  56. responses_server/config.py +6 -12
  57. responses_server/gemini_api.py +333 -0
  58. responses_server/messages_api.py +9 -1
  59. responses_server/payload_processors.py +4 -4
  60. responses_server/request_translation.py +486 -0
  61. responses_server/server.py +31 -24
  62. responses_server/stream_events.py +124 -0
  63. responses_server/stream_router.py +48 -830
  64. responses_server/tools/custom_adapter.py +29 -29
  65. responses_server/tools/web_search.py +3 -0
  66. responses_server/transport.py +388 -0
  67. pycodex/tools/close_agent_tool.py +0 -60
  68. pycodex/tools/exec_runtime.js +0 -161
  69. pycodex/tools/request_user_input_tool.py +0 -102
  70. pycodex/tools/resume_agent_tool.py +0 -54
  71. pycodex/tools/send_input_tool.py +0 -110
  72. python_codex-0.5.2.dist-info/METADATA +0 -262
  73. python_codex-0.5.2.dist-info/RECORD +0 -90
  74. {python_codex-0.5.2.dist-info → python_codex-0.6.1.dist-info}/WHEEL +0 -0
  75. {python_codex-0.5.2.dist-info → python_codex-0.6.1.dist-info}/entry_points.txt +0 -0
  76. {python_codex-0.5.2.dist-info → python_codex-0.6.1.dist-info}/licenses/LICENSE +0 -0
@@ -2,13 +2,16 @@ import json
2
2
  import mmap
3
3
  import os
4
4
  import re
5
+ import tempfile
5
6
  import typing
6
7
  from collections import deque
7
8
  from contextlib import closing
9
+ from copy import deepcopy
8
10
  from datetime import datetime
9
11
  from pathlib import Path
10
12
 
11
13
  from ..protocol import (
14
+ AgentMessage,
12
15
  AssistantMessage,
13
16
  ContextMessage,
14
17
  ConversationItem,
@@ -16,9 +19,14 @@ from ..protocol import (
16
19
  ToolCall,
17
20
  ToolResult,
18
21
  UserMessage,
22
+ qualified_tool_name,
19
23
  )
20
24
  from .compactor import SUMMARY_PREFIX
21
25
  from .event_helpers import shorten_title
26
+ from .history import (
27
+ conversation_history_to_turns, iter_display_turns,
28
+ restore_visibility, serialize_history_item,
29
+ )
22
30
  from .get_env import get_package_version
23
31
 
24
32
  SESSION_INDEX_FILENAME = "session_index.jsonl"
@@ -44,9 +52,49 @@ def resolve_codex_home(
44
52
 
45
53
 
46
54
  class SessionRolloutRecorder:
55
+ @property
56
+ def recorded_path(self):
57
+ return self.rollout_path if self._session_meta is None else None
58
+
47
59
  def __init__(self, rollout_path: "Path") -> "None":
48
60
  self.rollout_path = rollout_path
49
61
  self._session_meta: "typing.Union[typing.Dict[str, object], None]" = None
62
+ self._environment_state_json = None
63
+
64
+ def read_environment_state(self):
65
+ path = Path(str(self.rollout_path) + ".state.json")
66
+ try:
67
+ with path.open("r", encoding="utf-8") as handle:
68
+ state = json.load(handle)
69
+ except FileNotFoundError:
70
+ return None
71
+ self._environment_state_json = json.dumps(
72
+ state, ensure_ascii=False, sort_keys=True, separators=(",", ":"),
73
+ )
74
+ return state
75
+
76
+ def save_environment_state(self, state):
77
+ serialized = json.dumps(
78
+ state, ensure_ascii=False, sort_keys=True, separators=(",", ":"),
79
+ )
80
+ if serialized == self._environment_state_json:
81
+ return
82
+ path = Path(str(self.rollout_path) + ".state.json")
83
+ temporary = tempfile.NamedTemporaryFile(
84
+ mode="w", encoding="utf-8", dir=str(path.parent),
85
+ prefix=path.name + ".", delete=False,
86
+ )
87
+ temporary_path = Path(temporary.name)
88
+ try:
89
+ with temporary as handle:
90
+ handle.write(serialized + "\n")
91
+ handle.flush()
92
+ os.fsync(handle.fileno())
93
+ os.replace(str(temporary_path), str(path))
94
+ finally:
95
+ if temporary_path.exists():
96
+ temporary_path.unlink()
97
+ self._environment_state_json = serialized
50
98
 
51
99
  @classmethod
52
100
  def create(
@@ -103,16 +151,18 @@ class SessionRolloutRecorder:
103
151
  for item in items:
104
152
  history.append(item)
105
153
  if isinstance(item, ContextMessage) and item.role == "user":
106
- # Preserve a fork's compact summary as context when replayed.
154
+ # Preserve compact summaries as context when replayed.
107
155
  yield "compacted", _compacted_payload(history)
108
156
  continue
109
- serialized = item.serialize()
157
+ serialized = serialize_history_item(item)
110
158
  if isinstance(serialized, dict):
111
159
  yield "response_item", serialized
112
160
  if isinstance(item, UserMessage):
113
161
  yield "event_msg", {
114
162
  "type": "user_message",
115
163
  "message": item.text,
164
+ "name": item.name,
165
+ "visible": item.visible,
116
166
  "images": [],
117
167
  "local_images": [],
118
168
  "text_elements": [],
@@ -232,7 +282,7 @@ def load_resumed_session_path(
232
282
  thread_id = _thread_id_from_rollout_path(rollout_path) or ""
233
283
  session_id = thread_id
234
284
  history: "typing.List[ConversationItem]" = []
235
- saw_user_turn = False
285
+ saw_input = False
236
286
  tool_names_by_call_id: "typing.Dict[str, str]" = {}
237
287
 
238
288
  # A rollout is append-only, and a compacted entry replaces everything
@@ -262,8 +312,9 @@ def load_resumed_session_path(
262
312
  history = _deserialize_compacted_history(
263
313
  replacement_history, payload.get("message")
264
314
  )
265
- saw_user_turn = any(
266
- isinstance(item, (UserMessage, ContextMessage)) for item in history
315
+ saw_input = any(
316
+ isinstance(item, (UserMessage, AgentMessage, ContextMessage))
317
+ for item in history
267
318
  )
268
319
  tool_names_by_call_id = {
269
320
  item.call_id: item.name
@@ -274,15 +325,15 @@ def load_resumed_session_path(
274
325
 
275
326
  if item_type == "event_msg" and isinstance(payload, dict):
276
327
  if payload.get("type") == "user_message":
277
- history.append(UserMessage(text=str(payload.get("message", ""))))
278
- saw_user_turn = True
328
+ history.append(_user_message_from_event(payload))
329
+ saw_input = True
279
330
  continue
280
331
 
281
- if (
282
- item_type != "response_item"
283
- or not saw_user_turn
284
- or not isinstance(payload, dict)
285
- ):
332
+ if item_type != "response_item" or not isinstance(payload, dict):
333
+ continue
334
+ if payload.get("type") == "agent_message":
335
+ saw_input = True
336
+ if not saw_input:
286
337
  continue
287
338
 
288
339
  _append_deserialized_response_item(
@@ -312,26 +363,6 @@ def load_resumed_session_path(
312
363
  }
313
364
 
314
365
 
315
- def conversation_history_to_turns(
316
- history: "typing.Iterable[ConversationItem]",
317
- ) -> "typing.Tuple[typing.Tuple[str, str], ...]":
318
- turns: "typing.List[typing.Tuple[str, str]]" = []
319
- current_user_text: "typing.Union[str, None]" = None
320
- current_assistant_text = ""
321
- for item in history:
322
- if isinstance(item, UserMessage):
323
- if current_user_text is not None or current_assistant_text:
324
- turns.append((current_user_text or "", current_assistant_text))
325
- current_user_text = item.text
326
- current_assistant_text = ""
327
- continue
328
- if isinstance(item, AssistantMessage):
329
- current_assistant_text = item.text
330
- if current_user_text is not None or current_assistant_text:
331
- turns.append((current_user_text or "", current_assistant_text))
332
- return tuple(turns)
333
-
334
-
335
366
  def read_rollout_history_page(rollout_path, before=None, limit=100):
336
367
  """Read a bounded page of conversation records in chronological order."""
337
368
  if isinstance(limit, bool) or not isinstance(limit, int) or not 1 <= limit <= 200:
@@ -351,6 +382,8 @@ def read_rollout_history_page(rollout_path, before=None, limit=100):
351
382
  payload = entry["payload"]
352
383
  if kind == "compacted":
353
384
  payload = {"message": payload.get("message", "")}
385
+ elif payload.get("type") == "message" and payload.get("role") == "user":
386
+ payload.setdefault("name", "user")
354
387
  entries.append({"index": index, "type": kind, "payload": payload})
355
388
  index += 1
356
389
  if before is not None and before > index:
@@ -368,26 +401,36 @@ def load_display_history(
368
401
  limit: "int" = 80,
369
402
  ) -> "typing.Tuple[typing.Union[typing.Tuple[str, str], None], ...]":
370
403
  """Read visible turns across checkpoints; None marks a compaction."""
404
+ return tuple(deque(iter_display_turns(_iter_display_items(rollout_path)), maxlen=limit))
405
+
406
+
407
+ def _user_message_from_event(payload):
408
+ return restore_visibility(UserMessage(
409
+ text=str(payload.get("message", "")), name=payload.get("name", "user"),
410
+ ), payload)
411
+
412
+
413
+ def _iter_display_items(rollout_path):
371
414
  path = Path(rollout_path).expanduser().resolve()
372
- turns = deque(maxlen=limit)
373
415
  for entry in _iter_rollout_entries(path):
374
416
  item_type = entry.get("type")
375
417
  payload = entry.get("payload")
376
418
  if not isinstance(payload, dict):
377
419
  continue
378
420
  if item_type == "compacted":
379
- turns.append(None)
421
+ yield None
380
422
  elif item_type == "event_msg" and payload.get("type") == "user_message":
381
- turns.append((str(payload.get("message", "")), ""))
423
+ yield _user_message_from_event(payload)
382
424
  elif (
383
425
  item_type == "response_item"
384
- and payload.get("type") == "message"
385
- and payload.get("role") == "assistant"
426
+ and (
427
+ payload.get("type") == "agent_message"
428
+ or (payload.get("type") == "message" and payload.get("role") == "assistant")
429
+ )
386
430
  ):
387
- if not turns or turns[-1] is None:
388
- turns.append(("", ""))
389
- turns[-1] = (turns[-1][0], _extract_response_message_text(payload))
390
- return tuple(turns)
431
+ items = []
432
+ _append_deserialized_response_item(items, payload, {}, False)
433
+ yield from items
391
434
 
392
435
 
393
436
  def _drop_unmatched_tool_calls(
@@ -550,7 +593,7 @@ def _compacted_payload(
550
593
  ) -> "typing.Dict[str, object]":
551
594
  payload: "typing.Dict[str, object]" = {"replacement_history": []}
552
595
  for item in history:
553
- serialized = item.serialize()
596
+ serialized = serialize_history_item(item)
554
597
  if isinstance(serialized, dict):
555
598
  payload["replacement_history"].append(serialized)
556
599
  if isinstance(item, ContextMessage) and item.role == "user":
@@ -591,16 +634,24 @@ def _append_deserialized_response_item(
591
634
  include_user_messages: "bool",
592
635
  ) -> "None":
593
636
  response_item_type = str(payload.get("type", "")).strip()
637
+ if response_item_type == "agent_message":
638
+ history.append(restore_visibility(
639
+ AgentMessage.from_response_item(payload), payload,
640
+ ))
641
+ return
594
642
  if response_item_type == "message":
595
643
  role = str(payload.get("role", "")).strip()
596
644
  if role == "assistant":
597
- history.append(AssistantMessage.from_response_item(payload))
645
+ history.append(restore_visibility(
646
+ AssistantMessage.from_response_item(payload), payload,
647
+ ))
598
648
  return
599
649
  if include_user_messages and role == "user":
600
650
  history.append(
601
- UserMessage(
602
- text=_extract_response_message_text(payload), id=payload.get("id")
603
- )
651
+ restore_visibility(UserMessage(
652
+ text=_extract_response_message_text(payload), id=payload.get("id"),
653
+ name=payload.get("name", "user"),
654
+ ), payload)
604
655
  )
605
656
  return
606
657
 
@@ -625,6 +676,8 @@ def _append_deserialized_response_item(
625
676
  name = str(payload.get("name", "")).strip()
626
677
  if not call_id or not name:
627
678
  return
679
+ namespace = payload.get("namespace")
680
+ name = qualified_tool_name(name, namespace)
628
681
  history.append(
629
682
  ToolCall(
630
683
  call_id=call_id,
@@ -632,7 +685,8 @@ def _append_deserialized_response_item(
632
685
  arguments=arguments,
633
686
  id=payload.get("id"),
634
687
  raw_arguments=raw_arguments if isinstance(raw_arguments, str) else None,
635
- namespace=payload.get("namespace"),
688
+ namespace=namespace,
689
+ encrypted_function_args=deepcopy(payload.get("encrypted_function_args")),
636
690
  )
637
691
  )
638
692
  tool_names_by_call_id[call_id] = name
@@ -643,6 +697,8 @@ def _append_deserialized_response_item(
643
697
  name = str(payload.get("name", "")).strip()
644
698
  if not call_id or not name:
645
699
  return
700
+ namespace = payload.get("namespace")
701
+ name = qualified_tool_name(name, namespace)
646
702
  history.append(
647
703
  ToolCall(
648
704
  call_id=call_id,
@@ -650,7 +706,7 @@ def _append_deserialized_response_item(
650
706
  arguments=str(payload.get("input", "")),
651
707
  tool_type="custom",
652
708
  id=payload.get("id"),
653
- namespace=payload.get("namespace"),
709
+ namespace=namespace,
654
710
  status=payload.get("status"),
655
711
  )
656
712
  )
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-codex
3
+ Version: 0.6.1
4
+ Summary: A minimal Python extraction of Codex's main agent loop
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.6.2
7
+ Requires-Dist: dataclasses>=0.8; python_version < '3.7'
8
+ Requires-Dist: importlib-metadata>=4.8.3; python_version < '3.8'
9
+ Requires-Dist: loguru>=0.7.3
10
+ Requires-Dist: prompt-toolkit>=3.0.36
11
+ Requires-Dist: pyyaml>=6.0
12
+ Requires-Dist: requests>=2.27.1
13
+ Requires-Dist: starlette<0.20,>=0.19.1; python_version < '3.7'
14
+ Requires-Dist: starlette>=0.19.1; python_version >= '3.7'
15
+ Requires-Dist: tomli<2,>=1.2.3; python_version < '3.11'
16
+ Requires-Dist: typing-extensions>=4.1.1; python_version < '3.8'
17
+ Requires-Dist: uvicorn<0.17,>=0.16.0; python_version < '3.7'
18
+ Requires-Dist: uvicorn>=0.16.0; python_version >= '3.7'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # pycodex
22
+
23
+ [中文](README_ZH.md)
24
+
25
+ pycodex is a Python implementation of the [Codex](https://github.com/openai/codex)
26
+ coding agent. Use it in a terminal, in a browser, or from your own Python code.
27
+ It supports file editing, command execution, multiple agents and saved sessions.
28
+ See [upstream alignment](docs/ALIGNMENT.md) for the supported scope and differences.
29
+
30
+ ## Install
31
+
32
+ | Package | Includes | Python |
33
+ | --- | --- | --- |
34
+ | `python-codex` | CLI and Python API | 3.6.2+ |
35
+ | `pycodex-ws` | Core plus browser workspace and optional Feishu integration | 3.7+ |
36
+
37
+ For the CLI and Python API:
38
+
39
+ ```bash
40
+ python3 -m pip install --upgrade python-codex
41
+ ```
42
+
43
+ For the browser workspace, install `pycodex-ws`; it includes the matching core version:
44
+
45
+ ```bash
46
+ python3 -m pip install --upgrade pycodex-ws
47
+ ```
48
+
49
+ ## Configure a model
50
+
51
+ Create `~/.codex/config.toml`. For example, with OpenAI:
52
+
53
+ ```toml
54
+ model = "gpt-5.4"
55
+ model_provider = "openai"
56
+ ```
57
+
58
+ Supply the API key through the environment or `~/.codex/.env`:
59
+
60
+ ```bash
61
+ export OPENAI_API_KEY="your-api-key"
62
+ ```
63
+
64
+ For another provider, configure its `base_url` and `env_key`. Select the API with
65
+ `compat_api` in the profile or provider table:
66
+
67
+ | `compat_api` | API |
68
+ | --- | --- |
69
+ | `"none"` (default) | Responses |
70
+ | `"chat_completions"` | Chat Completions, including Step |
71
+ | `"messages"` | Claude Messages |
72
+ | `"gemini"` | Gemini API |
73
+
74
+ Legacy `use_chat_completion = true/false` remains supported as `chat_completions/none`.
75
+
76
+ Use `--profile NAME` to select `NAME.config.toml` beside the base config or an
77
+ embedded `[profiles.NAME]` table. Use `--config PATH` for a different config file,
78
+ and `pycodex doctor` to check configuration and connectivity.
79
+ The browser workspace picks up profile changes for new sessions without a restart.
80
+
81
+ See [configuration](docs/CONTEXT.md#配置读取与-profile) and the
82
+ [Gemini setup example](docs/responses_server/README.md#gemini-api).
83
+ Gemini 4 Argon includes a prompt adapted from Antigravity.
84
+ Gemini tool arguments stream as they are generated; tools run after the complete call is received.
85
+
86
+ ## Use the CLI
87
+
88
+ Run these commands from your project directory:
89
+
90
+ ```bash
91
+ pycodex
92
+ pycodex "Summarize this repository."
93
+ pycodex --profile my_profile "Review the latest changes."
94
+ pycodex --json "Summarize this repository."
95
+ ```
96
+
97
+ The first command starts an interactive session; the others run a single task.
98
+ The agent can edit files and run commands with your user account's permissions.
99
+
100
+ | Command | Purpose |
101
+ | --- | --- |
102
+ | `/model`, `/effort` | View or change the model and reasoning effort |
103
+ | `/cd <directory>` | Change directory while idle |
104
+ | `/title`, `/history` | Manage the title and inspect conversation history |
105
+ | `/resume` | List or resume saved sessions |
106
+ | `/compact` | Summarize history to free context |
107
+ | `/queue <message>` | Submit a task after the current one finishes |
108
+
109
+ Send a message while the agent is working to redirect it, or use `/queue` to
110
+ wait. Sessions are saved under `~/.codex/sessions` by default.
111
+ Ctrl+C or Ctrl+D closes the session after issued operations finish.
112
+ Run `pycodex --help` for all options.
113
+
114
+ For a local vLLM server:
115
+
116
+ ```bash
117
+ pycodex --vllm-endpoint http://127.0.0.1:18000
118
+ ```
119
+
120
+ ## Use the browser workspace
121
+
122
+ After installing `pycodex-ws`, create `workspaces.json`:
123
+
124
+ ```json
125
+ {
126
+ "workspaces": [
127
+ {"id": "demo", "work_dir": ".", "state_path": "demo", "enable_board": true}
128
+ ]
129
+ }
130
+ ```
131
+
132
+ Start the server and keep the terminal open:
133
+
134
+ ```bash
135
+ pycodex-ws --listen 127.0.0.1:6007 --workspace-config workspaces.json
136
+ ```
137
+
138
+ Open `http://127.0.0.1:6007`. The workspace uses the same model configuration as
139
+ the CLI and provides conversations, a live HTML Canvas, and file/diff viewers.
140
+ Click file links to inspect code, then select text and use **Insert into chat**
141
+ to include it in your next message.
142
+
143
+ The settings menu provides interface customization and password-protected
144
+ workspace sharing. See the [workspace guide](packages/pycodex-ws/README.md) for
145
+ session controls, storage and Feishu setup. A separate
146
+ [VS Code extension](packages/pycodex-ws/extensions/vscode/README.md) connects to
147
+ the same backend, including over Remote SSH.
148
+
149
+ ## Use the Python API
150
+
151
+ Save this as `example.py` and run `python3 example.py`. It uses the model
152
+ configuration above and the standard tools:
153
+
154
+ ```python
155
+ from contextlib import closing
156
+
157
+ from pycodex import AgentsManager, CodexConfig
158
+ from pycodex.bootstrap import build_model
159
+ from pycodex.utils.async_bridge import run_async
160
+
161
+
162
+ async def main():
163
+ config = CodexConfig.from_env()
164
+ with closing(build_model(config.provider)) as model:
165
+ runtime = AgentsManager(
166
+ model.client, config.context,
167
+ ).create_root_runtime()
168
+ try:
169
+ await runtime.start()
170
+ receipt = await runtime.submit_input("Summarize this repository.")
171
+ print((await receipt.future).output_text)
172
+ finally:
173
+ await runtime.close()
174
+
175
+
176
+ run_async(main())
177
+ ```
178
+
179
+ `AgentsManager` creates the runtime; `submit_input` submits work.
180
+ Await `receipt.future` for the result. The example closes the runtime and any
181
+ local compatibility server when finished. See [runtime contracts](docs/RUNTIME.md#ownership) for
182
+ custom models, tools and integrations.
183
+
184
+ ## More features
185
+
186
+ - [Portable configuration](docs/PORTABLE.md): transfer encrypted configuration, instructions and skills to another machine.
187
+ - [Frontend customization](packages/pycodex-ws/README.md#customize-the-interface): change the workspace through an Agent conversation or your own CSS/JavaScript.
188
+ - [Responses compatibility server](docs/responses_server/README.md): expose a supported backend through the Responses API.
189
+ - [Retries and fallback models](docs/RUNTIME.md#responses-reliability): configure recovery from model failures.
190
+
191
+ ## Development
192
+
193
+ From the repository root:
194
+
195
+ ```bash
196
+ env -u VIRTUAL_ENV uv sync --dev
197
+ env -u VIRTUAL_ENV uv run --dev pytest
198
+ ```
199
+
200
+ See the [development guide](AGENTS.md), [test guide](tests/TESTS.md),
201
+ [runtime architecture](docs/RUNTIME.md) and [workspace API](docs/WORKSPACE_API.md).
@@ -0,0 +1,106 @@
1
+ pycodex/__init__.py,sha256=2rP9Qd5ClJlSI3bPNB0Jmn9lJUpeeo7gcbRPUvH81eI,2904
2
+ pycodex/__main__.py,sha256=MHKZ_ae3fSLGTLUUMOx15fWdeOnJSHhq-zslRP5F5Lc,79
3
+ pycodex/agent.py,sha256=yZ75cpCBM2acDBayKo9ekqHZRvODXsKtJFjyhm78v9M,22704
4
+ pycodex/bootstrap.py,sha256=MR0msG5SEAAbdT8i_wCn1ueLdNx9sETsqIVWQPhPxus,4990
5
+ pycodex/cli.py,sha256=HkX_fFNUyPnNo25FeSa9ZMaQG79rqk3b0oV4ZH0h68c,12576
6
+ pycodex/config.py,sha256=mGM7oLaciBwGXHMQjKVifWFTd7gZTfzqlQeJSFzcQic,1218
7
+ pycodex/context.py,sha256=Quc8VBNr7XVoan6-l1rzVJ1njH7Hj7lbdux_mJLXESQ,41096
8
+ pycodex/events.py,sha256=dvEzq6jH5esN4Y99M-66feD19oVfmrOBvm4LG5xEhSs,22736
9
+ pycodex/model.py,sha256=omwYru3BZ2ejZTCvUTFsIltjtH1LQWG3zWrzZ3hyNhI,58672
10
+ pycodex/multi_agents.py,sha256=3KN_Ai3UremtsQppvxd0pE7pFam_v0zBastCNi-NNx8,16150
11
+ pycodex/protocol.py,sha256=-rqxpXiYkbSTzzzsAOGXwIXWREAb4uOd3sh0V0GHLW8,14650
12
+ pycodex/runtime.py,sha256=Szeufq_cAPSw_r7HCmpin1nm_Ugsj3FCcn-pgCCkrrI,37525
13
+ pycodex/portable/__init__.py,sha256=NgACNTFK5hbRK6fqbL89qjPuh44N950pr4eoDWLfKD4,1110
14
+ pycodex/portable/client.py,sha256=ZvXjKCB557ZZ-ELmec9DIxymWbG8QBZsaU6e0axu0T0,15508
15
+ pycodex/portable/protocol.py,sha256=jtyPHI3aVY4UldlSIzeZRQX3MCFzPYfG-0iDC6JSWYo,931
16
+ pycodex/portable/server.py,sha256=UCQAqcO0OTNkEv4MQgR-fIt1y5bzdqMndFJtMm16Lqk,7503
17
+ pycodex/prompts/default_base_instructions.md,sha256=D65mcj6bo4CDvVom-D9cbJRJVNquo0NghKt164_fRsg,20923
18
+ pycodex/prompts/developer_messages.json,sha256=E-CAWMOL2KoImJ1U_1aA-OYbuVtJF0-GtZkn983B-TI,4007
19
+ pycodex/prompts/models.json,sha256=cMpnFFT56zmndGnESKSIVzUyKZOCuxjVFAouZiDx_Qk,619361
20
+ pycodex/prompts/goals/budget_limit.md,sha256=RbvI03fMD3tTy-ytnzylqAsIr9b2O_Cb81CQejR1J-k,775
21
+ pycodex/prompts/goals/continuation.md,sha256=K7OtQKQNoCKcgne-e-SQBGJjEpnCVcVCtML7T-82bWI,6153
22
+ pycodex/prompts/permissions/approval_policy/never.md,sha256=QceTG6wjkaJARjYr0HYV1aPnPcpGcrkRUW-smWRr6MQ,120
23
+ pycodex/prompts/permissions/approval_policy/on_failure.md,sha256=dfJjpXkpO6_ANdCKxbVJ8o4vyLxevrJWfKsGHTqtbkc,289
24
+ pycodex/prompts/permissions/approval_policy/on_request.md,sha256=hVQalzh0FAdkKzw5u-N4H7-LtC9ijVDlYsh3OKsZKzo,3661
25
+ pycodex/prompts/permissions/approval_policy/on_request_rule_request_permission.md,sha256=mOinishp1k-wlPsaEuIOMn5GoVm_dAIsWIuEMmv2r7o,1725
26
+ pycodex/prompts/permissions/approval_policy/unless_trusted.md,sha256=XHpi1Lfx1iIXFbbQ_ho_kGstA3JN-RLho291HM30UNw,247
27
+ pycodex/prompts/permissions/sandbox_mode/danger_full_access.md,sha256=nZ7YHacBd3cAHKRZc9XClOOOnXJPXPh0WFBueh5C2D0,197
28
+ pycodex/prompts/permissions/sandbox_mode/read_only.md,sha256=2rAPEXsBYCcuttI5j3euS-3uv_v97catIsnhxlSQSIM,173
29
+ pycodex/prompts/permissions/sandbox_mode/workspace_write.md,sha256=lVN-LwrBbHqlv5yVjcd_mU8tzZW8jfKpTatJKIZu9HI,277
30
+ pycodex/tools/__init__.py,sha256=yE_9gmbNrbUKXMfZO79Y8chfHMmOe9NBozy4i0vn0bY,5175
31
+ pycodex/tools/agent_tool_schemas.py,sha256=juw4b2pp2tDhDPVTVY4rytm8IyVr2h686Qfk_5e9S0E,780
32
+ pycodex/tools/apply_patch_tool.py,sha256=LcyJuGtndmLLbFL1sIUQ2Y6KLCef95KBfi0adGA1bN8,13183
33
+ pycodex/tools/base_tool.py,sha256=dD_makVyjbnJN_cAhRAj_sJJHYh8VUDoXFiRoWDh6Ko,8644
34
+ pycodex/tools/clock_manager.py,sha256=Xn1i4aasN_ZZdL9WsA_cS-RAVLV-SQXmOecMc1nGCa4,5884
35
+ pycodex/tools/clock_tool.py,sha256=14Y1uLagSuEO8eaACQcQQbPZP1R6cSAYaReZIyZen4c,3790
36
+ pycodex/tools/code_mode_manager.py,sha256=_bZ7RlKzAEqb2m6PBfR7Or1GJYajeuSz1xCmuJcGsV8,15975
37
+ pycodex/tools/exec_command_tool.py,sha256=Mf2FRsx6o5pWq68PCXNCSOce4wzwqyX6VrXNOvym_So,4076
38
+ pycodex/tools/exec_runtime.py,sha256=vR4HfTxknxbKDhO7QFlBDgltKegFy5KJE1eAODWVYqY,12061
39
+ pycodex/tools/exec_tool.py,sha256=7HQ8sazJBr4WQklJsCJS30kfVaQOsg5gBgIutC6QyRY,5209
40
+ pycodex/tools/followup_task_tool.py,sha256=D3nRu6csiriwe1WVig_HNLRzJQfDNMmk2R75vMfSI4Y,1609
41
+ pycodex/tools/goal_manager.py,sha256=8zicCSjqJgYyONL6EaOIyaGjTA6EBECi1NYQgEwLFms,8480
42
+ pycodex/tools/goal_tool.py,sha256=TShHf6dh6YCdMPoc6zuIgj0W2D_O95ewmh6OZKFXAX0,5225
43
+ pycodex/tools/grep_files_tool.py,sha256=KCBVNaSTU45ND-iAhh14YawMyjQnMRZnGI1NGKL3zgg,4809
44
+ pycodex/tools/interrupt_agent_tool.py,sha256=q4TBTam6sFLwAQwDsoz1WNL_b9y1Esne7awgc77gerw,1589
45
+ pycodex/tools/list_agents_tool.py,sha256=_8WLGZiD006Txw2GRwgda2TVPWSbyfZVUD9-2RK5Xn0,2366
46
+ pycodex/tools/list_dir_tool.py,sha256=_U6ouRcVbGHT5mChVyUsiMgDGrFK7EFMFaspPLAHtH8,5337
47
+ pycodex/tools/python_tool_schema.py,sha256=yoJHP7GJGSu6oyT_0nxbGJWy_TaTobFwDoFQMl65464,5781
48
+ pycodex/tools/read_file_tool.py,sha256=YK__uhIVldBjAQega5S_ZuZU5jgP_kLOwr-YhjAmRo4,9735
49
+ pycodex/tools/request_permissions_tool.py,sha256=t-Y-iEhvUyE9IJAeiwnzfUdbQ73Gw7uxFcWLwS0no4o,4000
50
+ pycodex/tools/runtime_services.py,sha256=oEqUyR7-oHQdTsEWXoiP7VKP_JDiG5dc8AjlSGQFjYI,7542
51
+ pycodex/tools/send_message_tool.py,sha256=mH51ufxTCcsHuLFI1tDKyX14AHPMij2cMJLJdlFFjZQ,1414
52
+ pycodex/tools/shell_command_tool.py,sha256=bJKlTdIs2i28vH5f4GZfpunezr6JNicRzsL_6Vc3HvU,3675
53
+ pycodex/tools/shell_tool.py,sha256=I6lYLABSmLddRrNmpk0Li83AV55MI8x0bckWaRkFGI0,3527
54
+ pycodex/tools/spawn_agent_tool.py,sha256=yjkjHsUxGdSHOn9_kZTs8Bd-0ZnWznZxOfcy3E-WKcA,3596
55
+ pycodex/tools/unified_exec_manager.py,sha256=O1o2dGkLsOLFf1XZ0_HeQQT_NIlDT6NOC1y2_OaYchw,14479
56
+ pycodex/tools/update_plan_tool.py,sha256=xwrSrerw5qfkbFc9Ltx1OZEmD__CWtryOy3UhL0-Jp4,3198
57
+ pycodex/tools/view_image_tool.py,sha256=H7OP-QZEU5Gf-E4YnQbXfu2hDkL5-dJ3Apla2YYjErQ,3754
58
+ pycodex/tools/wait_agent_tool.py,sha256=uo4KcFZBm8BAmw7i_wVjg2i3f_T9PrGL4ZnxbGt3-38,2516
59
+ pycodex/tools/wait_tool.py,sha256=fGpLbNP236xefDKg7wdJckzwEjFoCOTYV_OW-qruyfg,3637
60
+ pycodex/tools/web_search_tool.py,sha256=RDdBy0TiaG2FPKOoHoWvSKUhq0yW_o2VXViTNq9uPoU,1010
61
+ pycodex/tools/write_stdin_tool.py,sha256=jvBDchLLmoDITd7g-ZVeEVXHRhWKkmnjM5laL-53FOM,3609
62
+ pycodex/utils/__init__.py,sha256=ih_KyZ2_bajR5YlZ1QMTWOHnuEBda-S3gQ7PwnBtLZQ,453
63
+ pycodex/utils/async_bridge.py,sha256=BXsKTUTUvUtPJnItQlulFRdV7opdKKDlsKLdtVTYshs,1732
64
+ pycodex/utils/codex_config.py,sha256=oCisEGUJcJxcZL1wIqXkon1xTShymOlz96E3VgDVTlY,3748
65
+ pycodex/utils/compactor.py,sha256=IzRC6bY1ab6WP33jRMFMbmlJ3TMJcoTgDFFG-Y4C86E,6299
66
+ pycodex/utils/compat.py,sha256=16FyHHlDES57mOHCasN4FWveEkGYd2aZex9-Eojlkg8,5277
67
+ pycodex/utils/crypto.py,sha256=HRCXF26Ft3S8CG2X0YpZwa8GMU9YJ0Loo8Q9PMPMcNw,1249
68
+ pycodex/utils/debug.py,sha256=5XMpWpwFSm6woyx6RGXvN2qL0afRtTQbwlOAv-LotTw,913
69
+ pycodex/utils/doctor.py,sha256=xhPflFEYFfmtQ4-LjnIyz-cNts0GjNtAK0inVTYfKiI,10764
70
+ pycodex/utils/dotenv.py,sha256=rLHBfz5zPZMbrJqyRyYPy3j4oiDwuzfrH4mDH3XRrow,1647
71
+ pycodex/utils/event_helpers.py,sha256=VH8MMmpAO98EFb-PeEKjqAw8LCiGGaWegENP9Jnc6kA,12021
72
+ pycodex/utils/get_env.py,sha256=L4S8h84tkgxZKvrxY7ezTgePbXepG-yIigUTKeY6uuE,6094
73
+ pycodex/utils/history.py,sha256=r9Fw9HmImzgvRAcnd92zw3E2tAOgerZCp4kyJOwA1AM,2362
74
+ pycodex/utils/image_utils.py,sha256=OUzUs0Cow4L8Z2np0EBeEUotAqqsCmRmhrV8AxZUXRw,2460
75
+ pycodex/utils/model_metadata.py,sha256=uK3iI4yC7Ge7yN4I1_gQYalQ4MYKddz2qMwsmQb-P80,1337
76
+ pycodex/utils/random_ids.py,sha256=jLTxZZ0MBbRdQOFDFWGVRjWzIo6FKSQ5ADXbQSLPp1s,379
77
+ pycodex/utils/session_persist.py,sha256=pKAJZqQ4gnxUc1pzGC3PjBJUZD8eeclqvxk5IWXJ3cs,27289
78
+ pycodex/utils/truncation.py,sha256=5D6vAorT8EgXgjd7ASwtraAyIZdlCR-w5jKZqJxDzho,5446
79
+ pycodex/utils/_aes_gcm/LICENSE,sha256=KvdHagY3sYIK34GldJaRi34sNnGwMVJIIoDhbC9MRu8,2805
80
+ pycodex/utils/_aes_gcm/README.md,sha256=D9XGeewCgU2PVqJCO6WusUs0Mw2FbMnABCqaVktqCnE,3045
81
+ pycodex/utils/_aes_gcm/__init__.py,sha256=p0U1CVy6dQBDAfGvSYG0opn6iP2VGF5rqUUM-mNLJxU,70
82
+ pycodex/utils/_aes_gcm/aes.py,sha256=12p_5O7gX-e-LQ08nNe2CBdP_H4eX3J84LlXaVr9i8A,9269
83
+ pycodex/utils/_aes_gcm/gcm.py,sha256=Z8fYHpnLpqJyTPmjDOZtryqe0xmT_93vscNuJe5ZY-w,2762
84
+ pycodex/utils/_aes_gcm/source-sha256.json,sha256=g9uPWXuA0D9Wq9EGnduyiVanTgi8QWRFW-9T69FG-fc,215
85
+ responses_server/__init__.py,sha256=SOMO5Q-Z0dpaRih8yWuKUTclPl28tpy_XIPTOO_BPq0,447
86
+ responses_server/__main__.py,sha256=876xZTqhPeDBD2GKKr8pKX33Af8PhFTosAI8bYQsFgQ,61
87
+ responses_server/app.py,sha256=658hV1uR51RZzTe8B5xPvaasWZdjJo5rxg2GJFnxOLk,8495
88
+ responses_server/config.py,sha256=HxoZYNkpDwZgbIxgVgoR_8BYTRV8V2e1dCddUTo1FyQ,2663
89
+ responses_server/gemini_api.py,sha256=XUG05JhCPqxpDYSQ1m7-KCCturqIIow8ZMgDRZYMk14,15589
90
+ responses_server/messages_api.py,sha256=3Mr0v0ieN18PpEgmR48DnP6PrCDk980cAckZG-2HKrM,19274
91
+ responses_server/payload_processors.py,sha256=jIiGCHGFootnkwPpZiM1-Zv1WKziHlklSWGo050hBgU,3567
92
+ responses_server/request_translation.py,sha256=9TYgGv4GV2M7m6TGXV-pqIpIFTn8v_ZBKULUq3nvaB8,18754
93
+ responses_server/server.py,sha256=hFSRU3GjYa9cI1YSDxKvg2gLjp3OJ_Mh_JFyau3yzl4,2535
94
+ responses_server/session_store.py,sha256=nwGxQL6nUVKnDVeDHz8IzqNQ7dWk8Ybf0URekOHdxTo,1133
95
+ responses_server/stream_events.py,sha256=nWi5VcssytFD3SDHW5hQik5LR-US-Clk-5EEWAi3t-k,4984
96
+ responses_server/stream_router.py,sha256=iDcgNUtcd1inotuWMLfaK7gZfEyCnc403_SKvrcpxaw,15037
97
+ responses_server/trajectory_dump.py,sha256=5_Wy6tslszrqx3j1JeP_boyTbzIicKy8No84PzMnmHk,5111
98
+ responses_server/transport.py,sha256=363GeSws0VS-yL7pPjtMvjEp7rZ60FdMJ5oD0vPPIWU,16519
99
+ responses_server/tools/__init__.py,sha256=ivsBSEy0SBUhY-Uea5v1XMLXShkwHdCVl0id-1FwdZg,150
100
+ responses_server/tools/custom_adapter.py,sha256=leYNJKp4Ute0JWNfGpe-ntSyFqRgYCdWF4dMYQFINlk,8615
101
+ responses_server/tools/web_search.py,sha256=JyF6NHCS0SqoBrO18jX8cgBsiV4OYQBPz0Ky4u3juSQ,9059
102
+ python_codex-0.6.1.dist-info/METADATA,sha256=c6tqvH3gR_x8Cax-kzRRds6sZ4FRSSUC8rfv28Cm1f0,6855
103
+ python_codex-0.6.1.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
104
+ python_codex-0.6.1.dist-info/entry_points.txt,sha256=sNUVakoVuTrzJH505ZgRTQxmtRRPUHV_EH0i6EbYTyM,45
105
+ python_codex-0.6.1.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
106
+ python_codex-0.6.1.dist-info/RECORD,,
@@ -2,11 +2,13 @@ from .app import ManagedResponseServer, launch_chat_completion_compat_server, ru
2
2
  from .config import CompatServerConfig
3
3
  from .server import ResponseServer
4
4
  from .stream_router import StreamRouter
5
+ from .transport import OutcommingTransport
5
6
 
6
7
  __all__ = [
7
8
  "CompatServerConfig",
8
9
  "ManagedResponseServer",
9
10
  "ResponseServer",
11
+ "OutcommingTransport",
10
12
  "launch_chat_completion_compat_server",
11
13
  "run_server",
12
14
  "StreamRouter",