Skip to content

Conversation

@ben-vargas
Copy link
Contributor

Summary

Fixes incorrect TypeScript types for the provider parameter in the chat.params plugin hook.

Closes #2392

Problem

The chat.params hook type uses Provider directly, but at runtime the hook receives a wrapper object with the provider info nested under an info property.

Before (incorrect):

provider: Provider  // expects provider.id

Runtime structure:

{
  source: "env" | "config" | "custom" | "api"
  info: Provider
  options: Record<string, any>
}

Solution

Added a new ProviderContext type that matches the actual runtime structure and updated the chat.params hook signature to use it.

export type ProviderContext = {
  source: "env" | "config" | "custom" | "api"
  info: Provider
  options: Record<string, any>
}

Changes

  • Added ProviderContext type export
  • Updated chat.params hook to use ProviderContext instead of Provider

Notes

  • The auth.loader callback correctly uses Provider (it receives raw provider info from the database, not the wrapper)
  • This is a breaking change for any plugins that incorrectly relied on the wrong types, but those plugins wouldn't have worked correctly at runtime anyway

Alternative Approach

This PR fixes the types to match the current runtime behavior. An alternative would be to change the runtime to pass provider.info directly (the raw Provider), matching how auth.loader works:

// Current runtime (wrapper object)
provider: { source, info: Provider, options }

// Alternative runtime (raw Provider, like auth.loader)
provider: Provider

The alternative would be a cleaner API but would be a breaking runtime change for existing plugins that have worked around the type mismatch by accessing provider.info.id etc.

Add ProviderContext type that matches the actual runtime structure
passed to the chat.params hook (wrapper with source, info, options)
instead of the raw Provider type.
@rekram1-node rekram1-node merged commit 6c25e64 into anomalyco:dev Dec 3, 2025
3 checks passed
@ben-vargas ben-vargas deleted the fix-plugin-type-mismatch branch December 3, 2025 19:43
spmurrayzzz pushed a commit to spmurrayzzz/opencode that referenced this pull request Dec 5, 2025
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.

Plugins: TypeScript type for Provider in "chat.params" event is wrong

2 participants