refactor: type computer use provider as an enum (#27086)

The deployment-wide computer use provider was passed around as a bare `string` on the `codersdk` wire structs, in `chattool`, and in the generated TypeScript, and its valid values (`anthropic`, `openai`) were never exposed as a `codersdk` enum. That's out of step with our other chat settings (`ChatDebugRunKind`, `ChatUsageLimitPeriod`), which already define enums with `Valid()` and an `All<Name>s` slice, and it left the allowed values duplicated as literals with no typed contract for clients.

This adds `codersdk.ChatComputerUseProvider` as the single source of truth and routes the API boundary, `chattool`, `chatd`, and the generated TypeScript through it. The DB layer and chattool's internal model-provider routing stay `string` on purpose, since they handle untrusted or fantasy-model values that just happen to share the names.
This commit is contained in:
Ethan
2026-07-13 18:37:48 +10:00
committed by GitHub
parent 27ed052d86
commit 1497ba14fe
13 changed files with 120 additions and 97 deletions
+22 -2
View File
@@ -913,16 +913,36 @@ type AdvisorConfig struct {
// the request and response shapes are currently identical.
type UpdateAdvisorConfigRequest = AdvisorConfig
// ChatComputerUseProvider identifies the provider that backs computer use for
// the virtual desktop.
type ChatComputerUseProvider string
const (
ChatComputerUseProviderAnthropic ChatComputerUseProvider = "anthropic"
ChatComputerUseProviderOpenAI ChatComputerUseProvider = "openai"
)
// AllChatComputerUseProviders contains every ChatComputerUseProvider value.
var AllChatComputerUseProviders = []ChatComputerUseProvider{
ChatComputerUseProviderAnthropic,
ChatComputerUseProviderOpenAI,
}
// Valid reports whether p is a supported computer use provider.
func (p ChatComputerUseProvider) Valid() bool {
return slices.Contains(AllChatComputerUseProviders, p)
}
// ChatComputerUseProviderResponse is the response for getting the computer use
// provider setting.
type ChatComputerUseProviderResponse struct {
Provider string `json:"provider"`
Provider ChatComputerUseProvider `json:"provider"`
}
// UpdateChatComputerUseProviderRequest is the request to update the computer use
// provider setting.
type UpdateChatComputerUseProviderRequest struct {
Provider string `json:"provider"`
Provider ChatComputerUseProvider `json:"provider"`
}
// ChatDebugLoggingAdminSettings describes the runtime admin setting