Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 48 additions & 15 deletions internal/providers/workbuddy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,28 +329,14 @@ func (c *Client) Models(ctx context.Context, accountID string) ([]providers.Mode
if env.Code != 0 {
return nil, fmt.Errorf("models envelope code=%d msg=%s", env.Code, env.Msg)
}
cliModels := map[string]struct{}{}
for _, agent := range env.Data.Agents {
if !isCLIAgent(agent.Name) {
continue
}
for _, id := range agent.Models {
cliModels[id] = struct{}{}
}
}
filterCLI := len(cliModels) > 0
var out []providers.ModelInfo
for _, model := range env.Data.Models {
if model.Disabled {
continue
}
if filterCLI {
if _, ok := cliModels[model.ID]; !ok {
continue
}
}
out = append(out, catalogModel(model))
}
out = appendAliasModels(out)
if len(out) == 0 {
return nil, fmt.Errorf("workbuddy model catalog returned no cli models")
}
Expand Down Expand Up @@ -943,3 +929,50 @@ type classifier struct{}
func (classifier) Classify(status int, body string) providers.ClassifiedError {
return Classify(status, body)
}

var workbuddyModelAliases = map[string]string{
"deepseek-v4.1-flash": "deep-model",
}

func appendAliasModels(out []providers.ModelInfo) []providers.ModelInfo {
if len(out) == 0 || len(workbuddyModelAliases) == 0 {
return out
}
seen := make(map[string]struct{}, len(out))
for _, model := range out {
seen[model.NativeModel] = struct{}{}
}
for alias, nativeModel := range workbuddyModelAliases {
if _, ok := seen[alias]; ok {
continue
}
if base, ok := findModelInfoByNativeModel(out, nativeModel); ok {
clone := base
clone.NativeModel = alias
clone.PublicModel = alias
clone.DisplayName = aliasDisplayName(alias, base.DisplayName)
out = append(out, clone)
}
}
return out
}

func findModelInfoByNativeModel(models []providers.ModelInfo, nativeModel string) (providers.ModelInfo, bool) {
for _, model := range models {
if model.NativeModel == nativeModel {
return model, true
}
}
return providers.ModelInfo{}, false
}

func aliasDisplayName(alias, fallback string) string {
switch alias {
case "deepseek-v4.1-flash":
return "Deepseek-V4.1-Flash"
}
if strings.TrimSpace(fallback) != "" {
return fallback
}
return strings.ToUpper(string(alias[0])) + alias[1:]
}
10 changes: 9 additions & 1 deletion internal/providers/workbuddy/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,17 @@ func TestModelsFiltersCliAgentAndDisabled(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(models) != 1 || models[0].NativeModel != "glm-5.2" || models[0].Capabilities.ContextWindow != 128000 {
// Disabled models must still be filtered out, but agent filtering is
// intentionally removed so all non-disabled models are exposed.
if len(models) != 2 {
t.Fatalf("models=%+v", models)
}
if models[0].NativeModel != "glm-5.2" || models[0].Capabilities.ContextWindow != 128000 {
t.Fatalf("models[0]=%+v", models[0])
}
if models[1].NativeModel != "web-model" {
t.Fatalf("models[1]=%+v", models[1])
}
}

func TestModelsParsesReasoningOptions(t *testing.T) {
Expand Down
9 changes: 0 additions & 9 deletions internal/providers/workbuddy/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,3 @@ func (c Credential) IsGlobal() bool {
}
return strings.Contains(domain, DomainGlobal) || strings.Contains(domain, "workbuddy")
}

func isCLIAgent(name string) bool {
switch strings.ToLower(strings.TrimSpace(name)) {
case "cli", "codebuddy", "workbuddy":
return true
default:
return false
}
}