@codemieai/code 0.15.3 → 0.15.5

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 (208) hide show
  1. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  2. package/dist/agents/core/AgentCLI.js +9 -0
  3. package/dist/agents/core/AgentCLI.js.map +1 -1
  4. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  5. package/dist/agents/core/BaseAgentAdapter.js +34 -9
  6. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  7. package/dist/agents/plugins/claude/claude.models.d.ts +58 -0
  8. package/dist/agents/plugins/claude/claude.models.d.ts.map +1 -1
  9. package/dist/agents/plugins/claude/claude.models.js +196 -10
  10. package/dist/agents/plugins/claude/claude.models.js.map +1 -1
  11. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  12. package/dist/agents/plugins/claude/claude.plugin.js +147 -45
  13. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  14. package/dist/agents/plugins/claude/plugin/statusline.bundle.mjs +729 -0
  15. package/dist/agents/plugins/claude/statusline-installer.d.ts +1 -1
  16. package/dist/agents/plugins/claude/statusline-installer.d.ts.map +1 -1
  17. package/dist/agents/plugins/claude/statusline-installer.js +41 -3
  18. package/dist/agents/plugins/claude/statusline-installer.js.map +1 -1
  19. package/dist/agents/plugins/codex/codex-models.d.ts.map +1 -1
  20. package/dist/agents/plugins/codex/codex-models.js +109 -8
  21. package/dist/agents/plugins/codex/codex-models.js.map +1 -1
  22. package/dist/agents/plugins/codex/codex.correlation.d.ts +39 -0
  23. package/dist/agents/plugins/codex/codex.correlation.d.ts.map +1 -0
  24. package/dist/agents/plugins/codex/codex.correlation.js +150 -0
  25. package/dist/agents/plugins/codex/codex.correlation.js.map +1 -0
  26. package/dist/agents/plugins/codex/codex.plugin.d.ts.map +1 -1
  27. package/dist/agents/plugins/codex/codex.plugin.js +8 -40
  28. package/dist/agents/plugins/codex/codex.plugin.js.map +1 -1
  29. package/dist/agents/plugins/kimi/kimi.env-model.d.ts +27 -0
  30. package/dist/agents/plugins/kimi/kimi.env-model.d.ts.map +1 -0
  31. package/dist/agents/plugins/kimi/kimi.env-model.js +52 -0
  32. package/dist/agents/plugins/kimi/kimi.env-model.js.map +1 -0
  33. package/dist/agents/plugins/kimi/kimi.session.d.ts +6 -0
  34. package/dist/agents/plugins/kimi/kimi.session.d.ts.map +1 -1
  35. package/dist/agents/plugins/kimi/kimi.session.js +24 -2
  36. package/dist/agents/plugins/kimi/kimi.session.js.map +1 -1
  37. package/dist/agents/plugins/opencode/opencode-dynamic-models.js +1 -1
  38. package/dist/agents/plugins/opencode/opencode-dynamic-models.js.map +1 -1
  39. package/dist/cli/commands/analytics/cost/cost-enricher.d.ts +19 -2
  40. package/dist/cli/commands/analytics/cost/cost-enricher.d.ts.map +1 -1
  41. package/dist/cli/commands/analytics/cost/cost-enricher.js +171 -14
  42. package/dist/cli/commands/analytics/cost/cost-enricher.js.map +1 -1
  43. package/dist/cli/commands/analytics/cost/local-models.d.ts +15 -0
  44. package/dist/cli/commands/analytics/cost/local-models.d.ts.map +1 -0
  45. package/dist/cli/commands/analytics/cost/local-models.js +21 -0
  46. package/dist/cli/commands/analytics/cost/local-models.js.map +1 -0
  47. package/dist/cli/commands/analytics/cost/types.d.ts +60 -0
  48. package/dist/cli/commands/analytics/cost/types.d.ts.map +1 -1
  49. package/dist/cli/commands/analytics/cost/types.js.map +1 -1
  50. package/dist/cli/commands/analytics/cost/usage-readers.d.ts +25 -2
  51. package/dist/cli/commands/analytics/cost/usage-readers.d.ts.map +1 -1
  52. package/dist/cli/commands/analytics/cost/usage-readers.js +61 -3
  53. package/dist/cli/commands/analytics/cost/usage-readers.js.map +1 -1
  54. package/dist/cli/commands/analytics/formatter.d.ts +11 -0
  55. package/dist/cli/commands/analytics/formatter.d.ts.map +1 -1
  56. package/dist/cli/commands/analytics/formatter.js +28 -0
  57. package/dist/cli/commands/analytics/formatter.js.map +1 -1
  58. package/dist/cli/commands/analytics/index.d.ts.map +1 -1
  59. package/dist/cli/commands/analytics/index.js +113 -72
  60. package/dist/cli/commands/analytics/index.js.map +1 -1
  61. package/dist/cli/commands/analytics/otel-loader.d.ts.map +1 -1
  62. package/dist/cli/commands/analytics/otel-loader.js +60 -14
  63. package/dist/cli/commands/analytics/otel-loader.js.map +1 -1
  64. package/dist/cli/commands/analytics/otel-pricing.d.ts +38 -0
  65. package/dist/cli/commands/analytics/otel-pricing.d.ts.map +1 -0
  66. package/dist/cli/commands/analytics/otel-pricing.js +33 -0
  67. package/dist/cli/commands/analytics/otel-pricing.js.map +1 -0
  68. package/dist/cli/commands/analytics/report/client/app.js +279 -18
  69. package/dist/cli/commands/analytics/report/output-target.d.ts +22 -0
  70. package/dist/cli/commands/analytics/report/output-target.d.ts.map +1 -0
  71. package/dist/cli/commands/analytics/report/output-target.js +56 -0
  72. package/dist/cli/commands/analytics/report/output-target.js.map +1 -0
  73. package/dist/cli/commands/analytics/report/payload-builder.d.ts.map +1 -1
  74. package/dist/cli/commands/analytics/report/payload-builder.js +6 -0
  75. package/dist/cli/commands/analytics/report/payload-builder.js.map +1 -1
  76. package/dist/cli/commands/analytics/report/report-generator.d.ts +1 -1
  77. package/dist/cli/commands/analytics/report/report-generator.js +1 -1
  78. package/dist/cli/commands/analytics/report/session-report.d.ts +1 -3
  79. package/dist/cli/commands/analytics/report/session-report.d.ts.map +1 -1
  80. package/dist/cli/commands/analytics/report/session-report.js +1 -3
  81. package/dist/cli/commands/analytics/report/session-report.js.map +1 -1
  82. package/dist/cli/commands/analytics/report/template.html +6 -6
  83. package/dist/cli/commands/analytics/report/types.d.ts +17 -1
  84. package/dist/cli/commands/analytics/report/types.d.ts.map +1 -1
  85. package/dist/cli/commands/analytics/sources/sessions-source.d.ts.map +1 -1
  86. package/dist/cli/commands/analytics/sources/sessions-source.js +9 -11
  87. package/dist/cli/commands/analytics/sources/sessions-source.js.map +1 -1
  88. package/dist/cli/commands/analytics/sources/types.d.ts +0 -2
  89. package/dist/cli/commands/analytics/sources/types.d.ts.map +1 -1
  90. package/dist/cli/commands/analytics/types.d.ts +13 -7
  91. package/dist/cli/commands/analytics/types.d.ts.map +1 -1
  92. package/dist/cli/commands/doctor/checks/NpmPrefixOverrideCheck.d.ts +9 -0
  93. package/dist/cli/commands/doctor/checks/NpmPrefixOverrideCheck.d.ts.map +1 -0
  94. package/dist/cli/commands/doctor/checks/NpmPrefixOverrideCheck.js +42 -0
  95. package/dist/cli/commands/doctor/checks/NpmPrefixOverrideCheck.js.map +1 -0
  96. package/dist/cli/commands/doctor/checks/index.d.ts +1 -0
  97. package/dist/cli/commands/doctor/checks/index.d.ts.map +1 -1
  98. package/dist/cli/commands/doctor/checks/index.js +1 -0
  99. package/dist/cli/commands/doctor/checks/index.js.map +1 -1
  100. package/dist/cli/commands/doctor/index.d.ts.map +1 -1
  101. package/dist/cli/commands/doctor/index.js +2 -1
  102. package/dist/cli/commands/doctor/index.js.map +1 -1
  103. package/dist/cli/commands/models.d.ts.map +1 -1
  104. package/dist/cli/commands/models.js +16 -3
  105. package/dist/cli/commands/models.js.map +1 -1
  106. package/dist/cli/commands/proxy/connect-orchestrator.js +1 -1
  107. package/dist/cli/commands/proxy/connect-orchestrator.js.map +1 -1
  108. package/dist/cli/commands/proxy/connectors/tenant-catalog.d.ts +16 -4
  109. package/dist/cli/commands/proxy/connectors/tenant-catalog.d.ts.map +1 -1
  110. package/dist/cli/commands/proxy/connectors/tenant-catalog.js +42 -14
  111. package/dist/cli/commands/proxy/connectors/tenant-catalog.js.map +1 -1
  112. package/dist/cli/commands/proxy/connectors/vscode-models.d.ts +18 -0
  113. package/dist/cli/commands/proxy/connectors/vscode-models.d.ts.map +1 -1
  114. package/dist/cli/commands/proxy/connectors/vscode-models.js +58 -0
  115. package/dist/cli/commands/proxy/connectors/vscode-models.js.map +1 -1
  116. package/dist/cli/commands/proxy/connectors/vscode.d.ts +2 -2
  117. package/dist/cli/commands/proxy/connectors/vscode.d.ts.map +1 -1
  118. package/dist/cli/commands/proxy/connectors/vscode.js +27 -38
  119. package/dist/cli/commands/proxy/connectors/vscode.js.map +1 -1
  120. package/dist/cli/commands/update.d.ts.map +1 -1
  121. package/dist/cli/commands/update.js +4 -3
  122. package/dist/cli/commands/update.js.map +1 -1
  123. package/dist/frameworks/plugins/codegraph.plugin.js +2 -2
  124. package/dist/frameworks/plugins/codegraph.plugin.js.map +1 -1
  125. package/dist/providers/core/codemie-auth-helpers.d.ts.map +1 -1
  126. package/dist/providers/core/codemie-auth-helpers.js +6 -1
  127. package/dist/providers/core/codemie-auth-helpers.js.map +1 -1
  128. package/dist/providers/core/default-agent-hooks.d.ts.map +1 -1
  129. package/dist/providers/core/default-agent-hooks.js +9 -0
  130. package/dist/providers/core/default-agent-hooks.js.map +1 -1
  131. package/dist/providers/plugins/bedrock/bedrock.template.d.ts.map +1 -1
  132. package/dist/providers/plugins/bedrock/bedrock.template.js +5 -31
  133. package/dist/providers/plugins/bedrock/bedrock.template.js.map +1 -1
  134. package/dist/providers/plugins/sso/proxy/plugins/background-request-normalizer.plugin.d.ts +44 -0
  135. package/dist/providers/plugins/sso/proxy/plugins/background-request-normalizer.plugin.d.ts.map +1 -0
  136. package/dist/providers/plugins/sso/proxy/plugins/background-request-normalizer.plugin.js +106 -0
  137. package/dist/providers/plugins/sso/proxy/plugins/background-request-normalizer.plugin.js.map +1 -0
  138. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +3 -1
  139. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  140. package/dist/providers/plugins/sso/proxy/plugins/index.js +5 -1
  141. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  142. package/dist/providers/plugins/sso/proxy/plugins/routing-header-injector.plugin.d.ts +67 -0
  143. package/dist/providers/plugins/sso/proxy/plugins/routing-header-injector.plugin.d.ts.map +1 -0
  144. package/dist/providers/plugins/sso/proxy/plugins/routing-header-injector.plugin.js +203 -0
  145. package/dist/providers/plugins/sso/proxy/plugins/routing-header-injector.plugin.js.map +1 -0
  146. package/dist/providers/plugins/sso/sso.http-client.d.ts +95 -0
  147. package/dist/providers/plugins/sso/sso.http-client.d.ts.map +1 -1
  148. package/dist/providers/plugins/sso/sso.http-client.js +79 -0
  149. package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
  150. package/dist/providers/plugins/sso/sso.models.d.ts +7 -0
  151. package/dist/providers/plugins/sso/sso.models.d.ts.map +1 -1
  152. package/dist/providers/plugins/sso/sso.models.js +22 -14
  153. package/dist/providers/plugins/sso/sso.models.js.map +1 -1
  154. package/dist/utils/bedrock-pricing.mjs +111 -0
  155. package/dist/utils/cli-bin.d.ts.map +1 -1
  156. package/dist/utils/cli-bin.js +3 -4
  157. package/dist/utils/cli-bin.js.map +1 -1
  158. package/dist/utils/cli-updater.d.ts +1 -0
  159. package/dist/utils/cli-updater.d.ts.map +1 -1
  160. package/dist/utils/cli-updater.js +37 -9
  161. package/dist/utils/cli-updater.js.map +1 -1
  162. package/dist/utils/credential-crypto.d.ts +51 -0
  163. package/dist/utils/credential-crypto.d.ts.map +1 -0
  164. package/dist/utils/credential-crypto.js +96 -0
  165. package/dist/utils/credential-crypto.js.map +1 -0
  166. package/dist/utils/model-normalizer.d.ts +6 -0
  167. package/dist/utils/model-normalizer.d.ts.map +1 -1
  168. package/dist/utils/model-normalizer.js +37 -19
  169. package/dist/utils/model-normalizer.js.map +1 -1
  170. package/dist/utils/npm-prefix.d.ts +48 -0
  171. package/dist/utils/npm-prefix.d.ts.map +1 -0
  172. package/dist/utils/npm-prefix.js +142 -0
  173. package/dist/utils/npm-prefix.js.map +1 -0
  174. package/dist/utils/paths.d.ts +7 -0
  175. package/dist/utils/paths.d.ts.map +1 -1
  176. package/dist/utils/paths.js +10 -0
  177. package/dist/utils/paths.js.map +1 -1
  178. package/dist/utils/platform.d.ts +10 -0
  179. package/dist/utils/platform.d.ts.map +1 -0
  180. package/dist/utils/platform.js +14 -0
  181. package/dist/utils/platform.js.map +1 -0
  182. package/dist/utils/price-resolution.d.ts +42 -0
  183. package/dist/utils/price-resolution.d.ts.map +1 -0
  184. package/dist/utils/price-resolution.js +112 -0
  185. package/dist/utils/price-resolution.js.map +1 -0
  186. package/dist/utils/pricing.d.ts +65 -6
  187. package/dist/utils/pricing.d.ts.map +1 -1
  188. package/dist/utils/pricing.js +91 -117
  189. package/dist/utils/pricing.js.map +1 -1
  190. package/dist/utils/pricing.json +201 -20
  191. package/dist/utils/processes.d.ts.map +1 -1
  192. package/dist/utils/processes.js +6 -3
  193. package/dist/utils/processes.js.map +1 -1
  194. package/dist/utils/routing-headers.mjs +104 -0
  195. package/dist/utils/security.d.ts +0 -32
  196. package/dist/utils/security.d.ts.map +1 -1
  197. package/dist/utils/security.js +20 -102
  198. package/dist/utils/security.js.map +1 -1
  199. package/package.json +4 -2
  200. package/scripts/bundle-statusline.mjs +37 -0
  201. package/scripts/copy-plugins.js +19 -2
  202. package/src/utils/tips.json +9 -9
  203. package/dist/agents/plugins/claude/plugin/__tests__/statusline.test.ts +0 -323
  204. package/dist/agents/plugins/claude/plugin/statusline.mjs +0 -282
  205. package/dist/cli/commands/analytics/exporter.d.ts +0 -20
  206. package/dist/cli/commands/analytics/exporter.d.ts.map +0 -1
  207. package/dist/cli/commands/analytics/exporter.js +0 -91
  208. package/dist/cli/commands/analytics/exporter.js.map +0 -1
@@ -1,7 +1,10 @@
1
- import { fetchCodeMieLlmModels } from '../../../providers/plugins/sso/sso.http-client.js';
1
+ import { fetchCodeMieLlmModels, buildModelLabelIndex, describeRouter } from '../../../providers/plugins/sso/sso.http-client.js';
2
2
  import { CodeMieSSO } from '../../../providers/plugins/sso/sso.auth.js';
3
3
  import { ConfigurationError } from '../../../utils/errors.js';
4
4
  import { logger } from '../../../utils/logger.js';
5
+ // CODEMIE_MODEL_SOURCE values that mean "the user picked this", as opposed to 'default'
6
+ // (read from a saved profile), which is the only case auto-resolution may override.
7
+ const EXPLICIT_MODEL_SOURCES = new Set(['cli', 'env']);
5
8
  const TIER_ENV_VAR = {
6
9
  model: 'CODEMIE_MODEL',
7
10
  haiku: 'CODEMIE_HAIKU_MODEL',
@@ -41,15 +44,30 @@ function getSearchText(model) {
41
44
  .join(' ')
42
45
  .toLowerCase();
43
46
  }
44
- function isClaudeCompatibleModel(model, tier) {
47
+ /**
48
+ * Every id the catalog may expose an entry under. A gateway or router deployment is usually
49
+ * addressed by its deployment name while the catalog also carries a base name and a display
50
+ * label, so a configured id has to be matched against all three.
51
+ */
52
+ function modelIdentifiers(model) {
53
+ return [model.deployment_name, model.base_name, model.label].filter((value) => Boolean(value));
54
+ }
55
+ /**
56
+ * Whether a deployment can serve an agent session at all: enabled, tool- and stream-capable,
57
+ * and not an embedding/rerank/audio endpoint. Says nothing about model family on purpose —
58
+ * `isClaudeCompatibleModel` layers the family check on top, and only for auto-selection.
59
+ */
60
+ function isServableModel(model) {
45
61
  if (!model.enabled)
46
62
  return false;
47
63
  if (model.features?.tools === false || model.features?.streaming === false)
48
64
  return false;
49
- const searchText = getSearchText(model);
50
- if (CLAUDE_INCOMPATIBLE_MODEL_PATTERNS.some((pattern) => pattern.test(searchText))) {
65
+ return !CLAUDE_INCOMPATIBLE_MODEL_PATTERNS.some((pattern) => pattern.test(getSearchText(model)));
66
+ }
67
+ function isClaudeCompatibleModel(model, tier) {
68
+ if (!isServableModel(model))
51
69
  return false;
52
- }
70
+ const searchText = getSearchText(model);
53
71
  if (!CLAUDE_FAMILY_PATTERNS.some((pattern) => pattern.test(searchText))) {
54
72
  return false;
55
73
  }
@@ -126,6 +144,154 @@ async function fetchCatalog(env) {
126
144
  cachedCatalog = { key: cacheKey, fetchedAt: Date.now(), models };
127
145
  return models;
128
146
  }
147
+ function isRouterCatalogEntry(model) {
148
+ return model.is_router === true || model.litellm_router?.is_router === true;
149
+ }
150
+ /**
151
+ * Every id the live catalog addresses a router by — a Switchyard virtual router (`is_router` on
152
+ * the catalog entry) or a declared LiteLLM auto-router (`litellm_router.is_router`) — rather than
153
+ * a concrete deployment. Only a router can dispatch a turn to a different backend model than the
154
+ * one it was addressed as, so membership in this list is the signal that gates the statusline's
155
+ * "routed to" widget (see statusline.mjs's `resolveActualModel`): showing it for a non-router
156
+ * model would misread ordinary provider aliasing (e.g. a Bedrock region snapshot) as routing.
157
+ *
158
+ * A full list rather than a single boolean for the session's starting model, because the
159
+ * statusline must keep gating correctly after a mid-session `/model` switch — Claude Code's own
160
+ * `/model` command changes the live model without re-running this process's `beforeRun` hook, so
161
+ * whichever model id the statusline currently reports has to be checked against this list on
162
+ * every render rather than against a value baked in once at session start.
163
+ *
164
+ * Returns `[]` — never throws — when the catalog cannot be fetched, the same conservative default
165
+ * `resolveClaudeModel` uses: the widget should stay off rather than risk showing it on uncertainty.
166
+ */
167
+ export async function listRouterModelIds(env) {
168
+ try {
169
+ const catalog = await fetchCatalog(env);
170
+ const ids = new Set();
171
+ for (const model of catalog) {
172
+ if (!isRouterCatalogEntry(model))
173
+ continue;
174
+ for (const id of modelIdentifiers(model))
175
+ ids.add(id);
176
+ }
177
+ return [...ids];
178
+ }
179
+ catch (error) {
180
+ logger.debug('[claude-models] Could not list router model ids', {
181
+ error: error instanceof Error ? error.message : String(error),
182
+ });
183
+ return [];
184
+ }
185
+ }
186
+ /**
187
+ * Maps every id the live catalog addresses a model by (deployment name, base name, and label —
188
+ * see {@link modelIdentifiers}) to that model's own `label`. Entries with no label are omitted:
189
+ * there is nothing better to show than the id already displayed, so a lookup miss just means
190
+ * "keep today's behavior" for the caller.
191
+ *
192
+ * Built for the statusline (see statusline.mjs's `parseModelLabels`/`resolveActualModel`), which
193
+ * runs detached and cannot query the catalog itself. Claude Code's own `display_name` for an id
194
+ * it does not recognize — a Switchyard router's custom `base_name`, for instance — is a best
195
+ * guess derived from the id string and can be misleading (e.g. showing a capable-tier family
196
+ * name for a router alias that only happens to embed it); the routed-to model id is even less
197
+ * readable, being an id/base_name rather than a display label. The catalog's own `label` is the
198
+ * one name CodeMie actually configured for the model, so it takes precedence over both wherever
199
+ * a lookup succeeds.
200
+ *
201
+ * Returns `{}` — never throws — when the catalog cannot be fetched, so a lookup miss degrades to
202
+ * exactly today's behavior (Claude Code's own display, or the raw routed-to id) rather than
203
+ * blocking the statusline.
204
+ */
205
+ export async function buildModelLabelMap(env) {
206
+ try {
207
+ const catalog = await fetchCatalog(env);
208
+ const labels = {};
209
+ for (const model of catalog) {
210
+ if (!model.label)
211
+ continue;
212
+ for (const id of modelIdentifiers(model)) {
213
+ labels[id] = model.label;
214
+ }
215
+ }
216
+ return labels;
217
+ }
218
+ catch (error) {
219
+ logger.debug('[claude-models] Could not build model label map', {
220
+ error: error instanceof Error ? error.message : String(error),
221
+ });
222
+ return {};
223
+ }
224
+ }
225
+ /**
226
+ * Whether a catalog entry — plain model or router — resolves to a Claude-family backend, for
227
+ * the model picker. Mirrors codex-models.ts's `isCodexCompatibleModel`: a LiteLLM auto-router's
228
+ * own alias name is family-agnostic by convention (`claude-smart-router` and `gpt-smart-router`
229
+ * are both named like routers, not like their target), so `counterfactual_model` — the concrete
230
+ * deployment it currently resolves to — is the deterministic signal to judge it by when present.
231
+ * A Switchyard virtual router carries no target-model field to check deterministically, so
232
+ * CodeMie's own naming convention (base_name/label embedding the constituent families, e.g.
233
+ * `sy-signal-claude-sonnet-haiku` vs `sy-signal-gpt-terra-luna`) is trusted instead — the same
234
+ * name check already used for a plain model.
235
+ */
236
+ function isClaudeFamilyPickerEntry(model) {
237
+ const counterfactual = model.litellm_router?.counterfactual_model;
238
+ if (counterfactual) {
239
+ return CLAUDE_FAMILY_PATTERNS.some((pattern) => pattern.test(counterfactual));
240
+ }
241
+ return CLAUDE_FAMILY_PATTERNS.some((pattern) => pattern.test(getSearchText(model)));
242
+ }
243
+ /**
244
+ * Builds the option list for Claude Code's `modelPicker` settings key (v2.1.243+) from the live
245
+ * CodeMie catalog: every enabled, servable model that resolves to a Claude-family backend —
246
+ * a plain Claude-named deployment, or a router (Switchyard virtual router / LiteLLM auto-router
247
+ * — see `isRouterCatalogEntry`) whose target is Claude-family (see `isClaudeFamilyPickerEntry`).
248
+ * A router targeting a different family (e.g. a GPT auto-router) is excluded — Claude Code can't
249
+ * drive it anyway, so listing it would just be catalog noise.
250
+ *
251
+ * Ranked with the same `rankModel`/`compareRankedModels` ordering already used for tier
252
+ * auto-resolution, so the picker's top rows match what auto-resolution would have picked.
253
+ *
254
+ * Returns `[]` — never throws — when the catalog is unavailable; the caller must treat an
255
+ * empty result as "leave the picker alone" rather than writing an empty lineup.
256
+ */
257
+ export async function buildModelPickerOptions(env) {
258
+ try {
259
+ const catalog = await fetchCatalog(env);
260
+ const ranked = catalog
261
+ .filter((model) => isServableModel(model) && isClaudeFamilyPickerEntry(model))
262
+ .map((model) => {
263
+ try {
264
+ return { ranked: rankModel(model), model };
265
+ }
266
+ catch {
267
+ // A malformed catalog entry (no usable id) must not abort the whole list.
268
+ return null;
269
+ }
270
+ })
271
+ .filter((entry) => entry !== null)
272
+ .sort((a, b) => compareRankedModels(a.ranked, b.ranked));
273
+ // Built from the FULL catalog, not just `ranked` — a router's classifier model can
274
+ // belong to a family this picker otherwise filters out (a Claude classifier gating a
275
+ // GPT-targeting router still needs its label resolved).
276
+ const labelIndex = buildModelLabelIndex(catalog);
277
+ const seen = new Set();
278
+ const options = [];
279
+ for (const { ranked: rankedModel, model } of ranked) {
280
+ if (seen.has(rankedModel.id))
281
+ continue; // a model may rank under >1 identifier
282
+ seen.add(rankedModel.id);
283
+ const description = describeRouter(model, labelIndex) || undefined;
284
+ options.push({ model: rankedModel.id, label: model.label || rankedModel.id, description });
285
+ }
286
+ return options;
287
+ }
288
+ catch (error) {
289
+ logger.debug('[claude-models] Could not build model picker options', {
290
+ error: error instanceof Error ? error.message : String(error),
291
+ });
292
+ return [];
293
+ }
294
+ }
129
295
  /**
130
296
  * Resolves the live CodeMie model id for a Claude tier, or `null` when the
131
297
  * currently configured model is still present in the live catalog (nothing to
@@ -133,11 +299,12 @@ async function fetchCatalog(env) {
133
299
  */
134
300
  export async function resolveClaudeModel(env, tier) {
135
301
  const currentModel = env[TIER_ENV_VAR[tier]] || undefined;
136
- // An explicit --model CLI flag is an unconditional override for the `model`
137
- // tier: never replace it via the live-catalog auto-heal below, even if this
138
- // identity's catalog doesn't list it (e.g. missing entitlement rather than a
139
- // globally retired model). Other tiers have no equivalent CLI flag.
140
- if (tier === 'model' && currentModel && env.CODEMIE_MODEL_SOURCE === 'cli') {
302
+ // A model the user just chose is never stale. CODEMIE_MODEL_SOURCE (set by AgentCLI, and by
303
+ // bin/codemie-copilot.js before it) marks a value that arrived from `--model` or the
304
+ // environment rather than from a saved profile. Only the default `model` tier is reachable
305
+ // that way, so haiku/sonnet/opus keep resolving against the live catalog as before.
306
+ if (currentModel && tier === 'model' && EXPLICIT_MODEL_SOURCES.has(env.CODEMIE_MODEL_SOURCE ?? '')) {
307
+ logger.debug(`[claude-models] Model "${currentModel}" was set explicitly (source: ${env.CODEMIE_MODEL_SOURCE}); skipping catalog resolution`);
141
308
  return null;
142
309
  }
143
310
  let catalog;
@@ -177,6 +344,25 @@ export async function resolveClaudeModel(env, tier) {
177
344
  // model now exists — it only gets re-resolved once fully retired.
178
345
  return null;
179
346
  }
347
+ // CLAUDE_FAMILY_PATTERNS is a heuristic over the model id whose job is picking a sensible
348
+ // Claude model automatically. It cannot see through a gateway or router alias whose id says
349
+ // nothing about the family behind it (`gpt-smart-router`, an internal deployment name), so
350
+ // using it to *validate* an already-configured id silently replaces working models. Check
351
+ // the unfiltered catalog first: if the deployment is still there and can serve a session,
352
+ // keep what is configured.
353
+ //
354
+ // Deliberately NOT narrowed to `tier === 'model'` the way the explicit-source skip above is.
355
+ // A tier var legitimately holds an out-of-family id: pinning a router alias as the haiku tier
356
+ // (`CODEMIE_HAIKU_MODEL=claude-smart-router`) matches CLAUDE_FAMILY_PATTERNS but not TIER_PATTERN
357
+ // /haiku/i, so it is filtered out of `ranked` and reaches here. Re-resolving it would replace the
358
+ // router with a literal haiku model and defeat the routing it was configured for. The cost is the
359
+ // same tradeoff already accepted above for in-family ids: a stale or mis-tiered value survives
360
+ // until it is fully retired from the catalog, rather than being silently swapped.
361
+ if (currentModel &&
362
+ catalog.some((model) => isServableModel(model) && modelIdentifiers(model).includes(currentModel))) {
363
+ logger.debug(`[claude-models] Model "${currentModel}" for tier "${tier}" is outside the Claude family but live in the catalog; keeping it`);
364
+ return null;
365
+ }
180
366
  if (ranked.length === 0) {
181
367
  if (currentModel) {
182
368
  logger.debug(`[claude-models] No compatible CodeMie models found for tier "${tier}"; keeping configured model`);
@@ -1 +1 @@
1
- {"version":3,"file":"claude.models.js","sourceRoot":"","sources":["../../../../src/agents/plugins/claude/claude.models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAclD,MAAM,YAAY,GAAoC;IACpD,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,qBAAqB;IAC5B,MAAM,EAAE,sBAAsB;IAC9B,IAAI,EAAE,oBAAoB;CAC3B,CAAC;AAEF,MAAM,kCAAkC,GAAa;IACnD,YAAY;IACZ,SAAS;IACT,UAAU;IACV,MAAM;IACN,aAAa;IACb,QAAQ;IACR,cAAc;CACf,CAAC;AAEF,MAAM,sBAAsB,GAAa;IACvC,SAAS;IACT,YAAY;IACZ,SAAS;IACT,OAAO;IACP,QAAQ;CACT,CAAC;AAEF,8EAA8E;AAC9E,0CAA0C;AAC1C,MAAM,YAAY,GAA2C;IAC3D,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,OAAO;CACd,CAAC;AAEF,SAAS,UAAU,CAAC,KAAe;IACjC,OAAO,KAAK,C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,6BAA6B,CAAC,CAAC;YAChH,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,IAAI,kBAAkB,CAAC,iDAAiD,IAAI,iBAAiB,CAAC,CAAC;IACvG,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,CAAC,MAAM,CAAC,0BAA0B,YAAY,eAAe,IAAI,0CAA0C,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnI,CAAC;IAED,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,CAAC;AAC1D,CAAC"}
1
+ {"version":3,"file":"claude.models.js","sourceRoot":"","sources":["../../../../src/agents/plugins/claude/claude.models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAChI,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAclD,wFAAwF;AACxF,oFAAoF;AACpF,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAEvD,MAAM,YAAY,GAAoC;IACpD,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,qBAAqB;IAC5B,MAAM,EAAE,sBAAsB;IAC9B,IAAI,EAAE,oBAAoB;CAC3B,CAAC;AAEF,MAAM,kCAAkC,GAAa;IACnD,YAAY;IACZ,SAAS;IACT,UAAU;IACV,MAAM;IACN,aAAa;IACb,QAAQ;IACR,cAAc;CACf,CAAC;AAEF,MAAM,sBAAsB,GAAa;IACvC,SAAS;IACT,YAAY;IACZ,SAAS;IACT,OAAO;IACP,QAAQ;CACT,CAAC;AAEF,8EAA8E;AAC9E,0CAA0C;AAC1C,MAAM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IAI/C;;;;;;;;;OASG;YACW,qBAAqB;IAc7B,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA8B1C;;;;;OAKG;IACG,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAQ1D;;;;;;OAMG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAcrC;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B;;;;;;;;;;OAUG;IACG,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA+G9D;;;;;OAKG;IACG,sBAAsB,CAAC,OAAO,CAAC,EAAE,OAAO,qBAAqB,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CAuC9G"}
@@ -1,6 +1,7 @@
1
1
  import { BaseAgentAdapter } from '../../core/BaseAgentAdapter.js';
2
2
  import { ClaudeSessionAdapter } from './claude.session.js';
3
- import { resolveClaudeModel } from './claude.models.js';
3
+ import { resolveClaudeModel, listRouterModelIds, buildModelLabelMap, buildModelPickerOptions } from './claude.models.js';
4
+ import { writeConfigToTempFile } from '../../core/temp-config.js';
4
5
  import { ClaudePluginInstaller } from './claude.plugin-installer.js';
5
6
  import { installNativeAgent } from '../../../utils/native-installer.js';
6
7
  import { isValidSemanticVersion } from '../../../utils/version-utils.js';
@@ -32,6 +33,21 @@ export const CLAUDE_SUPPORTED_VERSION = '2.1.281';
32
33
  * **UPDATE THIS WHEN BUMPING CLAUDE VERSION**
33
34
  */
34
35
  const CLAUDE_MINIMUM_SUPPORTED_VERSION = '2.1.269';
36
+ /**
37
+ * Providers whose gateway is known to round-trip what tool search requires: the
38
+ * `tool-search-tool-2025-10-19` beta header, `defer_loading` tool fields and `tool_reference`
39
+ * content blocks.
40
+ *
41
+ * - `ai-run-sso` — the local CodeMie proxy forwards every request header except `host`/`connection`
42
+ * (`sso.proxy.ts`), and this was verified end to end (44,396 -> 24,353 turn-one tokens).
43
+ * - `litellm` — documents passing the beta header, `defer_loading` and `tool_reference` through.
44
+ *
45
+ * `beforeRun` is provider-agnostic and runs for bedrock, ollama and subscription endpoints too, for
46
+ * which no such evidence exists — and a gateway that takes the body fields without the header answers
47
+ * HTTP 400. So the tool-search defaults below are applied only here; every other provider keeps the
48
+ * conservative values, and either variable set explicitly in the environment still wins everywhere.
49
+ */
50
+ const TOOL_SEARCH_VERIFIED_PROVIDERS = new Set(['ai-run-sso', 'litellm']);
35
51
  /**
36
52
  * Claude Code installer URLs
37
53
  * Official Anthropic installer scripts for native installation
@@ -41,6 +57,43 @@ const CLAUDE_INSTALLER_URLS = {
41
57
  windows: 'https://claude.ai/install.cmd',
42
58
  linux: 'https://claude.ai/install.sh',
43
59
  };
60
+ /**
61
+ * Sanitize a config-sourced value before rendering it to the terminal.
62
+ *
63
+ * Shared by the settings-conflict banner and the model-substitution notice: both print
64
+ * profile/settings values (URLs, model IDs) that the user does not necessarily control.
65
+ *
66
+ * ASCII allowlist: accept only printable ASCII (0x20–0x7E) after stripping ANSI
67
+ * sequences. This blocks C0/C1 bytes, Bidi override chars, soft hyphen,
68
+ * zero-width chars, combining marks, and every other non-ASCII Unicode vector.
69
+ *
70
+ * DCS pre-strip: strip-ansi only removes the 2-byte introducer (\x1bP etc.),
71
+ * leaving the payload as plain ASCII. Strip the full sequence — from introducer
72
+ * to BEL/ST/C1-ST terminator — before handing off to strip-ansi. If no terminator
73
+ * is found, consume to end-of-string (greedy fallback) to prevent partial leakage.
74
+ *
75
+ * URL userinfo guard: https://user@evil.com routes to evil.com; the @ is valid
76
+ * ASCII so the allowlist cannot catch it — URL parsing is required.
77
+ */
78
+ function safeTerminalValue(s) {
79
+ // ESC-form: P=DCS X=SOS ^=PM _=APC; C1-form: \x90 \x98 \x9d(OSC) \x9e \x9f
80
+ const noStringCmds = s.replace(/(?:\x1b[PX^_]|[\x90\x98\x9d\x9e\x9f])[\s\S]*?(?:\x07|\x1b\\|\x9c|$)/g, ''); // eslint-disable-line no-control-regex
81
+ const stripped = stripAnsi(noStringCmds).replace(/[^\x20-\x7e]/gu, '');
82
+ try {
83
+ const url = new URL(stripped);
84
+ if (url.username || url.password || url.search || url.hash) {
85
+ url.username = '';
86
+ url.password = '';
87
+ url.search = '';
88
+ url.hash = '';
89
+ return `[credentials removed] ${url.toString()}`;
90
+ }
91
+ }
92
+ catch {
93
+ // Not a parseable URL — return stripped string as-is
94
+ }
95
+ return stripped;
96
+ }
44
97
  /**
45
98
  * Claude Code Plugin Metadata
46
99
  */
@@ -134,9 +187,20 @@ export const ClaudePluginMetadata = {
134
187
  lifecycle: {
135
188
  // Default hooks for ALL providers (provider-agnostic)
136
189
  async beforeRun(env) {
137
- // Keep experimental betas enabled if not already set
190
+ // Whether this provider's gateway is known to carry the tool-search payload — see
191
+ // TOOL_SEARCH_VERIFIED_PROVIDERS. CODEMIE_PROVIDER is populated before this hook runs.
192
+ const toolSearchVerified = TOOL_SEARCH_VERIFIED_PROVIDERS.has(env.CODEMIE_PROVIDER ?? '');
193
+ // Allow experimental betas on a verified provider. This is a prerequisite for tool search
194
+ // below: CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS suppresses the tool-search beta header
195
+ // (`tool-search-tool-2025-10-19`) and wins over ENABLE_TOOL_SEARCH, so leaving it at '1'
196
+ // makes the tool-search default unreachable.
197
+ // Parsed as a boolean upstream, so '0' reads as false — do NOT use '' here: the
198
+ // `!env.X` guard treats an empty string as unset and would restore the default.
199
+ // Set to '1' in the environment to opt back out (e.g. if a gateway rejects
200
+ // `context_management` / `output_config` body fields with HTTP 400).
201
+ // https://code.claude.com/docs/en/llm-gateway-protocol
138
202
  if (!env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS) {
139
- env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS = '0';
203
+ env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS = toolSearchVerified ? '0' : '1';
140
204
  }
141
205
  // Disable Claude Code telemetry to prevent 404s on /api/event_logging/batch
142
206
  // when using proxy (telemetry endpoint doesn't exist on CodeMie backend)
@@ -163,9 +227,25 @@ export const ClaudePluginMetadata = {
163
227
  if (!env.FORCE_AUTOUPDATE_PLUGINS) {
164
228
  env.FORCE_AUTOUPDATE_PLUGINS = '1';
165
229
  }
166
- // Enable tool search feature if not already set
230
+ // Enable tool search: MCP/deferrable tool definitions are withheld from the context
231
+ // window and loaded on demand instead of upfront, which cuts a large fixed cost from
232
+ // every turn. Measured on a trivial prompt: 44,396 -> 24,353 turn-one tokens (-45%).
233
+ //
234
+ // This must be forced explicitly rather than left unset. Claude Code turns tool search
235
+ // off by itself whenever ANTHROPIC_BASE_URL is not a first-party Anthropic host, on the
236
+ // assumption that a proxy will not round-trip `tool_reference` blocks — and CodeMie
237
+ // always points it at the local SSO proxy. Ours does forward them (sso.proxy.ts strips
238
+ // only `host`/`connection`, and LiteLLM passes the beta header, `defer_loading` and
239
+ // `tool_reference` through), so the assumption does not hold here.
240
+ //
241
+ // Superseded the pre-2.1.69 '0' workaround, which no longer reproduces.
242
+ // Only enabled for a verified provider (see toolSearchVerified above); everything else keeps
243
+ // the conservative '0', because a gateway that receives `tool_reference` blocks it cannot
244
+ // round-trip answers HTTP 400 rather than degrading.
245
+ // Set to '0'/'false' in the environment to opt out; 'true'/'auto:N' to opt in anywhere.
246
+ // https://code.claude.com/docs/en/agent-sdk/tool-search
167
247
  if (!env.ENABLE_TOOL_SEARCH) {
168
- env.ENABLE_TOOL_SEARCH = 'true';
248
+ env.ENABLE_TOOL_SEARCH = toolSearchVerified ? 'true' : '0';
169
249
  }
170
250
  if (!env.ENABLE_PROMPT_CACHING_1H) {
171
251
  env.ENABLE_PROMPT_CACHING_1H = '1';
@@ -210,54 +290,24 @@ export const ClaudePluginMetadata = {
210
290
  const { detectSettingsConflict } = await import('./settings-conflict.js');
211
291
  const conflict = await detectSettingsConflict(env);
212
292
  if (conflict) {
213
- // ASCII allowlist: accept only printable ASCII (0x20–0x7E) after stripping ANSI
214
- // sequences. This blocks C0/C1 bytes, Bidi override chars, soft hyphen,
215
- // zero-width chars, combining marks, and every other non-ASCII Unicode vector.
216
- //
217
- // DCS pre-strip: strip-ansi only removes the 2-byte introducer (\x1bP etc.),
218
- // leaving the payload as plain ASCII. Strip the full sequence — from introducer
219
- // to BEL/ST/C1-ST terminator — before handing off to strip-ansi. If no terminator
220
- // is found, consume to end-of-string (greedy fallback) to prevent partial leakage.
221
- //
222
- // URL userinfo guard: https://user@evil.com routes to evil.com; the @ is valid
223
- // ASCII so the allowlist cannot catch it — URL parsing is required.
224
- const safeUrl = (s) => {
225
- // ESC-form: P=DCS X=SOS ^=PM _=APC; C1-form: \x90 \x98 \x9d(OSC) \x9e \x9f
226
- const noStringCmds = s.replace(/(?:\x1b[PX^_]|[\x90\x98\x9d\x9e\x9f])[\s\S]*?(?:\x07|\x1b\\|\x9c|$)/g, ''); // eslint-disable-line no-control-regex
227
- const stripped = stripAnsi(noStringCmds).replace(/[^\x20-\x7e]/gu, '');
228
- try {
229
- const url = new URL(stripped);
230
- if (url.username || url.password || url.search || url.hash) {
231
- url.username = '';
232
- url.password = '';
233
- url.search = '';
234
- url.hash = '';
235
- return `[credentials removed] ${url.toString()}`;
236
- }
237
- }
238
- catch {
239
- // Not a parseable URL — return stripped string as-is
240
- }
241
- return stripped;
242
- };
243
293
  // The fallback literal contains U+2014 (em dash) which the ASCII allowlist strips.
244
294
  // Bypass safeUrl for the known-safe constant; only user-controlled values need it.
245
295
  console.error(chalk.yellow('\n⚠️ ~/.claude/settings.json overrides detected'));
246
296
  console.error(chalk.yellow('─'.repeat(60)));
247
297
  if (conflict.settingsUrl) {
248
298
  const profileDisplay = conflict.profileUrl
249
- ? safeUrl(conflict.profileUrl)
299
+ ? safeTerminalValue(conflict.profileUrl)
250
300
  : '(not set — direct Anthropic API)';
251
- const activeDisplay = safeUrl(conflict.settingsUrl);
301
+ const activeDisplay = safeTerminalValue(conflict.settingsUrl);
252
302
  console.error(chalk.yellow(` Profile URL │ ${profileDisplay}`));
253
303
  console.error(chalk.yellow(` Active URL │ ${activeDisplay} ← settings.json wins`));
254
304
  console.error(chalk.yellow(''));
255
305
  }
256
306
  if (conflict.settingsModel) {
257
307
  const profileModelDisplay = conflict.profileModel
258
- ? safeUrl(conflict.profileModel)
308
+ ? safeTerminalValue(conflict.profileModel)
259
309
  : '(not set — profile default)';
260
- const activeModelDisplay = safeUrl(conflict.settingsModel);
310
+ const activeModelDisplay = safeTerminalValue(conflict.settingsModel);
261
311
  console.error(chalk.yellow(` Profile model │ ${profileModelDisplay}`));
262
312
  console.error(chalk.yellow(` Active model │ ${activeModelDisplay} ← settings.json wins`));
263
313
  console.error(chalk.yellow(''));
@@ -299,14 +349,21 @@ export const ClaudePluginMetadata = {
299
349
  if (!resolution)
300
350
  continue;
301
351
  const { generic, native } = TIER_TARGET_VARS[tier];
352
+ // Swapping the model the user asked for is a decision they need to see: it changes
353
+ // which model answers every turn, and logger.* only reaches the debug file. The
354
+ // session tier is the one a person selects (`--model`, `codemie setup`), so surface
355
+ // that one on stderr; the haiku/sonnet/opus tiers stay quiet in the log.
356
+ const previousModel = env[generic];
357
+ if (tier === 'model' && previousModel && previousModel !== resolution.selectedModel) {
358
+ console.error(chalk.yellow(`⚠ Model "${safeTerminalValue(previousModel)}" is not available in this CodeMie catalog — using ${safeTerminalValue(resolution.selectedModel)} instead.`));
359
+ console.error(chalk.yellow(' Run "codemie models list" to see the available model IDs.'));
360
+ }
302
361
  env[generic] = resolution.selectedModel;
303
362
  for (const nativeVar of native) {
304
- // Never overwrite a native var the user (or another hook) already
305
- // set directly — only the generic CODEMIE_*_MODEL var is treated
306
- // as the "configured" signal by resolveClaudeModel itself.
307
- if (!env[nativeVar]) {
308
- env[nativeVar] = resolution.selectedModel;
309
- }
363
+ // resolution is non-null only when the model was stale/absent — always
364
+ // propagate so transformEnvVars()'s pre-population of ANTHROPIC_MODEL
365
+ // from the old CODEMIE_MODEL value does not silently survive here.
366
+ env[nativeVar] = resolution.selectedModel;
310
367
  }
311
368
  }
312
369
  catch (error) {
@@ -315,6 +372,42 @@ export const ClaudePluginMetadata = {
315
372
  }));
316
373
  }
317
374
  }
375
+ // The statusline's "routed to" widget must not fire for a plain deployment — only a
376
+ // router can dispatch a turn elsewhere. Exported as the full set of router ids (rather
377
+ // than a single boolean for the session's starting model) so the gate stays correct
378
+ // even after a mid-session `/model` switch: Claude Code's own /model command changes
379
+ // the live model without re-running this beforeRun hook, so the statusline must re-check
380
+ // whichever model id it currently reports against this list on every render rather than
381
+ // trusting a value baked in at session start. listRouterModelIds() never throws and
382
+ // defaults to an empty list on any failure — never shows the widget on uncertainty.
383
+ env.CODEMIE_ROUTER_MODEL_IDS = JSON.stringify(await listRouterModelIds(env));
384
+ // Same reasoning, same export mechanism: the catalog's own display labels, so the
385
+ // statusline can show them instead of Claude Code's own best-guess `display_name` for
386
+ // an id it doesn't recognize (a router's custom base_name, for instance) and instead of
387
+ // a raw id/base_name for whichever model a turn actually routed to. Reuses the same
388
+ // cached catalog fetchCatalog() already populated above — no extra network call.
389
+ env.CODEMIE_MODEL_LABELS = JSON.stringify(await buildModelLabelMap(env));
390
+ // Populate Claude Code's own /model picker (modelPicker settings key, v2.1.243+) with
391
+ // the live CodeMie catalog so switching mid-session actually works — otherwise the
392
+ // picker only shows Anthropic's built-in rows, none of which are valid IDs on this
393
+ // tenant. Delivered via `--settings <tempfile>` (enrichArgs, default-agent-hooks.ts)
394
+ // rather than writing into ~/.claude/settings.json the way statusLine does below: that
395
+ // file is shared across every concurrent Claude Code process on the machine, and an
396
+ // anthropic-subscription session running alongside this one would inherit SSO
397
+ // deployment IDs it can't use. A per-process --settings file avoids that entirely, and
398
+ // needs no afterRun cleanup — writeConfigToTempFile() already registers deletion on exit.
399
+ try {
400
+ const options = await buildModelPickerOptions(env);
401
+ if (options.length > 0) {
402
+ const settingsJson = JSON.stringify({
403
+ modelPicker: { options, replaceBuiltInOptions: true },
404
+ });
405
+ env.CODEMIE_CLAUDE_MODEL_PICKER_SETTINGS = writeConfigToTempFile(settingsJson, 'claude-model-picker');
406
+ }
407
+ }
408
+ catch (error) {
409
+ logger.warn('[Claude] Failed to populate /model picker from CodeMie catalog', ...sanitizeLogArgs({ error: error instanceof Error ? error.message : String(error) }));
410
+ }
318
411
  // AC-6 (EPMCDME-14355): surface tier availability at startup so the user sees when a
319
412
  // subagent-requestable tier is missing. Per-subagent model resolution happens inside
320
413
  // the upstream binary — the CLI has no dispatch-time hook — so a launch-time notice is
@@ -326,6 +419,15 @@ export const ClaudePluginMetadata = {
326
419
  ? `pinned to ${env.CLAUDE_CODE_SUBAGENT_MODEL}`
327
420
  : 'per-request';
328
421
  logger.info(`[Claude] Provisioned tiers: haiku=${hasHaiku ? 'yes' : 'no'}, sonnet=${hasSonnet ? 'yes' : 'no'}, opus=${hasOpus ? 'yes' : 'no'}. Subagent default: ${subagentDefault}.`);
422
+ // A pinned CLAUDE_CODE_SUBAGENT_MODEL is read before both the agent's frontmatter
423
+ // `model` and the Agent tool's `model` parameter, so it silently wins over BOTH —
424
+ // including `model: inherit`, which is what a subagent gets when it declares no model
425
+ // at all. The pin only survives when it matches the session model (see
426
+ // BaseAgentAdapter.transformEnvVars), but say so explicitly: without this line the
427
+ // "pinned to X" notice reads as a default rather than an override.
428
+ if (env.CLAUDE_CODE_SUBAGENT_MODEL) {
429
+ logger.warn(`[Claude] Subagent model is pinned to ${env.CLAUDE_CODE_SUBAGENT_MODEL} — this overrides both \`model: inherit\` in agent frontmatter and any per-subagent \`model\` parameter. Provision a distinct sonnet tier (CODEMIE_SONNET_MODEL) to restore per-subagent model selection.`);
430
+ }
329
431
  // The silent-fallback problem is symmetric across tiers, not haiku-specific: a subagent
330
432
  // dispatched with model:"opus" (or "sonnet") on a tenant that lacks that tier lands on
331
433
  // the subagent default just as a model:"haiku" request does. So warn for EVERY absent