@codemieai/code 0.13.1 → 0.14.1

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 (144) hide show
  1. package/README.md +44 -6
  2. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  3. package/dist/agents/core/AgentCLI.js +53 -4
  4. package/dist/agents/core/AgentCLI.js.map +1 -1
  5. package/dist/agents/plugins/claude/claude.models.d.ts +12 -0
  6. package/dist/agents/plugins/claude/claude.models.d.ts.map +1 -0
  7. package/dist/agents/plugins/claude/claude.models.js +191 -0
  8. package/dist/agents/plugins/claude/claude.models.js.map +1 -0
  9. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  10. package/dist/agents/plugins/claude/claude.plugin.js +45 -1
  11. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  12. package/dist/agents/plugins/codex/codex-models.d.ts +11 -0
  13. package/dist/agents/plugins/codex/codex-models.d.ts.map +1 -1
  14. package/dist/agents/plugins/codex/codex-models.js +71 -0
  15. package/dist/agents/plugins/codex/codex-models.js.map +1 -1
  16. package/dist/agents/plugins/gemini/gemini.paths.d.ts +11 -0
  17. package/dist/agents/plugins/gemini/gemini.paths.d.ts.map +1 -0
  18. package/dist/agents/plugins/gemini/gemini.paths.js +21 -0
  19. package/dist/agents/plugins/gemini/gemini.paths.js.map +1 -0
  20. package/dist/agents/plugins/gemini/gemini.session-adapter.d.ts +20 -0
  21. package/dist/agents/plugins/gemini/gemini.session-adapter.d.ts.map +1 -1
  22. package/dist/agents/plugins/gemini/gemini.session-adapter.js +119 -3
  23. package/dist/agents/plugins/gemini/gemini.session-adapter.js.map +1 -1
  24. package/dist/agents/plugins/pi/pi.models.d.ts +14 -0
  25. package/dist/agents/plugins/pi/pi.models.d.ts.map +1 -1
  26. package/dist/agents/plugins/pi/pi.models.js +89 -0
  27. package/dist/agents/plugins/pi/pi.models.js.map +1 -1
  28. package/dist/cli/commands/analytics/agent-labels.d.ts.map +1 -1
  29. package/dist/cli/commands/analytics/agent-labels.js +1 -0
  30. package/dist/cli/commands/analytics/agent-labels.js.map +1 -1
  31. package/dist/cli/commands/analytics/aggregator.js +1 -1
  32. package/dist/cli/commands/analytics/aggregator.js.map +1 -1
  33. package/dist/cli/commands/analytics/cost/cost-calculator.d.ts +1 -1
  34. package/dist/cli/commands/analytics/cost/cost-calculator.d.ts.map +1 -1
  35. package/dist/cli/commands/analytics/cost/cost-enricher.js +2 -2
  36. package/dist/cli/commands/analytics/cost/cost-enricher.js.map +1 -1
  37. package/dist/cli/commands/analytics/data-loader.d.ts.map +1 -1
  38. package/dist/cli/commands/analytics/data-loader.js +9 -0
  39. package/dist/cli/commands/analytics/data-loader.js.map +1 -1
  40. package/dist/cli/commands/analytics/native-loader.js +1 -1
  41. package/dist/cli/commands/analytics/native-loader.js.map +1 -1
  42. package/dist/cli/commands/analytics/otel-loader.js +1 -1
  43. package/dist/cli/commands/analytics/otel-loader.js.map +1 -1
  44. package/dist/cli/commands/analytics/report/client/app.js +1 -1
  45. package/dist/cli/commands/hook.d.ts.map +1 -1
  46. package/dist/cli/commands/hook.js +70 -1
  47. package/dist/cli/commands/hook.js.map +1 -1
  48. package/dist/cli/commands/proxy/connect-orchestrator.d.ts +95 -0
  49. package/dist/cli/commands/proxy/connect-orchestrator.d.ts.map +1 -0
  50. package/dist/cli/commands/proxy/connect-orchestrator.js +501 -0
  51. package/dist/cli/commands/proxy/connect-orchestrator.js.map +1 -0
  52. package/dist/cli/commands/proxy/connectors/codex-config-toml.d.ts +81 -0
  53. package/dist/cli/commands/proxy/connectors/codex-config-toml.d.ts.map +1 -0
  54. package/dist/cli/commands/proxy/connectors/codex-config-toml.js +218 -0
  55. package/dist/cli/commands/proxy/connectors/codex-config-toml.js.map +1 -0
  56. package/dist/cli/commands/proxy/connectors/codex-desktop.d.ts +85 -0
  57. package/dist/cli/commands/proxy/connectors/codex-desktop.d.ts.map +1 -0
  58. package/dist/cli/commands/proxy/connectors/codex-desktop.js +299 -0
  59. package/dist/cli/commands/proxy/connectors/codex-desktop.js.map +1 -0
  60. package/dist/cli/commands/proxy/connectors/desktop.d.ts +5 -0
  61. package/dist/cli/commands/proxy/connectors/desktop.d.ts.map +1 -1
  62. package/dist/cli/commands/proxy/connectors/desktop.js +48 -2
  63. package/dist/cli/commands/proxy/connectors/desktop.js.map +1 -1
  64. package/dist/cli/commands/proxy/connectors/managed-mcp-remote.d.ts +10 -0
  65. package/dist/cli/commands/proxy/connectors/managed-mcp-remote.d.ts.map +1 -1
  66. package/dist/cli/commands/proxy/connectors/managed-mcp-remote.js.map +1 -1
  67. package/dist/cli/commands/proxy/connectors/vscode-claude-code.d.ts +26 -0
  68. package/dist/cli/commands/proxy/connectors/vscode-claude-code.d.ts.map +1 -0
  69. package/dist/cli/commands/proxy/connectors/vscode-claude-code.js +132 -0
  70. package/dist/cli/commands/proxy/connectors/vscode-claude-code.js.map +1 -0
  71. package/dist/cli/commands/proxy/connectors/vscode.d.ts +2 -0
  72. package/dist/cli/commands/proxy/connectors/vscode.d.ts.map +1 -1
  73. package/dist/cli/commands/proxy/connectors/vscode.js +2 -2
  74. package/dist/cli/commands/proxy/connectors/vscode.js.map +1 -1
  75. package/dist/cli/commands/proxy/disconnect-orchestrator.d.ts +8 -0
  76. package/dist/cli/commands/proxy/disconnect-orchestrator.d.ts.map +1 -0
  77. package/dist/cli/commands/proxy/disconnect-orchestrator.js +43 -0
  78. package/dist/cli/commands/proxy/disconnect-orchestrator.js.map +1 -0
  79. package/dist/cli/commands/proxy/index.d.ts.map +1 -1
  80. package/dist/cli/commands/proxy/index.js +91 -370
  81. package/dist/cli/commands/proxy/index.js.map +1 -1
  82. package/dist/cli/index.js +7 -7
  83. package/dist/providers/integration/setup-ui.d.ts +14 -2
  84. package/dist/providers/integration/setup-ui.d.ts.map +1 -1
  85. package/dist/providers/integration/setup-ui.js +70 -33
  86. package/dist/providers/integration/setup-ui.js.map +1 -1
  87. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.d.ts.map +1 -1
  88. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.js +9 -2
  89. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.js.map +1 -1
  90. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.template.d.ts.map +1 -1
  91. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.template.js +18 -28
  92. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.template.js.map +1 -1
  93. package/dist/providers/plugins/bedrock/bedrock.setup-steps.d.ts.map +1 -1
  94. package/dist/providers/plugins/bedrock/bedrock.setup-steps.js +4 -4
  95. package/dist/providers/plugins/bedrock/bedrock.setup-steps.js.map +1 -1
  96. package/dist/providers/plugins/litellm/litellm.setup-steps.d.ts.map +1 -1
  97. package/dist/providers/plugins/litellm/litellm.setup-steps.js +3 -1
  98. package/dist/providers/plugins/litellm/litellm.setup-steps.js.map +1 -1
  99. package/dist/providers/plugins/moonshot-subscription/moonshot-subscription.setup-steps.d.ts.map +1 -1
  100. package/dist/providers/plugins/moonshot-subscription/moonshot-subscription.setup-steps.js +5 -1
  101. package/dist/providers/plugins/moonshot-subscription/moonshot-subscription.setup-steps.js.map +1 -1
  102. package/dist/providers/plugins/ollama/ollama.setup-steps.d.ts.map +1 -1
  103. package/dist/providers/plugins/ollama/ollama.setup-steps.js +3 -2
  104. package/dist/providers/plugins/ollama/ollama.setup-steps.js.map +1 -1
  105. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts.map +1 -1
  106. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js +4 -0
  107. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js.map +1 -1
  108. package/dist/providers/plugins/sso/proxy/plugins/codex-model-resolver.d.ts +45 -0
  109. package/dist/providers/plugins/sso/proxy/plugins/codex-model-resolver.d.ts.map +1 -0
  110. package/dist/providers/plugins/sso/proxy/plugins/codex-model-resolver.js +129 -0
  111. package/dist/providers/plugins/sso/proxy/plugins/codex-model-resolver.js.map +1 -0
  112. package/dist/providers/plugins/sso/proxy/plugins/codex-request-normalizer.plugin.d.ts +27 -0
  113. package/dist/providers/plugins/sso/proxy/plugins/codex-request-normalizer.plugin.d.ts.map +1 -0
  114. package/dist/providers/plugins/sso/proxy/plugins/codex-request-normalizer.plugin.js +242 -0
  115. package/dist/providers/plugins/sso/proxy/plugins/codex-request-normalizer.plugin.js.map +1 -0
  116. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +2 -1
  117. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  118. package/dist/providers/plugins/sso/proxy/plugins/index.js +3 -1
  119. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  120. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.d.ts.map +1 -1
  121. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.js +15 -1
  122. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.js.map +1 -1
  123. package/dist/providers/plugins/sso/sso.auth.d.ts.map +1 -1
  124. package/dist/providers/plugins/sso/sso.auth.js +3 -0
  125. package/dist/providers/plugins/sso/sso.auth.js.map +1 -1
  126. package/dist/utils/analytics-auth-status.d.ts +48 -0
  127. package/dist/utils/analytics-auth-status.d.ts.map +1 -0
  128. package/dist/utils/analytics-auth-status.js +89 -0
  129. package/dist/utils/analytics-auth-status.js.map +1 -0
  130. package/dist/utils/model-normalizer.d.ts.map +1 -0
  131. package/dist/utils/model-normalizer.js.map +1 -0
  132. package/dist/utils/pricing.d.ts.map +1 -0
  133. package/dist/{cli/commands/analytics/cost → utils}/pricing.js +3 -3
  134. package/dist/utils/pricing.js.map +1 -0
  135. package/package.json +1 -1
  136. package/scripts/copy-plugins.js +3 -3
  137. package/dist/cli/commands/analytics/cost/pricing.d.ts.map +0 -1
  138. package/dist/cli/commands/analytics/cost/pricing.js.map +0 -1
  139. package/dist/cli/commands/analytics/model-normalizer.d.ts.map +0 -1
  140. package/dist/cli/commands/analytics/model-normalizer.js.map +0 -1
  141. /package/dist/{cli/commands/analytics → utils}/model-normalizer.d.ts +0 -0
  142. /package/dist/{cli/commands/analytics → utils}/model-normalizer.js +0 -0
  143. /package/dist/{cli/commands/analytics/cost → utils}/pricing.d.ts +0 -0
  144. /package/dist/{cli/commands/analytics/cost → utils}/pricing.json +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-model-resolver.d.ts","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/codex-model-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoBH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,CAAC;AAEjF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAyCD;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAyBtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EAAE,EACnB,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,oBAAoB,CAwBtB"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Deployment-name resolution for Codex clients.
3
+ *
4
+ * The Codex desktop app owns the `model` key in `~/.codex/config.toml`: it
5
+ * writes its model-picker selection back to that file, overwriting whatever the
6
+ * connector pinned. The names it picks come from its own bundled catalog and are
7
+ * undated (`gpt-5.6-luna`, `gpt-5.5`, `gpt-5.2`), while CodeMie deployments are
8
+ * dated (`gpt-5.6-luna-2026-07-09`). The gateway rejects the undated form, so
9
+ * every picker selection would fail without this mapping.
10
+ *
11
+ * Self-contained on purpose: the proxy must not depend on the Codex agent
12
+ * plugin, which installs independently of the provider stack.
13
+ */
14
+ /**
15
+ * Release date embedded in a CodeMie deployment name, e.g. `-2026-07-09`.
16
+ *
17
+ * Not anchored to end-of-string: a deployment may carry a suffix after the date
18
+ * (`gpt-5-2025-08-07-preview`). Anchoring would fail the match there, and the
19
+ * version reader would then take `2025` as the minor version — the exact
20
+ * date-as-version inversion this module exists to avoid.
21
+ */
22
+ const DEPLOYMENT_DATE_PATTERN = /[-._](20\d{2})[-._](\d{2})[-._](\d{2})/;
23
+ /**
24
+ * Parse a model name into its identity.
25
+ *
26
+ * The release date is stripped BEFORE the version is read — otherwise
27
+ * `gpt-5-2025-08-07` reads as major 5, minor 2025 and never matches a request
28
+ * for `gpt-5`.
29
+ */
30
+ function parseIdentity(name) {
31
+ const lower = name.trim().toLowerCase();
32
+ const dateMatch = lower.match(DEPLOYMENT_DATE_PATTERN);
33
+ const withoutDate = dateMatch ? lower.slice(0, dateMatch.index) : lower;
34
+ // Dotted and dashed minor versions are the same model: the app sends `gpt-5.2`
35
+ // for the deployment CodeMie names `gpt-5-2-...`.
36
+ const canonical = withoutDate.replace(/\./g, '-').replace(/-+$/, '');
37
+ const versionMatch = canonical.match(/^gpt-(\d+)(?:-(\d+))?/);
38
+ if (!versionMatch)
39
+ return null;
40
+ const rest = canonical.slice(versionMatch[0].length).replace(/^-/, '');
41
+ return {
42
+ major: Number(versionMatch[1]),
43
+ minor: Number(versionMatch[2] ?? 0),
44
+ variant: rest,
45
+ };
46
+ }
47
+ function sameIdentity(a, b) {
48
+ return a.major === b.major && a.minor === b.minor && a.variant === b.variant;
49
+ }
50
+ /** Model families that cannot serve a Codex Responses request. */
51
+ const INCOMPATIBLE_NAME_PATTERN = /claude|sonnet|opus|haiku|anthropic|gemini|qwen|deepseek|llama|mistral|grok|embedding/i;
52
+ /** Model families that can. */
53
+ const COMPATIBLE_NAME_PATTERN = /codex|^gpt[-._]?5(?:[-._]|\b)|^gpt[-._]?6(?:[-._]|\b)/i;
54
+ /**
55
+ * True when a deployment can serve a Codex Responses request.
56
+ *
57
+ * The gateway lists every model the account can reach, including Claude and
58
+ * embedding deployments. Substituting one of those for an unmatched Codex
59
+ * request would be far worse than passing the request through and letting the
60
+ * gateway report the real problem.
61
+ */
62
+ export function isCodexServableDeployment(name) {
63
+ if (INCOMPATIBLE_NAME_PATTERN.test(name))
64
+ return false;
65
+ return COMPATIBLE_NAME_PATTERN.test(name);
66
+ }
67
+ /**
68
+ * Rank deployments newest-first, so a caller with no pinned model can still
69
+ * choose a sensible substitute — the same choice `connect` would have pinned.
70
+ */
71
+ export function rankDeploymentsByRecency(available) {
72
+ return available
73
+ .map((id) => {
74
+ const identity = parseIdentity(id);
75
+ const dateMatch = id.toLowerCase().match(DEPLOYMENT_DATE_PATTERN);
76
+ return {
77
+ id,
78
+ score: [
79
+ identity?.major ?? 0,
80
+ identity?.minor ?? 0,
81
+ /mini|nano/i.test(id) ? 0 : 1,
82
+ dateMatch ? Number(dateMatch[1]) : 0,
83
+ dateMatch ? Number(dateMatch[2]) : 0,
84
+ dateMatch ? Number(dateMatch[3]) : 0,
85
+ ],
86
+ };
87
+ })
88
+ .sort((a, b) => {
89
+ for (let i = 0; i < a.score.length; i++) {
90
+ const diff = (b.score[i] ?? 0) - (a.score[i] ?? 0);
91
+ if (diff !== 0)
92
+ return diff;
93
+ }
94
+ return a.id.localeCompare(b.id);
95
+ })
96
+ .map((entry) => entry.id);
97
+ }
98
+ /**
99
+ * Resolve the model a Codex client asked for to a deployment the gateway has.
100
+ *
101
+ * Returns the request unchanged when it is already a known deployment, the
102
+ * matching dated deployment when the request identifies one, the pinned
103
+ * fallback when nothing matches, or the request untouched when there is no
104
+ * fallback to offer. Never throws — an unresolvable request is passed upstream
105
+ * so the gateway's own error reaches the client.
106
+ */
107
+ export function resolveCodexDeployment(requested, available, pinnedFallback) {
108
+ if (available.includes(requested)) {
109
+ return { model: requested, kind: 'exact' };
110
+ }
111
+ const wanted = parseIdentity(requested);
112
+ if (wanted) {
113
+ const matches = available.filter((candidate) => {
114
+ const identity = parseIdentity(candidate);
115
+ return identity !== null && sameIdentity(identity, wanted);
116
+ });
117
+ // Rank rather than take the first: gateway order is arbitrary and in practice
118
+ // lists the oldest deployment first, so `find` would pin a stale date when
119
+ // several deployments share one identity.
120
+ if (matches.length > 0) {
121
+ return { model: rankDeploymentsByRecency(matches)[0], kind: 'resolved' };
122
+ }
123
+ }
124
+ if (pinnedFallback && available.includes(pinnedFallback)) {
125
+ return { model: pinnedFallback, kind: 'substituted', requested };
126
+ }
127
+ return { model: requested, kind: 'unresolved' };
128
+ }
129
+ //# sourceMappingURL=codex-model-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-model-resolver.js","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/codex-model-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;GAOG;AACH,MAAM,uBAAuB,GAAG,wCAAwC,CAAC;AAmBzE;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAExE,+EAA+E;IAC/E,kDAAkD;IAClD,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAErE,MAAM,YAAY,GAAG,SAAS,CAAC,KAA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E,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7C,CAAC;IAED,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE;YAC7C,MAAM,QAAQ,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;YAC1C,OAAO,QAAQ,KAAK,IAAI,IAAI,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QACH,8EAA8E;QAC9E,2EAA2E;QAC3E,0CAA0C;QAC1C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,KAAK,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,IAAI,cAAc,IAAI,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACzD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;IACnE,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAClD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Codex Request Normalizer Plugin
3
+ * Priority: 14 (runs before generic request sanitization, alongside the other
4
+ * per-client normalizers)
5
+ *
6
+ * The Codex desktop app owns the `model` key in `~/.codex/config.toml`: it
7
+ * writes its model-picker selection back to that file, overwriting whatever
8
+ * `codemie proxy connect --codex-desktop` pinned. The names its picker offers
9
+ * come from the app's own bundled catalog and are undated (`gpt-5.6-luna`,
10
+ * `gpt-5.5`), while CodeMie deployments carry a release date
11
+ * (`gpt-5.6-luna-2026-07-09`). The gateway rejects the undated form with
12
+ * "Invalid model name", and the app then cascades through further catalog
13
+ * entries that fail the same way.
14
+ *
15
+ * This plugin maps the requested name onto a deployment the gateway actually
16
+ * has, so the picker works instead of failing.
17
+ */
18
+ import { ProxyPlugin, PluginContext, ProxyInterceptor } from './types.js';
19
+ export declare function repairEmptyToolDescriptions(node: unknown): number;
20
+ export declare class CodexRequestNormalizerPlugin implements ProxyPlugin {
21
+ id: string;
22
+ name: string;
23
+ version: string;
24
+ priority: number;
25
+ createInterceptor(context: PluginContext): Promise<ProxyInterceptor>;
26
+ }
27
+ //# sourceMappingURL=codex-request-normalizer.plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-request-normalizer.plugin.d.ts","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/codex-request-normalizer.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA6C1E,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAEjE;AAgDD,qBAAa,4BAA6B,YAAW,WAAW;IAC9D,EAAE,SAA6C;IAC/C,IAAI,SAA8B;IAClC,OAAO,SAAW;IAClB,QAAQ,SAAM;IAER,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAQ3E"}
@@ -0,0 +1,242 @@
1
+ /**
2
+ * Codex Request Normalizer Plugin
3
+ * Priority: 14 (runs before generic request sanitization, alongside the other
4
+ * per-client normalizers)
5
+ *
6
+ * The Codex desktop app owns the `model` key in `~/.codex/config.toml`: it
7
+ * writes its model-picker selection back to that file, overwriting whatever
8
+ * `codemie proxy connect --codex-desktop` pinned. The names its picker offers
9
+ * come from the app's own bundled catalog and are undated (`gpt-5.6-luna`,
10
+ * `gpt-5.5`), while CodeMie deployments carry a release date
11
+ * (`gpt-5.6-luna-2026-07-09`). The gateway rejects the undated form with
12
+ * "Invalid model name", and the app then cascades through further catalog
13
+ * entries that fail the same way.
14
+ *
15
+ * This plugin maps the requested name onto a deployment the gateway actually
16
+ * has, so the picker works instead of failing.
17
+ */
18
+ import { logger } from '../../../../../utils/logger.js';
19
+ import { fetchCodeMieLlmModels } from '../../sso.http-client.js';
20
+ import { isCodexServableDeployment, rankDeploymentsByRecency, resolveCodexDeployment, } from './codex-model-resolver.js';
21
+ const ALLOWED_CLIENTS = ['codex-desktop'];
22
+ /** Re-list deployments occasionally so a long-lived daemon picks up new models. */
23
+ const MODEL_CACHE_TTL_MS = 10 * 60 * 1000;
24
+ /** How long to wait before retrying after a failed or empty listing. */
25
+ const MODEL_RETRY_BACKOFF_MS = 60 * 1000;
26
+ /**
27
+ * Repair empty `description` fields on tool definitions, in place.
28
+ *
29
+ * Azure — which backs CodeMie deployments through LiteLLM — rejects a tool whose
30
+ * `description` is an empty string ("Expected a string with minimum length 1"),
31
+ * while direct OpenAI accepts it. The Codex desktop app and the MCP servers it
32
+ * loads do emit empty descriptions, so a turn that works against OpenAI fails
33
+ * here. The client cannot be fixed from our side, so the proxy repairs it.
34
+ *
35
+ * Scoped deliberately to arrays literally named `tools`: a JSON-schema property
36
+ * description is legitimately allowed to be empty and is not what Azure rejects,
37
+ * so rewriting one would silently alter the tool's schema.
38
+ *
39
+ * An empty description carries no information the model does not already have
40
+ * from the tool's name, so the name is the least-lossy replacement. The key is
41
+ * dropped when there is no usable name, which the gateway also accepts.
42
+ *
43
+ * Returns the number of descriptions repaired.
44
+ */
45
+ /**
46
+ * Depth ceiling for the walk. Request bodies are client-controlled — Codex
47
+ * accumulates conversation history plus nested MCP tool schemas — so an
48
+ * unbounded walk risks a RangeError escaping into the proxy pipeline. Real
49
+ * bodies nest far shallower than this.
50
+ */
51
+ const MAX_WALK_DEPTH = 64;
52
+ export function repairEmptyToolDescriptions(node) {
53
+ return walk(node, 0, new WeakSet());
54
+ }
55
+ function repairToolEntry(tool) {
56
+ if (tool === null || typeof tool !== 'object' || Array.isArray(tool))
57
+ return false;
58
+ const toolRecord = tool;
59
+ if (typeof toolRecord.description !== 'string')
60
+ return false;
61
+ if (toolRecord.description.trim() !== '')
62
+ return false;
63
+ const name = typeof toolRecord.name === 'string' ? toolRecord.name.trim() : '';
64
+ if (name !== '') {
65
+ toolRecord.description = name;
66
+ }
67
+ else {
68
+ delete toolRecord.description;
69
+ }
70
+ return true;
71
+ }
72
+ function walk(node, depth, seen) {
73
+ if (depth > MAX_WALK_DEPTH)
74
+ return 0;
75
+ if (node === null || typeof node !== 'object')
76
+ return 0;
77
+ // Guard against cycles. The function is exported and takes `unknown`, so it
78
+ // cannot assume its input came from JSON.parse.
79
+ if (seen.has(node))
80
+ return 0;
81
+ seen.add(node);
82
+ if (Array.isArray(node)) {
83
+ return node.reduce((count, item) => count + walk(item, depth + 1, seen), 0);
84
+ }
85
+ let repaired = 0;
86
+ const record = node;
87
+ for (const [key, value] of Object.entries(record)) {
88
+ if (key === 'tools' && Array.isArray(value)) {
89
+ for (const tool of value) {
90
+ if (repairToolEntry(tool))
91
+ repaired++;
92
+ }
93
+ }
94
+ // Recurse regardless: a `tools` array can sit at any depth, and the entries
95
+ // of one may themselves nest further structures.
96
+ repaired += walk(value, depth + 1, seen);
97
+ }
98
+ return repaired;
99
+ }
100
+ export class CodexRequestNormalizerPlugin {
101
+ id = '@codemie/proxy-codex-request-normalizer';
102
+ name = 'Codex Request Normalizer';
103
+ version = '1.0.0';
104
+ priority = 14;
105
+ async createInterceptor(context) {
106
+ const clientType = context.config.clientType;
107
+ if (!clientType || !ALLOWED_CLIENTS.includes(clientType)) {
108
+ throw new Error(`Plugin disabled for agent: ${clientType}`);
109
+ }
110
+ return new CodexRequestNormalizerInterceptor(context);
111
+ }
112
+ }
113
+ class CodexRequestNormalizerInterceptor {
114
+ context;
115
+ name = 'codex-request-normalizer';
116
+ availableModels = [];
117
+ loadedAt = 0;
118
+ lastAttemptAt = 0;
119
+ inFlight = null;
120
+ constructor(context) {
121
+ this.context = context;
122
+ }
123
+ /** Test seam — lets the suite supply a deployment list without a network call. */
124
+ setAvailableModelsForTest(models) {
125
+ this.availableModels = models;
126
+ this.loadedAt = Date.now();
127
+ }
128
+ async onRequest(context) {
129
+ if (!context.requestBody || !context.headers['content-type']?.includes('application/json')) {
130
+ return;
131
+ }
132
+ let body;
133
+ try {
134
+ body = JSON.parse(context.requestBody.toString('utf-8'));
135
+ }
136
+ catch {
137
+ // Not JSON — pass through unchanged.
138
+ return;
139
+ }
140
+ const repairedDescriptions = repairEmptyToolDescriptions(body);
141
+ if (repairedDescriptions > 0) {
142
+ logger.debug(`[${this.name}] Replaced ${repairedDescriptions} empty tool description(s) rejected by upstream`);
143
+ }
144
+ if (typeof body.model !== 'string' || body.model === '') {
145
+ if (repairedDescriptions > 0)
146
+ this.writeBody(context, body);
147
+ return;
148
+ }
149
+ await this.ensureModelsLoaded();
150
+ if (this.availableModels.length === 0) {
151
+ // Never block a turn on an unavailable model list; the gateway's own
152
+ // error is more useful than a guess.
153
+ if (repairedDescriptions > 0)
154
+ this.writeBody(context, body);
155
+ return;
156
+ }
157
+ const resolution = resolveCodexDeployment(body.model, this.availableModels, this.resolveFallbackModel());
158
+ if (resolution.kind === 'exact' || resolution.kind === 'unresolved') {
159
+ if (repairedDescriptions > 0)
160
+ this.writeBody(context, body);
161
+ return;
162
+ }
163
+ if (resolution.kind === 'substituted') {
164
+ logger.info(`[${this.name}] CodeMie has no deployment for "${resolution.requested}"; ` +
165
+ `using pinned model "${resolution.model}" instead`);
166
+ }
167
+ else {
168
+ logger.debug(`[${this.name}] Resolved "${body.model}" to deployment "${resolution.model}"`);
169
+ }
170
+ body.model = resolution.model;
171
+ this.writeBody(context, body);
172
+ }
173
+ /** Serialize the mutated body back onto the request, keeping content-length honest. */
174
+ writeBody(context, body) {
175
+ context.requestBody = Buffer.from(JSON.stringify(body), 'utf-8');
176
+ context.headers['content-length'] = String(context.requestBody.length);
177
+ }
178
+ /**
179
+ * The model to substitute when CodeMie carries nothing matching the request.
180
+ *
181
+ * `config.model` is normally absent here: the daemon is spawned before the
182
+ * connector resolves a model, because discovery itself goes through this
183
+ * proxy. So the fallback cannot depend on a pinned value — it defaults to the
184
+ * newest available deployment, which is what `connect` would have pinned.
185
+ */
186
+ resolveFallbackModel() {
187
+ const pinned = this.context.config.model;
188
+ if (pinned && this.availableModels.includes(pinned))
189
+ return pinned;
190
+ return rankDeploymentsByRecency(this.availableModels)[0];
191
+ }
192
+ /**
193
+ * Load the deployment list once, then refresh it on a TTL. Concurrent requests
194
+ * share a single in-flight fetch so a burst of turns does not fan out into a
195
+ * burst of list calls.
196
+ */
197
+ async ensureModelsLoaded() {
198
+ const now = Date.now();
199
+ const fresh = this.availableModels.length > 0 && now - this.loadedAt < MODEL_CACHE_TTL_MS;
200
+ if (fresh)
201
+ return;
202
+ // Negative cache: without this, expired credentials or a 5xx gateway turn
203
+ // every single request into a fresh listing call, because a failed load
204
+ // leaves availableModels empty and so never looks "fresh".
205
+ const backingOff = this.lastAttemptAt !== 0
206
+ && now - this.lastAttemptAt < MODEL_RETRY_BACKOFF_MS;
207
+ if (backingOff)
208
+ return;
209
+ if (this.inFlight)
210
+ return this.inFlight;
211
+ this.inFlight = this.loadModels().finally(() => { this.inFlight = null; });
212
+ return this.inFlight;
213
+ }
214
+ async loadModels() {
215
+ this.lastAttemptAt = Date.now();
216
+ const credentials = this.context.credentials;
217
+ if (!credentials) {
218
+ logger.debug(`[${this.name}] No credentials available; model names pass through unchanged`);
219
+ return;
220
+ }
221
+ try {
222
+ const apiUrl = credentials.apiUrl || this.context.config.targetApiUrl;
223
+ const models = 'cookies' in credentials
224
+ ? await fetchCodeMieLlmModels(apiUrl, credentials.cookies)
225
+ : await fetchCodeMieLlmModels(apiUrl, credentials.token);
226
+ this.availableModels = models
227
+ .filter((model) => model.enabled !== false)
228
+ .map((model) => model.deployment_name || model.base_name)
229
+ .filter((name) => Boolean(name))
230
+ // Only Codex-servable deployments may be resolved to or substituted.
231
+ .filter(isCodexServableDeployment);
232
+ this.loadedAt = Date.now();
233
+ logger.debug(`[${this.name}] Loaded ${this.availableModels.length} deployments for model resolution`);
234
+ }
235
+ catch (error) {
236
+ // A failed list must not fail the request.
237
+ logger.debug(`[${this.name}] Could not list deployments; passing model names through: ` +
238
+ `${error instanceof Error ? error.message : String(error)}`);
239
+ }
240
+ }
241
+ }
242
+ //# sourceMappingURL=codex-request-normalizer.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-request-normalizer.plugin.js","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/codex-request-normalizer.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,eAAe,GAAG,CAAC,eAAe,CAAC,CAAC;AAE1C,mFAAmF;AACnF,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C,wEAAwE;AACxE,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH;;;;;GAKG;AACH,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,UAAU,2BAA2B,CAAC,IAAa;IACvD,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,OAAO,EAAU,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,eAAe,CAAC,IAAa;IACpC,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnF,MAAM,UAAU,GAAG,IAA+B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,CAAC,CAAC,MAAM,qBAAqB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC;gBAC1D,CAAC,CAAC,MAAM,qBAAqB,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;YAE3D,IAAI,CAAC,eAAe,GAAG,MAAM;iBAC1B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC;iBAC1C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,IAAI,KAAK,CAAC,SAAS,CAAC;iBACxD,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChD,qEAAqE;iBACpE,MAAM,CAAC,yBAAyB,CAAC,CAAC;YACrC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE3B,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,YAAY,IAAI,CAAC,eAAe,CAAC,MAAM,mCAAmC,CAAC,CAAC;QACxG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,2CAA2C;YAC3C,MAAM,CAAC,KAAK,CACV,IAAI,IAAI,CAAC,IAAI,6DAA6D;gBAC1E,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -13,6 +13,7 @@ import { HeaderInjectionPlugin } from './header-injection.plugin.js';
13
13
  import { RequestSanitizerPlugin } from './request-sanitizer.plugin.js';
14
14
  import { ClaudeRequestNormalizerPlugin } from './claude-request-normalizer.plugin.js';
15
15
  import { KimiRequestNormalizerPlugin } from './kimi-request-normalizer.plugin.js';
16
+ import { CodexRequestNormalizerPlugin } from './codex-request-normalizer.plugin.js';
16
17
  import { CodexEncryptedContentSanitizerPlugin } from './codex-encrypted-content-sanitizer.plugin.js';
17
18
  import { CopilotEncryptedContentSanitizerPlugin } from './copilot-encrypted-content-sanitizer.plugin.js';
18
19
  import { VsCodeRequestNormalizerPlugin } from './vscode-request-normalizer.plugin.js';
@@ -22,7 +23,7 @@ import { LoggingPlugin } from './logging.plugin.js';
22
23
  * Called at app startup
23
24
  */
24
25
  export declare function registerCorePlugins(): void;
25
- export { MCPAuthPlugin, EndpointBlockerPlugin, GatewayKeyPlugin, SSOAuthPlugin, JWTAuthPlugin, HeaderInjectionPlugin, RequestSanitizerPlugin, ClaudeRequestNormalizerPlugin, KimiRequestNormalizerPlugin, CodexEncryptedContentSanitizerPlugin, CopilotEncryptedContentSanitizerPlugin, VsCodeRequestNormalizerPlugin, LoggingPlugin, };
26
+ export { MCPAuthPlugin, EndpointBlockerPlugin, GatewayKeyPlugin, SSOAuthPlugin, JWTAuthPlugin, HeaderInjectionPlugin, RequestSanitizerPlugin, ClaudeRequestNormalizerPlugin, KimiRequestNormalizerPlugin, CodexRequestNormalizerPlugin, CodexEncryptedContentSanitizerPlugin, CopilotEncryptedContentSanitizerPlugin, VsCodeRequestNormalizerPlugin, LoggingPlugin, };
26
27
  export { SSOSessionSyncPlugin } from './sso.session-sync.plugin.js';
27
28
  export { getPluginRegistry, resetPluginRegistry } from './registry.js';
28
29
  export * from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,sCAAsC,EAAE,MAAM,iDAAiD,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAkB1C;AAMD,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,oCAAoC,EACpC,sCAAsC,EACtC,6BAA6B,EAC7B,aAAa,GACd,CAAC;AACF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,sCAAsC,EAAE,MAAM,iDAAiD,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAmB1C;AAMD,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,sCAAsC,EACtC,6BAA6B,EAC7B,aAAa,GACd,CAAC;AACF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,cAAc,YAAY,CAAC"}
@@ -14,6 +14,7 @@ import { HeaderInjectionPlugin } from './header-injection.plugin.js';
14
14
  import { RequestSanitizerPlugin } from './request-sanitizer.plugin.js';
15
15
  import { ClaudeRequestNormalizerPlugin } from './claude-request-normalizer.plugin.js';
16
16
  import { KimiRequestNormalizerPlugin } from './kimi-request-normalizer.plugin.js';
17
+ import { CodexRequestNormalizerPlugin } from './codex-request-normalizer.plugin.js';
17
18
  import { CodexEncryptedContentSanitizerPlugin } from './codex-encrypted-content-sanitizer.plugin.js';
18
19
  import { CopilotEncryptedContentSanitizerPlugin } from './copilot-encrypted-content-sanitizer.plugin.js';
19
20
  import { VsCodeRequestNormalizerPlugin } from './vscode-request-normalizer.plugin.js';
@@ -33,6 +34,7 @@ export function registerCorePlugins() {
33
34
  registry.register(new JWTAuthPlugin());
34
35
  registry.register(new ClaudeRequestNormalizerPlugin()); // Priority 14 - normalizes thinking params for claude models
35
36
  registry.register(new KimiRequestNormalizerPlugin()); // Priority 14 - caps Kimi output token requests for upstream limits
37
+ registry.register(new CodexRequestNormalizerPlugin()); // Priority 14 - maps the Codex app's undated model names onto dated CodeMie deployments
36
38
  registry.register(new RequestSanitizerPlugin()); // Priority 15 - strips unsupported reasoning params
37
39
  registry.register(new CodexEncryptedContentSanitizerPlugin()); // Priority 16 - forwards Responses reasoning state; strips it only after upstream rejects a replay
38
40
  registry.register(new CopilotEncryptedContentSanitizerPlugin()); // Priority 16 - retries Copilot once after encrypted reasoning replay rejection
@@ -44,7 +46,7 @@ export function registerCorePlugins() {
44
46
  // Auto-register on import
45
47
  registerCorePlugins();
46
48
  // Re-export for convenience
47
- export { MCPAuthPlugin, EndpointBlockerPlugin, GatewayKeyPlugin, SSOAuthPlugin, JWTAuthPlugin, HeaderInjectionPlugin, RequestSanitizerPlugin, ClaudeRequestNormalizerPlugin, KimiRequestNormalizerPlugin, CodexEncryptedContentSanitizerPlugin, CopilotEncryptedContentSanitizerPlugin, VsCodeRequestNormalizerPlugin, LoggingPlugin, };
49
+ export { MCPAuthPlugin, EndpointBlockerPlugin, GatewayKeyPlugin, SSOAuthPlugin, JWTAuthPlugin, HeaderInjectionPlugin, RequestSanitizerPlugin, ClaudeRequestNormalizerPlugin, KimiRequestNormalizerPlugin, CodexRequestNormalizerPlugin, CodexEncryptedContentSanitizerPlugin, CopilotEncryptedContentSanitizerPlugin, VsCodeRequestNormalizerPlugin, LoggingPlugin, };
48
50
  export { SSOSessionSyncPlugin } from './sso.session-sync.plugin.js';
49
51
  export { getPluginRegistry, resetPluginRegistry } from './registry.js';
50
52
  export * from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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ACF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,cAAc,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"metrics-api-client.d.ts","sourceRoot":"","sources":["../../../../../../../src/providers/plugins/sso/session/processors/metrics/metrics-api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,aAAa,EAEb,mBAAmB,EAGpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AA4NtG;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,qB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O,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,oBAAoB;IAiBzC;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,kBAAkB,GAAG,YAAY,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EACjJ,gBAAgB,EAAE,MAAM,EACxB,MAAM,GAAE,kBAA0C,EAClD,KAAK,CAAC,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,gBAAgB,EAC7B,iBAAiB,CAAC,EAAE,qBAAqB,GACxC,OAAO,CAAC,mBAAmB,CAAC;IAyH/B;;;;;;;;;;OAUG;IACG,cAAc,CAClB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,kBAAkB,GAAG,YAAY,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EACjJ,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,YAAY,EACpB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,mBAAmB,CAAC;IAmF/B;;;;;OAKG;IACG,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA6B7E"}
@@ -17,6 +17,7 @@
17
17
  import { logger } from '../../../../../../utils/logger.js';
18
18
  import { detectGitBranch } from '../../../../../../utils/processes.js';
19
19
  import { extractRepository } from '../../../../../../utils/paths.js';
20
+ import { markAnalyticsAuthInvalid, clearAnalyticsAuthStatus } from '../../../../../../utils/analytics-auth-status.js';
20
21
  import { CODEMIE_ENDPOINTS } from '../../../sso.http-client.js';
21
22
  /**
22
23
  * Low-level HTTP client for sending metrics to CodeMie API
@@ -49,13 +50,21 @@ class MetricsApiClient {
49
50
  logger.debug(`[MetricsApiClient] Retry attempt ${attempt} after ${delay}ms`);
50
51
  await this.sleep(delay);
51
52
  }
52
- return await this.sendRequest(metric);
53
+ const response = await this.sendRequest(metric);
54
+ // Server accepted our credentials — clear any stale invalid-auth marker
55
+ await clearAnalyticsAuthStatus();
56
+ return response;
53
57
  }
54
58
  catch (error) {
55
59
  lastError = error;
56
60
  const errorMessage = error instanceof Error ? error.message : String(error);
57
61
  const errorName = error instanceof Error ? error.name : 'Unknown';
58
62
  const statusCode = error.statusCode;
63
+ // Record credential rejections (401/403 or HTML SSO login page) so the
64
+ // hook auth gate can prompt the user to re-authenticate
65
+ if (error.isAuthFailure) {
66
+ await markAnalyticsAuthInvalid(statusCode ? `HTTP ${statusCode}: ${errorMessage}` : errorMessage, this.config.baseUrl);
67
+ }
59
68
  if (!this.isRetryable(error)) {
60
69
  logger.error(`[MetricsApiClient] Non-retryable error [${errorName}]: ${errorMessage}${statusCode ? ` (HTTP ${statusCode})` : ''}`);
61
70
  throw error;
@@ -143,12 +152,14 @@ class MetricsApiClient {
143
152
  const error = new Error(errorMessage);
144
153
  error.statusCode = response.status;
145
154
  error.response = data;
155
+ error.isAuthFailure = response.status === 401 || response.status === 403;
146
156
  throw error;
147
157
  }
148
158
  const errorMessage = 'message' in data ? data.message : response.statusText;
149
159
  const error = new Error(`API returned ${response.status}: ${errorMessage}`);
150
160
  error.statusCode = response.status;
151
161
  error.response = data;
162
+ error.isAuthFailure = response.status === 401 || response.status === 403;
152
163
  throw error;
153
164
  }
154
165
  const successData = data;
@@ -197,6 +208,9 @@ function parseMetricsResponse(responseText, statusCode, contentType) {
197
208
  const error = new Error(`API returned non-JSON metrics response (HTTP ${statusCode}, content-type=${contentType || 'unknown'}): ${excerpt}`);
198
209
  error.statusCode = statusCode;
199
210
  error.responseText = excerpt;
211
+ // An HTML page instead of JSON means the request was redirected to the SSO
212
+ // login page (e.g. Keycloak answers HTTP 200 + login HTML for expired cookies)
213
+ error.isAuthFailure = Boolean(contentType?.includes('text/html'));
200
214
  throw error;
201
215
  }
202
216
  }