@oai404iao/pi-codex-minimal-tools 1.3.0

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 (39) hide show
  1. package/LICENSE +28 -0
  2. package/LICENSES/Apache-2.0.txt +201 -0
  3. package/LICENSES/OpenAI-Codex-NOTICE.txt +6 -0
  4. package/README.md +410 -0
  5. package/THIRD_PARTY_NOTICES.md +97 -0
  6. package/config.schema.json +174 -0
  7. package/models.schema.json +217 -0
  8. package/package.json +87 -0
  9. package/provenance/openai-codex-eb9dceba-reserved-tools.json +140 -0
  10. package/src/activation.ts +56 -0
  11. package/src/background-image-generation.ts +574 -0
  12. package/src/capabilities.ts +146 -0
  13. package/src/codex-http.ts +133 -0
  14. package/src/codex-request-profile.ts +45 -0
  15. package/src/codex-reserved-tools.ts +323 -0
  16. package/src/codex-wire-identity.ts +182 -0
  17. package/src/fast-mode.ts +124 -0
  18. package/src/glyphs.ts +70 -0
  19. package/src/index.ts +332 -0
  20. package/src/model-catalog/catalog.ts +636 -0
  21. package/src/model-catalog/default-models.json +252 -0
  22. package/src/model-catalog/runtime.ts +113 -0
  23. package/src/model-catalog/types.ts +95 -0
  24. package/src/native-compaction.ts +393 -0
  25. package/src/patch/apply.ts +338 -0
  26. package/src/patch/parser.ts +224 -0
  27. package/src/patch/render.ts +201 -0
  28. package/src/provider-headers.ts +54 -0
  29. package/src/provider-native-tools.ts +71 -0
  30. package/src/provider-shim.ts +4338 -0
  31. package/src/providers/codex-apply-patch-tool.ts +23 -0
  32. package/src/providers/codex-apply-patch.lark +19 -0
  33. package/src/providers/openai-responses-shared.ts +1463 -0
  34. package/src/settings.ts +247 -0
  35. package/src/tools/apply-patch.ts +84 -0
  36. package/src/tools/image-generation.ts +274 -0
  37. package/src/tools/view-image.ts +98 -0
  38. package/src/tools/web-search.ts +524 -0
  39. package/src/utils/images.ts +73 -0
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ Licensing for pi-codex-minimal-tools
2
+
3
+ Except for the third-party materials identified in THIRD_PARTY_NOTICES.md,
4
+ the project-authored portions of this package are available under the
5
+ following MIT License:
6
+
7
+ Copyright (c) 2026 oai404iao
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ Third-party materials remain under their respective terms. See
28
+ THIRD_PARTY_NOTICES.md and the license texts under LICENSES/.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 OpenAI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ OpenAI Codex
2
+ Copyright 2025 OpenAI
3
+
4
+ This project includes code derived from [Ratatui](https://github.com/ratatui/ratatui), licensed under the MIT license.
5
+ Copyright (c) 2016-2022 Florian Dehau
6
+ Copyright (c) 2023-2025 The Ratatui Developers
package/README.md ADDED
@@ -0,0 +1,410 @@
1
+ # @oai404iao/pi-codex-minimal-tools
2
+
3
+ Codex-specific Responses support for Pi, driven by an exact per-model JSON
4
+ catalog instead of model-name heuristics.
5
+
6
+ Compatibility: Pi 0.84.2 or newer; tested against 0.84.2.
7
+
8
+ > npm identity: `@oai404iao/pi-codex-minimal-tools`. Version `1.3.0` is
9
+ > prepared for a one-time manually authenticated npm bootstrap from a reviewed
10
+ > public `main` commit.
11
+
12
+ > **Compatibility boundary:** Responses Lite uses an internal Codex request
13
+ > shape. This package pins and tests a compatibility serialization for exact
14
+ > configured model profiles, but it is not an OpenAI-supported public API
15
+ > contract and may stop working if that internal protocol changes.
16
+
17
+ The extension adds:
18
+
19
+ - Responses SSE, WebSocket, cached continuation, WebSocket retry, upgrade-only
20
+ SSE fallback, and WebSocket prewarm.
21
+ - Standard Responses and the internal Codex Responses Lite envelope.
22
+ - Codex freeform `apply_patch`, including streaming preview and exact replay.
23
+ - Hosted Responses web search or standalone Codex `web.run`.
24
+ - Hosted Responses image generation or standalone Codex `image_gen.imagegen`.
25
+ - Codex remote compaction v2 and legacy `/responses/compact`.
26
+ - Per-model Fast service tiers.
27
+ - User overrides and user-added provider/model profiles.
28
+
29
+ Unknown models are not guessed. They keep Pi's native provider implementation
30
+ and do not receive package tools.
31
+
32
+ ## Install
33
+
34
+ After `1.3.0` is available on npm:
35
+
36
+ ```bash
37
+ pi install npm:@oai404iao/pi-codex-minimal-tools@1.3.0
38
+ ```
39
+
40
+ Before the initial bootstrap, or when testing unreleased source:
41
+
42
+ ```bash
43
+ pi install /absolute/path/to/pi-codex-minimal-tools
44
+ ```
45
+
46
+ Restart Pi or run `/reload`.
47
+
48
+ ## Commands
49
+
50
+ | Command | Action |
51
+ | --- | --- |
52
+ | `/codex-minimal-tools` | Show the active model profile and effective capabilities. |
53
+ | `/codex-minimal-tools:doctor` | Show config/catalog diagnostics. |
54
+ | `/fast [on\|off\|status]` | Toggle the active profile's Fast service tier. |
55
+ | `/image-gen <prompt> [@reference.png]` | Run background image generation or editing. |
56
+
57
+ ## Two Configuration Files
58
+
59
+ There are two separate model-related files:
60
+
61
+ 1. Pi's agent `models.json` defines providers and actual models: API type,
62
+ base URL, authentication, headers, modalities, context window, and cost.
63
+ 2. This extension's `models.json` defines Codex behavior for an exact
64
+ `provider/model` ID: Responses mode, reasoning summary, transport, tools,
65
+ compaction, and Fast.
66
+
67
+ Typical paths:
68
+
69
+ ```text
70
+ <PI_CODING_AGENT_DIR>/models.json
71
+ <PI_CODING_AGENT_DIR>/extensions/pi-codex-minimal-tools/models.json
72
+ <PI_CODING_AGENT_DIR>/extensions/pi-codex-minimal-tools/config.json
73
+ ```
74
+
75
+ Without `PI_CODING_AGENT_DIR`, Pi normally uses `~/.config/pi/agent` or
76
+ `~/.pi/agent`, depending on the installation.
77
+
78
+ ### Extension Global Config
79
+
80
+ `config.json` now contains only package-wide preferences:
81
+
82
+ ```json
83
+ {
84
+ "$schema": "https://unpkg.com/@oai404iao/pi-codex-minimal-tools@1/config.schema.json",
85
+ "enabled": true,
86
+ "glyphStyle": "unicode",
87
+ "autoEnable": true,
88
+ "fastMode": false,
89
+ "imageOutputDir": ".pi/openai-codex-images",
90
+ "imageModel": "gpt-image-2",
91
+ "directImageApiFallback": false,
92
+ "viewImageWorkspaceOnly": false,
93
+ "deferApplyPatchRendering": false
94
+ }
95
+ ```
96
+
97
+ | Setting | Meaning |
98
+ | --- | --- |
99
+ | `enabled` | Enable all package behavior. |
100
+ | `glyphStyle` | Use `unicode` or `ascii` UI glyphs. |
101
+ | `autoEnable` | Add supported package tools automatically. |
102
+ | `fastMode` | Global user toggle; only profiles with `fast` are affected. |
103
+ | `imageOutputDir` | Generated-image output directory. Relative paths resolve from the workspace root. |
104
+ | `imageModel` | Image model used by standalone/hosted image requests and direct fallback. |
105
+ | `directImageApiFallback` | Permit the separate `OPENAI_API_KEY` Images API fallback. |
106
+ | `viewImageWorkspaceOnly` | Restrict `view_image` to the workspace. |
107
+ | `deferApplyPatchRendering` | Use Pi's fallback renderer instead of the streaming patch preview. |
108
+
109
+ The older model-level keys remain readable for one migration version, but are
110
+ deprecated. See [Legacy migration](#legacy-migration).
111
+
112
+ ### Per-Model Catalog
113
+
114
+ Create:
115
+
116
+ ```text
117
+ <PI_CODING_AGENT_DIR>/extensions/pi-codex-minimal-tools/models.json
118
+ ```
119
+
120
+ Example overriding a bundled model and adding a custom provider/model:
121
+
122
+ ```json
123
+ {
124
+ "$schema": "https://unpkg.com/@oai404iao/pi-codex-minimal-tools@1/models.schema.json",
125
+ "version": 1,
126
+ "models": [
127
+ {
128
+ "id": "openai/gpt-5.5",
129
+ "responses": {
130
+ "reasoningSummary": "none",
131
+ "transport": "sse",
132
+ "websocketPrewarm": false
133
+ },
134
+ "tools": {
135
+ "webSearch": false
136
+ }
137
+ },
138
+ {
139
+ "id": "my-provider/my-codex-model",
140
+ "extends": "openai/gpt-5.5",
141
+ "responses": {
142
+ "endpoint": "openai",
143
+ "transport": "websocket-cached"
144
+ },
145
+ "tools": {
146
+ "imageGeneration": false
147
+ }
148
+ }
149
+ ]
150
+ }
151
+ ```
152
+
153
+ Resolution rules:
154
+
155
+ - IDs are exact, case-insensitive `provider/model` matches.
156
+ - A user entry with the same ID deep-overrides the bundled entry.
157
+ - `extends` can inherit from a bundled or user profile.
158
+ - Objects merge recursively; arrays replace the inherited array.
159
+ - Duplicate IDs, malformed JSON, missing parents, cycles, and unknown fields
160
+ are reported by `/codex-minimal-tools:doctor`.
161
+ - Each effective profile has a stable hash. WebSocket continuation, sticky
162
+ fallback, and native-compaction replay are isolated by that hash.
163
+
164
+ Full field documentation is in
165
+ [`reference/model-catalog.md`](https://github.com/oai404iao/omp/blob/main/pi-extensions/pi-codex-minimal-tools/reference/model-catalog.md), and editor
166
+ validation is provided by [`models.schema.json`](models.schema.json).
167
+
168
+ ## Custom Provider Example
169
+
170
+ The custom model must exist in Pi's agent `models.json`. For provider-shim
171
+ features, its Pi `api` must be `openai-responses` or
172
+ `openai-codex-responses`:
173
+
174
+ ```json
175
+ {
176
+ "providers": {
177
+ "my-provider": {
178
+ "baseUrl": "https://api.example.com/v1",
179
+ "apiKey": "$MY_PROVIDER_API_KEY",
180
+ "api": "openai-responses",
181
+ "models": [
182
+ {
183
+ "id": "my-codex-model",
184
+ "name": "My Codex Model",
185
+ "reasoning": true,
186
+ "input": ["text", "image"],
187
+ "contextWindow": 272000,
188
+ "maxTokens": 16384,
189
+ "cost": {
190
+ "input": 0,
191
+ "output": 0,
192
+ "cacheRead": 0,
193
+ "cacheWrite": 0
194
+ }
195
+ }
196
+ ]
197
+ }
198
+ }
199
+ }
200
+ ```
201
+
202
+ The extension dynamically attaches only its stream handler to a selected
203
+ custom provider. It does not replace the provider's URL, authentication,
204
+ headers, or model definitions.
205
+
206
+ If a profile requests the provider shim but the Pi model uses another API
207
+ type, wire-only features are disabled:
208
+
209
+ - hosted web/image tools;
210
+ - custom/freeform `apply_patch`;
211
+ - native Responses compaction;
212
+ - Fast service tiers.
213
+
214
+ Standalone web/image tools and function `apply_patch` can still be used when
215
+ the profile enables them.
216
+
217
+ ## Model Profile Fields
218
+
219
+ ```json
220
+ {
221
+ "id": "provider/model",
222
+ "extends": "provider/parent-model",
223
+ "enabled": true,
224
+ "responses": {
225
+ "providerShim": true,
226
+ "endpoint": "auto",
227
+ "mode": "standard",
228
+ "reasoningSummary": "auto",
229
+ "systemPromptPlacement": "instructions",
230
+ "transport": "auto",
231
+ "websocketPrewarm": true
232
+ },
233
+ "tools": {
234
+ "parallelCalls": true,
235
+ "applyPatch": "custom",
236
+ "webSearch": {
237
+ "implementation": "hosted",
238
+ "contentTypes": ["text", "image"]
239
+ },
240
+ "imageGeneration": "standalone",
241
+ "viewImage": false
242
+ },
243
+ "compaction": "responses",
244
+ "fast": {
245
+ "serviceTier": "priority",
246
+ "costMultiplier": 2
247
+ }
248
+ }
249
+ ```
250
+
251
+ Important constraints:
252
+
253
+ - `responses.reasoningSummary` accepts `"auto"`, `"concise"`, `"detailed"`,
254
+ or `"none"`. `"none"` omits `reasoning.summary`; when absent, Standard
255
+ defaults to `"auto"` and Lite defaults to `"none"`.
256
+ - `responses.mode:"lite"` always uses a developer message, namespace tools in
257
+ `additional_tools`, `parallel_tool_calls:false`,
258
+ `reasoning.context:"all_turns"`, and strips input-image `detail`.
259
+ - Lite cannot use hosted `web_search` or hosted `image_generation`; choose
260
+ `standalone` instead.
261
+ - `tools.applyPatch:"custom"` uses the Codex freeform grammar and requires the
262
+ provider shim. `"function"` works as a normal Pi tool.
263
+ - `responses.endpoint:"openai"` uses API-key endpoint/auth semantics.
264
+ `"codex"` uses ChatGPT/Codex endpoint/auth semantics. `"auto"` infers from
265
+ the provider.
266
+ - `compaction:"responses"` uses `compaction_trigger` through the selected
267
+ SSE/WebSocket transport. `"responses-compact"` uses the legacy unary
268
+ endpoint. `"pi"` keeps Pi summaries.
269
+
270
+ ## Built-In Profiles
271
+
272
+ The bundled catalog is based on local Codex commit
273
+ `eb9dceba1a2e658142a456c5898836774835616b` from August 12, 2026.
274
+
275
+ | Models | Responses | Web | Image | Patch | Compaction |
276
+ | --- | --- | --- | --- | --- | --- |
277
+ | `gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-5.6-luna` | Lite, auto WS/SSE | standalone text+image | standalone | custom | responses |
278
+ | `gpt-5.5`, `gpt-5.4` | Standard, auto WS/SSE | hosted text+image | standalone | custom | responses |
279
+ | `gpt-5.4-mini`, `codex-auto-review` | Standard, auto WS/SSE | hosted text+image | standalone | custom | responses |
280
+ | `gpt-5.2` | Standard, auto WS/SSE | hosted text | standalone | custom | responses |
281
+ | legacy GPT-5/Codex entries | inherited Standard profile | profile-specific | standalone | custom | responses |
282
+ | `gpt-4.1` | Standard SSE | off | hosted | off | Pi |
283
+ | `o4-mini` | Standard SSE | off | off | off | Pi |
284
+
285
+ Equivalent `openai/...` and `openai-codex/...` IDs are included; the latter
286
+ switch only the endpoint/auth shape to `codex`.
287
+
288
+ These entries are defaults, not claims that every proxy with the same model
289
+ slug supports the protocol. Override or disable a profile for the endpoint
290
+ actually in use.
291
+
292
+ ## Web Search
293
+
294
+ `tools.webSearch` supports two implementations:
295
+
296
+ - `hosted`: rewrites the Pi placeholder to Responses
297
+ `{"type":"web_search"}` and preserves progress, sources, results, and
298
+ citation replay. Standard Responses only.
299
+ - `standalone`: exposes `web.run` as a client-executed namespace tool and calls
300
+ the provider's `alpha/search` endpoint. It supports search/image queries,
301
+ open/click/find, PDF screenshots, finance, weather, sports, and time.
302
+
303
+ Standalone search sends a bounded recent visible conversation tail, resolved
304
+ Pi authentication, direct-caller/live-web settings, the active turn metadata,
305
+ and the model's 10,000-token truncation budget. Search rows stay compact by
306
+ default and show deduplicated source hosts; expand the tool row to inspect the
307
+ raw result text.
308
+
309
+ ## Image Generation
310
+
311
+ `tools.imageGeneration` supports:
312
+
313
+ - `hosted`: Responses `image_generation`.
314
+ - `standalone`: `image_gen.imagegen`, backed by the provider's
315
+ `images/generations` and `images/edits` endpoints.
316
+
317
+ Standalone input follows current Codex:
318
+
319
+ - required `prompt`;
320
+ - up to five `referenced_image_paths`; or
321
+ - `num_last_images_to_include` from 1 through 5.
322
+
323
+ Generated PNGs are saved under `imageOutputDir`, mirrored to `latest.png`, and
324
+ returned to the model before the saved-path text. `/image-gen` selects any
325
+ loaded image-capable model with an enabled catalog profile.
326
+
327
+ ## WebSocket And Compaction
328
+
329
+ `transport` values:
330
+
331
+ - `sse`: HTTP streaming only.
332
+ - `websocket`: reusable WebSocket; exact logical prefixes opportunistically use
333
+ `previous_response_id` input deltas.
334
+ - `websocket-cached`: compatibility alias with the same safe continuation
335
+ behavior.
336
+ - `auto`: retry transient WebSocket failures, but use sticky per-session SSE
337
+ fallback only when the WebSocket upgrade is rejected with HTTP 426. Model,
338
+ request, output-limit, context-limit, and post-upgrade connection errors do
339
+ not change transports.
340
+
341
+ Prewarm is scheduled once per session startup (including resume/fork), in the
342
+ background without delaying session initialization. If the first WebSocket
343
+ request starts while prewarm is pending, it consumes that one startup handle
344
+ before sending. Prewarm sends a best-effort `response.create` with
345
+ `generate:false` containing only the startup system/tool/request
346
+ envelope—never conversation history or the pending user message. The first real
347
+ request appends its full conversation input, and later turns continue from real
348
+ response IDs. A failed or timed-out prewarm is not retried on every user
349
+ message. Continuation reuse always requires the new request to extend the
350
+ previous logical request exactly.
351
+
352
+ Native compaction stores opaque encrypted state in the Pi session. New
353
+ checkpoints replay only to the same provider, model, API, and effective
354
+ profile hash. Switching any of those falls back to Pi's retained local
355
+ context. Treat session files containing native compaction as sensitive data.
356
+
357
+ ## Apply Patch
358
+
359
+ When `apply_patch` activates, the extension temporarily hides Pi's `edit` and
360
+ `write` tools and restores their prior positions after switching away.
361
+
362
+ The executor supports Codex `@@ class/function` contexts, ordered update
363
+ chunks, `*** Move to:`, `*** End of File`, fuzzy matching, CRLF preservation,
364
+ and atomic verification before writes. See
365
+ [`reference/apply-patch-behavior.md`](https://github.com/oai404iao/omp/blob/main/pi-extensions/pi-codex-minimal-tools/reference/apply-patch-behavior.md).
366
+
367
+ ## Legacy Migration
368
+
369
+ These `config.json` keys are deprecated but still projected into an in-memory
370
+ model override for compatibility:
371
+
372
+ | Old key | New model-profile field |
373
+ | --- | --- |
374
+ | `nativeProviderTools` | `responses.providerShim` plus hosted/standalone tool selection |
375
+ | `openaiTransport` | `responses.transport` |
376
+ | `openaiWebSocketPrewarm` | `responses.websocketPrewarm` |
377
+ | `compactionMode` | `compaction` |
378
+ | `requestProfile.responsesMode` | `responses.mode` |
379
+ | `requestProfile.reasoningSummary` | `responses.reasoningSummary` |
380
+ | `requestProfile.systemPromptPlacement` | `responses.systemPromptPlacement` |
381
+ | `requestProfile.patchTransport` | `tools.applyPatch` |
382
+ | `apiKeyMode` | `responses.endpoint` |
383
+ | `imageGeneration` | `tools.imageGeneration` |
384
+ | `webSearchEnabled` | `tools.webSearch` |
385
+ | `viewImage` | `tools.viewImage` |
386
+ | `applyPatchEnabled` | `tools.applyPatch` |
387
+ | `additionalModelIds` | one exact user catalog entry per model |
388
+
389
+ Move these values to extension `models.json`; legacy projection is intended
390
+ only as a transition path.
391
+
392
+ ## Protocol Reference
393
+
394
+ [`reference/`](https://github.com/oai404iao/omp/tree/main/pi-extensions/pi-codex-minimal-tools/reference) documents the Codex snapshot, Responses
395
+ Standard/Lite envelopes, namespace tools, WebSocket continuation, custom-tool
396
+ streaming/replay, standalone web/image endpoints, compaction, and apply-patch
397
+ protocol.
398
+
399
+ ## License and publication status
400
+
401
+ Project-authored portions are MIT-licensed, copyright 2026 oai404iao.
402
+ Third-party material retains its own terms; see
403
+ [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
404
+
405
+ The Codex namespace-tool source attribution is recorded in
406
+ `provenance/openai-codex-eb9dceba-reserved-tools.json`. The `1.3.0` source
407
+ revision is intentionally staged for its one-time manual npm bootstrap and
408
+ excluded from guarded GitHub Actions release artifacts until trusted publishing
409
+ is configured. Responses Lite remains an internal Codex compatibility path,
410
+ not an OpenAI-supported public API contract.