python-codex 0.6.3__py3-none-any.whl → 0.7.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.
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-codex
3
- Version: 0.6.3
3
+ Version: 0.7.1
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
7
+ Requires-Dist: aiocontextvars>=0.2.2; python_version < '3.7'
7
8
  Requires-Dist: dataclasses>=0.8; python_version < '3.7'
8
9
  Requires-Dist: importlib-metadata>=4.8.3; python_version < '3.8'
9
10
  Requires-Dist: loguru>=0.7.3
@@ -20,7 +21,7 @@ Description-Content-Type: text/markdown
20
21
 
21
22
  # pycodex
22
23
 
23
- [中文](README_ZH.md)
24
+ [中文](README_ZH.md) · [0.7.0 release notes](https://github.com/Randomizez/pycodex/blob/v0.7.0/docs/RELEASE_0.7.0.md)
24
25
 
25
26
  pycodex is a Python implementation of the [Codex](https://github.com/openai/codex)
26
27
  coding agent. Use it in a terminal, in a browser, or from your own Python code.
@@ -32,7 +33,8 @@ See [upstream alignment](docs/ALIGNMENT.md) for the supported scope and differen
32
33
  | Package | Includes | Python |
33
34
  | --- | --- | --- |
34
35
  | `python-codex` | CLI and Python API | 3.6.2+ |
35
- | `pycodex-ws` | Core plus browser workspace and optional Feishu integration | 3.7+ |
36
+ | `pyagy` | Core plus Antigravity CLI (`agy`) wire-compatible harness | 3.7+ |
37
+ | `pycodex-ws` | Core, `pyagy`, browser workspace and optional Feishu integration | 3.7+ |
36
38
 
37
39
  For the CLI and Python API:
38
40
 
@@ -40,7 +42,7 @@ For the CLI and Python API:
40
42
  python3 -m pip install --upgrade python-codex
41
43
  ```
42
44
 
43
- For the browser workspace, install `pycodex-ws`; it includes the matching core version:
45
+ For the browser workspace, install `pycodex-ws`; it includes matching `python-codex` and `pyagy` versions:
44
46
 
45
47
  ```bash
46
48
  python3 -m pip install --upgrade pycodex-ws
@@ -82,10 +84,15 @@ Use `--profile NAME` to select `NAME.config.toml` beside the base config or an
82
84
  embedded `[profiles.NAME]` table. Use `--config PATH` for a different config file,
83
85
  and `pycodex doctor` to check configuration and connectivity.
84
86
  The browser workspace picks up profile changes for new sessions without a restart.
87
+ With `harness = "pyagy"`, Web and Feishu preview the current reasoning text or
88
+ summary until assistant text streams in and takes its place. The browser limits
89
+ the Markdown preview to four lines, lets you scroll longer text, and expands
90
+ the same block for the final reply. Native pycodex exposes reasoning through
91
+ its own event and uses assistant text for the preview.
85
92
 
86
93
  See [configuration](docs/CONTEXT.md#配置读取与-profile) and the
87
94
  [Gemini setup example](docs/responses_server/README.md#gemini-api).
88
- Gemini 4 Argon includes a prompt adapted from Antigravity.
95
+ Gemini 4 Argon and Carbon include prompts adapted from Antigravity's coding guidance.
89
96
  Gemini tool arguments stream as they are generated; tools run after the complete call is received.
90
97
  Gemini tool results use `response.output`; returned images stay in the matching
91
98
  `functionResponse.parts`.
@@ -114,9 +121,19 @@ The agent can edit files and run commands with your user account's permissions.
114
121
  | `/cd <directory>` | Change directory while idle |
115
122
  | `/title`, `/history` | Manage the title and inspect conversation history |
116
123
  | `/resume` | List or resume saved sessions |
124
+ | `/retry` | Retry the last failed model request |
117
125
  | `/compact` | Summarize history to free context |
118
126
  | `/queue <message>` | Submit a task after the current one finishes |
119
127
 
128
+ Use `/retry 429|502` to retry either error code indefinitely, or `/retry *` to
129
+ retry every model request error, including disconnects. `/retry off` disables infinite retries.
130
+
131
+ Manual and automatic compaction preserve the tool declarations, instruction
132
+ prefix and ordinary tool choice. The Agent can use its live tools while
133
+ preparing the summary in memory. Success writes one summary checkpoint.
134
+ On failure, completed tool exchanges are saved so the Agent can use their
135
+ results on retry.
136
+
120
137
  Send a message while the agent is working to redirect it, or use `/queue` to
121
138
  wait. Sessions are saved under `~/.codex/sessions` by default.
122
139
  Ctrl+C or Ctrl+D closes the session after issued operations finish.
@@ -149,20 +166,25 @@ pycodex-ws --listen 127.0.0.1:6007 --workspace-config workspaces.json
149
166
  Open `http://127.0.0.1:6007`. The workspace uses the same model configuration as
150
167
  the CLI and provides conversations, a live HTML Canvas, and file/diff viewers.
151
168
  Chat updates arrive through two-second polling; completed replies render as Markdown.
169
+ When opening or switching conversations, a loading indicator above the input
170
+ stays visible until the latest session snapshot arrives, including when cached
171
+ messages are shown immediately.
172
+ Click the × beside a session and confirm to remove it from the workspace.
173
+ Each entry shows the time since the session's last activity.
152
174
  Click file links to inspect code, then select text and use **Insert into chat**
153
175
  to include it in your next message.
176
+ Local HTML links such as `report.html#results` open the preview at the named section.
154
177
  Each input displays its author and creation time, including separate messages
155
178
  in a steer batch. Recorded messages keep that metadata when the session resumes.
156
179
  Restoring a tab reads the rollout tail needed for its latest 80 display rows;
157
180
  Agent resume still restores the complete active context after the last checkpoint.
158
181
 
159
- The settings menu provides interface customization, password-protected
160
- workspace sharing, and [One-line Agent](packages/pycodex-ws/README.md#one-line-agent):
161
- an Agent that runs directly in most shells without installation, for bootstrapping
162
- an Agent environment or simple debugging. See the [workspace guide](packages/pycodex-ws/README.md) for
163
- session controls, storage and Feishu setup. A separate
164
- [VS Code extension](packages/pycodex-ws/extensions/vscode/README.md) connects to
165
- the same backend, including over Remote SSH.
182
+ **Settings → Customize Agent** opens the optional feature catalog. Browse the
183
+ descriptions and send a feature name, ID or custom request in chat to start the Agent.
184
+ Settings also provides password-protected sharing
185
+ and [External Call](packages/pycodex-ws/README.md#external-call)
186
+ sessions that connect an external client to a Web conversation. See the [workspace guide](packages/pycodex-ws/README.md) for
187
+ session controls, storage and Feishu setup.
166
188
 
167
189
  ## Use the Python API
168
190
 
@@ -195,7 +217,12 @@ run_async(main())
195
217
  ```
196
218
 
197
219
  `AgentsManager` creates the runtime; `submit_input` submits work.
198
- Await `receipt.future` for the result. The example closes the runtime and any
220
+ Await `receipt.future` for the result. Models and tools import `EventScope` from
221
+ `pycodex.events` and call `EventScope.emit(event)` to notify the session’s observers.
222
+ Each observer receives its own copy. During a turn the event loop reports
223
+ observer errors and the Agent continues.
224
+ Custom model clients return token counts in `ModelResponse.usage` for goal accounting
225
+ and automatic compaction. The example closes the runtime and any
199
226
  local compatibility server when finished. See [runtime contracts](docs/RUNTIME.md#ownership) for
200
227
  custom models, tools and integrations.
201
228
 
@@ -1,22 +1,22 @@
1
1
  pycodex/__init__.py,sha256=2rP9Qd5ClJlSI3bPNB0Jmn9lJUpeeo7gcbRPUvH81eI,2904
2
2
  pycodex/__main__.py,sha256=MHKZ_ae3fSLGTLUUMOx15fWdeOnJSHhq-zslRP5F5Lc,79
3
- pycodex/agent.py,sha256=EanBfEvRLnGSfvWv_P447mUw5CezVk680h2vP4pc_YI,23848
3
+ pycodex/agent.py,sha256=uwhdz4YpJonSvGvc0FOmS1rBu-f0-jDKczNsMm-6IaU,25867
4
4
  pycodex/bootstrap.py,sha256=4bn2MhNzAHk1fFVFO1V8p2hFKcOMbe4-y2PA5qhPY98,5429
5
5
  pycodex/cli.py,sha256=HkX_fFNUyPnNo25FeSa9ZMaQG79rqk3b0oV4ZH0h68c,12576
6
- pycodex/config.py,sha256=mGM7oLaciBwGXHMQjKVifWFTd7gZTfzqlQeJSFzcQic,1218
7
- pycodex/context.py,sha256=OKIm-bs8ZosKn_tqy3CEU7XUu6rMFLbNZ_eyuIkzMaQ,42016
8
- pycodex/events.py,sha256=8gPVe_wb5r5s2hVQhywFMnz1YVvBmDLhyq43e9Y71wk,23090
9
- pycodex/model.py,sha256=SaAMysy0MaeFNbRgJS4zP_QcAerBYa5_Jilwvgtv34s,59992
10
- pycodex/multi_agents.py,sha256=3KN_Ai3UremtsQppvxd0pE7pFam_v0zBastCNi-NNx8,16150
11
- pycodex/protocol.py,sha256=qYUS9371F-DadlsYgctCpQbm3JCqyfpcWcxkANRAZWQ,15586
12
- pycodex/runtime.py,sha256=92hVNdBzugUYQb01-bbkAOYpNpjIB1IWVEU6_U6SERA,37120
6
+ pycodex/config.py,sha256=wK4CKaykZuGH1dFG_K3yGuH8nWcY-lOEOmGERrqD2FE,1844
7
+ pycodex/context.py,sha256=yMG7JzsDo8OP7-SUmF-YKkIc9_GT2dgViUgiKnJfQEg,42632
8
+ pycodex/events.py,sha256=nU874-hrO3pvXqMSfoy4Kd4VAoLcJGmWcvYNjhht8sU,26555
9
+ pycodex/model.py,sha256=NAmwkQ1n8yhJ6Vi3LIz43t3CVphfV33UkllMO6OGC8I,68617
10
+ pycodex/multi_agents.py,sha256=OMtHSVY1hwg7aIk9RBxasJxVtZRkZjAxBU-K_MiJaRg,15233
11
+ pycodex/protocol.py,sha256=agGs0pxCHWbJyFRnItd-hKPemF_BP9uRKxPiEDAc9iA,15718
12
+ pycodex/runtime.py,sha256=ceocvyzdUZ32QyShUmpCt8yurP0NRe1IHR6UL3y5FPw,41133
13
13
  pycodex/portable/__init__.py,sha256=NgACNTFK5hbRK6fqbL89qjPuh44N950pr4eoDWLfKD4,1110
14
14
  pycodex/portable/client.py,sha256=ZvXjKCB557ZZ-ELmec9DIxymWbG8QBZsaU6e0axu0T0,15508
15
15
  pycodex/portable/protocol.py,sha256=jtyPHI3aVY4UldlSIzeZRQX3MCFzPYfG-0iDC6JSWYo,931
16
16
  pycodex/portable/server.py,sha256=UCQAqcO0OTNkEv4MQgR-fIt1y5bzdqMndFJtMm16Lqk,7503
17
17
  pycodex/prompts/default_base_instructions.md,sha256=D65mcj6bo4CDvVom-D9cbJRJVNquo0NghKt164_fRsg,20923
18
18
  pycodex/prompts/developer_messages.json,sha256=E-CAWMOL2KoImJ1U_1aA-OYbuVtJF0-GtZkn983B-TI,4007
19
- pycodex/prompts/models.json,sha256=m2edzANgpiRutpuw3nGJFiJQX4Y7751_omr4E4zN_uU,747802
19
+ pycodex/prompts/models.json,sha256=55xs5IxAY04P4XqC7BdfyEoXoI8uT8Fhz9SnaEwDSYA,743063
20
20
  pycodex/prompts/goals/budget_limit.md,sha256=RbvI03fMD3tTy-ytnzylqAsIr9b2O_Cb81CQejR1J-k,775
21
21
  pycodex/prompts/goals/continuation.md,sha256=K7OtQKQNoCKcgne-e-SQBGJjEpnCVcVCtML7T-82bWI,6153
22
22
  pycodex/prompts/permissions/approval_policy/never.md,sha256=QceTG6wjkaJARjYr0HYV1aPnPcpGcrkRUW-smWRr6MQ,120
@@ -27,18 +27,18 @@ pycodex/prompts/permissions/approval_policy/unless_trusted.md,sha256=XHpi1Lfx1iI
27
27
  pycodex/prompts/permissions/sandbox_mode/danger_full_access.md,sha256=nZ7YHacBd3cAHKRZc9XClOOOnXJPXPh0WFBueh5C2D0,197
28
28
  pycodex/prompts/permissions/sandbox_mode/read_only.md,sha256=2rAPEXsBYCcuttI5j3euS-3uv_v97catIsnhxlSQSIM,173
29
29
  pycodex/prompts/permissions/sandbox_mode/workspace_write.md,sha256=lVN-LwrBbHqlv5yVjcd_mU8tzZW8jfKpTatJKIZu9HI,277
30
- pycodex/tools/__init__.py,sha256=yE_9gmbNrbUKXMfZO79Y8chfHMmOe9NBozy4i0vn0bY,5175
30
+ pycodex/tools/__init__.py,sha256=tppYyq7lmcyEuCaXKZgi231JSvoaaCiFOWnv3hg3hOI,5166
31
31
  pycodex/tools/agent_tool_schemas.py,sha256=juw4b2pp2tDhDPVTVY4rytm8IyVr2h686Qfk_5e9S0E,780
32
32
  pycodex/tools/apply_patch_tool.py,sha256=LcyJuGtndmLLbFL1sIUQ2Y6KLCef95KBfi0adGA1bN8,13183
33
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
34
+ pycodex/tools/clock_manager.py,sha256=mOlTjqHqWTCH3MVKj9nw9UPWmuABIsVjqKalFLh4oCQ,5525
35
35
  pycodex/tools/clock_tool.py,sha256=14Y1uLagSuEO8eaACQcQQbPZP1R6cSAYaReZIyZen4c,3790
36
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
37
+ pycodex/tools/exec_command_tool.py,sha256=1LXoHkK-1ueACABk-qE5qXOVpp8vhFqtakn9M1q8pqU,4583
38
+ pycodex/tools/exec_runtime.py,sha256=9e5dMdOJGF-kv7r9v8PZIDprVVvVSI_4wUa2_wNK40Y,12243
39
39
  pycodex/tools/exec_tool.py,sha256=7HQ8sazJBr4WQklJsCJS30kfVaQOsg5gBgIutC6QyRY,5209
40
40
  pycodex/tools/followup_task_tool.py,sha256=D3nRu6csiriwe1WVig_HNLRzJQfDNMmk2R75vMfSI4Y,1609
41
- pycodex/tools/goal_manager.py,sha256=8zicCSjqJgYyONL6EaOIyaGjTA6EBECi1NYQgEwLFms,8480
41
+ pycodex/tools/goal_manager.py,sha256=wDTSsHX1dCp46xi_aSyged76Ggnw7ES4NBzMKxYfk4g,8058
42
42
  pycodex/tools/goal_tool.py,sha256=TShHf6dh6YCdMPoc6zuIgj0W2D_O95ewmh6OZKFXAX0,5225
43
43
  pycodex/tools/grep_files_tool.py,sha256=KCBVNaSTU45ND-iAhh14YawMyjQnMRZnGI1NGKL3zgg,4809
44
44
  pycodex/tools/interrupt_agent_tool.py,sha256=q4TBTam6sFLwAQwDsoz1WNL_b9y1Esne7awgc77gerw,1589
@@ -47,12 +47,12 @@ pycodex/tools/list_dir_tool.py,sha256=_U6ouRcVbGHT5mChVyUsiMgDGrFK7EFMFaspPLAHtH
47
47
  pycodex/tools/python_tool_schema.py,sha256=yoJHP7GJGSu6oyT_0nxbGJWy_TaTobFwDoFQMl65464,5781
48
48
  pycodex/tools/read_file_tool.py,sha256=YK__uhIVldBjAQega5S_ZuZU5jgP_kLOwr-YhjAmRo4,9735
49
49
  pycodex/tools/request_permissions_tool.py,sha256=t-Y-iEhvUyE9IJAeiwnzfUdbQ73Gw7uxFcWLwS0no4o,4000
50
- pycodex/tools/runtime_services.py,sha256=oEqUyR7-oHQdTsEWXoiP7VKP_JDiG5dc8AjlSGQFjYI,7542
50
+ pycodex/tools/runtime_services.py,sha256=59Vg22uQ6F0VPokAVf8x5AXdSdmj8_FffBzheD6RLFo,7810
51
51
  pycodex/tools/send_message_tool.py,sha256=mH51ufxTCcsHuLFI1tDKyX14AHPMij2cMJLJdlFFjZQ,1414
52
52
  pycodex/tools/shell_command_tool.py,sha256=bJKlTdIs2i28vH5f4GZfpunezr6JNicRzsL_6Vc3HvU,3675
53
53
  pycodex/tools/shell_tool.py,sha256=I6lYLABSmLddRrNmpk0Li83AV55MI8x0bckWaRkFGI0,3527
54
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
55
+ pycodex/tools/unified_exec_manager.py,sha256=CC3lxhiEl5yBqEypkS_dfmliaT7ERwv0u58zQCDoMD4,15926
56
56
  pycodex/tools/update_plan_tool.py,sha256=xwrSrerw5qfkbFc9Ltx1OZEmD__CWtryOy3UhL0-Jp4,3198
57
57
  pycodex/tools/view_image_tool.py,sha256=H7OP-QZEU5Gf-E4YnQbXfu2hDkL5-dJ3Apla2YYjErQ,3754
58
58
  pycodex/tools/wait_agent_tool.py,sha256=uo4KcFZBm8BAmw7i_wVjg2i3f_T9PrGL4ZnxbGt3-38,2516
@@ -62,20 +62,20 @@ pycodex/tools/write_stdin_tool.py,sha256=jvBDchLLmoDITd7g-ZVeEVXHRhWKkmnjM5laL-5
62
62
  pycodex/utils/__init__.py,sha256=ih_KyZ2_bajR5YlZ1QMTWOHnuEBda-S3gQ7PwnBtLZQ,453
63
63
  pycodex/utils/async_bridge.py,sha256=BXsKTUTUvUtPJnItQlulFRdV7opdKKDlsKLdtVTYshs,1732
64
64
  pycodex/utils/codex_config.py,sha256=oCisEGUJcJxcZL1wIqXkon1xTShymOlz96E3VgDVTlY,3748
65
- pycodex/utils/compactor.py,sha256=qSHZpTP_hWuxuqeVt6JijbtgkXiW2act1CdTQ5wovBM,6399
66
- pycodex/utils/compat.py,sha256=16FyHHlDES57mOHCasN4FWveEkGYd2aZex9-Eojlkg8,5277
65
+ pycodex/utils/compactor.py,sha256=Nzh_W2YxU-c-HBjsPiUmAYxlXfBwRM75uvnDeIkT6u0,4172
66
+ pycodex/utils/compat.py,sha256=eVI53Jb3TxXQuiNeDwtlI0q2KW7KFGSQlT6mCES9E70,5487
67
67
  pycodex/utils/crypto.py,sha256=HRCXF26Ft3S8CG2X0YpZwa8GMU9YJ0Loo8Q9PMPMcNw,1249
68
68
  pycodex/utils/debug.py,sha256=5XMpWpwFSm6woyx6RGXvN2qL0afRtTQbwlOAv-LotTw,913
69
69
  pycodex/utils/doctor.py,sha256=xhPflFEYFfmtQ4-LjnIyz-cNts0GjNtAK0inVTYfKiI,10764
70
70
  pycodex/utils/dotenv.py,sha256=rLHBfz5zPZMbrJqyRyYPy3j4oiDwuzfrH4mDH3XRrow,1647
71
- pycodex/utils/event_helpers.py,sha256=ULvTSktxMd--VEL2UJA6CbuWHLsrctAcAuEk91wGLL8,12021
71
+ pycodex/utils/event_helpers.py,sha256=fzVvCJ3u8zi0FseuTJi7OcpVnNuASwEwIMwUcuurInw,13732
72
72
  pycodex/utils/get_env.py,sha256=L4S8h84tkgxZKvrxY7ezTgePbXepG-yIigUTKeY6uuE,6094
73
- pycodex/utils/history.py,sha256=qgt5IxxkfCYjjpr08VJFhasICSSlqxQM7d-DjRJVjHA,3845
73
+ pycodex/utils/history.py,sha256=EsXbZFvtMrzZ99dkthjPmdN5ZvOjUI6WCFVNImi5G5M,4495
74
74
  pycodex/utils/http_headers.py,sha256=4Jlnmun6QFSQ6L7javlDQfom1p2AZZQFXvcHzD3_cQk,877
75
75
  pycodex/utils/image_utils.py,sha256=OUzUs0Cow4L8Z2np0EBeEUotAqqsCmRmhrV8AxZUXRw,2460
76
- pycodex/utils/model_metadata.py,sha256=uK3iI4yC7Ge7yN4I1_gQYalQ4MYKddz2qMwsmQb-P80,1337
76
+ pycodex/utils/model_metadata.py,sha256=kCfe3jof1wrXJX9f2nDB9XN11v6JFSATNW4ewXb9gBI,1392
77
77
  pycodex/utils/random_ids.py,sha256=jLTxZZ0MBbRdQOFDFWGVRjWzIo6FKSQ5ADXbQSLPp1s,379
78
- pycodex/utils/session_persist.py,sha256=7JXXInvKaeO-9zz-n4LrnqrNn4BvFPEoVgZ88c9yZrM,31333
78
+ pycodex/utils/session_persist.py,sha256=B2CULvlofibcdnzMcszIM-R8spqtKmZJRsTZcTmTjPw,31455
79
79
  pycodex/utils/skill_catalog.py,sha256=3W-r6pn_fzEGyd89aKD2shGNhrUK2hLgrlwOlqYOpgU,618
80
80
  pycodex/utils/truncation.py,sha256=5D6vAorT8EgXgjd7ASwtraAyIZdlCR-w5jKZqJxDzho,5446
81
81
  pycodex/utils/_aes_gcm/LICENSE,sha256=KvdHagY3sYIK34GldJaRi34sNnGwMVJIIoDhbC9MRu8,2805
@@ -86,9 +86,9 @@ pycodex/utils/_aes_gcm/gcm.py,sha256=Z8fYHpnLpqJyTPmjDOZtryqe0xmT_93vscNuJe5ZY-w
86
86
  pycodex/utils/_aes_gcm/source-sha256.json,sha256=g9uPWXuA0D9Wq9EGnduyiVanTgi8QWRFW-9T69FG-fc,215
87
87
  responses_server/__init__.py,sha256=SOMO5Q-Z0dpaRih8yWuKUTclPl28tpy_XIPTOO_BPq0,447
88
88
  responses_server/__main__.py,sha256=876xZTqhPeDBD2GKKr8pKX33Af8PhFTosAI8bYQsFgQ,61
89
- responses_server/app.py,sha256=6D23sAyftNUwGwmWT7WGM6aau78i7KCkhZfc16Sul3o,8600
89
+ responses_server/app.py,sha256=9DwnX7DlvaGFpqy4FwVOxcIjIFE_nWLPVUJt1ivWh5s,8773
90
90
  responses_server/config.py,sha256=XxBRXrLEeCnaqKXGV-f_3iTtur0hPn4yqM7wLngcTFM,2931
91
- responses_server/gemini_api.py,sha256=d5ChR4_fOnx2tPVSQQWWYIgXuIEcHdJUScaOptoGii4,16163
91
+ responses_server/gemini_api.py,sha256=cVc9UMN6Mjv9MRaIXFxLFfU0WpThDCBrebvSkd0osxU,16745
92
92
  responses_server/messages_api.py,sha256=dDZ2z2AfE5Mfayuy0yt3tmgYp7fj11QtOBQ51gtdVCE,19613
93
93
  responses_server/payload_processors.py,sha256=-lcw5DJ-uGiK4ZDsw373gjxpqVTapC-kWGVBXFGmr1A,3585
94
94
  responses_server/request_translation.py,sha256=qG5rxW0bf6NS83L24YmMOuVNpPZGWnl2NVjNtQ-_GeQ,20508
@@ -97,12 +97,12 @@ responses_server/session_store.py,sha256=nwGxQL6nUVKnDVeDHz8IzqNQ7dWk8Ybf0URekOH
97
97
  responses_server/stream_events.py,sha256=nWi5VcssytFD3SDHW5hQik5LR-US-Clk-5EEWAi3t-k,4984
98
98
  responses_server/stream_router.py,sha256=7-_KoXtaDtEISeSxGL-tJ-l6gmypbIgQ_Mxx9dtyklA,15474
99
99
  responses_server/trajectory_dump.py,sha256=5_Wy6tslszrqx3j1JeP_boyTbzIicKy8No84PzMnmHk,5111
100
- responses_server/transport.py,sha256=PmflqUUZ-p7dO4vTFPNM4SzbQITXT0lntMqwiTrw2rw,16810
100
+ responses_server/transport.py,sha256=-pR-8zMxarSOH8H62i6IaG9nxi-IcWibRQarXs3Nk-s,17150
101
101
  responses_server/tools/__init__.py,sha256=ivsBSEy0SBUhY-Uea5v1XMLXShkwHdCVl0id-1FwdZg,150
102
102
  responses_server/tools/custom_adapter.py,sha256=leYNJKp4Ute0JWNfGpe-ntSyFqRgYCdWF4dMYQFINlk,8615
103
103
  responses_server/tools/web_search.py,sha256=JyF6NHCS0SqoBrO18jX8cgBsiV4OYQBPz0Ky4u3juSQ,9059
104
- python_codex-0.6.3.dist-info/METADATA,sha256=shh4KMFZrpoJD0vfiDk2WFzZ-5tbAni_J4nn8bevZ-g,8187
105
- python_codex-0.6.3.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
106
- python_codex-0.6.3.dist-info/entry_points.txt,sha256=sNUVakoVuTrzJH505ZgRTQxmtRRPUHV_EH0i6EbYTyM,45
107
- python_codex-0.6.3.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
108
- python_codex-0.6.3.dist-info/RECORD,,
104
+ python_codex-0.7.1.dist-info/METADATA,sha256=sqpv6usBJFmgaQapfJ6M_qoyYwMFmvD97KFnKsiI2wE,10077
105
+ python_codex-0.7.1.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
106
+ python_codex-0.7.1.dist-info/entry_points.txt,sha256=sNUVakoVuTrzJH505ZgRTQxmtRRPUHV_EH0i6EbYTyM,45
107
+ python_codex-0.7.1.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
108
+ python_codex-0.7.1.dist-info/RECORD,,
responses_server/app.py CHANGED
@@ -59,6 +59,10 @@ def _stream_events(
59
59
  error_type = getattr(exc, "error_type", None)
60
60
  if error_type:
61
61
  error["type"] = error_type
62
+ if exc.error_code is not None:
63
+ error["code"] = exc.error_code
64
+ if exc.http_status is not None:
65
+ error["http_status"] = exc.http_status
62
66
  yield _format_sse_event(
63
67
  "response.failed",
64
68
  {
@@ -1,5 +1,6 @@
1
1
  """Gemini generateContent request and streaming response adapter."""
2
2
 
3
+ import base64
3
4
  import json
4
5
  import re
5
6
  import uuid
@@ -7,6 +8,10 @@ from copy import deepcopy
7
8
 
8
9
  from .request_translation import inline_history_instructions
9
10
 
11
+ SKIP_THOUGHT_SIGNATURE_VALIDATOR = base64.b64encode(
12
+ b"skip_thought_signature_validator"
13
+ ).decode("ascii")
14
+
10
15
 
11
16
  class GeminiAPIAdapterError(ValueError):
12
17
  pass
@@ -36,16 +41,17 @@ def build_gemini_request(request):
36
41
  # Unsigned empty text can end a stream, but is not input data.
37
42
  parts = [part for part in parts
38
43
  if part.get("text") != "" or "thoughtSignature" in part]
44
+ native_call_ids = {
45
+ entry["call_id"] for entry in native
46
+ if "call_id" in entry and "functionCall" in entry["part"]
47
+ }
48
+ for call in message.get("tool_calls", []):
49
+ if call["id"] not in native_call_ids:
50
+ parts.append(_unsigned_function_call_part(call))
39
51
  else:
40
52
  parts = _content_parts(message.get("content"))
41
53
  for call in message.get("tool_calls", []):
42
- function = call["function"]
43
- arguments = json.loads(function["arguments"])
44
- if not isinstance(arguments, dict):
45
- raise GeminiAPIAdapterError("Gemini function arguments must be objects")
46
- parts.append({"functionCall": {
47
- "name": function["name"], "args": arguments, "id": call["id"],
48
- }})
54
+ parts.append(_unsigned_function_call_part(call))
49
55
  role = "model"
50
56
  elif role == "tool":
51
57
  call_id = message["tool_call_id"]
@@ -116,6 +122,19 @@ def build_gemini_request(request):
116
122
  return payload
117
123
 
118
124
 
125
+ def _unsigned_function_call_part(call):
126
+ function = call["function"]
127
+ arguments = json.loads(function["arguments"])
128
+ if not isinstance(arguments, dict):
129
+ raise GeminiAPIAdapterError("Gemini function arguments must be objects")
130
+ return {
131
+ "functionCall": {
132
+ "name": function["name"], "args": arguments, "id": call["id"],
133
+ },
134
+ "thoughtSignature": SKIP_THOUGHT_SIGNATURE_VALIDATOR,
135
+ }
136
+
137
+
119
138
  def _content_parts(content):
120
139
  if not content:
121
140
  return []
@@ -25,9 +25,13 @@ class OutcommingChatError(RuntimeError):
25
25
  self,
26
26
  message: "str",
27
27
  error_type: "typing.Union[str, None]" = None,
28
+ http_status: "typing.Union[int, None]" = None,
29
+ error_code: "typing.Union[str, None]" = None,
28
30
  ) -> "None":
29
31
  super().__init__(message)
30
32
  self.error_type = error_type
33
+ self.http_status = http_status
34
+ self.error_code = error_code
31
35
 
32
36
 
33
37
  class OutcommingTransport:
@@ -120,7 +124,7 @@ class OutcommingTransport:
120
124
  yield payload
121
125
  if not saw_done:
122
126
  raise OutcommingChatError(
123
- "outcomming chat stream ended before [DONE]"
127
+ "outcomming chat stream ended before [DONE]", error_code="502",
124
128
  )
125
129
  except (
126
130
  ConnectionError,
@@ -139,7 +143,8 @@ class OutcommingTransport:
139
143
  progress["phase"] = "reading_error_body"
140
144
  body = exc.read().decode("utf-8", errors="replace")
141
145
  raise OutcommingChatError(
142
- f"outcomming chat request failed with status {exc.code}: {body[:500]}"
146
+ f"outcomming chat request failed with status {exc.code}: {body[:500]}",
147
+ http_status=exc.code,
143
148
  ) from exc
144
149
  except TimeoutError as exc:
145
150
  raise OutcommingChatError(
@@ -219,7 +224,7 @@ class OutcommingTransport:
219
224
  if not finished:
220
225
  terminal = "finishReason" if api == "gemini" else "message_stop"
221
226
  raise OutcommingChatError(
222
- f"outcomming {api} stream ended before `{terminal}`"
227
+ f"outcomming {api} stream ended before `{terminal}`", error_code="502",
223
228
  )
224
229
  if api == "gemini":
225
230
  yield gemini_continuation_chunk(stream_state)
@@ -246,7 +251,8 @@ class OutcommingTransport:
246
251
  progress["phase"] = "reading_error_body"
247
252
  body = exc.read().decode("utf-8", errors="replace")
248
253
  raise OutcommingChatError(
249
- f"outcomming {api} request failed with status {exc.code}: {body[:500]}"
254
+ f"outcomming {api} request failed with status {exc.code}: {body[:500]}",
255
+ http_status=exc.code,
250
256
  ) from exc
251
257
  except TimeoutError as exc:
252
258
  raise OutcommingChatError(
@@ -338,7 +344,8 @@ class OutcommingTransport:
338
344
  progress["phase"] = "reading_error_body"
339
345
  body = exc.read().decode("utf-8", errors="replace")
340
346
  raise OutcommingChatError(
341
- f"outcomming request failed with status {exc.code}: {body[:500]}"
347
+ f"outcomming request failed with status {exc.code}: {body[:500]}",
348
+ http_status=exc.code,
342
349
  ) from exc
343
350
  except TimeoutError as exc:
344
351
  raise OutcommingChatError(