@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
@@ -0,0 +1,140 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "upstream": {
4
+ "repository": "https://github.com/openai/codex",
5
+ "revision": "eb9dceba1a2e658142a456c5898836774835616b",
6
+ "commitUrl": "https://github.com/openai/codex/commit/eb9dceba1a2e658142a456c5898836774835616b",
7
+ "license": "Apache-2.0"
8
+ },
9
+ "files": {
10
+ "LICENSE": {
11
+ "role": "upstream Apache-2.0 license",
12
+ "gitBlobSha": "4606e72e042564097e8780d66c1d4dcb611869bd",
13
+ "sha256": "d17f227e4df5da1600391338865ce0f3055211760a36688f816941d58232d8dc",
14
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/LICENSE"
15
+ },
16
+ "NOTICE": {
17
+ "role": "upstream NOTICE",
18
+ "gitBlobSha": "2805899d56d0332d175cfc613c67d45d6f006db7",
19
+ "sha256": "9d71575ecfd9a843fc1677b0efb08053c6ba9fd686a0de1a6f5382fd3c220915",
20
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/NOTICE"
21
+ },
22
+ "codex-rs/ext/web-search/web_run_description.md": {
23
+ "role": "exact web.run function description",
24
+ "gitBlobSha": "77be9a0a03e6e2e2760651e903ead2dce9996a57",
25
+ "sha256": "1f3879b44690eb7aad9ba97351acda16c4d0c26847bcb4af2964d5989404407e",
26
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/ext/web-search/web_run_description.md"
27
+ },
28
+ "codex-rs/ext/web-search/src/tool.rs": {
29
+ "role": "web namespace and tool construction",
30
+ "gitBlobSha": "9747b75eddd1052ee4d75e868a644de7fd4135c1",
31
+ "sha256": "6ce56d7705c4b29b91d9d39af5468788a04dd925b414c7b44de67014f3329cb3",
32
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/ext/web-search/src/tool.rs"
33
+ },
34
+ "codex-rs/ext/web-search/src/schema.rs": {
35
+ "role": "web parameter-schema generation",
36
+ "gitBlobSha": "2f71f1595c3b75d21cf78f35877f75b9314a3737",
37
+ "sha256": "6371391751d2a5dddad546aa810a6c64f770498702cec8153df74d1d7dff6f9b",
38
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/ext/web-search/src/schema.rs"
39
+ },
40
+ "codex-rs/codex-api/src/search.rs": {
41
+ "role": "web SearchCommands input types",
42
+ "gitBlobSha": "237e7a7ebff4a0eeaa6dbb7b94c457d23dfc09de",
43
+ "sha256": "a83fd7ddd41c86985cce2aa899a2907ca820c226d5e7337949cc7e47a35c5f4f",
44
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/codex-api/src/search.rs"
45
+ },
46
+ "codex-rs/ext/image-generation/imagegen_description.md": {
47
+ "role": "exact image_gen.imagegen function description",
48
+ "gitBlobSha": "368aa10ea8f1909f9171b7a7b701bba6321f6f89",
49
+ "sha256": "77a992a7c90e45fcd11623a1efa34bfd4c7870697e0aa54ce9b28f690877170e",
50
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/ext/image-generation/imagegen_description.md"
51
+ },
52
+ "codex-rs/ext/image-generation/src/lib.rs": {
53
+ "role": "image namespace and function names",
54
+ "gitBlobSha": "fd9db419309e5b06acb944a553f5ef144c8a261d",
55
+ "sha256": "c710abe1967cd3f7faaf78c0a35de0f5e6cc5c461f130b79d2b25d27ba8df9de",
56
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/ext/image-generation/src/lib.rs"
57
+ },
58
+ "codex-rs/ext/image-generation/src/tool.rs": {
59
+ "role": "image namespace-tool construction and ImagegenArgs schema",
60
+ "gitBlobSha": "ab973da74cec4de053cbe943171bb9ad5703bad6",
61
+ "sha256": "8b8abe637c63e1fa8f52340a4609d96f37a5089364c4d82f0e695fd6731b2206",
62
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/ext/image-generation/src/tool.rs"
63
+ },
64
+ "codex-rs/tools/src/responses_api.rs": {
65
+ "role": "namespace serialization and descriptions",
66
+ "gitBlobSha": "e450dcf35f93ab4af7bf3f34956755066114ccae",
67
+ "sha256": "7af0354e43c3fa7f052d86df5ae0c6ce276569243af6f6ea5fe00abcb15bd244",
68
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/tools/src/responses_api.rs"
69
+ },
70
+ "codex-rs/tools/src/tool_spec.rs": {
71
+ "role": "Responses Lite namespace-tool serialization",
72
+ "gitBlobSha": "530da1be164ce3c6aa4b128ccb878bda7025e217",
73
+ "sha256": "af8b5286fb6d2eb3574c484b25076f515bca2d4350ecb5059e436966ecdd519d",
74
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/tools/src/tool_spec.rs"
75
+ },
76
+ "codex-rs/core/src/client.rs": {
77
+ "role": "Responses Lite additional_tools placement",
78
+ "gitBlobSha": "da3b6dad382fd4520026ac447c270e5cc11fa887",
79
+ "sha256": "4b4d00234a7fb649525fdcc913ffe288e4ef3348a916acbd265c22607fd8652d",
80
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/core/src/client.rs"
81
+ },
82
+ "codex-rs/Cargo.toml": {
83
+ "role": "pinned workspace dependency manifest for schema generation",
84
+ "gitBlobSha": "f23232e3d0b8246330d2409fc7fe9690062075c2",
85
+ "sha256": "2e8122fdd528a4d648d9417865153827dc5f7b45ee3afd86bfb129a1e01dcdb8",
86
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/Cargo.toml"
87
+ },
88
+ "codex-rs/Cargo.lock": {
89
+ "role": "pinned schema-generator dependency lockfile",
90
+ "gitBlobSha": "a67d1f3d7b062424d881a612f4cfd8b14e0ac630",
91
+ "sha256": "3a4a5361f289227c1ce09dc072811a1e7d1c7b599c58dd91dce6758d187c993d",
92
+ "rawUrl": "https://raw.githubusercontent.com/openai/codex/eb9dceba1a2e658142a456c5898836774835616b/codex-rs/Cargo.lock"
93
+ }
94
+ },
95
+ "localCompatibilitySerialization": {
96
+ "path": "src/codex-reserved-tools.ts",
97
+ "classification": "modified TypeScript compatibility serialization",
98
+ "boundary": "This local compatibility path uses an internal Codex Responses Lite shape and does not claim a stable or OpenAI-supported public API contract.",
99
+ "canonicalization": "SHA-256 of recursively lexicographically sorted JSON object keys; arrays retain their order and no whitespace is emitted.",
100
+ "namespaces": {
101
+ "web_search": {
102
+ "namespace": "web",
103
+ "function": "run",
104
+ "description": {
105
+ "sourcePath": "codex-rs/ext/web-search/web_run_description.md",
106
+ "relationship": "byte-for-byte",
107
+ "sha256": "1f3879b44690eb7aad9ba97351acda16c4d0c26847bcb4af2964d5989404407e"
108
+ },
109
+ "parameters": {
110
+ "sourcePaths": [
111
+ "codex-rs/ext/web-search/src/tool.rs",
112
+ "codex-rs/ext/web-search/src/schema.rs",
113
+ "codex-rs/codex-api/src/search.rs"
114
+ ],
115
+ "relationship": "compatibility serialization",
116
+ "canonicalJsonSha256": "de3be87e7abfe9b67ba757f27804d4206b51c2a8de9e9799fa7db9ef4abe3539"
117
+ },
118
+ "canonicalJsonSha256": "f67597d3df3f3a77cb517646508e7305804ea029c6f8b1c1c1f241f0de0b214f"
119
+ },
120
+ "image_generation": {
121
+ "namespace": "image_gen",
122
+ "function": "imagegen",
123
+ "description": {
124
+ "sourcePath": "codex-rs/ext/image-generation/imagegen_description.md",
125
+ "relationship": "byte-for-byte",
126
+ "sha256": "77a992a7c90e45fcd11623a1efa34bfd4c7870697e0aa54ce9b28f690877170e"
127
+ },
128
+ "parameters": {
129
+ "sourcePaths": [
130
+ "codex-rs/ext/image-generation/src/lib.rs",
131
+ "codex-rs/ext/image-generation/src/tool.rs"
132
+ ],
133
+ "relationship": "compatibility serialization",
134
+ "canonicalJsonSha256": "b4fea7c38ae74635e0072643ac2030899db242657071271e13cdd192a7377a27"
135
+ },
136
+ "canonicalJsonSha256": "ccc508cff0a216bbdf368be8c98be94134a1aed0479cddd28c77d8e004f5b73e"
137
+ }
138
+ }
139
+ }
140
+ }
@@ -0,0 +1,56 @@
1
+ import type { ModelLike } from "./capabilities.js";
2
+ import { listResolvedModelProfiles, resolveModelProfile } from "./model-catalog/catalog.js";
3
+ import type { CodexMinimalToolsSettings } from "./settings.js";
4
+
5
+ export interface ModelRegistryLike {
6
+ getAll?: () => unknown;
7
+ getAvailable?: () => unknown;
8
+ find?: (provider: string, id: string) => unknown;
9
+ }
10
+
11
+ export interface ActivationContextLike {
12
+ model?: ModelLike;
13
+ modelRegistry?: ModelRegistryLike;
14
+ }
15
+
16
+ export function registryModels(registry: ModelRegistryLike | undefined): ModelLike[] {
17
+ if (!registry) return [];
18
+ for (const method of [registry.getAll, registry.getAvailable]) {
19
+ if (typeof method !== "function") continue;
20
+ try {
21
+ const value = method.call(registry);
22
+ if (Array.isArray(value)) return value.filter((model): model is ModelLike => Boolean(model) && typeof model === "object");
23
+ } catch {
24
+ // Try the next registry shape.
25
+ }
26
+ }
27
+ return [];
28
+ }
29
+
30
+ export function hasConfiguredModelsLoaded(
31
+ ctx: ActivationContextLike,
32
+ settings?: CodexMinimalToolsSettings,
33
+ ): boolean {
34
+ const current = resolveModelProfile(ctx.model, { settings });
35
+ if (current?.effective.enabled) return true;
36
+ const configured = new Set(
37
+ listResolvedModelProfiles({ settings })
38
+ .filter((profile) => profile.effective.enabled)
39
+ .map((profile) => profile.id.toLowerCase()),
40
+ );
41
+ if (registryModels(ctx.modelRegistry).some((model) => {
42
+ const provider = model.provider?.trim().toLowerCase();
43
+ const id = model.id?.trim().toLowerCase();
44
+ return Boolean(provider && id && configured.has(`${provider}/${id}`));
45
+ })) {
46
+ return true;
47
+ }
48
+ try {
49
+ return [...configured].some((fullId) => {
50
+ const slash = fullId.indexOf("/");
51
+ return Boolean(ctx.modelRegistry?.find?.(fullId.slice(0, slash), fullId.slice(slash + 1)));
52
+ });
53
+ } catch {
54
+ return false;
55
+ }
56
+ }