fix(auth): routed copilot business endpoint

Stored GitHub Copilot plan-specific API endpoints discovered during OAuth login and propagated them through structured credentials, model discovery, usage/probe metadata, and request base URL resolution.

Added regression coverage for Business endpoint discovery, serialization, dynamic model discovery, and chat/responses routing.

Fixes #2876
This commit is contained in:
roboomp
2026-06-17 12:47:19 +00:00
parent c750d89ddd
commit 13b2b55221
16 changed files with 214 additions and 11 deletions
@@ -81,6 +81,20 @@ describe("github copilot model limits mapping", () => {
expect(fetchMock).toHaveBeenCalledTimes(1);
});
it("unwraps structured OAuth keys for discovery and routes business discovery to the business host", async () => {
const structuredApiKey = JSON.stringify({
token: "ghu_test_copilot_token",
apiEndpoint: "https://api.business.githubcopilot.com",
});
const { fetchMock } = await discoverCopilotModels(
{ data: [] },
structuredApiKey,
"https://api.business.githubcopilot.com",
"ghu_test_copilot_token",
);
expect(fetchMock).toHaveBeenCalledTimes(1);
});
it("uses max_context_window_tokens as context window when Copilot reports a prompt budget", async () => {
const { models, fetchMock } = await discoverCopilotModels({
data: [