fix(types): preserve GHE Copilot executor configuration (#9988)

This commit is contained in:
backryun
2026-08-11 20:46:32 +09:00
committed by GitHub
parent 425396d11d
commit 861011c02b
2 changed files with 28 additions and 7 deletions

View File

@@ -1,4 +1,9 @@
import { BaseExecutor, ExecuteInput, type ProviderCredentials } from "./base.ts";
import {
BaseExecutor,
ExecuteInput,
type ProviderConfig,
type ProviderCredentials,
} from "./base.ts";
import { PROVIDERS, OAUTH_ENDPOINTS } from "../config/constants.ts";
import { getModelTargetFormat } from "../config/providerModels.ts";
import {
@@ -28,9 +33,11 @@ export interface RefreshedCopilotCredentials {
providerSpecificData?: Record<string, unknown>;
}
type GithubExecutorConfig = ProviderConfig & Record<string, unknown>;
export class GithubExecutor extends BaseExecutor {
constructor() {
super("github", PROVIDERS.github);
constructor(provider = "github", config?: GithubExecutorConfig) {
super(provider, config ?? PROVIDERS.github);
}
getCopilotToken(credentials: Record<string, any> | null | undefined) {

View File

@@ -61,8 +61,14 @@ test("buildUrl uses responses endpoint for gpt-5.4-mini and gpt-5.6-sol", () =>
const credentials: ProviderCredentials = {
providerSpecificData: { gheUrl: "https://ghe.company.com" },
};
assert.strictEqual(executor.buildUrl("gpt-5.4-mini", true, 0, credentials), "https://ghe.company.com/responses");
assert.strictEqual(executor.buildUrl("ghe-copilot/gpt-5.6-sol", true, 0, credentials), "https://ghe.company.com/responses");
assert.strictEqual(
executor.buildUrl("gpt-5.4-mini", true, 0, credentials),
"https://ghe.company.com/responses"
);
assert.strictEqual(
executor.buildUrl("ghe-copilot/gpt-5.6-sol", true, 0, credentials),
"https://ghe.company.com/responses"
);
});
test("buildUrl uses chat/completions endpoint for claude and gemini models", () => {
@@ -74,8 +80,14 @@ test("buildUrl uses chat/completions endpoint for claude and gemini models", ()
const credentials: ProviderCredentials = {
providerSpecificData: { gheUrl: "https://ghe.company.com" },
};
assert.strictEqual(executor.buildUrl("claude-opus-5", true, 0, credentials), "https://ghe.company.com/chat/completions");
assert.strictEqual(executor.buildUrl("gemini-3.5-flash", true, 0, credentials), "https://ghe.company.com/chat/completions");
assert.strictEqual(
executor.buildUrl("claude-opus-5", true, 0, credentials),
"https://ghe.company.com/chat/completions"
);
assert.strictEqual(
executor.buildUrl("gemini-3.5-flash", true, 0, credentials),
"https://ghe.company.com/chat/completions"
);
});
test("buildUrl handles gheUrl with trailing slash", () => {
@@ -152,6 +164,8 @@ test("executor extends GithubExecutor", () => {
clientSecret: "test-secret",
});
assert.strictEqual(executor.constructor.name, "GheCopilotExecutor");
assert.strictEqual(executor.getProvider(), "ghe-copilot");
assert.strictEqual(executor.config.baseUrl, "https://api.githubcopilot.com/chat/completions");
});
test("isValidGheUrl accepts https enterprise hosts and rejects malformed or non-https input", async () => {