diff --git a/internal/provider/migrate_workbuddy.go b/internal/provider/migrate_workbuddy.go index 44ddcad1a..03eaf083e 100644 --- a/internal/provider/migrate_workbuddy.go +++ b/internal/provider/migrate_workbuddy.go @@ -16,7 +16,7 @@ func init() { for _, w := range []*wbSite{wbCN, wbAI} { movers[w.id] = &mover{ pkg: "@magpie-community/opencode-workbuddy-auth", - min: "0.1.15", // a system prompt sent as a developer message passes the channel check, an object tool_choice is sent as WorkBuddy takes it, and max_completion_tokens goes as max_tokens so the cap holds (plugins #96); 0.1.14: the Credits window says when the soonest credits left run out, for Smart routing to spend them first (cdredfox on X); an enterprise account names its enterprise, so it lists and uses the enterprise's models, not the personal plan's (plugins #75); a chat's tools get shapes WorkBuddy AI's models take, so ZCode's and DeepSeek Harness's chats on deepseek-v4.1-flash aren't 400 "Invalid request parameters" (wyh on Discord); one user send is one request in the usage list: every step carries one X-Conversation-Request-ID, and both builds name the client (使用端) (plugins #48); credits used up (code 14018) say so, with the nested error message (plugins #25); Codex's and Claude Code's chats pass WorkBuddy's channel check (#182); a failure's status and its sign-in mark as the built-in's; each model's credit rate; the sign-in renewed ahead of time through auth.refresh; the credits' count beside their share (#659) + min: "0.1.16", // WorkBuddy AI's GLM models are text-only, so magpie's image-describing model reads their images (Yirasumi on Discord); 0.1.15: a system prompt sent as a developer message passes the channel check, an object tool_choice is sent as WorkBuddy takes it, and max_completion_tokens goes as max_tokens so the cap holds (plugins #96); 0.1.14: the Credits window says when the soonest credits left run out, for Smart routing to spend them first (cdredfox on X); an enterprise account names its enterprise, so it lists and uses the enterprise's models, not the personal plan's (plugins #75); a chat's tools get shapes WorkBuddy AI's models take, so ZCode's and DeepSeek Harness's chats on deepseek-v4.1-flash aren't 400 "Invalid request parameters" (wyh on Discord); one user send is one request in the usage list: every step carries one X-Conversation-Request-ID, and both builds name the client (使用端) (plugins #48); credits used up (code 14018) say so, with the nested error message (plugins #25); Codex's and Claude Code's chats pass WorkBuddy's channel check (#182); a failure's status and its sign-in mark as the built-in's; each model's credit rate; the sign-in renewed ahead of time through auth.refresh; the credits' count beside their share (#659) agents: []string{w.id}, out: func() ([]Moving, error) { var out []Moving diff --git a/internal/provider/models.go b/internal/provider/models.go index 1ae7f5373..d783f4f14 100644 --- a/internal/provider/models.go +++ b/internal/provider/models.go @@ -71,6 +71,10 @@ func (p Provider) available() []catalog.Model { live = withoutCursorCapacity(collapseCursorModels(withCursorContexts(live))) case "devin": live = withDevinContexts(devinCollapse(live, devinCached(), p.Models)) + case WorkBuddyAIID: + // a list saved before its GLM models were known to drop + // images says they take them (wbSite.textOnly) + live = wbAI.textOnly(live) case "antigravity": // after its names are filled in, and so that a family's // levels aren't taken off by a known model of its id diff --git a/internal/provider/workbuddy.go b/internal/provider/workbuddy.go index c7274e7ab..13fb9ed60 100644 --- a/internal/provider/workbuddy.go +++ b/internal/provider/workbuddy.go @@ -371,7 +371,7 @@ func wbProvider(a wbAccount) Provider { return nil } acct.explain = wbExplain - acct.models = func() []catalog.Model { return w.models } + acct.models = func() []catalog.Model { return w.textOnly(w.models) } acct.fetch = func(ctx context.Context) ([]catalog.Model, error) { ms, err := wbFetchModels(ctx, w, acct.sign) if err != nil { diff --git a/internal/provider/workbuddy_images_test.go b/internal/provider/workbuddy_images_test.go new file mode 100644 index 000000000..c917bc0f7 --- /dev/null +++ b/internal/provider/workbuddy_images_test.go @@ -0,0 +1,123 @@ +package provider + +import ( + "context" + "net/http" + "net/http/httptest" + "path/filepath" + "testing" + + "github.com/yetone/magpie/internal/catalog" + "github.com/yetone/magpie/internal/settings" +) + +// WorkBuddy AI's GLM models take no images, though its config says every +// model does: on 2026-10-13 a real account's image sent to glm-5.3-flash, +// glm-5.3 and glm-5.2 came back as "[System reminder: the current model +// does not support images. Content filtered. ...]" (Yirasumi on Discord). +// Its other models read them, and WorkBuddy (China)'s GLM does too, so +// only WorkBuddy AI's GLM models are listed text-only, and magpie's +// image-describing model reads their images. +func TestWorkBuddyAIGLMIsTextOnly(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(`{"code":0,"data":{"agents":[{"name":"cli","models":["glm-5.3-flash","glm-5.3","glm-5.2","glm-6","deepseek-v4.1-flash","kimi-k3","my-glm-5"]}], + "models":[{"id":"glm-5.3-flash","supportsImages":true},{"id":"glm-5.3","supportsImages":true},{"id":"glm-5.2","supportsImages":true}, + {"id":"glm-6","supportsImages":true},{"id":"deepseek-v4.1-flash","supportsImages":true},{"id":"kimi-k3","supportsImages":true}, + {"id":"my-glm-5","supportsImages":true}]}}`)) + })) + defer srv.Close() + defer WorkBuddyBaseForTest(srv.URL, srv.URL)() + sign := func(context.Context, *http.Request, []byte) error { return nil } + images := func(w *wbSite) map[string]bool { + ms, err := wbFetchModels(context.Background(), w, sign) + if err != nil { + t.Fatal(err) + } + out := map[string]bool{} + for _, m := range ms { + if m.ImageInput == nil || *m.ImageInput != m.Images { + t.Errorf("%s %s: Images %v, ImageInput %v", w.id, m.ID, m.Images, m.ImageInput) + } + out[m.ID] = m.Images + } + return out + } + ai := images(wbAI) + for id, want := range map[string]bool{"glm-5.3-flash": false, "glm-5.3": false, "glm-5.2": false, "glm-6": false, + "deepseek-v4.1-flash": true, "kimi-k3": true, "my-glm-5": true} { + if ai[id] != want { + t.Errorf("WorkBuddy AI %s: images %v, want %v", id, ai[id], want) + } + } + for id, v := range images(wbCN) { + if !v { + t.Errorf("WorkBuddy (China) %s lost its images", id) + } + } + + // the list shown before the config is read says the same, and the + // site's own list is left as it was + for _, m := range wbAI.textOnly(wbAI.models) { + if m.ID == "glm-5.3" && (m.Images || m.ImageInput == nil || *m.ImageInput) { + t.Errorf("WorkBuddy AI's built-in glm-5.3: %+v", m) + } + } + for _, m := range wbAI.models { + if m.ImageInput != nil { + t.Errorf("wbAIModels %s changed: %+v", m.ID, m) + } + } + + // a user who said the model takes images keeps their answer + ms, _ := wbFetchModels(context.Background(), wbAI, sign) + for _, m := range ms { + if m.ID != "glm-5.3-flash" { + continue + } + p := Provider{ID: WorkBuddyAIID} + if e := entryFor(p, m, settings.Settings{}); e.Images { + t.Errorf("glm-5.3-flash with no answer of the user's: Images %v", e.Images) + } + s := settings.Settings{ModelImages: map[string]bool{WorkBuddyAIID + "/glm-5.3-flash": true}} + if e := entryFor(p, m, s); !e.Images || e.ImageInput == nil || !*e.ImageInput { + t.Errorf("the user's own yes was overridden: %+v", e) + } + } +} + +// A list saved before this was known, with WorkBuddy AI's GLM taking +// images, reads text-only too, without waiting for the next fetch. +func TestWorkBuddyAISavedGLMIsTextOnly(t *testing.T) { + home := t.TempDir() + t.Setenv("HOME", home) + t.Setenv("USERPROFILE", home) + t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config")) + t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache")) + yes := true + saved := []catalog.Model{{ID: "glm-5.3-flash", Images: true, ImageInput: &yes}, {ID: "deepseek-v4.1-flash", Images: true, ImageInput: &yes}} + for _, id := range []string{WorkBuddyAIID, "workbuddy"} { + if err := catalog.SaveLive(id, "", saved); err != nil { + t.Fatal(err) + } + } + want := map[string]map[string]bool{ + WorkBuddyAIID: {"glm-5.3-flash": false, "deepseek-v4.1-flash": true}, + "workbuddy": {"glm-5.3-flash": true, "deepseek-v4.1-flash": true}, + } + for pid, w := range want { + seen := 0 + for _, m := range (Provider{ID: pid}).Available() { + v, ok := w[m.ID] + if !ok { + continue + } + seen++ + if m.ImageInput == nil || *m.ImageInput != v || m.Images != v { + t.Errorf("%s %s: Images %v, ImageInput %v, want %v", pid, m.ID, m.Images, m.ImageInput, v) + } + } + if seen != len(w) { + t.Errorf("%s: %d of the saved models listed", pid, seen) + } + } +} diff --git a/internal/provider/workbuddy_models.go b/internal/provider/workbuddy_models.go index 156224e37..e1cf91107 100644 --- a/internal/provider/workbuddy_models.go +++ b/internal/provider/workbuddy_models.go @@ -24,6 +24,7 @@ import ( "io" "math" "net/http" + "slices" "strconv" "strings" @@ -85,7 +86,7 @@ func wbFetchModels(ctx context.Context, w *wbSite, sign func(context.Context, *h if env.Code != 0 { return nil, fmt.Errorf("WorkBuddy's config: %s (%d)", env.Msg, env.Code) } - ms := env.Data.cliModels() + ms := w.textOnly(env.Data.cliModels()) if len(ms) == 0 { return nil, fmt.Errorf("WorkBuddy's config lists no models for its CLI agent") } @@ -130,6 +131,32 @@ func (c wbProductConfig) cliModels() []catalog.Model { return wbDistinctNames(out) } +// textOnly marks the models of ms whose images w drops as taking none, +// whatever WorkBuddy's config says: WorkBuddy AI's GLM models. On +// 2026-10-13, with a real WorkBuddy AI account (Yirasumi on Discord), +// www.workbuddy.ai's /v3/config marked every model supportsImages: true, +// but a chat to glm-5.3-flash, glm-5.3 or glm-5.2 came back saying +// "[System reminder: the current model does not support images. Content +// filtered. ...]": the server had taken the image out. Its other models +// (deepseek-v4.1-flash, kimi, gemini, grok, gpt) read them, and WorkBuddy +// (China)'s glm-5.3-flash does too, so this is WorkBuddy AI's GLM family +// alone. Said text-only, magpie's image-describing model reads the image +// for them; a user's own answer (settings' ModelImages) still wins over +// this, in entryFor. ms is not changed; the result is a copy. +func (w *wbSite) textOnly(ms []catalog.Model) []catalog.Model { + if w.id != WorkBuddyAIID { + return ms + } + out := slices.Clone(ms) + for i := range out { + if strings.HasPrefix(out[i].ID, "glm-") { + no := false + out[i].Images, out[i].ImageInput = false, &no + } + } + return out +} + // wbCredits reads a model's credits, the multiple WorkBuddy's picker shows // by it: "x0.03", "0" or 0; "x0.00" is free. A rate it can't read (or // none) is not ok, and the model is neither free nor rated.