Skip to content
Source
Sign inSign up

providerEnv.ts

23 lines1.1 KB

1// Agent shells carry real provider credentials (CLIProxy sets ANTHROPIC_AUTH_TOKEN and
2// ANTHROPIC_BASE_URL) and the agent's own T3 state. Tests that read the ambient environment
3// then pass or fail by who runs them. Tests that need one of these variables set it
4// themselves. Set T3CODE_TEST_KEEP_PROVIDER_ENV=1 to keep them, for example for a live run.
5const PROVIDER_ENV_PREFIXES = ["ANTHROPIC_", "CLAUDE_", "CODEX_", "OPENAI_", "T3CODE_"];
6​
7const KEPT_ENV = new Set([
8 // CI sets these so the transfer budget integration test writes its report for the job summary.
9 "T3CODE_TRANSFER_BUDGET_REPORT_PATH",
10 "T3CODE_TRANSFER_BUDGET_RESULT_PATH",
11 "T3CODE_TRANSFER_BUDGET_SCENARIOS_PATH",
12 // Opt-in: points the HtmlRender tests at a headless browser, which they skip without.
13 "T3CODE_TEST_HEADLESS_SHELL",
14]);
15​
16if (process.env.T3CODE_TEST_KEEP_PROVIDER_ENV !== "1") {
17 for (const key of Object.keys(process.env)) {
18 if (KEPT_ENV.has(key)) continue;
19 if (PROVIDER_ENV_PREFIXES.some((prefix) => key.startsWith(prefix))) {
20 delete process.env[key];
21 }
22 }