@oai404iao/pi-codex-minimal-tools 1.4.0 → 2.0.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 (99) hide show
  1. package/README.md +44 -17
  2. package/THIRD_PARTY_NOTICES.md +20 -0
  3. package/config.schema.json +1 -2
  4. package/index.ts +2 -0
  5. package/package.json +14 -13
  6. package/provenance/openai-codex-ddea03ad-astra.json +54 -0
  7. package/src/activation.ts +1 -56
  8. package/src/adapter/compaction/checkpoint.ts +1 -0
  9. package/src/adapter/compaction/collect.ts +1 -0
  10. package/src/adapter/compaction/http.ts +1 -0
  11. package/src/adapter/compaction/request.ts +1 -0
  12. package/src/adapter/compaction/transport.ts +1 -0
  13. package/src/adapter/compaction/websocket.ts +1 -0
  14. package/src/background-image-generation.ts +1 -574
  15. package/src/capabilities.ts +1 -146
  16. package/src/codex-http.ts +1 -133
  17. package/src/codex-identity-extension.ts +1 -339
  18. package/src/codex-request-profile.ts +1 -45
  19. package/src/codex-reserved-tools.ts +1 -323
  20. package/src/codex-wire-identity.ts +1 -596
  21. package/src/extension/prewarm-snapshot.ts +1 -0
  22. package/src/extension/provider-presentation.ts +1 -0
  23. package/src/extension/provider-runtime.ts +1 -0
  24. package/src/extension/register.ts +36 -0
  25. package/src/extension/startup-prewarm.ts +1 -0
  26. package/src/fast-mode.ts +1 -124
  27. package/src/glyphs.ts +1 -70
  28. package/src/index.ts +8 -331
  29. package/src/model-catalog/catalog.ts +1 -636
  30. package/src/model-catalog/default-models.json +8 -0
  31. package/src/model-catalog/runtime.ts +1 -113
  32. package/src/model-catalog/types.ts +1 -95
  33. package/src/native-compaction.ts +1 -393
  34. package/src/patch/apply.ts +1 -338
  35. package/src/patch/parser.ts +1 -224
  36. package/src/patch/render.ts +1 -201
  37. package/src/provider-headers.ts +1 -54
  38. package/src/provider-native-tools.ts +1 -71
  39. package/src/provider-shim.ts +20 -4511
  40. package/src/providers/codex-apply-patch-tool.ts +1 -23
  41. package/src/providers/openai-codex/cache-key.ts +1 -0
  42. package/src/providers/openai-codex/captured-stream.ts +1 -0
  43. package/src/providers/openai-codex/constants.ts +1 -0
  44. package/src/providers/openai-codex/continuation.ts +1 -0
  45. package/src/providers/openai-codex/errors.ts +1 -0
  46. package/src/providers/openai-codex/events.ts +1 -0
  47. package/src/providers/openai-codex/headers.ts +1 -0
  48. package/src/providers/openai-codex/lite.ts +1 -0
  49. package/src/providers/openai-codex/message.ts +1 -0
  50. package/src/providers/openai-codex/prewarm.ts +1 -0
  51. package/src/providers/openai-codex/proxy.ts +1 -0
  52. package/src/providers/openai-codex/reasoning.ts +1 -0
  53. package/src/providers/openai-codex/request-body.ts +1 -0
  54. package/src/providers/openai-codex/request-context.ts +1 -0
  55. package/src/providers/openai-codex/request-metadata.ts +1 -0
  56. package/src/providers/openai-codex/retry.ts +1 -0
  57. package/src/providers/openai-codex/runtime.ts +1 -0
  58. package/src/providers/openai-codex/sse.ts +1 -0
  59. package/src/providers/openai-codex/stream-effects.ts +1 -0
  60. package/src/providers/openai-codex/stream.ts +1 -0
  61. package/src/providers/openai-codex/types.ts +1 -0
  62. package/src/providers/openai-codex/urls.ts +1 -0
  63. package/src/providers/openai-codex/usage.ts +1 -0
  64. package/src/providers/openai-codex/websocket-connection.ts +1 -0
  65. package/src/providers/openai-codex/websocket-events.ts +1 -0
  66. package/src/providers/openai-codex/websocket-session.ts +1 -0
  67. package/src/providers/openai-codex/websocket-socket.ts +1 -0
  68. package/src/providers/openai-codex/websocket-stream.ts +1 -0
  69. package/src/providers/openai-responses-shared.ts +7 -1463
  70. package/src/providers/responses/citations.ts +1 -0
  71. package/src/providers/responses/history.ts +1 -0
  72. package/src/providers/responses/items.ts +1 -0
  73. package/src/providers/responses/markdown.ts +1 -0
  74. package/src/providers/responses/messages.ts +1 -0
  75. package/src/providers/responses/signatures.ts +1 -0
  76. package/src/providers/responses/stream-state.ts +1 -0
  77. package/src/providers/responses/stream.ts +1 -0
  78. package/src/providers/responses/text-renderer.ts +1 -0
  79. package/src/providers/responses/text.ts +1 -0
  80. package/src/providers/responses/tool-identity.ts +1 -0
  81. package/src/providers/responses/tools.ts +1 -0
  82. package/src/providers/responses/types.ts +1 -0
  83. package/src/providers/responses/usage.ts +1 -0
  84. package/src/settings.ts +1 -247
  85. package/src/subagent-inline.ts +1 -8
  86. package/src/tools/apply-patch.ts +1 -84
  87. package/src/tools/image-generation/capture.ts +1 -0
  88. package/src/tools/image-generation/display.ts +1 -0
  89. package/src/tools/image-generation/preview.ts +1 -0
  90. package/src/tools/image-generation/storage.ts +1 -0
  91. package/src/tools/image-generation/types.ts +1 -0
  92. package/src/tools/image-generation.ts +1 -274
  93. package/src/tools/view-image.ts +1 -98
  94. package/src/tools/web-search/activity.ts +1 -0
  95. package/src/tools/web-search/capture.ts +1 -0
  96. package/src/tools/web-search/render.ts +1 -0
  97. package/src/tools/web-search.ts +1 -554
  98. package/src/utils/images.ts +1 -73
  99. package/src/utils/theme.ts +1 -0
@@ -1,323 +1 @@
1
- /*
2
- * SPDX-FileCopyrightText: 2025 OpenAI
3
- * SPDX-FileCopyrightText: 2026 oai404iao
4
- * SPDX-License-Identifier: Apache-2.0
5
- *
6
- * Modified TypeScript compatibility serialization derived from the namespace
7
- * tool construction in OpenAI Codex at revision
8
- * eb9dceba1a2e658142a456c5898836774835616b.
9
- *
10
- * This preserves the reviewed `web.run` and `image_gen.imagegen` declaration
11
- * shapes for this package's internal Responses Lite compatibility path. It is
12
- * not an OpenAI-supported public API contract. Immutable upstream blob IDs,
13
- * source hashes, and local compatibility fingerprints are recorded in
14
- * provenance/openai-codex-eb9dceba-reserved-tools.json.
15
- *
16
- * See THIRD_PARTY_NOTICES.md and LICENSES/Apache-2.0.txt.
17
- */
18
-
19
- export type CodexReservedToolName = "web_search" | "image_generation";
20
-
21
- export interface CodexReservedNamespaceTool {
22
- type: "namespace";
23
- name: "web" | "image_gen";
24
- description: string;
25
- tools: Array<{
26
- type: "function";
27
- name: "run" | "imagegen";
28
- description: string;
29
- strict: false;
30
- parameters: Record<string, unknown>;
31
- }>;
32
- }
33
-
34
- const CODEX_RESERVED_NAMESPACE_TOOLS: Record<CodexReservedToolName, CodexReservedNamespaceTool> = {
35
- web_search: {
36
- type: "namespace",
37
- name: "web",
38
- description: "Tools in the web namespace.",
39
- tools: [
40
- {
41
- type: "function",
42
- name: "run",
43
- description: "Tool for accessing the internet.\n\n\n---\n\n## Examples of different commands available in this tool\n\nExamples of different commands available in this tool:\n* `search_query`: {\"search_query\": [{\"q\": \"What is the capital of France?\"}, {\"q\": \"What is the capital of belgium?\"}]}. Searches the internet for a given query (and optionally with a domain or recency filter)\n* `image_query`: {\"image_query\":[{\"q\": \"waterfalls\"}]}.\n* `open`: {\"open\": [{\"ref_id\": \"turn0search0\"}, {\"ref_id\": \"https://www.openai.com\", \"lineno\": 120}]}\n* `click`: {\"click\": [{\"ref_id\": \"turn0fetch3\", \"id\": 17}]}\n* `find`: {\"find\": [{\"ref_id\": \"turn0fetch3\", \"pattern\": \"Annie Case\"}]}\n* `screenshot`: {\"screenshot\": [{\"ref_id\": \"turn1view0\", \"pageno\": 0}, {\"ref_id\": \"turn1view0\", \"pageno\": 3}]}\n* `finance`: {\"finance\":[{\"ticker\":\"AMD\",\"type\":\"equity\",\"market\":\"USA\"}]}, {\"finance\":[{\"ticker\":\"BTC\",\"type\":\"crypto\",\"market\":\"\"}]}\n* `weather`: {\"weather\":[{\"location\":\"San Francisco, CA\"}]}\n* `sports`: {\"sports\":[{\"fn\":\"standings\",\"league\":\"nfl\"}, {\"fn\":\"schedule\",\"league\":\"nba\",\"team\":\"GSW\",\"date_from\":\"2025-02-24\"}]}\n* `time`: {\"time\":[{\"utc_offset\":\"+03:00\"}]}\n\n---\n\n## Usage hints\nTo use this tool efficiently:\n* Use multiple commands and queries in one call to get more results faster; e.g. {\"search_query\": [{\"q\": \"bitcoin news\"}], \"finance\":[{\"ticker\":\"BTC\",\"type\":\"crypto\",\"market\":\"\"}], \"find\": [{\"ref_id\": \"turn0search0\", \"pattern\": \"Annie Case\"}, {\"ref_id\": \"turn0search1\", \"pattern\": \"John Smith\"}]}\n* Use \"response_length\" to control the number of results returned by this tool, omit it if you intend to pass \"short\" in\n* Only write required parameters; do not write empty lists or nulls where they could be omitted.\n* `search_query` must have length at most 4 in each call. If it has length > 3, response_length must be medium or long\n* If you find yourself in a situation where you accidentally call the `web.run` tool, it's best just to send an empty query: {\"search_query\": [{\"q\": \"\"}]}.\n\n---\n\n## Decision boundary\n\nIf the user makes an explicit request to search the internet, find latest information, look up, etc (or to not do so), you must obey their request.\nWhen you make an assumption, always consider whether it is temporally stable; i.e. whether there's even a small (>10%) chance it has changed. If it is unstable, you must verify with browsing the internet for verification.\n\n<situations_where_you_must_browse_the_internet>\nBelow is a list of scenarios where browsing the internet MUST be used. PAY CLOSE ATTENTION: you MUST browse the internet in these cases. If you're unsure or on the fence, you MUST bias towards browsing the internet.\n- The information could have changed recently: for example news; prices; laws; schedules; product specs; sports scores; economic indicators; political/public/company figures (e.g. the question relates to 'the president of country A' or 'the CEO of company B', which might change over time); rules; regulations; standards; software libraries that could be updated; exchange rates; recommendations (i.e., recommendations about various topics or things might be informed by what currently exists / is popular / is safe / is unsafe / is in the zeitgeist / etc.); and many many many more categories -- again, if you're on the fence, you MUST browse the internet!\n - For news queries, prioritize more recent events, ensuring you compare publish dates and the date that the event happened.\n- The user is seeking recommendations that could lead them to spend substantial time or money -- researching products, restaurants, travel plans, etc.\n- The user wants (or would benefit from) direct quotes, links, or precise source attribution.\n- A specific page, paper, dataset, PDF, or site is referenced and you haven't been given its contents.\n- You're unsure about a fact, the topic is niche or emerging, or you suspect there's at least a 10% chance you will incorrectly recall it\n- High-stakes accuracy matters (medical, legal, financial guidance). For these you generally should search by default because this information is highly temporally unstable\n- The user explicitly says to search, browse, verify, or look it up.\n</situations_where_you_must_browse_the_internet>\n\n---\n\n## Citations\n\nResults from `web.run` include internal reference IDs such as `turn2search5`. Use\nthose reference IDs only in calls to `web.run`; do not expose them in the final\nresponse.\n\nCite sources in the final response using Markdown links:\n\n- Cite a single source as `[descriptive source title](https://example.com/page)`.\n- Cite multiple sources with separate Markdown links, for example\n `[first source](https://example.com/one), [second source](https://example.com/two)`.\n- Link directly to the page that supports the claim. Do not link to search result\n pages or use bare URLs.\n\nFormatting of citations:\n\n- Place each citation as near as possible to the claim it supports, normally at\n the end of the sentence or paragraph and after punctuation.\n- Do not place citations inside code fences.\n- Do not put citations on a line by themselves or collect all citations at the\n end of the response.\n\nIf you browse the internet, cite statements supported by web sources. Each cited\nsource must directly support the associated claim. Prefer primary and\nauthoritative sources, and use sources from different domains when the response\nbenefits from multiple perspectives.\n\n---\n\n## Special cases\nIf these conflict with any other instructions, these should take precedence.\n\n<special_cases>\n- When the user asks for information about how to use OpenAI products, (ChatGPT, the OpenAI API, etc.), you should check the code in local env and only browse as fallback, when you browse restrict your sources to official OpenAI websites using the domains filter, unless otherwise requested.\n- When using search to answer technical questions, you must only rely on primary sources (research papers, official documentation, etc.)\n- Clearly indicate when you are making an inference from sources.\n</special_cases>\n\n---\n\n## Word limits\nResponses may not excessively quote or draw on a specific source. There are several limits here:\n- **Limit on verbatim quotes:**\n - You may not quote more than 25 words verbatim from any single non-lyrical source, unless the source is reddit.\n - For song lyrics, verbatim quotes must be limited to at most 10 words.\n - Long quotes from reddit are allowed, as long as you indicate that those are direct quotes via a markdown blockquote starting with \">\", copy verbatim, and link the source.\n- **Word limits:**\n - Each webpage source in the sources has a word limit label formatted like \"[wordlim N]\", in which N is the maximum number of words in the whole response that are attributed to that source. If omitted, the word limit is 200 words.\n - Non-contiguous words derived from a given source must be counted to the word limit.\n - The summarization limit N is a maximum for each source.\n - When using multiple sources, their summarization limits add together. However, each article used must be relevant to the response.\n- **Copyright compliance:**\n - You must avoid providing full articles, long verbatim passages, or extensive direct quotes due to copyright concerns.\n - If the user asked for a verbatim quote, the response should provide a short compliant excerpt and then answer with paraphrases and summaries.\n - Again, this limit does not apply to reddit content, as long as it's appropriately indicated that those are direct quotes and you link to the source.\n",
44
- strict: false,
45
- parameters: {
46
- type: "object",
47
- properties: {
48
- click: {
49
- type: "array",
50
- description: "Open links from previously opened pages.",
51
- items: {
52
- type: "object",
53
- properties: {
54
- id: {
55
- type: "integer",
56
- description: "Numbered link id to open.",
57
- },
58
- ref_id: {
59
- type: "string",
60
- description: "Reference id containing the numbered link.",
61
- },
62
- },
63
- required: ["id", "ref_id"],
64
- },
65
- },
66
- finance: {
67
- type: "array",
68
- description: "Look up prices for the given stock symbols.",
69
- items: {
70
- type: "object",
71
- properties: {
72
- market: {
73
- type: "string",
74
- description: "ISO 3166-1 alpha-3 country code, \"OTC\", or \"\" for cryptocurrency.",
75
- },
76
- ticker: {
77
- type: "string",
78
- description: "Ticker symbol to look up.",
79
- },
80
- type: {
81
- type: "string",
82
- description: "Asset type to look up.",
83
- enum: ["equity", "fund", "crypto", "index"],
84
- },
85
- },
86
- required: ["ticker", "type"],
87
- },
88
- },
89
- find: {
90
- type: "array",
91
- description: "Find text patterns in pages.",
92
- items: {
93
- type: "object",
94
- properties: {
95
- pattern: {
96
- type: "string",
97
- description: "Text pattern to find.",
98
- },
99
- ref_id: {
100
- type: "string",
101
- description: "Reference id or URL to search within.",
102
- },
103
- },
104
- required: ["pattern", "ref_id"],
105
- },
106
- },
107
- image_query: {
108
- type: "array",
109
- description: "Query the image search engine for a given list of queries.",
110
- items: {
111
- type: "object",
112
- properties: {
113
- domains: {
114
- type: "array",
115
- description: "Whether to filter by a specific list of domains.",
116
- items: { type: "string" },
117
- },
118
- q: {
119
- type: "string",
120
- description: "Search query.",
121
- },
122
- recency: {
123
- type: "integer",
124
- description: "Whether to filter by recency, as a number of recent days.",
125
- },
126
- },
127
- required: ["q"],
128
- },
129
- },
130
- open: {
131
- type: "array",
132
- description: "Open pages by reference id or URL.",
133
- items: {
134
- type: "object",
135
- properties: {
136
- lineno: {
137
- type: "integer",
138
- description: "Line number to position the page at.",
139
- },
140
- ref_id: {
141
- type: "string",
142
- description: "Reference id or URL to open.",
143
- },
144
- },
145
- required: ["ref_id"],
146
- },
147
- },
148
- response_length: {
149
- type: "string",
150
- description: "Set the length of the response to be returned.",
151
- enum: ["short", "medium", "long"],
152
- },
153
- screenshot: {
154
- type: "array",
155
- description: "Take screenshots of PDF pages.",
156
- items: {
157
- type: "object",
158
- properties: {
159
- pageno: {
160
- type: "integer",
161
- description: "Zero-indexed PDF page number.",
162
- },
163
- ref_id: {
164
- type: "string",
165
- description: "Reference id or URL to screenshot.",
166
- },
167
- },
168
- required: ["pageno", "ref_id"],
169
- },
170
- },
171
- search_query: {
172
- type: "array",
173
- description: "Query the internet search engine for a given list of queries.",
174
- items: {
175
- type: "object",
176
- properties: {
177
- domains: {
178
- type: "array",
179
- description: "Whether to filter by a specific list of domains.",
180
- items: { type: "string" },
181
- },
182
- q: {
183
- type: "string",
184
- description: "Search query.",
185
- },
186
- recency: {
187
- type: "integer",
188
- description: "Whether to filter by recency, as a number of recent days.",
189
- },
190
- },
191
- required: ["q"],
192
- },
193
- },
194
- sports: {
195
- type: "array",
196
- description: "Look up sports schedules and standings.",
197
- items: {
198
- type: "object",
199
- properties: {
200
- date_from: {
201
- type: "string",
202
- description: "Start date in YYYY-MM-DD format.",
203
- },
204
- date_to: {
205
- type: "string",
206
- description: "End date in YYYY-MM-DD format.",
207
- },
208
- fn: {
209
- type: "string",
210
- description: "Sports function to call.",
211
- enum: ["schedule", "standings"],
212
- },
213
- league: {
214
- type: "string",
215
- description: "League to look up.",
216
- enum: ["nba", "wnba", "nfl", "nhl", "mlb", "epl", "ncaamb", "ncaawb", "ipl"],
217
- },
218
- locale: {
219
- type: "string",
220
- description: "Locale for the lookup.",
221
- },
222
- num_games: {
223
- type: "integer",
224
- description: "Number of games to return.",
225
- },
226
- opponent: {
227
- type: "string",
228
- description: "Opponent to use with `team` when narrowing the lookup.",
229
- },
230
- team: {
231
- type: "string",
232
- description: "Team to look up, using the common 3 or 4 letter alias used in broadcasts.",
233
- },
234
- tool: {
235
- type: "string",
236
- description: "Tool name for sports requests.",
237
- enum: ["sports"],
238
- },
239
- },
240
- required: ["fn", "league"],
241
- },
242
- },
243
- time: {
244
- type: "array",
245
- description: "Get time for the given UTC offsets.",
246
- items: {
247
- type: "object",
248
- properties: {
249
- utc_offset: {
250
- type: "string",
251
- description: "UTC offset formatted like \"+03:00\".",
252
- },
253
- },
254
- required: ["utc_offset"],
255
- },
256
- },
257
- weather: {
258
- type: "array",
259
- description: "Look up weather forecasts.",
260
- items: {
261
- type: "object",
262
- properties: {
263
- duration: {
264
- type: "integer",
265
- description: "Number of days to return. Defaults to 7.",
266
- },
267
- location: {
268
- type: "string",
269
- description: "Location in \"Country, Area, City\" format.",
270
- },
271
- start: {
272
- type: "string",
273
- description: "Start date in YYYY-MM-DD format. Defaults to today.",
274
- },
275
- },
276
- required: ["location"],
277
- },
278
- },
279
- },
280
- },
281
- },
282
- ],
283
- },
284
- image_generation: {
285
- type: "namespace",
286
- name: "image_gen",
287
- description: "Tools in the image_gen namespace.",
288
- tools: [
289
- {
290
- type: "function",
291
- name: "imagegen",
292
- description: "The `image_gen.imagegen` tool enables image generation from descriptions and editing of existing images based on specific instructions. Use it when:\n\n- The user requests an image based on a scene description, such as a diagram, portrait, comic, meme, or any other visual.\n- The user wants to modify an attached or previously generated image with specific changes, including adding or removing elements, altering colors, improving quality/resolution, or transforming the style (e.g., cartoon, oil painting).\n\nGuidelines:\n- imagegen needs a few minutes to finish. In code-mode, use the first-line @exec directive to give the initial call 120 seconds and the same yield for any waits that follow. Once it finishes, return the image with generatedImage(result).\n- Omit both `referenced_image_paths` and `num_last_images_to_include` when generating a brand new image.\n- For edits, use `referenced_image_paths` when every target image has a local file path.\n- If you have not seen a local image yet, use `view_image` to inspect it before editing.\n- Use `num_last_images_to_include` only when at least one target image has no local file path.\n- Set `num_last_images_to_include` to the smallest number of recent conversation images that includes every target image, up to 5.\n- Never provide both `referenced_image_paths` and `num_last_images_to_include`.\n- If neither mechanism can include every target image, ask the user to attach the missing images again.\n- Directly generate the image without reconfirmation or clarification unless required images must be attached again.\n- Always use this tool for image editing unless the user explicitly requests otherwise. Do not use the `python` tool for image editing unless specifically instructed.\n",
293
- strict: false,
294
- parameters: {
295
- type: "object",
296
- properties: {
297
- num_last_images_to_include: {
298
- type: ["integer", "null"],
299
- },
300
- prompt: {
301
- type: "string",
302
- },
303
- referenced_image_paths: {
304
- type: ["array", "null"],
305
- items: {
306
- type: "string",
307
- description: "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
308
- },
309
- },
310
- },
311
- required: ["prompt"],
312
- additionalProperties: false,
313
- },
314
- },
315
- ],
316
- },
317
- };
318
-
319
- export function createCodexReservedNamespaceTool(
320
- name: CodexReservedToolName,
321
- ): CodexReservedNamespaceTool {
322
- return structuredClone(CODEX_RESERVED_NAMESPACE_TOOLS[name]);
323
- }
1
+ export * from "@oai404iao/pi-codex-runtime/internal/codex-reserved-tools";