* When the host owns inference routing (sets * CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST in spawn env), strip * provider-selection / model-default vars from settings-sourced env so a * user's ~/.claude/settings.json can't redirect requests away from the * host-configured provider.
( env: Record<string, string> | undefined, )
| 43 | * host-configured provider. |
| 44 | */ |
| 45 | function withoutHostManagedProviderVars( |
| 46 | env: Record<string, string> | undefined, |
| 47 | ): Record<string, string> { |
| 48 | if (!env) return {} |
| 49 | if (!isEnvTruthy(process.env.CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST)) { |
| 50 | return env |
| 51 | } |
| 52 | const out: Record<string, string> = {} |
| 53 | for (const [key, value] of Object.entries(env)) { |
| 54 | if (!isProviderManagedEnvVar(key)) { |
| 55 | out[key] = value |
| 56 | } |
| 57 | } |
| 58 | return out |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Snapshot of env keys present before any settings.env is applied — for CCD, |
no test coverage detected