diff --git a/src/agents/models-config.providers.ts b/src/agents/models-config.providers.ts index ee367c594..0acb6aaaf 100644 --- a/src/agents/models-config.providers.ts +++ b/src/agents/models-config.providers.ts @@ -312,7 +312,7 @@ export async function resolveImplicitCopilotProvider(params: { env?: NodeJS.ProcessEnv; }): Promise { const env = params.env ?? process.env; - const authStore = ensureAuthProfileStore(params.agentDir); + const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false }); const hasProfile = listProfilesForProvider(authStore, "github-copilot").length > 0; const envToken = env.COPILOT_GITHUB_TOKEN ?? env.GH_TOKEN ?? env.GITHUB_TOKEN; const githubToken = (envToken ?? "").trim(); diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index 25f36a712..cf7c65734 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -116,7 +116,7 @@ export async function runEmbeddedPiAgent( ); } - const authStore = ensureAuthProfileStore(agentDir); + const authStore = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false }); const explicitProfileId = params.authProfileId?.trim(); const profileOrder = resolveAuthProfileOrder({ cfg: params.config, diff --git a/test/test-env.ts b/test/test-env.ts index f6a8ba9ee..7560aa0cf 100644 --- a/test/test-env.ts +++ b/test/test-env.ts @@ -63,6 +63,9 @@ export function installTestEnv(): { cleanup: () => void; tempHome: string } { { key: "CLAWDBOT_STATE_DIR", value: process.env.CLAWDBOT_STATE_DIR }, { key: "CLAWDBOT_CONFIG_PATH", value: process.env.CLAWDBOT_CONFIG_PATH }, { key: "CLAWDBOT_TEST_HOME", value: process.env.CLAWDBOT_TEST_HOME }, + { key: "COPILOT_GITHUB_TOKEN", value: process.env.COPILOT_GITHUB_TOKEN }, + { key: "GH_TOKEN", value: process.env.GH_TOKEN }, + { key: "GITHUB_TOKEN", value: process.env.GITHUB_TOKEN }, ]; const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "clawdbot-test-home-")); @@ -75,6 +78,10 @@ export function installTestEnv(): { cleanup: () => void; tempHome: string } { delete process.env.CLAWDBOT_CONFIG_PATH; // Prefer deriving state dir from HOME so nested tests that change HOME also isolate correctly. delete process.env.CLAWDBOT_STATE_DIR; + // Avoid leaking real GitHub/Copilot tokens into non-live test runs. + delete process.env.COPILOT_GITHUB_TOKEN; + delete process.env.GH_TOKEN; + delete process.env.GITHUB_TOKEN; // Windows: prefer the legacy default state dir so auth/profile tests match real paths. if (process.platform === "win32") {