codex-multi-auth 0.1.0 → 0.1.2

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 (124) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +223 -98
  3. package/assets/readme-hero.svg +31 -31
  4. package/config/README.md +30 -87
  5. package/config/{opencode-legacy.json → codex-legacy.json} +571 -571
  6. package/config/{opencode-modern.json → codex-modern.json} +241 -239
  7. package/config/{minimal-opencode.json → minimal-codex.json} +15 -13
  8. package/config/schema/config.schema.json +21 -0
  9. package/dist/index.d.ts +5 -5
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +23 -20
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/accounts.d.ts +1 -1
  14. package/dist/lib/accounts.d.ts.map +1 -1
  15. package/dist/lib/auth/auth.d.ts +1 -1
  16. package/dist/lib/auth/auth.js +1 -1
  17. package/dist/lib/cli.d.ts +1 -1
  18. package/dist/lib/cli.js +4 -4
  19. package/dist/lib/cli.js.map +1 -1
  20. package/dist/lib/codex-manager/settings-hub.d.ts +6 -0
  21. package/dist/lib/codex-manager/settings-hub.d.ts.map +1 -0
  22. package/dist/lib/codex-manager/settings-hub.js +1786 -0
  23. package/dist/lib/codex-manager/settings-hub.js.map +1 -0
  24. package/dist/lib/codex-manager.d.ts.map +1 -1
  25. package/dist/lib/codex-manager.js +5 -1637
  26. package/dist/lib/codex-manager.js.map +1 -1
  27. package/dist/lib/config.d.ts.map +1 -1
  28. package/dist/lib/config.js +20 -11
  29. package/dist/lib/config.js.map +1 -1
  30. package/dist/lib/context-overflow.d.ts +1 -1
  31. package/dist/lib/context-overflow.js +11 -11
  32. package/dist/lib/oauth-success.html +1 -1
  33. package/dist/lib/prompts/codex-host-bridge.d.ts +19 -0
  34. package/dist/lib/prompts/codex-host-bridge.d.ts.map +1 -0
  35. package/dist/lib/prompts/{codex-opencode-bridge.js → codex-host-bridge.js} +143 -143
  36. package/dist/lib/prompts/codex-host-bridge.js.map +1 -0
  37. package/dist/lib/prompts/codex.d.ts +2 -2
  38. package/dist/lib/prompts/codex.d.ts.map +1 -1
  39. package/dist/lib/prompts/codex.js +3 -3
  40. package/dist/lib/prompts/host-codex-prompt.d.ts +25 -0
  41. package/dist/lib/prompts/host-codex-prompt.d.ts.map +1 -0
  42. package/dist/lib/prompts/{opencode-codex.js → host-codex-prompt.js} +136 -47
  43. package/dist/lib/prompts/host-codex-prompt.js.map +1 -0
  44. package/dist/lib/recovery/storage.d.ts +2 -2
  45. package/dist/lib/recovery/storage.js +2 -2
  46. package/dist/lib/recovery/types.d.ts +1 -1
  47. package/dist/lib/recovery/types.js +1 -1
  48. package/dist/lib/recovery.d.ts +1 -1
  49. package/dist/lib/recovery.d.ts.map +1 -1
  50. package/dist/lib/recovery.js +1 -4
  51. package/dist/lib/recovery.js.map +1 -1
  52. package/dist/lib/request/fetch-helpers.d.ts +3 -3
  53. package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
  54. package/dist/lib/request/fetch-helpers.js +6 -2
  55. package/dist/lib/request/fetch-helpers.js.map +1 -1
  56. package/dist/lib/request/helpers/input-utils.d.ts +2 -2
  57. package/dist/lib/request/helpers/input-utils.d.ts.map +1 -1
  58. package/dist/lib/request/helpers/input-utils.js +14 -14
  59. package/dist/lib/request/helpers/input-utils.js.map +1 -1
  60. package/dist/lib/request/helpers/model-map.d.ts +2 -2
  61. package/dist/lib/request/helpers/model-map.js +2 -2
  62. package/dist/lib/request/request-transformer.d.ts +12 -12
  63. package/dist/lib/request/request-transformer.d.ts.map +1 -1
  64. package/dist/lib/request/request-transformer.js +23 -24
  65. package/dist/lib/request/request-transformer.js.map +1 -1
  66. package/dist/lib/runtime-paths.d.ts +4 -4
  67. package/dist/lib/runtime-paths.d.ts.map +1 -1
  68. package/dist/lib/runtime-paths.js +57 -13
  69. package/dist/lib/runtime-paths.js.map +1 -1
  70. package/dist/lib/storage/paths.d.ts +11 -0
  71. package/dist/lib/storage/paths.d.ts.map +1 -1
  72. package/dist/lib/storage/paths.js +167 -5
  73. package/dist/lib/storage/paths.js.map +1 -1
  74. package/dist/lib/storage.d.ts +1 -0
  75. package/dist/lib/storage.d.ts.map +1 -1
  76. package/dist/lib/storage.js +290 -81
  77. package/dist/lib/storage.js.map +1 -1
  78. package/dist/lib/tools/hashline-tools.d.ts +1 -1
  79. package/dist/lib/tools/hashline-tools.d.ts.map +1 -1
  80. package/dist/lib/tools/hashline-tools.js +1 -1
  81. package/dist/lib/tools/hashline-tools.js.map +1 -1
  82. package/dist/lib/types.d.ts +1 -1
  83. package/dist/lib/types.d.ts.map +1 -1
  84. package/dist/lib/ui/copy.d.ts +6 -6
  85. package/dist/lib/ui/copy.js +6 -6
  86. package/dist/lib/ui/copy.js.map +1 -1
  87. package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -0
  88. package/node_modules/@codex-ai/plugin/dist/index.js +2 -0
  89. package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -0
  90. package/node_modules/@codex-ai/plugin/dist/tool.js +29 -0
  91. package/node_modules/@codex-ai/plugin/package.json +9 -0
  92. package/package.json +30 -16
  93. package/scripts/audit-dev-allowlist.js +128 -128
  94. package/scripts/bench-format/{opencode.mjs → codex-host.mjs} +206 -205
  95. package/scripts/bench-format/hashline-v2.mjs +642 -642
  96. package/scripts/bench-format/models.mjs +111 -105
  97. package/scripts/bench-format/render.mjs +496 -496
  98. package/scripts/bench-format/stats.mjs +54 -54
  99. package/scripts/bench-format/tasks.mjs +151 -151
  100. package/scripts/benchmark-edit-formats.mjs +1162 -1161
  101. package/scripts/benchmark-render-dashboard.mjs +49 -49
  102. package/scripts/codex.js +40 -2
  103. package/scripts/copy-oauth-success.js +37 -37
  104. package/scripts/install-codex-auth-utils.js +49 -0
  105. package/scripts/{install-opencode-codex-auth.js → install-codex-auth.js} +220 -193
  106. package/scripts/repo-hygiene.js +320 -0
  107. package/scripts/test-all-models.sh +7 -7
  108. package/scripts/test-model-matrix.js +475 -423
  109. package/scripts/validate-model-map.sh +7 -7
  110. package/vendor/codex-ai-plugin/dist/index.d.ts +2 -0
  111. package/vendor/codex-ai-plugin/dist/index.js +2 -0
  112. package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -0
  113. package/vendor/codex-ai-plugin/dist/tool.js +29 -0
  114. package/vendor/codex-ai-plugin/package.json +9 -0
  115. package/vendor/codex-ai-sdk/dist/index.d.ts +4 -0
  116. package/vendor/codex-ai-sdk/dist/index.js +2 -0
  117. package/vendor/codex-ai-sdk/package.json +8 -0
  118. package/assets/opencode-logo-ornate-dark.svg +0 -18
  119. package/dist/lib/prompts/codex-opencode-bridge.d.ts +0 -19
  120. package/dist/lib/prompts/codex-opencode-bridge.d.ts.map +0 -1
  121. package/dist/lib/prompts/codex-opencode-bridge.js.map +0 -1
  122. package/dist/lib/prompts/opencode-codex.d.ts +0 -25
  123. package/dist/lib/prompts/opencode-codex.d.ts.map +0 -1
  124. package/dist/lib/prompts/opencode-codex.js.map +0 -1
@@ -1,105 +1,111 @@
1
- import { spawnSync } from "node:child_process";
2
- import { resolveOpencodeExecutable } from "./opencode.mjs";
3
-
4
- const FALLBACK_OPENAI_CODEX_STABLE = [
5
- "openai/gpt-5-codex",
6
- "openai/gpt-5.1-codex",
7
- "openai/gpt-5.1-codex-mini",
8
- "openai/gpt-5.1-codex-max",
9
- "openai/gpt-5.2-codex",
10
- "openai/gpt-5.3-codex",
11
- ];
12
-
13
- const OPENAI_CODEX_PREFIXES = ["openai/", "openai-multi/"];
14
-
15
- export function isOpenAiCodexProviderPrefix(modelId) {
16
- return OPENAI_CODEX_PREFIXES.some((prefix) => modelId.startsWith(prefix));
17
- }
18
-
19
- export function codexTail(modelId) {
20
- const slash = modelId.indexOf("/");
21
- return slash >= 0 ? modelId.slice(slash + 1) : modelId;
22
- }
23
-
24
- export function canonicalCodexModelId(modelId) {
25
- return `openai/${codexTail(modelId)}`;
26
- }
27
-
28
- export function aliasCandidatesForCodexModel(modelId) {
29
- if (!isOpenAiCodexProviderPrefix(modelId)) {
30
- return [modelId];
31
- }
32
- const tail = codexTail(modelId);
33
- const candidates = [`openai/${tail}`, `openai-multi/${tail}`];
34
- return [...new Set([modelId, ...candidates])];
35
- }
36
-
37
- export function isStableOpenAiCodexModel(modelId) {
38
- if (!isOpenAiCodexProviderPrefix(modelId)) {
39
- return false;
40
- }
41
- if (!modelId.includes("codex")) {
42
- return false;
43
- }
44
- if (modelId.includes("-spark") || modelId.includes("-latest")) {
45
- return false;
46
- }
47
- return true;
48
- }
49
-
50
- export function listOpencodeModels() {
51
- const executable = resolveOpencodeExecutable();
52
- const child = spawnSync(executable.command, ["models"], {
53
- encoding: "utf8",
54
- windowsHide: true,
55
- shell: executable.shell,
56
- maxBuffer: 10 * 1024 * 1024,
57
- });
58
- const text = `${child.stdout ?? ""}\n${child.stderr ?? ""}`;
59
- if ((child.status ?? 1) !== 0) {
60
- throw new Error(`Failed to list OpenCode models (exit=${child.status ?? 1})`);
61
- }
62
- return text
63
- .split(/\r?\n/)
64
- .map((line) => line.trim())
65
- .filter((line) => line.length > 0)
66
- .filter((line) => !line.startsWith("Using Node "));
67
- }
68
-
69
- function dedupeCodexModels(models) {
70
- const byCanonical = new Map();
71
- for (const modelId of models) {
72
- const canonical = canonicalCodexModelId(modelId);
73
- const existing = byCanonical.get(canonical);
74
- if (!existing) {
75
- byCanonical.set(canonical, modelId);
76
- continue;
77
- }
78
- // Prefer the shorter/default provider form when both exist.
79
- if (existing.startsWith("openai-multi/") && modelId.startsWith("openai/")) {
80
- byCanonical.set(canonical, modelId);
81
- }
82
- }
83
- return [...byCanonical.values()].sort((a, b) => canonicalCodexModelId(a).localeCompare(canonicalCodexModelId(b)));
84
- }
85
-
86
- export function resolveModelPreset(presetName, explicitModels) {
87
- if (explicitModels && explicitModels.length > 0) {
88
- return explicitModels;
89
- }
90
-
91
- if (presetName !== "codex-core") {
92
- throw new Error(`Unsupported preset: ${presetName}`);
93
- }
94
-
95
- try {
96
- const models = dedupeCodexModels(listOpencodeModels().filter(isStableOpenAiCodexModel));
97
- if (models.length > 0) {
98
- return models;
99
- }
100
- } catch {
101
- // Fall back to static list.
102
- }
103
-
104
- return [...FALLBACK_OPENAI_CODEX_STABLE];
105
- }
1
+ import { spawnSync } from "node:child_process";
2
+ import { resolveCodexExecutable } from "./codex-host.mjs";
3
+
4
+ const FALLBACK_OPENAI_CODEX_STABLE = [
5
+ "openai/gpt-5-codex",
6
+ "openai/gpt-5.1-codex",
7
+ "openai/gpt-5.1-codex-mini",
8
+ "openai/gpt-5.1-codex-max",
9
+ "openai/gpt-5.2-codex",
10
+ "openai/gpt-5.3-codex",
11
+ ];
12
+
13
+ const OPENAI_CODEX_PREFIXES = ["openai/", "openai-multi/"];
14
+
15
+ export function isOpenAiCodexProviderPrefix(modelId) {
16
+ return OPENAI_CODEX_PREFIXES.some((prefix) => modelId.startsWith(prefix));
17
+ }
18
+
19
+ export function codexTail(modelId) {
20
+ const slash = modelId.indexOf("/");
21
+ return slash >= 0 ? modelId.slice(slash + 1) : modelId;
22
+ }
23
+
24
+ export function canonicalCodexModelId(modelId) {
25
+ return `openai/${codexTail(modelId)}`;
26
+ }
27
+
28
+ export function aliasCandidatesForCodexModel(modelId) {
29
+ if (!isOpenAiCodexProviderPrefix(modelId)) {
30
+ return [modelId];
31
+ }
32
+ const tail = codexTail(modelId);
33
+ const candidates = [`openai/${tail}`, `openai-multi/${tail}`];
34
+ return [...new Set([modelId, ...candidates])];
35
+ }
36
+
37
+ export function isStableOpenAiCodexModel(modelId) {
38
+ if (!isOpenAiCodexProviderPrefix(modelId)) {
39
+ return false;
40
+ }
41
+ if (!modelId.includes("codex")) {
42
+ return false;
43
+ }
44
+ if (modelId.includes("-spark") || modelId.includes("-latest")) {
45
+ return false;
46
+ }
47
+ return true;
48
+ }
49
+
50
+ export function listCodexModels() {
51
+ const executable = resolveCodexExecutable();
52
+ const child = spawnSync(executable.command, ["models"], {
53
+ encoding: "utf8",
54
+ windowsHide: true,
55
+ shell: executable.shell,
56
+ maxBuffer: 10 * 1024 * 1024,
57
+ timeout: Number.parseInt(process.env.CODEX_MODELS_TIMEOUT_MS ?? "30000", 10),
58
+ killSignal: "SIGKILL",
59
+ });
60
+ if (child.error && child.error.code === "ETIMEDOUT") {
61
+ throw new Error(`Timed out while listing Codex models after ${process.env.CODEX_MODELS_TIMEOUT_MS ?? "30000"}ms`);
62
+ }
63
+ const text = `${child.stdout ?? ""}\n${child.stderr ?? ""}`;
64
+ if ((child.status ?? 1) !== 0) {
65
+ throw new Error(`Failed to list Codex models (exit=${child.status ?? 1})`);
66
+ }
67
+ return text
68
+ .split(/\r?\n/)
69
+ .map((line) => line.trim())
70
+ .filter((line) => line.length > 0)
71
+ .filter((line) => !line.startsWith("Using Node "));
72
+ }
73
+
74
+ function dedupeCodexModels(models) {
75
+ const byCanonical = new Map();
76
+ for (const modelId of models) {
77
+ const canonical = canonicalCodexModelId(modelId);
78
+ const existing = byCanonical.get(canonical);
79
+ if (!existing) {
80
+ byCanonical.set(canonical, modelId);
81
+ continue;
82
+ }
83
+ // Prefer the shorter/default provider form when both exist.
84
+ if (existing.startsWith("openai-multi/") && modelId.startsWith("openai/")) {
85
+ byCanonical.set(canonical, modelId);
86
+ }
87
+ }
88
+ return [...byCanonical.values()].sort((a, b) => canonicalCodexModelId(a).localeCompare(canonicalCodexModelId(b)));
89
+ }
90
+
91
+ export function resolveModelPreset(presetName, explicitModels) {
92
+ if (explicitModels && explicitModels.length > 0) {
93
+ return explicitModels;
94
+ }
95
+
96
+ if (presetName !== "codex-core") {
97
+ throw new Error(`Unsupported preset: ${presetName}`);
98
+ }
99
+
100
+ try {
101
+ const models = dedupeCodexModels(listCodexModels().filter(isStableOpenAiCodexModel));
102
+ if (models.length > 0) {
103
+ return models;
104
+ }
105
+ } catch {
106
+ // Fall back to static list.
107
+ }
108
+
109
+ return [...FALLBACK_OPENAI_CODEX_STABLE];
110
+ }
111
+