python-codex 0.4.7__py3-none-any.whl → 0.5.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.
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-codex
3
+ Version: 0.5.0
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 brings the [Codex](https://github.com/openai/codex) agent loop to Python,
26
+ with a CLI, reusable Agent API and browser workspace. It aims to follow upstream
27
+ behavior; supported features and deliberate differences are documented in
28
+ [Alignment](docs/ALIGNMENT.md).
29
+
30
+ | Package | Provides | Python |
31
+ | --- | --- | --- |
32
+ | `python-codex` | Agent, runtime, CLI, tools, Responses compatibility server and portable storage | 3.6.2+ |
33
+ | `pycodex-ws` | Browser workspace, Canvas, file/diff viewers and optional Feishu integration | 3.7+ |
34
+
35
+ The workspace package installs the matching core version. Python imports use
36
+ `pycodex`; the commands are `pycodex` and `pycodex-ws`.
37
+
38
+ ## Install and run
39
+
40
+ Install the core CLI:
41
+
42
+ ```bash
43
+ python3 -m pip install python-codex
44
+ pycodex
45
+ ```
46
+
47
+ Or install the browser workspace, which includes core:
48
+
49
+ ```bash
50
+ python3 -m pip install pycodex-ws
51
+ pycodex-ws --help
52
+ ```
53
+
54
+ Use `python3 -m pip install --upgrade pycodex-ws` to upgrade both packages
55
+ together. If a command is missing from `PATH`, use `python3 -m pycodex` or
56
+ `python3 -m workspace_server` with the interpreter used for installation.
57
+
58
+ ## Model configuration
59
+
60
+ pycodex reads `~/.codex/config.toml` and the adjacent `.env`. Configure `model`,
61
+ `model_provider`, and the provider's `base_url` and `env_key` as needed.
62
+ The built-in `openai` provider uses `OPENAI_API_KEY`. Authentication uses API
63
+ keys; ChatGPT sign-in credentials from `auth.json` or the OS keychain are not
64
+ loaded.
65
+
66
+ ```bash
67
+ pycodex --profile my_profile "Summarize this repository."
68
+ pycodex --config /path/to/config.toml
69
+ pycodex doctor
70
+ ```
71
+
72
+ Models use the streaming Responses API. For a Chat Completions backend, set
73
+ `use_chat_completion = true` in its provider table. Other backend options include:
74
+
75
+ ```bash
76
+ pycodex --vllm-endpoint http://127.0.0.1:18000
77
+ pycodex --profile my_profile --use-messages
78
+ ```
79
+
80
+ See [context and configuration](docs/CONTEXT.md) and the
81
+ [Responses compatibility server](docs/responses_server/README.md).
82
+
83
+ ## CLI
84
+
85
+ Run `pycodex` without a prompt for an interactive session, or supply a prompt
86
+ for a single turn:
87
+
88
+ ```bash
89
+ pycodex "Summarize this repository in one sentence."
90
+ printf 'Reply with exactly OK.' | pycodex
91
+ pycodex --json "Reply with exactly OK."
92
+ ```
93
+
94
+ | Command | Purpose |
95
+ | --- | --- |
96
+ | `/model`, `/effort` | Show or change the model and reasoning effort |
97
+ | `/cd <directory>` | Change the session's working directory while idle |
98
+ | `/title`, `/history` | Manage the title and inspect conversation history |
99
+ | `/resume` | List saved sessions; pass an index or session UUID to resume |
100
+ | `/compact` | Summarize history to free context |
101
+ | `/fork` | Continue the current history under a new session ID |
102
+ | `/queue <message>` | Wait for the active turn to finish before submitting |
103
+
104
+ Ordinary input during a turn steers at the next safe sampling boundary.
105
+ Sessions are saved under `CODEX_HOME/sessions`. Set
106
+ `model_auto_compact_token_limit` in the configuration to compact automatically.
107
+
108
+ Ctrl+D or Ctrl+C closes the CLI after accepted work finishes. A second Ctrl+C
109
+ during closing exits immediately. Use `pycodex --help` for startup options.
110
+
111
+ ## Browser workspace
112
+
113
+ Create `workspaces.json`:
114
+
115
+ ```json
116
+ {
117
+ "workspaces": [
118
+ {"id": "demo", "work_dir": ".", "state_path": "demo", "enable_board": true}
119
+ ]
120
+ }
121
+ ```
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 combines conversations with a live
128
+ HTML Canvas and read-only file/diff viewers. Click file links in replies to open
129
+ them, and use **Insert into chat** to add selected code to an editable draft.
130
+ Keep the server's stdin open: EOF initiates shutdown.
131
+ The gear button starts an Agent conversation for customizing the interface
132
+ through files in `~/.pycodex/frontend/`.
133
+
134
+ See the [workspace guide](packages/pycodex-ws/README.md) for session controls,
135
+ storage and Feishu setup. The separately distributed
136
+ [VS Code extension](packages/pycodex-ws/extensions/vscode/README.md) uses the same
137
+ workspace backend, including on Remote SSH hosts.
138
+
139
+ ## Python API
140
+
141
+ Use the standard model and tool setup from Python:
142
+
143
+ ```python
144
+ from pycodex.bootstrap import build_agent, build_model
145
+
146
+ agent = build_agent(build_model())
147
+ try:
148
+ result = agent.ask("Summarize this repository in one sentence.")
149
+ print(result.output_text)
150
+ finally:
151
+ agent.shutdown()
152
+ ```
153
+
154
+ For custom integrations, `Agent` accepts a model client, `ToolRegistry` and
155
+ `ContextConfig`. `await agent.run_turn([...])` runs an asynchronous turn;
156
+ `AgentRuntime` adds input queues, commands and frontend subscriptions.
157
+ See [runtime contracts and examples](docs/RUNTIME.md).
158
+
159
+ ## Portable configuration
160
+
161
+ Portable mode transfers an encrypted bundle of your configuration, instructions
162
+ and skills to another machine. Start a storage service in a separate terminal:
163
+
164
+ ```bash
165
+ python3 -m pycodex.portable.server --root .tmp/pycodex_storage --host 127.0.0.1 --port 5577
166
+ ```
167
+
168
+ Upload the default Codex home, or specify another directory:
169
+
170
+ ```bash
171
+ pycodex --put @127.0.0.1:5577
172
+ pycodex --put /path/to/.codex/@127.0.0.1:5577
173
+ ```
174
+
175
+ After verifying a download round trip, the command prints a reusable
176
+ `pycodex --call ...` command. Run it on the target machine using a storage
177
+ address reachable from that machine.
178
+
179
+ ## Development and reference
180
+
181
+ ```bash
182
+ uv sync --dev
183
+ uv run pycodex
184
+ uv run --dev pytest
185
+ ```
186
+
187
+ - [Test environments and coverage](tests/TESTS.md)
188
+ - [Architecture, package layout and runtime contracts](docs/RUNTIME.md)
189
+ - [Prompts, configuration and context](docs/CONTEXT.md)
190
+ - [Upstream alignment](docs/ALIGNMENT.md)
191
+ - [Responses compatibility server](docs/responses_server/README.md)
192
+
193
+ Release notes and implementation details live in `docs/`.
@@ -1,13 +1,13 @@
1
1
  pycodex/__init__.py,sha256=fHEyhylULeRo-5xEnl-UxT5ZpBzbFzRW7vLwdy_7oxU,2660
2
2
  pycodex/__main__.py,sha256=MHKZ_ae3fSLGTLUUMOx15fWdeOnJSHhq-zslRP5F5Lc,79
3
- pycodex/agent.py,sha256=GF-mNTnxHW8qw-72QEXfGGvExZzl8c3m6emZBux6ddw,21418
4
- pycodex/bootstrap.py,sha256=U1X5kwORpS5JnPk9HhIiOVWPQzDLlk_ro_cY2knwL8I,12421
3
+ pycodex/agent.py,sha256=4YtHLDL0lKpU_KWnbKTNyI5UEfBPgkI4f8lndn8yjGA,21807
4
+ pycodex/bootstrap.py,sha256=wUNipqvIPzJlcP3PTY0cCyPH_QTeIbSR8xtyw4AEP6Y,12282
5
5
  pycodex/cli.py,sha256=uCrRARI2IypIU-1aC0Y2DLzhzYGWQta1f7zYWsyaNnU,12797
6
- pycodex/context.py,sha256=yfNY2alT3caQQwhay47pSSrGUbgEAcLKhTVaZqtQ4yU,26610
6
+ pycodex/context.py,sha256=8P3fBXbwzTKmoXGDdkzTsAghfOkAZstJnMTqr-cxHyI,27019
7
7
  pycodex/events.py,sha256=L7RkZ3EtFQOfWg1FIG2Y0mLpDKTKV6HGmXMy9HCoWX0,29794
8
8
  pycodex/model.py,sha256=VwPN9GEdoL8N8V4hFdMmJ1rGxL_tom3Nq7ZBonCum2k,45648
9
9
  pycodex/protocol.py,sha256=uzUz_06iA4m9vAoqZeCGiJ4SocKZDzOfCJUU4Bpt5dI,12033
10
- pycodex/runtime.py,sha256=M_gvWDvsZBivELjNkuhmwiZVRmlaQmzKZK1ZQ5-kLLE,24271
10
+ pycodex/runtime.py,sha256=kEW4dLGcTX0nRArDpWhwm62c1il_1O-AgRHvsQqSYBY,24661
11
11
  pycodex/portable/__init__.py,sha256=FmspRPmblYuZIVXMpXaxE1uosCaz2hZDpkpOzxDJQic,1084
12
12
  pycodex/portable/client.py,sha256=DOxzZljVfN1ynmhqrChX7NsT1IFSFVKzEn1J3wvV3XQ,16038
13
13
  pycodex/portable/server.py,sha256=w4YD71Sxb7MD5q57GPuIgx7AoicTv0R9xzX2kAaibPA,7503
@@ -23,15 +23,15 @@ pycodex/prompts/permissions/sandbox_mode/read_only.md,sha256=2rAPEXsBYCcuttI5j3e
23
23
  pycodex/prompts/permissions/sandbox_mode/workspace_write.md,sha256=lVN-LwrBbHqlv5yVjcd_mU8tzZW8jfKpTatJKIZu9HI,277
24
24
  pycodex/tools/__init__.py,sha256=UYwmsX_Ckw_YaYQ6TYhUU6w5pxi2qzZoTrq6BAgNErM,1857
25
25
  pycodex/tools/agent_tool_schemas.py,sha256=8cL9ml4So0H6IIeK0ZzjAo9bk3VeprDOSYPpIamOqEU,2048
26
- pycodex/tools/apply_patch_tool.py,sha256=t8XFCGZ7q-s9C1Ty6qkReBRk-QD3ONvcKXLAz9djKRY,13956
27
- pycodex/tools/base_tool.py,sha256=Oqe-0RgH3mz70YckgBFD-tdvNJ9TQXrb0tuMbdy3bfc,6477
26
+ pycodex/tools/apply_patch_tool.py,sha256=n30M-ofZlOkDCC18nX10MPF5FLROiURACFLG1hd4FK8,13906
27
+ pycodex/tools/base_tool.py,sha256=NtzDTCudWIdwjhfgk6kd98C5KVl3PrruymOOURLApSA,6655
28
28
  pycodex/tools/clock_tool.py,sha256=2_RYbBEw4V9_f1L-qZl3hhJ6XNPM_gBDmOlCh1cCAjo,6575
29
29
  pycodex/tools/close_agent_tool.py,sha256=uIbCjsQx9MLkjVYheS8ZVf5VVPbC6Iviwox4pneJpmI,2030
30
- pycodex/tools/code_mode_manager.py,sha256=HUgtXxj3hGj2i4_tsToHLr8mGTV8uIob9vtYAZeLnQc,19166
31
- pycodex/tools/exec_command_tool.py,sha256=iqRiKaaX-AjG6LjATAMOakHIP0gpCWCj2o8af_8eAiQ,4464
30
+ pycodex/tools/code_mode_manager.py,sha256=oEzYkebFdgX993NBC0A4R0mthg4qdhJ-dD0fgeE3III,18948
31
+ pycodex/tools/exec_command_tool.py,sha256=EvlV355-i9trrKTAXDFiZyYMviTxL_FehhKlQmjuDpw,4443
32
32
  pycodex/tools/exec_runtime.js,sha256=DR1uocKailTqNWAcJNFJuQgFFMSUzTpT_uQsRaneg2s,3643
33
33
  pycodex/tools/exec_tool.py,sha256=tuC21rlhP8CPSYml4XnSDSRV0UPGkQ6aHj0DLIoOOvM,2274
34
- pycodex/tools/grep_files_tool.py,sha256=Ysw68VKI9OEvUH5haYx8FWuthkHykc1wskbuzjj8gTk,5293
34
+ pycodex/tools/grep_files_tool.py,sha256=KCBVNaSTU45ND-iAhh14YawMyjQnMRZnGI1NGKL3zgg,4809
35
35
  pycodex/tools/list_dir_tool.py,sha256=_U6ouRcVbGHT5mChVyUsiMgDGrFK7EFMFaspPLAHtH8,5337
36
36
  pycodex/tools/read_file_tool.py,sha256=YK__uhIVldBjAQega5S_ZuZU5jgP_kLOwr-YhjAmRo4,9735
37
37
  pycodex/tools/request_permissions_tool.py,sha256=nEt3_uw3lmFXyydqcN3PxuKwrEvaRPtfjA_U8nikCtU,3978
@@ -39,12 +39,12 @@ pycodex/tools/request_user_input_tool.py,sha256=_7siHF2p3KiNDFwsTqKKIUw2kPCXMzLa
39
39
  pycodex/tools/resume_agent_tool.py,sha256=bZvXEUNdc1RVD2N5Msjv63Rni62FQk4gj9LAXK1Vsy8,1613
40
40
  pycodex/tools/runtime_services.py,sha256=KPLtB1e7jmqEN9rhXV70rUMlhYNFsXja4CypIunzXLU,15962
41
41
  pycodex/tools/send_input_tool.py,sha256=w63SKM05_e3oXvdaBtL-hk941TvkWKuTUDEqTSyWEMQ,3761
42
- pycodex/tools/shell_command_tool.py,sha256=US63I5xiV5zfO1Oox2yHUg7F6XoKzmyxtohfaQIsmrw,4216
43
- pycodex/tools/shell_tool.py,sha256=lqFH2XosfBg7yQKhpB7i4vLGz9sNQtEZihD0rjsmBCQ,4068
42
+ pycodex/tools/shell_command_tool.py,sha256=bJKlTdIs2i28vH5f4GZfpunezr6JNicRzsL_6Vc3HvU,3675
43
+ pycodex/tools/shell_tool.py,sha256=I6lYLABSmLddRrNmpk0Li83AV55MI8x0bckWaRkFGI0,3527
44
44
  pycodex/tools/spawn_agent_tool.py,sha256=Jx5jYpxsH_CQ3BLkXYPZuIINW5deO_zY8tyw8kZpreY,6208
45
- pycodex/tools/unified_exec_manager.py,sha256=XPN6PgBnjZ5WFZATNIqpWKUAuw8HMMD7mlfHJQjJQZM,14544
45
+ pycodex/tools/unified_exec_manager.py,sha256=n6N9Sf125Tt4Vdl8C0lqng8tQbS7Dj04uZnDVqgGkxw,14056
46
46
  pycodex/tools/update_plan_tool.py,sha256=xwrSrerw5qfkbFc9Ltx1OZEmD__CWtryOy3UhL0-Jp4,3198
47
- pycodex/tools/view_image_tool.py,sha256=SCoiIHaQ51oYjYX69MRxjAK9b1P6_wOCIuZqzsC2rj8,4082
47
+ pycodex/tools/view_image_tool.py,sha256=H7OP-QZEU5Gf-E4YnQbXfu2hDkL5-dJ3Apla2YYjErQ,3754
48
48
  pycodex/tools/wait_agent_tool.py,sha256=pLsnk9TxSt4v7krC7s7vxi91pLisSNU0lATt9s-P_3E,3134
49
49
  pycodex/tools/wait_tool.py,sha256=0_OO_DvMsBhG3oDKZePTOjZTBq1lmWntXAzqIqvebdA,3206
50
50
  pycodex/tools/web_search_tool.py,sha256=3ao1IvJw7MwcP35UKLbqrM-nlm5Z-UUFVdEzkJYOV1o,988
@@ -57,7 +57,7 @@ pycodex/utils/crypto.py,sha256=HRCXF26Ft3S8CG2X0YpZwa8GMU9YJ0Loo8Q9PMPMcNw,1249
57
57
  pycodex/utils/debug.py,sha256=5XMpWpwFSm6woyx6RGXvN2qL0afRtTQbwlOAv-LotTw,913
58
58
  pycodex/utils/doctor.py,sha256=fI66oQqB5zNL7aEpFbiHnzhELyp9XydwMyAGznw5YSE,10616
59
59
  pycodex/utils/dotenv.py,sha256=h7ZgvqpEswetqjhtwfiaHyokAHwNKPakizTAHPHz5Ds,1865
60
- pycodex/utils/event_helpers.py,sha256=EJToMDBcoxSYN71IUyZu_OEb0T0yXU4InYrowYon-OQ,6442
60
+ pycodex/utils/event_helpers.py,sha256=ar4WoIkpiShoayN_GZlnDijy74CC2Z8_5p76EryduNk,6517
61
61
  pycodex/utils/get_env.py,sha256=L4S8h84tkgxZKvrxY7ezTgePbXepG-yIigUTKeY6uuE,6094
62
62
  pycodex/utils/image_utils.py,sha256=OUzUs0Cow4L8Z2np0EBeEUotAqqsCmRmhrV8AxZUXRw,2460
63
63
  pycodex/utils/model_metadata.py,sha256=uK3iI4yC7Ge7yN4I1_gQYalQ4MYKddz2qMwsmQb-P80,1337
@@ -83,8 +83,8 @@ responses_server/trajectory_dump.py,sha256=5_Wy6tslszrqx3j1JeP_boyTbzIicKy8No84P
83
83
  responses_server/tools/__init__.py,sha256=ivsBSEy0SBUhY-Uea5v1XMLXShkwHdCVl0id-1FwdZg,150
84
84
  responses_server/tools/custom_adapter.py,sha256=SnIiNUdomff3APtTriURAC9YCeEdhCDjzGMEYusfUdk,8340
85
85
  responses_server/tools/web_search.py,sha256=pnKH9JyTScRehWpZS3HpXRvjWsQvC0QZqxjEOCT4ndg,8936
86
- python_codex-0.4.7.dist-info/METADATA,sha256=vJgPquHMbmWwNuGdS_iP1KP8vvS4rApkjHPtKMfJU0M,48049
87
- python_codex-0.4.7.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
88
- python_codex-0.4.7.dist-info/entry_points.txt,sha256=sNUVakoVuTrzJH505ZgRTQxmtRRPUHV_EH0i6EbYTyM,45
89
- python_codex-0.4.7.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
90
- python_codex-0.4.7.dist-info/RECORD,,
86
+ python_codex-0.5.0.dist-info/METADATA,sha256=Y_z_aUh-nRYLRGhB6_kEkOia9hOenpz87ECOWNAcsVs,6541
87
+ python_codex-0.5.0.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
88
+ python_codex-0.5.0.dist-info/entry_points.txt,sha256=sNUVakoVuTrzJH505ZgRTQxmtRRPUHV_EH0i6EbYTyM,45
89
+ python_codex-0.5.0.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
90
+ python_codex-0.5.0.dist-info/RECORD,,