Repository navigation
feat(provider): add GitHub Enterprise support for Copilot - #2522
Conversation
|
I will keep rebasing on top so that this branch can be checked out if you want to use Copilot Enterprise with the latest features |
1dcadfb to
5b94852
Compare
2988fcc to
8551924
Compare
|
let me know if there's anything you want changed @thdxr |
c5f403b to
28bd07c
Compare
f16de3d to
cc0d460
Compare
|
will this get any attention? |
Co-authored-by: Jon-Mikkel Korsvik <[email protected]>
- Extract URL normalization utilities to reduce code duplication - Simplify API domain construction logic - Improve enterprise URL handling consistency between CLI and config - Allow flexible URL input in auth process with better validation - Simplify provider logic to only use auth-stored enterpriseUrl - Update CLI labels for clearer enterprise deployment options - Remove confusing 'Server' terminology, use 'Enterprise' with descriptive hint
|
Is there anything anyone could help with here? This is the only blocker why I can't really promote this in my company because we only have GHE and double licensing just because people cannot login to GHE is not really an option 😅 would be really great if this could be tackled in some way any time soon |
|
Checking this out |
|
@OlaHulleberg i would love to merge this, important note: auth/github-copilot.ts wasnt being used and has been deleted now the logic lives here: https://github.com/sst/opencode-copilot-auth |
I see! |
|
I hope to see this PR merged. It's essential to adopt Opencode in large companies. |
|
Yes definitely this weekend I will handle conflicts, and get this integrated |
|
I've given you |
- Inline OAuth device flow logic in handleGithubCopilotAuth() - Remove auth/github-copilot module (moved to external plugin) - Update provider loader to work with plugin - Store enterpriseUrl in auth data for plugin consumption - Support github.com and enterprise deployments
Resolve conflicts and align with upstream architecture: - Accept upstream's wellknown auth implementation - Accept upstream's simplified GitHub install command - Integrate enterprise support via external plugin approach - Maintain core's excellent UX for Copilot authentication
|
going to merge this and stuff, just waiting on dax to give an npm token so I can update https://github.com/sst/opencode-copilot-auth |
hold on, I'm doing some polishing and fixing some errors I've made in the refactor |
|
yeah ofc i just wanted to state i didnt forget about u i shouldnt have worded it like it is being merged in 5 min haha |
I've been trying to tackle this enterprise URL prompting within the plugin for a bit, and discussed back and forth with AI. EDIT: Example of how this could look like in core: if (authorize.method === "configure") {
const inputs = {}
for (const prompt of authorize.prompts) {
const value = await prompts.text({
message: prompt.message,
placeholder: prompt.placeholder,
validate: prompt.validate,
})
if (prompts.isCancel(value)) throw new UI.CancelledError()
inputs[prompt.key] = value
}
const result = await authorize.callback(inputs)
// ... handle result
}EDIT 2: if (method.type === "custom") {
const inputs = {}
for (const prompt of method.prompts) {
inputs[prompt.key] = await prompts.text({...})
}
const result = await method.authorize(inputs)
if (result.type === "success") {
const { type: _, auth_type, ...authData } = result
await Auth.set(provider, {
type: auth_type,
...authData
})
}
} |
Extends plugin auth system to support custom authentication flows that can prompt users for configuration during login. This enables GitHub Copilot Enterprise support by allowing the plugin to request enterprise URL from users. Changes: - Add 'custom' auth type to plugin interface with configurable prompts - Add handler for custom auth type in core auth command - Remove hardcoded GitHub Copilot auth logic from core - Remove github-copilot-enterprise custom loader (now handled by plugin) The plugin architecture now cleanly separates provider-specific auth logic from core, making it easier to support providers requiring configuration.
- Add select prompt type to custom auth methods - Add conditional prompts that only show based on previous inputs - Allow plugins to specify provider ID for saving auth - Ensure github-copilot plugin loads when only enterprise auth exists
- Handle undefined values in validate function wrapper - Add type assertion for dynamic auth data spreading
|
@rekram1-node opened up this PR in the copilot plugin Please go through these changes and highlight decisions you do not agree on! |
- Add optional prompts field to OAuth and API auth method types - OAuth and API types can now ask preliminary questions before auth - Remove custom auth type entirely (no longer needed) - Prompts support select and text inputs with conditional display - Update auth command to handle prompts for all auth types This enables cleaner plugin architecture where auth types use their proper patterns (OAuth for OAuth flows) while still supporting configuration questions upfront.
Preserve custom fetch functions from plugins when wrapping them with timeout logic. Previously, the timeout wrapper would replace any custom fetch function, breaking plugins that rely on custom fetch for auth or other purposes. Also preserve extra OAuth fields like enterpriseUrl when saving auth results from plugin callbacks.
|
@rekram1-node updated the copilot auth plugin to version 0.0.4 and tested with
|
|
@OlaHulleberg is that fetch override necessary? Im just surprised why it is needed now and not before |
I actually asked my own AI agent the same question, here's the response it had:
I chose to go with option 1, but I can gladly remove it if this is misunderstood |
|
Does it work without that change tho? @OlaHulleberg |
|
the token refreshing has been working for me, but I haven't directly tried configuring timeout for copilot @rekram1-node |
|
okay looking at it again it makes sense, i hate the github view i need to open everything in my ide |
|
Thanks for your work on this btw Do u have an X/twitter account by chance we like to shout out people |
no need, just glad I can help colleagues try out agentic development at work ;) |
…2522) Co-authored-by: Jon-Mikkel Korsvik <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
…2522) Co-authored-by: Jon-Mikkel Korsvik <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
…2522) Co-authored-by: Jon-Mikkel Korsvik <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
…2522) Co-authored-by: Jon-Mikkel Korsvik <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Aiden Cline <[email protected]>

Solves
Summary
Add universal prompts support for OAuth and API authentication methods, enabling plugins to provide better configuration UX. This enables the GitHub Copilot plugin to support both GitHub.com and GitHub Enterprise deployments with a unified auth flow.
Changes
This PR extends the plugin authentication system to support more advanced auth flows:
Implementation Details
Plugin Interface (
packages/plugin/src/index.ts):promptsfield to OAuth and API auth method typesconditionfunction allows prompts to be shown based on previous input valuesproviderfield to auth success results for overrideAuth Command (
packages/opencode/src/cli/cmd/auth.ts):authorize()for all auth typesauthorize()functionenterpriseUrl) when saving auth resultsProvider (
packages/opencode/src/provider/provider.ts):github-copilot-enterpriseprovider that inherits fromgithub-copilotRelated