From f8550a536e80639697b37d73da1870ddad1061ed Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 15 Dec 2025 19:16:08 +0100 Subject: [PATCH] Read GitHub Copilot token from oauth.json in test --- packages/ai/test/stream.test.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/ai/test/stream.test.ts b/packages/ai/test/stream.test.ts index 5fd5c95f..85663f4e 100644 --- a/packages/ai/test/stream.test.ts +++ b/packages/ai/test/stream.test.ts @@ -678,19 +678,29 @@ describe("Generate E2E Tests", () => { }); }); - describe.skipIf(!process.env.GITHUB_COPILOT_TOKEN)("GitHub Copilot Provider (gpt-4o via OpenAI Completions)", () => { + // Read GitHub Copilot token from ~/.pi/agent/oauth.json if available + let githubCopilotToken: string | undefined; + try { + const oauthPath = join(process.env.HOME || "", ".pi/agent/oauth.json"); + const oauthData = JSON.parse(readFileSync(oauthPath, "utf-8")); + githubCopilotToken = oauthData["github-copilot"]?.access; + } catch { + // oauth.json doesn't exist or is invalid + } + + describe.skipIf(!githubCopilotToken)("GitHub Copilot Provider (gpt-4o via OpenAI Completions)", () => { const llm = getModel("github-copilot", "gpt-4o"); it("should complete basic text generation", async () => { - await basicTextGeneration(llm, { apiKey: process.env.GITHUB_COPILOT_TOKEN }); + await basicTextGeneration(llm, { apiKey: githubCopilotToken }); }); it("should handle tool calling", async () => { - await handleToolCall(llm, { apiKey: process.env.GITHUB_COPILOT_TOKEN }); + await handleToolCall(llm, { apiKey: githubCopilotToken }); }); it("should handle streaming", async () => { - await handleStreaming(llm, { apiKey: process.env.GITHUB_COPILOT_TOKEN }); + await handleStreaming(llm, { apiKey: githubCopilotToken }); }); });