feat(copilot): consolidate GHE enterprise support on top of upstream #15114#1
Merged
Merged
Conversation
Make all Copilot OAuth and API URLs configurable via environment variables, enabling Hermes to work with GitHub Enterprise (GHE) Copilot deployments in addition to public github.com. Changes: - copilot_auth.py: Make COPILOT_OAUTH_CLIENT_ID, COPILOT_DEVICE_CODE_URL, COPILOT_ACCESS_TOKEN_URL, COPILOT_TOKEN_EXCHANGE_URL, COPILOT_API_BASE_URL configurable via env vars (defaults unchanged for public GitHub) - copilot_auth.py: Add is_copilot_url() helper to match both public and custom GHE Copilot endpoints - copilot_auth.py: Add COPILOT_AUTH_MODE=oauth to force device-code flow, skipping env vars and gh CLI token lookup - copilot_auth.py: Add COPILOT_GH_HOST for host-aware gh auth token --hostname lookup (avoids picking up wrong host's token) - auth.py: Add base_url_env_var to copilot ProviderConfig so COPILOT_API_BASE_URL is respected by provider resolution - models.py: Read COPILOT_BASE_URL from env; add debug logging for catalog fetch attempts - run_agent.py: Add _is_copilot_base() helper; replace all 5 hardcoded api.githubcopilot.com checks to support custom GHE endpoints - main.py: Add re-auth prompt in hermes models setup when a Copilot token already exists (OAuth re-login or manual token entry) - config.py: Register COPILOT_API_BASE_URL, COPILOT_GH_HOST, COPILOT_AUTH_MODE in OPTIONAL_ENV_VARS (advanced/provider) - tests: Update test_copilot_env_vars to expect new base_url_env_var Env vars for GHE setup (in ~/.hermes/.env): COPILOT_API_BASE_URL=https://copilot-api.your-ghe.com COPILOT_DEVICE_CODE_URL=https://your-ghe.com/login/device/code COPILOT_ACCESS_TOKEN_URL=https://your-ghe.com/login/oauth/access_token COPILOT_GH_HOST=your-ghe.com # COPILOT_AUTH_MODE=oauth (optional, to force re-auth)
Document all GHE-related env vars with placeholder values and explanatory comments so new users can discover the configuration without reading source.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This internal consolidation rebases/ports GitHub Enterprise Copilot support onto the current upstream Copilot foundation from NousResearch#15114.
It includes:
develop(token exchange, 401 refresh, live context, ACP HOME handling).hermes_cli/model_setup_flows.py) with re-auth/account-switch flow.Why
Upstream requested rebasing NousResearch#6468 on top of NousResearch#15114 due overlapping auth/model-routing changes. This PR provides the reconciled internal branch for review + UAT.
Changesets consolidated
.env.examplehermes_cli/auth.pyhermes_cli/config.pyhermes_cli/copilot_auth.pyhermes_cli/model_setup_flows.pyhermes_cli/models.pyrun_agent.pyBehavior highlights
COPILOT_API_BASE_URLCOPILOT_DEVICE_CODE_URLCOPILOT_ACCESS_TOKEN_URLCOPILOT_TOKEN_EXCHANGE_URLCOPILOT_OAUTH_CLIENT_IDCOPILOT_GH_HOST.COPILOT_AUTH_MODE=oauthto force OAuth device flow.Validation (executed)
scripts/run_tests.sh tests/hermes_cli/test_model_provider_persistence.py tests/hermes_cli/test_copilot_auth.py tests/hermes_cli/test_copilot_context.py tests/hermes_cli/test_copilot_token_exchange.py tests/hermes_cli/test_api_key_providers.py tests/run_agent/test_run_agent_codex_responses.pyFollow-up after internal merge
developonce UAT passes.