mirror of
https://github.com/coder/coder.git
synced 2026-09-23 05:43:53 +08:00
## Why PR #26797 was accidentally merged into the stale `graphite-base/26797` branch instead of `main` (Graphite picked the wrong base), so its changes never landed on `main`. This PR re-lands that work as a clean cherry-pick onto the current `main`. ## What Adds a `WatchAIProviders` streaming RPC to the `ProviderConfigurator` service so a running standalone AI Gateway refetches its provider set when the provider configuration changes. The server subscribes to `AIProvidersChangedChannel` (published by the provider CRUD endpoints) and forwards each event as a payload-free signal, plus one signal on subscribe; the gateway calls `GetAIProviders` on each signal to rebuild its pool. The aibridged API is bumped to v1.2. Env-seeded providers don't need a signal: seeding finishes before coderd serves the gateway connection, so the gateway's initial fetch already reflects the seeded set. ## For reviewers The change is split into two commits to make review easy: 1. **`feat: synchronise provider changes with WatchAIProviders`** is a faithful cherry-pick of #26797, identical to the originally reviewed PR. It is committed without pre-commit hooks because it does not build against current `main` on its own. 2. **`fix: resolve cherry-pick conflicts against main`** contains only the deltas needed to re-land on current `main`, and passes the full pre-commit suite: - `coderd/aibridged/proto/aibridged.pb.go` regenerated via the proto make target (the cherry-picked copy was generated against the older proto). - `enterprise/cli/aigatewaystart.go` import block unioned; `main` added `os` and `strings` while the PR added `sync`. - Three `aibridgedserver.NewServer` test call sites that landed on `main` after the original branch diverged now pass the new `pubsub` argument. Refs https://linear.app/codercom/issue/AIGOV-465 *This PR was produced by opencode (agent) using the `anthropic/claude-opus-4-8` model, under human direction and review.*
35 lines
1.3 KiB
Go
35 lines
1.3 KiB
Go
package proto
|
|
|
|
import "github.com/coder/coder/v2/apiversion"
|
|
|
|
// Version history:
|
|
//
|
|
// API v1.0:
|
|
// - Initial version. Serves the Recorder, MCPConfigurator, and Authorizer
|
|
// services to embedded and standalone AI Gateway daemons.
|
|
//
|
|
// API v1.1:
|
|
// - Adds the ProviderConfigurator service with the GetAIProviders unary RPC,
|
|
// letting embedded and standalone gateways fetch provider configuration
|
|
// over DRPC instead of reading the database directly.
|
|
//
|
|
// API v1.2:
|
|
// - Adds the ProviderConfigurator.WatchAIProviders streaming RPC, pushing a
|
|
// change signal to gateways so a running standalone gateway refetches its
|
|
// provider set when the provider configuration changes.
|
|
const (
|
|
CurrentMajor = 1
|
|
CurrentMinor = 2
|
|
)
|
|
|
|
// VersionQueryParam is the URL query parameter the standalone AI Gateway
|
|
// uses to advertise its aibridged API version when dialing coderd's serve
|
|
// endpoint, and that coderd reads to negotiate compatibility.
|
|
const VersionQueryParam = "version"
|
|
|
|
// CurrentVersion is the current aibridged API version.
|
|
// Breaking changes to the aibridged API **MUST** increment CurrentMajor above.
|
|
// Non-breaking changes to the aibridged API **MUST** increment CurrentMinor
|
|
// above.
|
|
var CurrentVersion = apiversion.New(CurrentMajor, CurrentMinor)
|