Skip to content

feat(copilot): consolidate GHE enterprise support on top of upstream #15114#1

Merged
tunings-lab merged 3 commits into
developfrom
feat/consolidate-copilot-ghe-sso
Jun 10, 2026
Merged

feat(copilot): consolidate GHE enterprise support on top of upstream #15114#1
tunings-lab merged 3 commits into
developfrom
feat/consolidate-copilot-ghe-sso

Conversation

@tunings-lab

Copy link
Copy Markdown
Owner

Summary

This internal consolidation rebases/ports GitHub Enterprise Copilot support onto the current upstream Copilot foundation from NousResearch#15114.

It includes:

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.example
  • hermes_cli/auth.py
  • hermes_cli/config.py
  • hermes_cli/copilot_auth.py
  • hermes_cli/model_setup_flows.py
  • hermes_cli/models.py
  • run_agent.py

Behavior highlights

  • Supports enterprise endpoint overrides:
    • COPILOT_API_BASE_URL
    • COPILOT_DEVICE_CODE_URL
    • COPILOT_ACCESS_TOKEN_URL
    • COPILOT_TOKEN_EXCHANGE_URL
    • COPILOT_OAUTH_CLIENT_ID
  • Supports enterprise host-aware token lookup via COPILOT_GH_HOST.
  • Supports COPILOT_AUTH_MODE=oauth to force OAuth device flow.
  • Copilot URL detection generalized for enterprise base URLs.
  • Model setup flow now supports explicit re-auth/account switching for Copilot credentials.

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.py
  • Result: 296/296 passing.

Follow-up after internal merge

  • UAT with enterprise host + WSL2 local-instance workflow.
  • Upstream PR from internal develop once UAT passes.

HearthCore and others added 3 commits June 9, 2026 16:15
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.
@tunings-lab tunings-lab marked this pull request as ready for review June 10, 2026 13:33
@tunings-lab tunings-lab merged commit b8f4fa3 into develop Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants