← Back to PRs

#13505: feat(copilot): add GitHub Enterprise Cloud (GHE.com) support for Copilot provider

by kryptus47 open 2026-02-10 16:22 View on GitHub →
cli commands agents stale size: L
### What Adds GitHub Enterprise Cloud with data residency (`.ghe.com` domains) support to the Copilot provider. GHE Cloud uses a different URL topology — `api.{host}` instead of `api.github.com`, `copilot-api.{host}` instead of `api.individual.githubcopilot.com`, no `/api/v3` prefix. No changes to existing github.com Copilot behavior. ### Why Users with GHE Cloud Copilot Enterprise seats couldn't use Copilot models through OpenClaw — all endpoints were hard-coded to github.com. ### Changes - **Endpoint derivation** inlined into `github-copilot-token.ts`: new `resolveGitHubCopilotEndpoints(host?)` derives all URLs from a single host value - **New onboarding option**: "GitHub Copilot Enterprise (GHE Cloud)" in `openclaw onboard` - **New CLI flags**: `--github-host` / `--client-id` on `login-github-copilot` - **Auth profile persistence**: `enterpriseUrl` stored on token credentials, propagated through `ResolvedProviderAuth` → embedded runner - **Runtime bug fix**: `run.ts` and `compact.ts` were calling `resolveCopilotApiToken()` without `githubHost`, causing 401 on Enterprise — now threaded from auth profile - **Usage tracking**: `fetchCopilotUsage` routes to correct Enterprise host ### Tests - New: endpoint derivation (github.com defaults, GHE Cloud, client ID override, whitespace, empty string) - New: `isGitHubDotCom` helper - Updated: GHE Cloud token response parsing, host-derived base URL (ignores shared proxy domain), host-scoped cache path, `deriveCopilotApiBaseUrlFromProxyEndpoint` - Updated: 3 existing mock files aligned to new imports ### Manual testing Validated end-to-end against a live GHE Cloud instance: device flow → token exchange → model listing → chat completion. All endpoint derivations confirmed correct. ### AI-assisted 🤖 - [x] AI-assisted (Claude Opus 4.6) - [x] Lightly tested (live GHE Cloud instance + unit tests) - [x] I understand what the code does 21 files changed, +592/−63 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds GitHub Enterprise Cloud (GHE.com) support to the GitHub Copilot provider by deriving all Copilot-related endpoints from a configurable GitHub host (instead of hard-coding github.com). It introduces a new onboarding/auth option for Copilot Enterprise, threads the `enterpriseUrl`/host through the auth profile and embedded runner paths, and updates usage tracking to call the correct host-scoped endpoints. The endpoint derivation logic is consolidated into `src/providers/github-copilot-token.ts` with updated unit tests to cover github.com defaults, GHE.com topology, client ID overrides, and host normalization. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - Reviewed the endpoint derivation changes, auth profile threading, embedded runner call sites, and updated tests; no functional regressions or broken integrations were found. The only issue identified is test-mock fragility that does not affect runtime behavior. - No files require special attention <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs