python-codex 0.6.0__tar.gz → 0.6.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 (114) hide show
  1. python_codex-0.6.2/PKG-INFO +216 -0
  2. python_codex-0.6.2/README.md +196 -0
  3. python_codex-0.6.2/README_ZH.md +181 -0
  4. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/__init__.py +4 -4
  5. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/agent.py +28 -9
  6. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/bootstrap.py +10 -12
  7. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/cli.py +0 -14
  8. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/context.py +43 -32
  9. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/events.py +20 -11
  10. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/model.py +16 -7
  11. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/models.json +14 -0
  12. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/protocol.py +18 -0
  13. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/runtime.py +49 -54
  14. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/__init__.py +9 -10
  15. python_codex-0.6.2/pycodex/tools/clock_tool.py +114 -0
  16. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/exec_runtime.py +29 -78
  17. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/exec_tool.py +2 -6
  18. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/compat.py +41 -0
  19. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/dotenv.py +0 -7
  20. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/event_helpers.py +5 -9
  21. python_codex-0.6.2/pycodex/utils/history.py +92 -0
  22. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/session_persist.py +133 -36
  23. python_codex-0.6.2/pycodex/utils/skill_catalog.py +18 -0
  24. {python_codex-0.6.0 → python_codex-0.6.2}/pyproject.toml +2 -2
  25. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/app.py +3 -1
  26. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/config.py +6 -1
  27. python_codex-0.6.2/responses_server/gemini_api.py +336 -0
  28. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/messages_api.py +9 -1
  29. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/request_translation.py +6 -0
  30. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/stream_router.py +15 -0
  31. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/tools/web_search.py +3 -0
  32. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/transport.py +75 -19
  33. python_codex-0.6.0/PKG-INFO +0 -352
  34. python_codex-0.6.0/README.md +0 -332
  35. python_codex-0.6.0/README_ZH.md +0 -233
  36. python_codex-0.6.0/pycodex/tools/clock_tool.py +0 -64
  37. python_codex-0.6.0/pycodex/tools/request_user_input_tool.py +0 -82
  38. python_codex-0.6.0/pycodex/utils/history.py +0 -33
  39. {python_codex-0.6.0 → python_codex-0.6.2}/.gitignore +0 -0
  40. {python_codex-0.6.0 → python_codex-0.6.2}/LICENSE +0 -0
  41. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/__main__.py +0 -0
  42. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/config.py +0 -0
  43. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/multi_agents.py +0 -0
  44. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/portable/__init__.py +0 -0
  45. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/portable/client.py +0 -0
  46. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/portable/protocol.py +0 -0
  47. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/portable/server.py +0 -0
  48. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/default_base_instructions.md +0 -0
  49. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/developer_messages.json +0 -0
  50. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/goals/budget_limit.md +0 -0
  51. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/goals/continuation.md +0 -0
  52. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/permissions/approval_policy/never.md +0 -0
  53. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/permissions/approval_policy/on_failure.md +0 -0
  54. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/permissions/approval_policy/on_request.md +0 -0
  55. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/permissions/approval_policy/on_request_rule_request_permission.md +0 -0
  56. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/permissions/approval_policy/unless_trusted.md +0 -0
  57. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/permissions/sandbox_mode/danger_full_access.md +0 -0
  58. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/permissions/sandbox_mode/read_only.md +0 -0
  59. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/prompts/permissions/sandbox_mode/workspace_write.md +0 -0
  60. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/agent_tool_schemas.py +0 -0
  61. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/apply_patch_tool.py +0 -0
  62. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/base_tool.py +0 -0
  63. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/clock_manager.py +0 -0
  64. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/code_mode_manager.py +0 -0
  65. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/exec_command_tool.py +0 -0
  66. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/followup_task_tool.py +0 -0
  67. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/goal_manager.py +0 -0
  68. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/goal_tool.py +0 -0
  69. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/grep_files_tool.py +0 -0
  70. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/interrupt_agent_tool.py +0 -0
  71. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/list_agents_tool.py +0 -0
  72. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/list_dir_tool.py +0 -0
  73. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/python_tool_schema.py +0 -0
  74. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/read_file_tool.py +0 -0
  75. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/request_permissions_tool.py +0 -0
  76. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/runtime_services.py +0 -0
  77. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/send_message_tool.py +0 -0
  78. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/shell_command_tool.py +0 -0
  79. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/shell_tool.py +0 -0
  80. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/spawn_agent_tool.py +0 -0
  81. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/unified_exec_manager.py +0 -0
  82. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/update_plan_tool.py +0 -0
  83. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/view_image_tool.py +0 -0
  84. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/wait_agent_tool.py +0 -0
  85. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/wait_tool.py +0 -0
  86. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/web_search_tool.py +0 -0
  87. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/tools/write_stdin_tool.py +0 -0
  88. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/__init__.py +0 -0
  89. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/_aes_gcm/LICENSE +0 -0
  90. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/_aes_gcm/README.md +0 -0
  91. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/_aes_gcm/__init__.py +0 -0
  92. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/_aes_gcm/aes.py +0 -0
  93. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/_aes_gcm/gcm.py +0 -0
  94. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/_aes_gcm/source-sha256.json +0 -0
  95. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/async_bridge.py +0 -0
  96. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/codex_config.py +0 -0
  97. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/compactor.py +0 -0
  98. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/crypto.py +0 -0
  99. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/debug.py +0 -0
  100. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/doctor.py +0 -0
  101. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/get_env.py +0 -0
  102. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/image_utils.py +0 -0
  103. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/model_metadata.py +0 -0
  104. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/random_ids.py +0 -0
  105. {python_codex-0.6.0 → python_codex-0.6.2}/pycodex/utils/truncation.py +0 -0
  106. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/__init__.py +0 -0
  107. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/__main__.py +0 -0
  108. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/payload_processors.py +0 -0
  109. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/server.py +0 -0
  110. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/session_store.py +0 -0
  111. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/stream_events.py +0 -0
  112. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/tools/__init__.py +0 -0
  113. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/tools/custom_adapter.py +0 -0
  114. {python_codex-0.6.0 → python_codex-0.6.2}/responses_server/trajectory_dump.py +0 -0
@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-codex
3
+ Version: 0.6.2
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
+ Start with [config_examples/](config_examples/README.md) for Responses, StepFun,
52
+ Chat Completions, Claude Messages or Gemini. Give an agent your endpoint and key
53
+ (StepFun Coding Plan includes its endpoint) and ask it to follow that guide to
54
+ install and verify a config or profile.
55
+
56
+ Create `~/.codex/config.toml`. For example, with OpenAI:
57
+
58
+ ```toml
59
+ model = "gpt-5.4"
60
+ model_provider = "openai"
61
+ ```
62
+
63
+ Supply the API key through the environment or `~/.codex/.env`:
64
+
65
+ ```bash
66
+ export OPENAI_API_KEY="your-api-key"
67
+ ```
68
+
69
+ For another provider, configure its `base_url` and `env_key`. Select the API with
70
+ `compat_api` in the profile or provider table:
71
+
72
+ | `compat_api` | API |
73
+ | --- | --- |
74
+ | `"none"` (default) | Responses |
75
+ | `"chat_completions"` | Chat Completions, including Step |
76
+ | `"messages"` | Claude Messages |
77
+ | `"gemini"` | Gemini API |
78
+
79
+ Legacy `use_chat_completion = true/false` remains supported as `chat_completions/none`.
80
+
81
+ Use `--profile NAME` to select `NAME.config.toml` beside the base config or an
82
+ embedded `[profiles.NAME]` table. Use `--config PATH` for a different config file,
83
+ and `pycodex doctor` to check configuration and connectivity.
84
+ The browser workspace picks up profile changes for new sessions without a restart.
85
+
86
+ See [configuration](docs/CONTEXT.md#配置读取与-profile) and the
87
+ [Gemini setup example](docs/responses_server/README.md#gemini-api).
88
+ Gemini 4 Argon includes a prompt adapted from Antigravity.
89
+ Gemini tool arguments stream as they are generated; tools run after the complete call is received.
90
+ Gemini continuation omits unsigned empty text parts while preserving thought signatures,
91
+ including when resuming recorded sessions.
92
+
93
+ ## Use the CLI
94
+
95
+ Run these commands from your project directory:
96
+
97
+ ```bash
98
+ pycodex
99
+ pycodex "Summarize this repository."
100
+ pycodex --profile my_profile "Review the latest changes."
101
+ pycodex --json "Summarize this repository."
102
+ ```
103
+
104
+ The first command starts an interactive session; the others run a single task.
105
+ Web skill completion is an [optional frontend feature](packages/pycodex-ws/workspace_server/optional_features/skill-completion/README.md).
106
+ Apply `skill-completion` through Customize to enable @/$ prefix suggestions.
107
+ The agent can edit files and run commands with your user account's permissions.
108
+
109
+ | Command | Purpose |
110
+ | --- | --- |
111
+ | `/model`, `/effort` | View or change the model and reasoning effort |
112
+ | `/cd <directory>` | Change directory while idle |
113
+ | `/title`, `/history` | Manage the title and inspect conversation history |
114
+ | `/resume` | List or resume saved sessions |
115
+ | `/compact` | Summarize history to free context |
116
+ | `/queue <message>` | Submit a task after the current one finishes |
117
+
118
+ Send a message while the agent is working to redirect it, or use `/queue` to
119
+ wait. Sessions are saved under `~/.codex/sessions` by default.
120
+ Ctrl+C or Ctrl+D closes the session after issued operations finish.
121
+ Run `pycodex --help` for all options.
122
+
123
+ For a local vLLM server:
124
+
125
+ ```bash
126
+ pycodex --vllm-endpoint http://127.0.0.1:18000
127
+ ```
128
+
129
+ ## Use the browser workspace
130
+
131
+ After installing `pycodex-ws`, create `workspaces.json`:
132
+
133
+ ```json
134
+ {
135
+ "workspaces": [
136
+ {"id": "demo", "work_dir": ".", "state_path": "demo", "enable_board": true}
137
+ ]
138
+ }
139
+ ```
140
+
141
+ Start the server and keep the terminal open:
142
+
143
+ ```bash
144
+ pycodex-ws --listen 127.0.0.1:6007 --workspace-config workspaces.json
145
+ ```
146
+
147
+ Open `http://127.0.0.1:6007`. The workspace uses the same model configuration as
148
+ the CLI and provides conversations, a live HTML Canvas, and file/diff viewers.
149
+ Click file links to inspect code, then select text and use **Insert into chat**
150
+ to include it in your next message.
151
+ Each input displays its author and creation time, including separate messages
152
+ in a steer batch. Recorded messages keep that metadata when the session resumes.
153
+ Restoring a tab reads the rollout tail needed for its latest 80 display rows;
154
+ Agent resume still restores the complete active context after the last checkpoint.
155
+
156
+ The settings menu provides interface customization, password-protected
157
+ workspace sharing, and [One-line Agent](packages/pycodex-ws/README.md#one-line-agent):
158
+ an Agent that runs directly in most shells without installation, for bootstrapping
159
+ an Agent environment or simple debugging. See the [workspace guide](packages/pycodex-ws/README.md) for
160
+ session controls, storage and Feishu setup. A separate
161
+ [VS Code extension](packages/pycodex-ws/extensions/vscode/README.md) connects to
162
+ the same backend, including over Remote SSH.
163
+
164
+ ## Use the Python API
165
+
166
+ Save this as `example.py` and run `python3 example.py`. It uses the model
167
+ configuration above and the standard tools:
168
+
169
+ ```python
170
+ from contextlib import closing
171
+
172
+ from pycodex import AgentsManager, CodexConfig
173
+ from pycodex.bootstrap import build_model
174
+ from pycodex.utils.async_bridge import run_async
175
+
176
+
177
+ async def main():
178
+ config = CodexConfig.from_env()
179
+ with closing(build_model(config.provider)) as model:
180
+ runtime = AgentsManager(
181
+ model.client, config.context,
182
+ ).create_root_runtime()
183
+ try:
184
+ await runtime.start()
185
+ receipt = await runtime.submit_input("Summarize this repository.")
186
+ print((await receipt.future).output_text)
187
+ finally:
188
+ await runtime.close()
189
+
190
+
191
+ run_async(main())
192
+ ```
193
+
194
+ `AgentsManager` creates the runtime; `submit_input` submits work.
195
+ Await `receipt.future` for the result. The example closes the runtime and any
196
+ local compatibility server when finished. See [runtime contracts](docs/RUNTIME.md#ownership) for
197
+ custom models, tools and integrations.
198
+
199
+ ## More features
200
+
201
+ - [Portable configuration](docs/PORTABLE.md): transfer encrypted configuration, instructions and skills to another machine.
202
+ - [Frontend customization](packages/pycodex-ws/README.md#customize-the-interface): change the workspace through an Agent conversation or your own CSS/JavaScript.
203
+ - [Responses compatibility server](docs/responses_server/README.md): expose a supported backend through the Responses API.
204
+ - [Retries and fallback models](docs/RUNTIME.md#responses-reliability): configure recovery from model failures.
205
+
206
+ ## Development
207
+
208
+ From the repository root:
209
+
210
+ ```bash
211
+ env -u VIRTUAL_ENV uv sync --dev
212
+ env -u VIRTUAL_ENV uv run --dev pytest
213
+ ```
214
+
215
+ See the [development guide](AGENTS.md), [test guide](tests/TESTS.md),
216
+ [runtime architecture](docs/RUNTIME.md) and [workspace API](docs/WORKSPACE_API.md).
@@ -0,0 +1,196 @@
1
+ # pycodex
2
+
3
+ [中文](README_ZH.md)
4
+
5
+ pycodex is a Python implementation of the [Codex](https://github.com/openai/codex)
6
+ coding agent. Use it in a terminal, in a browser, or from your own Python code.
7
+ It supports file editing, command execution, multiple agents and saved sessions.
8
+ See [upstream alignment](docs/ALIGNMENT.md) for the supported scope and differences.
9
+
10
+ ## Install
11
+
12
+ | Package | Includes | Python |
13
+ | --- | --- | --- |
14
+ | `python-codex` | CLI and Python API | 3.6.2+ |
15
+ | `pycodex-ws` | Core plus browser workspace and optional Feishu integration | 3.7+ |
16
+
17
+ For the CLI and Python API:
18
+
19
+ ```bash
20
+ python3 -m pip install --upgrade python-codex
21
+ ```
22
+
23
+ For the browser workspace, install `pycodex-ws`; it includes the matching core version:
24
+
25
+ ```bash
26
+ python3 -m pip install --upgrade pycodex-ws
27
+ ```
28
+
29
+ ## Configure a model
30
+
31
+ Start with [config_examples/](config_examples/README.md) for Responses, StepFun,
32
+ Chat Completions, Claude Messages or Gemini. Give an agent your endpoint and key
33
+ (StepFun Coding Plan includes its endpoint) and ask it to follow that guide to
34
+ install and verify a config or profile.
35
+
36
+ Create `~/.codex/config.toml`. For example, with OpenAI:
37
+
38
+ ```toml
39
+ model = "gpt-5.4"
40
+ model_provider = "openai"
41
+ ```
42
+
43
+ Supply the API key through the environment or `~/.codex/.env`:
44
+
45
+ ```bash
46
+ export OPENAI_API_KEY="your-api-key"
47
+ ```
48
+
49
+ For another provider, configure its `base_url` and `env_key`. Select the API with
50
+ `compat_api` in the profile or provider table:
51
+
52
+ | `compat_api` | API |
53
+ | --- | --- |
54
+ | `"none"` (default) | Responses |
55
+ | `"chat_completions"` | Chat Completions, including Step |
56
+ | `"messages"` | Claude Messages |
57
+ | `"gemini"` | Gemini API |
58
+
59
+ Legacy `use_chat_completion = true/false` remains supported as `chat_completions/none`.
60
+
61
+ Use `--profile NAME` to select `NAME.config.toml` beside the base config or an
62
+ embedded `[profiles.NAME]` table. Use `--config PATH` for a different config file,
63
+ and `pycodex doctor` to check configuration and connectivity.
64
+ The browser workspace picks up profile changes for new sessions without a restart.
65
+
66
+ See [configuration](docs/CONTEXT.md#配置读取与-profile) and the
67
+ [Gemini setup example](docs/responses_server/README.md#gemini-api).
68
+ Gemini 4 Argon includes a prompt adapted from Antigravity.
69
+ Gemini tool arguments stream as they are generated; tools run after the complete call is received.
70
+ Gemini continuation omits unsigned empty text parts while preserving thought signatures,
71
+ including when resuming recorded sessions.
72
+
73
+ ## Use the CLI
74
+
75
+ Run these commands from your project directory:
76
+
77
+ ```bash
78
+ pycodex
79
+ pycodex "Summarize this repository."
80
+ pycodex --profile my_profile "Review the latest changes."
81
+ pycodex --json "Summarize this repository."
82
+ ```
83
+
84
+ The first command starts an interactive session; the others run a single task.
85
+ Web skill completion is an [optional frontend feature](packages/pycodex-ws/workspace_server/optional_features/skill-completion/README.md).
86
+ Apply `skill-completion` through Customize to enable @/$ prefix suggestions.
87
+ The agent can edit files and run commands with your user account's permissions.
88
+
89
+ | Command | Purpose |
90
+ | --- | --- |
91
+ | `/model`, `/effort` | View or change the model and reasoning effort |
92
+ | `/cd <directory>` | Change directory while idle |
93
+ | `/title`, `/history` | Manage the title and inspect conversation history |
94
+ | `/resume` | List or resume saved sessions |
95
+ | `/compact` | Summarize history to free context |
96
+ | `/queue <message>` | Submit a task after the current one finishes |
97
+
98
+ Send a message while the agent is working to redirect it, or use `/queue` to
99
+ wait. Sessions are saved under `~/.codex/sessions` by default.
100
+ Ctrl+C or Ctrl+D closes the session after issued operations finish.
101
+ Run `pycodex --help` for all options.
102
+
103
+ For a local vLLM server:
104
+
105
+ ```bash
106
+ pycodex --vllm-endpoint http://127.0.0.1:18000
107
+ ```
108
+
109
+ ## Use the browser workspace
110
+
111
+ After installing `pycodex-ws`, create `workspaces.json`:
112
+
113
+ ```json
114
+ {
115
+ "workspaces": [
116
+ {"id": "demo", "work_dir": ".", "state_path": "demo", "enable_board": true}
117
+ ]
118
+ }
119
+ ```
120
+
121
+ Start the server and keep the terminal open:
122
+
123
+ ```bash
124
+ pycodex-ws --listen 127.0.0.1:6007 --workspace-config workspaces.json
125
+ ```
126
+
127
+ Open `http://127.0.0.1:6007`. The workspace uses the same model configuration as
128
+ the CLI and provides conversations, a live HTML Canvas, and file/diff viewers.
129
+ Click file links to inspect code, then select text and use **Insert into chat**
130
+ to include it in your next message.
131
+ Each input displays its author and creation time, including separate messages
132
+ in a steer batch. Recorded messages keep that metadata when the session resumes.
133
+ Restoring a tab reads the rollout tail needed for its latest 80 display rows;
134
+ Agent resume still restores the complete active context after the last checkpoint.
135
+
136
+ The settings menu provides interface customization, password-protected
137
+ workspace sharing, and [One-line Agent](packages/pycodex-ws/README.md#one-line-agent):
138
+ an Agent that runs directly in most shells without installation, for bootstrapping
139
+ an Agent environment or simple debugging. See the [workspace guide](packages/pycodex-ws/README.md) for
140
+ session controls, storage and Feishu setup. A separate
141
+ [VS Code extension](packages/pycodex-ws/extensions/vscode/README.md) connects to
142
+ the same backend, including over Remote SSH.
143
+
144
+ ## Use the Python API
145
+
146
+ Save this as `example.py` and run `python3 example.py`. It uses the model
147
+ configuration above and the standard tools:
148
+
149
+ ```python
150
+ from contextlib import closing
151
+
152
+ from pycodex import AgentsManager, CodexConfig
153
+ from pycodex.bootstrap import build_model
154
+ from pycodex.utils.async_bridge import run_async
155
+
156
+
157
+ async def main():
158
+ config = CodexConfig.from_env()
159
+ with closing(build_model(config.provider)) as model:
160
+ runtime = AgentsManager(
161
+ model.client, config.context,
162
+ ).create_root_runtime()
163
+ try:
164
+ await runtime.start()
165
+ receipt = await runtime.submit_input("Summarize this repository.")
166
+ print((await receipt.future).output_text)
167
+ finally:
168
+ await runtime.close()
169
+
170
+
171
+ run_async(main())
172
+ ```
173
+
174
+ `AgentsManager` creates the runtime; `submit_input` submits work.
175
+ Await `receipt.future` for the result. The example closes the runtime and any
176
+ local compatibility server when finished. See [runtime contracts](docs/RUNTIME.md#ownership) for
177
+ custom models, tools and integrations.
178
+
179
+ ## More features
180
+
181
+ - [Portable configuration](docs/PORTABLE.md): transfer encrypted configuration, instructions and skills to another machine.
182
+ - [Frontend customization](packages/pycodex-ws/README.md#customize-the-interface): change the workspace through an Agent conversation or your own CSS/JavaScript.
183
+ - [Responses compatibility server](docs/responses_server/README.md): expose a supported backend through the Responses API.
184
+ - [Retries and fallback models](docs/RUNTIME.md#responses-reliability): configure recovery from model failures.
185
+
186
+ ## Development
187
+
188
+ From the repository root:
189
+
190
+ ```bash
191
+ env -u VIRTUAL_ENV uv sync --dev
192
+ env -u VIRTUAL_ENV uv run --dev pytest
193
+ ```
194
+
195
+ See the [development guide](AGENTS.md), [test guide](tests/TESTS.md),
196
+ [runtime architecture](docs/RUNTIME.md) and [workspace API](docs/WORKSPACE_API.md).
@@ -0,0 +1,181 @@
1
+ # pycodex
2
+
3
+ [English](README.md)
4
+
5
+ pycodex 用 Python 实现 [Codex](https://github.com/openai/codex) 编程 Agent,
6
+ 可在终端、浏览器或自己的 Python 程序中使用,支持文件编辑、命令执行、
7
+ 多 Agent 协作和会话恢复。支持范围及与上游的差异见[对齐文档](docs/ALIGNMENT.md)。
8
+
9
+ ## 安装
10
+
11
+ | 包 | 内容 | Python |
12
+ | --- | --- | --- |
13
+ | `python-codex` | CLI 和 Python API | 3.6.2+ |
14
+ | `pycodex-ws` | Core、浏览器工作区和可选飞书集成 | 3.7+ |
15
+
16
+ 使用 CLI 或 Python API:
17
+
18
+ ```bash
19
+ python3 -m pip install --upgrade python-codex
20
+ ```
21
+
22
+ 使用浏览器工作区则安装 `pycodex-ws`,它会同时安装匹配版本的 core:
23
+
24
+ ```bash
25
+ python3 -m pip install --upgrade pycodex-ws
26
+ ```
27
+
28
+ ## 配置模型
29
+
30
+ 可从 [config_examples/](config_examples/README.md) 选择 Responses、StepFun、
31
+ Chat Completions、Claude Messages 或 Gemini 模板。向 Agent 提供 endpoint 和 key
32
+ (StepFun Coding Plan 已内置 endpoint),让它按目录说明安装配置或 profile 并验证连接。
33
+
34
+ 创建 `~/.codex/config.toml`。以 OpenAI 为例:
35
+
36
+ ```toml
37
+ model = "gpt-5.4"
38
+ model_provider = "openai"
39
+ ```
40
+
41
+ API key 通过环境变量或 `~/.codex/.env` 提供:
42
+
43
+ ```bash
44
+ export OPENAI_API_KEY="your-api-key"
45
+ ```
46
+
47
+ 其他 provider 需要配置 `base_url` 和 `env_key`,并在 profile 或 provider 中
48
+ 用 `compat_api` 选择接口:
49
+
50
+ | `compat_api` | 接口 |
51
+ | --- | --- |
52
+ | `"none"`(默认) | Responses |
53
+ | `"chat_completions"` | Chat Completions,包括 Step |
54
+ | `"messages"` | Claude Messages |
55
+ | `"gemini"` | Gemini API |
56
+
57
+ 旧配置 `use_chat_completion = true/false` 仍可用,分别对应 `chat_completions/none`。
58
+
59
+ 用 `--profile NAME` 选择同目录的 `NAME.config.toml` 或内嵌的 `[profiles.NAME]`;
60
+ 用 `--config PATH` 指定其他配置文件。`pycodex doctor` 可检查配置和连接。
61
+ 浏览器工作区会为新会话动态读取 profile,修改配置后无需重启。
62
+
63
+ 详见[配置文档](docs/CONTEXT.md#配置读取与-profile)和
64
+ [Gemini 配置示例](docs/responses_server/README.md#gemini-api)。
65
+ Gemini 4 Argon 内置基于 Antigravity 适配的提示词。
66
+ Gemini 工具参数支持流式接收,完整调用收到后再执行工具。
67
+
68
+ ## 使用 CLI
69
+
70
+ 在项目目录中运行:
71
+
72
+ ```bash
73
+ pycodex
74
+ pycodex "概括这个仓库。"
75
+ pycodex --profile my_profile "审查最近的改动。"
76
+ pycodex --json "概括这个仓库。"
77
+ ```
78
+
79
+ 不带问题时进入交互会话,其他命令执行单次任务。
80
+ 网页 skill 补全是 [optional feature](packages/pycodex-ws/workspace_server/optional_features/skill-completion/README.md):
81
+ 通过 Customize 应用 `skill-completion` 后启用 @/$ 名称前缀补全。
82
+ Agent 可以修改文件、执行命令,使用当前用户的系统权限。
83
+
84
+ | 命令 | 用途 |
85
+ | --- | --- |
86
+ | `/model`、`/effort` | 查看或切换模型及推理强度 |
87
+ | `/cd <directory>` | 空闲时切换目录 |
88
+ | `/title`、`/history` | 管理标题、查看历史 |
89
+ | `/resume` | 列出或恢复已保存会话 |
90
+ | `/compact` | 压缩历史,释放上下文 |
91
+ | `/queue <message>` | 等当前任务完成后再执行 |
92
+
93
+ Agent 工作时可直接发送消息调整方向,或用 `/queue` 排队。
94
+ 会话默认保存在 `~/.codex/sessions`。
95
+ Ctrl+C 或 Ctrl+D 会在已发出的操作完成后退出。完整选项见 `pycodex --help`。
96
+
97
+ 接入本地 vLLM 服务:
98
+
99
+ ```bash
100
+ pycodex --vllm-endpoint http://127.0.0.1:18000
101
+ ```
102
+
103
+ ## 使用浏览器工作区
104
+
105
+ 安装 `pycodex-ws` 后,创建 `workspaces.json`:
106
+
107
+ ```json
108
+ {
109
+ "workspaces": [
110
+ {"id": "demo", "work_dir": ".", "state_path": "demo", "enable_board": true}
111
+ ]
112
+ }
113
+ ```
114
+
115
+ 启动服务并保持终端打开:
116
+
117
+ ```bash
118
+ pycodex-ws --listen 127.0.0.1:6007 --workspace-config workspaces.json
119
+ ```
120
+
121
+ 访问 `http://127.0.0.1:6007`。工作区沿用 CLI 的模型配置,提供对话、
122
+ 实时 HTML Canvas 和文件/diff 查看器。点击文件链接查看代码,选中文字后
123
+ 用 **Insert into chat** 加入下一条消息。
124
+
125
+ 设置菜单支持界面定制和带密码的工作区分享。会话操作、存储和飞书配置见
126
+ [工作区指南](packages/pycodex-ws/README.md)。
127
+ 独立安装的 [VS Code 扩展](packages/pycodex-ws/extensions/vscode/README.md)
128
+ 可连接同一后端,也支持 Remote SSH。
129
+
130
+ ## 使用 Python API
131
+
132
+ 将以下代码保存为 `example.py`,运行 `python3 example.py`。
133
+ 它会使用前面的模型配置和内置工具:
134
+
135
+ ```python
136
+ from contextlib import closing
137
+
138
+ from pycodex import AgentsManager, CodexConfig
139
+ from pycodex.bootstrap import build_model
140
+ from pycodex.utils.async_bridge import run_async
141
+
142
+
143
+ async def main():
144
+ config = CodexConfig.from_env()
145
+ with closing(build_model(config.provider)) as model:
146
+ runtime = AgentsManager(
147
+ model.client, config.context,
148
+ ).create_root_runtime()
149
+ try:
150
+ await runtime.start()
151
+ receipt = await runtime.submit_input("概括这个仓库。")
152
+ print((await receipt.future).output_text)
153
+ finally:
154
+ await runtime.close()
155
+
156
+
157
+ run_async(main())
158
+ ```
159
+
160
+ `AgentsManager` 创建 runtime,`submit_input` 提交任务,等待 `receipt.future` 获取结果。
161
+ 示例结束时会关闭 runtime 和本地兼容服务。
162
+ 自定义模型、工具与集成方式见[运行时文档](docs/RUNTIME.md#ownership)。
163
+
164
+ ## 更多功能
165
+
166
+ - [Portable 配置](docs/PORTABLE.md):将配置、指令和 skills 加密迁移到其他机器。
167
+ - [界面定制](packages/pycodex-ws/README.md#customize-the-interface):通过 Agent 对话或 CSS/JavaScript 修改工作区。
168
+ - [Responses 兼容服务](docs/responses_server/README.md):通过 Responses API 接入支持的模型后端。
169
+ - [重试与备用模型](docs/RUNTIME.md#responses-reliability):配置模型故障后的恢复策略。
170
+
171
+ ## 开发
172
+
173
+ 在仓库根目录运行:
174
+
175
+ ```bash
176
+ env -u VIRTUAL_ENV uv sync --dev
177
+ env -u VIRTUAL_ENV uv run --dev pytest
178
+ ```
179
+
180
+ 参考[开发约定](AGENTS.md)、[测试指南](tests/TESTS.md)、
181
+ [运行时架构](docs/RUNTIME.md)和[工作区 API](docs/WORKSPACE_API.md)。
@@ -42,7 +42,6 @@ from .tools import (
42
42
  ApplyPatchTool,
43
43
  BaseTool,
44
44
  ClockManager,
45
- ClockTool,
46
45
  CodeModeManager,
47
46
  ExecCommandTool,
48
47
  ExecTool,
@@ -54,10 +53,11 @@ from .tools import (
54
53
  ReadFileTool,
55
54
  Registry,
56
55
  RequestPermissionsTool,
57
- RequestUserInputTool,
58
56
  SendMessageTool,
57
+ SetPeriodTool,
59
58
  ShellCommandTool,
60
59
  ShellTool,
60
+ SleepTool,
61
61
  SpawnAgentTool,
62
62
  ToolContext,
63
63
  ToolRegistry,
@@ -84,7 +84,6 @@ __all__ = [
84
84
  "AssistantMessage",
85
85
  "BaseTool",
86
86
  "ClockManager",
87
- "ClockTool",
88
87
  "create_agent_runtime_environment",
89
88
  "CodeModeManager",
90
89
  "CodexConfig",
@@ -105,7 +104,6 @@ __all__ = [
105
104
  "Registry",
106
105
  "ReadFileTool",
107
106
  "RequestPermissionsTool",
108
- "RequestUserInputTool",
109
107
  "ModelResponse",
110
108
  "ModelEvent",
111
109
  "PlanStore",
@@ -118,8 +116,10 @@ __all__ = [
118
116
  "ResponsesModelClient",
119
117
  "ResponsesProviderConfig",
120
118
  "SendMessageTool",
119
+ "SetPeriodTool",
121
120
  "ShellCommandTool",
122
121
  "ShellTool",
122
+ "SleepTool",
123
123
  "SpawnAgentTool",
124
124
  "ToolCall",
125
125
  "ToolContext",