feat(plugin): add getAuth, route, model.select and AuthLoaderResult to plugin SDK#16941
Closed
vglafirov wants to merge 12 commits intoanomalyco:devfrom
Closed
feat(plugin): add getAuth, route, model.select and AuthLoaderResult to plugin SDK#16941vglafirov wants to merge 12 commits intoanomalyco:devfrom
vglafirov wants to merge 12 commits intoanomalyco:devfrom
Conversation
…o plugin SDK - Add optional getAuth to PluginInput for plugin auth credential access - Add route hook (object form with prefix) for plugin HTTP routes - Add model.select hook for sub-model resolution (e.g. workflow models) - Add AuthLoaderResult type with optional getModel for auth loaders - Exclude route from trigger type constraint (not a callable hook) - Add tests for all new types and trigger constraints All additions are backward-compatible with existing plugins.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This was referenced Mar 11, 2026
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.
Issue for this PR
Extends the plugin SDK to support plugins that need auth access, HTTP routes, and model sub-selection. Part of the work to extract GitLab DAP workflow model support into a standalone plugin, keeping opencode core free of provider-specific code.
Type of change
What does this PR do?
Adds four backward-compatible type extensions to the plugin SDK (
packages/plugin/src/index.ts):getAuth?onPluginInput— lets plugins retrieve stored auth credentials (OAuth tokens, API keys) for a provider. Plugins previously had no way to access auth state.AuthLoaderResulttype — replaces untypedRecord<string, any>return ofAuthHook.loaderwith a type that optionally includesgetModel, so auth loaders can provide custom model creation logic.routehook onHooks— accepts either(app) => void(existing) or{ prefix: string; handler: (app) => void }(new). Object form lets plugins specify a URL prefix so routes mount at/plugin/<prefix>/.model.selecthook onHooks— called when a model is selected. Plugins can resolve sub-models (e.g. a workflow model needing further discovery). Takes{ providerID, modelID }, mutates{ subModel?, displayName? }.Also excludes
routefromPlugin.trigger()type constraint inpackages/opencode/src/plugin/index.tssinceroutecan be an object, not a callable function.All changes are additive — existing plugins compile and work without modification.
How did you verify your code works?
test/plugin/hooks.test.ts(14 tests) andtest/plugin/trigger.test.ts(6 tests) plus the existing 14 intest/cli/plugin-auth-picker.test.tsbun turbo typecheck --filter=@opencode-ai/pluginpassesbun turbo typecheck --filter=opencodehas no new errors (only pre-existingeffect/accountmodule errors on dev)bun test test/plugin/— 34 pass, 0 failScreenshots / recordings
Not a UI change.
Checklist