#13505: feat(copilot): add GitHub Enterprise Cloud (GHE.com) support for Copilot provider
cli
commands
agents
stale
size: L
Cluster:
GitHub Copilot Enhancements
### 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
#4364: fix(github-copilot): use gho_ tokens directly without exchange
by RebelSyntax · 2026-01-30
87.1%
#8467: fix(github-copilot): add configurable IDE headers + fix null filtering
by ericchansen · 2026-02-04
82.5%
#8805: [Bug Fix][AI-assisted] Refresh Copilot token before expiry and retr...
by Arthur742Ramos · 2026-02-04
79.4%
#11782: fix: resolve 403 auth error for GithubCopilot imageModel (#10277)
by adamkoncz · 2026-02-08
78.9%
#11447: feat(providers): add Claude models to GitHub Copilot provider
by yylonly · 2026-02-07
78.5%
#15044: fix: refresh GitHub Copilot default model list
by Godzilla675 · 2026-02-12
78.1%
#9164: feat(apply_patch): enable for github-copilot provider
by kieutrongthien · 2026-02-04
77.9%
#19311: feat: add github-copilot gpt-5.3-codex with xhigh support (AI-assis...
by mrutunjay-kinagi · 2026-02-17
77.7%
#20095: fix(model-forward-compat): extend claude-sonnet-4.6 forward-compat ...
by SeeYangZhi · 2026-02-18
76.3%
#22352: fix(auth): validate Copilot token cache belongs to requesting account
by xinhuagu · 2026-02-21
75.3%