fix: avoid keychain prompts in embedded runner
This commit is contained in:
@@ -312,7 +312,7 @@ export async function resolveImplicitCopilotProvider(params: {
|
|||||||
env?: NodeJS.ProcessEnv;
|
env?: NodeJS.ProcessEnv;
|
||||||
}): Promise<ProviderConfig | null> {
|
}): Promise<ProviderConfig | null> {
|
||||||
const env = params.env ?? process.env;
|
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 hasProfile = listProfilesForProvider(authStore, "github-copilot").length > 0;
|
||||||
const envToken = env.COPILOT_GITHUB_TOKEN ?? env.GH_TOKEN ?? env.GITHUB_TOKEN;
|
const envToken = env.COPILOT_GITHUB_TOKEN ?? env.GH_TOKEN ?? env.GITHUB_TOKEN;
|
||||||
const githubToken = (envToken ?? "").trim();
|
const githubToken = (envToken ?? "").trim();
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export async function runEmbeddedPiAgent(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const authStore = ensureAuthProfileStore(agentDir);
|
const authStore = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false });
|
||||||
const explicitProfileId = params.authProfileId?.trim();
|
const explicitProfileId = params.authProfileId?.trim();
|
||||||
const profileOrder = resolveAuthProfileOrder({
|
const profileOrder = resolveAuthProfileOrder({
|
||||||
cfg: params.config,
|
cfg: params.config,
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ export function installTestEnv(): { cleanup: () => void; tempHome: string } {
|
|||||||
{ key: "CLAWDBOT_STATE_DIR", value: process.env.CLAWDBOT_STATE_DIR },
|
{ key: "CLAWDBOT_STATE_DIR", value: process.env.CLAWDBOT_STATE_DIR },
|
||||||
{ key: "CLAWDBOT_CONFIG_PATH", value: process.env.CLAWDBOT_CONFIG_PATH },
|
{ key: "CLAWDBOT_CONFIG_PATH", value: process.env.CLAWDBOT_CONFIG_PATH },
|
||||||
{ key: "CLAWDBOT_TEST_HOME", value: process.env.CLAWDBOT_TEST_HOME },
|
{ 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-"));
|
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;
|
delete process.env.CLAWDBOT_CONFIG_PATH;
|
||||||
// Prefer deriving state dir from HOME so nested tests that change HOME also isolate correctly.
|
// Prefer deriving state dir from HOME so nested tests that change HOME also isolate correctly.
|
||||||
delete process.env.CLAWDBOT_STATE_DIR;
|
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.
|
// Windows: prefer the legacy default state dir so auth/profile tests match real paths.
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
|
|||||||
Reference in New Issue
Block a user