Skip to content

Conversation

@vglafirov
Copy link
Contributor

@vglafirov vglafirov commented Jan 8, 2026

Add GitLab Duo Provider Support

Problem

In-line with GitLab's open-core strategy, we want to officially integrate GitLab Duo with OpenCode as a supported provider, operable with both GitLab.com and self-hosted GitLab instances. To streamline our users' journey across tools and enable access to GitLab's AI capabilities including agentic chat with native tool calling, GitLab is upstreaming the required provider packages to this repository.

Solution

This PR adds GitLab as a supported provider with three agentic chat model variants (Haiku, Sonnet, Opus), enabling seamless integration with GitLab.com and self-hosted instances.

Changes

Dependencies Added

Provider Implementation

  • Added GitLab to bundled providers in provider.ts
  • Implemented custom loader with multi-source auth (env, config, OAuth, PAT)
  • Registered three Claude-based models: haiku-4-5, sonnet-4-5, opus-4-5
  • OAuth token refresh support
  • Self-hosted GitLab instance support via GITLAB_INSTANCE_URL

Plugin Auto-Loading

  • GitLab auth/tools plugins load automatically when GitLab is configured
  • Checks environment variables, config, and auth.json
  • Respects OPENCODE_DISABLE_DEFAULT_PLUGINS flag

Tests

  • Added 8 provider-specific tests covering auth methods, config options, and model availability
  • All 619 existing tests pass

Files Changed

  • packages/opencode/package.json - Added 3 GitLab dependencies
  • packages/opencode/src/provider/provider.ts - GitLab provider implementation
  • packages/opencode/src/plugin/index.ts - Auto-loading logic
  • packages/opencode/test/provider/gitlab-duo.test.ts - New tests (8 tests)
  • packages/docs/essentials/gitlab-duo.mdx - Documentation

Usage

Basic setup with environment variable:

export GITLAB_TOKEN="glpat-xxxxxxxxxxxx"

Then use in config:

{
  "model": "gitlab/duo-chat-sonnet-4-5"
}

Self-hosted GitLab:

export GITLAB_INSTANCE_URL="https://gitlab.company.internal"
export GITLAB_TOKEN="glpat-xxxxxxxxxxxx"

Testing

  • All 619 existing tests pass
  • Added 8 provider-specific tests
  • Tested with GitLab.com and environment variable auth

Closes #7455

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@vglafirov
Copy link
Contributor Author

Related PR to models.dev registry: anomalyco/models.dev#616

@rekram1-node
Copy link
Collaborator

/review

@vglafirov
Copy link
Contributor Author

/review

@vglafirov
Copy link
Contributor Author

Closes #7455

@vglafirov
Copy link
Contributor Author

I am not sure why PR Standards check is failing. I've created an issue and linked it to this PR.

@rekram1-node
Copy link
Collaborator

@vglafirov apologies for delay I had this open on my computer but forgot to look at it

@vglafirov
Copy link
Contributor Author

@rekram1-node You recently merged Gitlab Duo PR on models.dev, but deployment pipeline is failing. If we get models deployed on models.dev, I can remove models from https://github.com/anomalyco/opencode/pull/7333/changes#diff-b0155a9e5561043f50ba86bc54d5fd59aa528c7af7c92b2f37585d80e792cd9aR740

PR to fix deployment issues: anomalyco/models.dev#631

@rekram1-node
Copy link
Collaborator

Just address these and I will merge tmr morn! Once again sorry for delays our issue and pr volume has exploded

Feel free to DM or email me if needed

@vglafirov
Copy link
Contributor Author

vglafirov commented Jan 13, 2026

Can you link me to these packages you are adding? for some reason they aren't popping up when I try to search for them but that is likely me being an idiot

You are not an idiot. I have no idea why, but they are not popping up in a search, for some reason 😞 Here they are:

  1. Gitlab AI Provider
  2. Gitlab Auth Plugin
  3. Gitlab Plugin for OpenCode

@kamilchm
Copy link

kamilchm commented Jan 13, 2026

@vglafirov this is awesome — thanks for building it!
I have a self-hosted GitLab in my organization and would love to test the integration.
Is there any doc I should follow, or a quick minimal setup guide (env vars + callback URL/redirect URI + required scopes) to get it working?

@vglafirov
Copy link
Contributor Author

vglafirov commented Jan 13, 2026

@vglafirov this is awesome — thanks for building it! I have a self-hosted GitLab in my organization and would love to test the integration. Is there any doc I should follow, or a quick minimal setup guide (env vars + callback URL/redirect URI + required scopes) to get it working?

@kamilchm This PR contains documentation update: https://github.com/anomalyco/opencode/pull/7333/changes#diff-b5d5affc6941bf7bb19805cc8f556cd1b9ae73ffd99e520120700536b166f8c0

Also check published npm packages in comment above. They providing extensive documentation how to use this integration. Feel free to provide a feedback here or on repositories behind these npm packages. We haven't tested this on self-hosted instances yet, I am highly interesting to see if it works as expected. Thanks

@kamilchm
Copy link

Great, one more question: do I need snything special on the GitLab Server side? Version, features?

@vglafirov
Copy link
Contributor Author

Great, one more question: do I need snything special on the GitLab Server side? Version, features?

If you have self-hosted Duo, then I guess nothing special is needed, if not: https://docs.gitlab.com/administration/gitlab_duo_self_hosted/

@vglafirov
Copy link
Contributor Author

Can you link me to these packages you are adding? for some reason they aren't popping up when I try to search for them but that is likely me being an idiot

@rekram1-node I've fixed npmjs search problems. It was due to poor metadata. Packages are searcheble now :)

@rekram1-node
Copy link
Collaborator

Nice! let me review these packages and then I think this is basically good to go

Follow Copilot plugin pattern by removing @gitlab/opencode-gitlab-auth
and @gitlab/opencode-gitlab-plugin from package.json dependencies.

Plugins are now dynamically installed via BunProc.install() when GitLab
is configured, matching the established pattern for opencode-copilot-auth
and opencode-anthropic-auth.

Changes:
- Removed plugin packages from package.json dependencies
- Pinned plugin versions (1.3.0 and 1.1.0) in auto-loading logic
- Updated bun.lock to reflect dynamic installation approach
- Kept @gitlab/gitlab-ai-provider as it's statically imported

Addresses feedback from @rekram1-node on PR #7333
- Move @gitlab/[email protected] to BUILTIN array
- Make @gitlab/[email protected] opt-in (not auto-loaded)
- Remove custom GitLab plugin detection logic (~33 lines)
- Simplify auth to use Auth.get() instead of manual parsing (~45 lines)
- Add documentation for optional GitLab tools plugin
- Update test mocks to handle versioned builtin plugins

Net reduction: 63 lines (-99/+36)
All 660 tests passing
@vglafirov
Copy link
Contributor Author

@rekram1-node Refactored plugins loading. Please take a look again 🙏

@rekram1-node
Copy link
Collaborator

lookin

@rekram1-node rekram1-node merged commit 05867f9 into anomalyco:dev Jan 13, 2026
5 checks passed
dl-alexandre pushed a commit to dl-alexandre/opencode that referenced this pull request Jan 13, 2026
fwang pushed a commit that referenced this pull request Jan 14, 2026
shuv1337 added a commit to Latitudes-Dev/shuvcode that referenced this pull request Jan 14, 2026
Upstream changes:
- feat: add plan mode with enter/exit tools (anomalyco#8281)
- feat: Add GitLab Duo Agentic Chat Provider Support (anomalyco#7333)
- feat(desktop): Ask Question Tool Support (anomalyco#8232)
- feat: add Undertale and Deltarune built-in themes (anomalyco#8240)
- fix: Add Plugin Mocks to Provider Tests (anomalyco#8276)
- fix: update User-Agent string to latest Chrome version in webfetch (anomalyco#8284)
- fix(prompt-input): handle Shift+Enter before IME check
- fix(state): delete key from recordsByKey on instance disposal
- fix(mcp): close existing client before reassignment to prevent leaks

Resolved conflicts:
- bun.lock: regenerated with fork dependencies
- global-sync.tsx: adopted upstream variable naming (question instead of request)
- session/index.tsx: merged upstream workdir display with fork's ANSI terminal emulation
- amazon-bedrock.test.ts: added all mock modules (fork + upstream)
- vscode/package.json: kept fork branding, updated version

Fork commits included:
- refactor(tui): use SDK client for tool list dialog
- chore: update lockfile with fork dependencies
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.

[FEATURE]: Add GitLab Duo Agentic Chat Provider Support

3 participants