agent: a model field's list is joined with the catalog once while neither changed

Each agent's model field returned append(its own models,
viaMagpieShared(...)...), a copy of the whole catalog's options for
each field of each agent on every poll: Picks was 94.7 MB of 496 MB
over forty polls of the Agents page with real accounts. withVia keeps
the joined list per agent and prefix while the own models read the same
(sameOption, field by field) and the catalog's list is the very one
kept (same array), and joins it again when either changed. The list is
read only and clipped, as viaMagpieShared's is; every caller of a
field's Options reads it, Picks clones it before it drops anything.
The 52 `return append(own, viaMagpieShared(...)...)` sites call it.
omp's and Reasonix's planner edit the joined list after the append, and
Grok's writes Same into its copy, so they keep their own copies.

TestWithViaKeepsTheJoinedList: the same own models give the same array,
own models changed in a value or only an icon are joined anew, a
provider saved since is listed, and nothing joined is the catalog's own
list. TestSameOptionReadsEveryField sets each field of Option alone and
fails when sameOption doesn't see it. Broken by hand: never answering
from the kept list ("the same own models joined the catalog again"),
and FastFor left out of sameOption ("sameOption doesn't read
Option.FastFor").

Run on mote: both tests alone 3 of 3; internal/agent, internal/tui and
internal/cli ok; internal/gui red only on TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestMainWindowCorners (#3949); gofmt, vet and GOOS=windows
and linux vet clean. Real accounts in a sandbox HOME, forty polls:
Picks 94.7 MB -> 51.2 MB, state 190.8 MB -> 154.0 MB, state and drift
replies byte for byte the same as before. Footprint peak 136 MB.
This commit is contained in:
yetone
2026-11-01 07:54:54 +08:00
parent d6aa9cdf60
commit cdfdb62c69
38 changed files with 192 additions and 52 deletions
+4 -4
View File
@@ -1000,7 +1000,7 @@ func openCodeLike(at place, id, name, icon, bin, dir, auth string, ua []string,
provider := openCodeKept(path, func() any { return magpieProviderJSONAt("opencode", id, at.gw()) })
opts := func(key string) func(map[string]string) []Option {
return func(cur map[string]string) []Option {
return append(ownOptions(auth, cur[key]), viaMagpieShared(id, magpieID+"/")...)
return withVia(ownOptions(auth, cur[key]), id, magpieID+"/")
}
}
get := func(k string) string { v, _ := edit.GetJSON(path, k); return v }
@@ -1416,7 +1416,7 @@ func piLikeKeyed(at place, id, name, dir string, key func() string) *Agent {
return piScopeWith(path, v)
},
Options: func(cur map[string]string) []Option {
return append(ownOptionsFrom(piRegistry(id), auth, cur["model"]), viaMagpieShared(id, magpieID+"/")...)
return withVia(ownOptionsFrom(piRegistry(id), auth, cur["model"]), id, magpieID+"/")
},
},
{
@@ -1536,7 +1536,7 @@ func gooseIn(at place, cfg string) *Agent {
// only the native providers this goose is set up with (#987:
// every one of four was listed, OpenRouter's hundreds of
// models on a goose that had only magpie)
return append(ownOptions("", cur["model"], gooseConfigured(path, keyEnv)...), viaMagpieShared("goose", gooseProviderID+"/")...)
return withVia(ownOptions("", cur["model"], gooseConfigured(path, keyEnv)...), "goose", gooseProviderID+"/")
},
}, {
// GOOSE_THINKING_EFFORT, the effort goose asks of a model that
@@ -1785,7 +1785,7 @@ func crushAt(at place, path, data string) *Agent {
}
}
}
return append(ownOptions("", cur[key], extra...), viaMagpieShared("crush", magpieID+"/")...)
return withVia(ownOptions("", cur[key], extra...), "crush", magpieID+"/")
}
}
// replacePick puts v in place of the whole models.<type> object in the
+1 -1
View File
@@ -391,7 +391,7 @@ func agyIn(at place) *Agent {
if c := cur["model"]; c != "" && !usesMagpie(c) && custom[c] == nil {
own = append([]Option{{Value: c, Icon: modelIcon("", c), Direct: "Google"}}, own...)
}
return append(group("Antigravity CLI", own), viaMagpieShared("agy", magpieID+"/")...)
return withVia(group("Antigravity CLI", own), "agy", magpieID+"/")
},
}},
}
+1 -1
View File
@@ -757,7 +757,7 @@ func alma() *Agent {
Get: almaGet,
Set: almaSet,
Options: func(map[string]string) []Option {
return append(almaOwn(), viaMagpieShared("alma", magpieID+"/")...)
return withVia(almaOwn(), "alma", magpieID+"/")
},
}},
}
+1 -1
View File
@@ -54,7 +54,7 @@ func asideIn(at place) *Agent {
}
return opts
}
return append(asideOwnOptions(c.models, cur[key]), viaMagpieShared("aside", "magpie/")...)
return withVia(asideOwnOptions(c.models, cur[key]), "aside", "magpie/")
}
a.Fields = append(a.Fields, f)
}
+1 -1
View File
@@ -302,7 +302,7 @@ func astrbotAt(at place) *Agent {
return setPick(v)
},
Options: func(cur map[string]string) []Option {
return append(astrbotOwn(path, cur["model"]), viaMagpieShared("astrbot", magpieID+"/")...)
return withVia(astrbotOwn(path, cur["model"]), "astrbot", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -221,7 +221,7 @@ func atomcodeIn(at place) *Agent {
return nil
},
Options: func(c map[string]string) []Option {
return append(atomcodeOwnModels(path, c["model"]), viaMagpieShared("atomcode", magpieID+"/")...)
return withVia(atomcodeOwnModels(path, c["model"]), "atomcode", magpieID+"/")
},
}, {
// the current model table's reasoning_effort, sent with every
+1 -1
View File
@@ -254,7 +254,7 @@ func clineIn(at place) *Agent {
edit.KV{Path: "providers." + p + ".settings.model", Value: v})
},
Options: func(cur map[string]string) []Option {
return append(ownOptions("", cur["model"]), viaMagpieShared("cline", magpieID+"/")...)
return withVia(ownOptions("", cur["model"]), "cline", magpieID+"/")
},
}, {
// the reasoning of the provider in use, what Cline's --thinking
+1 -1
View File
@@ -104,7 +104,7 @@ func codebuddyIn(at place) *Agent {
if v := cur["model"]; v != "" && !usesMagpie(v) {
out = append(out, Option{Value: v, Icon: modelIcon("", v)})
}
return append(out, viaMagpieShared("codebuddy", magpieID+"/")...)
return withVia(out, "codebuddy", magpieID+"/")
},
}},
}
+1 -1
View File
@@ -1265,7 +1265,7 @@ func codexIn(at place) *Agent {
// models direct only). Routed, Codex's own say via magpie already.
onSignIn := (p == "" || p == "openai" || isCCSwitchMirror(p)) && chatGPT()
if !through && (!onSignIn || codexFailover()) {
return append(own, viaMagpieShared("codex", "")...)
return withVia(own, "codex", "")
}
return append(own, codexViaMagpieFor(own)...)
}
+1 -1
View File
@@ -98,7 +98,7 @@ func commandCodeIn(at place) *Agent {
if v := cur["model"]; v != "" && !usesMagpie(v) {
out = append(out, Option{Value: v, Icon: modelIcon("", v)})
}
return append(out, viaMagpieShared("commandcode", magpieID+"/")...)
return withVia(out, "commandcode", magpieID+"/")
},
}, {
// settings.json's reasoningEffort keeps an effort for each model
+1 -1
View File
@@ -450,7 +450,7 @@ func droidIn(at place) *Agent {
if c := cur["model"]; c != "" && !usesMagpie(c) && !seen[c] {
own = append([]Option{{Value: c, Icon: modelIcon("", c)}}, own...)
}
return append(group("Droid", own), viaMagpieShared("droid", magpieID+"/")...)
return withVia(group("Droid", own), "droid", magpieID+"/")
},
}},
}
+1 -1
View File
@@ -225,7 +225,7 @@ func dshAt(at place) *Agent {
own[i].Direct = "DeepSeek"
}
}
return append(own, viaMagpieShared("dsh", magpieID+"/")...)
return withVia(own, "dsh", magpieID+"/")
},
}, {
// the thinking effort sessions start with: agent-default-model's
+1 -1
View File
@@ -170,7 +170,7 @@ func empryoAt(at place) *Agent {
_, id, _ := strings.Cut(c, "/")
own = append(own, Option{Value: c, Icon: modelIcon("", id)})
}
return append(group("Empryo", own), viaMagpieShared("empryo", magpieID+"/")...)
return withVia(group("Empryo", own), "empryo", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -118,7 +118,7 @@ func fxIn(at place) *Agent {
if v := cur["model"]; v != "" && !usesMagpie(v) {
out = append(out, Option{Value: v, Icon: modelIcon("", v)})
}
return append(out, viaMagpieShared("fx", magpieID+"/")...)
return withVia(out, "fx", magpieID+"/")
},
}},
}
+1 -1
View File
@@ -261,7 +261,7 @@ func geminiIn(at place) *Agent {
}
}
own := group("Gemini CLI", options(ms, ""))
return append(own, viaMagpieShared("gemini", "")...)
return withVia(own, "gemini", "")
},
},
},
+1 -1
View File
@@ -412,7 +412,7 @@ func grokApp(home string) *Agent {
return setDefault(v)
},
Options: func(cur map[string]string) []Option {
return append(grokAppOwn(path, keyDefault, cur["model"]), viaMagpieShared("grok-app", magpieID+"/")...)
return withVia(grokAppOwn(path, keyDefault, cur["model"]), "grok-app", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -169,7 +169,7 @@ func hanako(home string) *Agent {
return hanakoChat(dir, agent, v)
},
Options: func(cur map[string]string) []Option {
return append(hanakoOwn(dir, cur["model"]), viaMagpieShared("hanako", magpieID+"/")...)
return withVia(hanakoOwn(dir, cur["model"]), "hanako", magpieID+"/")
},
}},
}
+2 -2
View File
@@ -222,7 +222,7 @@ func hermesIn(at place) *Agent {
return edit.SetYAML(path, edit.KV{Path: "model.default", Value: v})
},
Options: func(cur map[string]string) []Option {
return append(ownOptions("", cur["model"]), viaMagpieShared("hermes", magpieID+"/")...)
return withVia(ownOptions("", cur["model"]), "hermes", magpieID+"/")
},
}, {
// agent.reasoning_effort, which Hermes's /reasoning saves; none
@@ -323,7 +323,7 @@ func hermesProfileFields(at place, dir string, provider func(string) any) []Fiel
return edit.SetYAML(p, edit.KV{Path: "model.default", Value: v})
},
Options: func(cur map[string]string) []Option {
return append(ownOptions("", cur[hermesProfileKey+name]), viaMagpieShared("hermes", magpieID+"/")...)
return withVia(ownOptions("", cur[hermesProfileKey+name]), "hermes", magpieID+"/")
},
})
}
+1 -1
View File
@@ -353,7 +353,7 @@ func jcodeAt(at place) *Agent {
return setPick(jcodePick{c.Provider.DefaultProvider, v})
},
Options: func(cur map[string]string) []Option {
return append(jcodeOwn(path, keyPick, cur["model"]), viaMagpieShared("jcode", magpieID+"/")...)
return withVia(jcodeOwn(path, keyPick, cur["model"]), "jcode", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -361,7 +361,7 @@ func kimiIn(at place) *Agent {
return dropMagpie()
},
Options: func(cur map[string]string) []Option {
return append(kimiOwnOptions(path, cur["model"]), viaMagpieShared("kimi", magpieID+"/")...)
return withVia(kimiOwnOptions(path, cur["model"]), "kimi", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -189,7 +189,7 @@ func miniMaxAt(at place, dir string) *Agent {
return nil
},
Options: func(cur map[string]string) []Option {
return append(miniMaxOwnOptions(path, cur["model"]), viaMagpieShared("minimax-code", magpieID+"/")...)
return withVia(miniMaxOwnOptions(path, cur["model"]), "minimax-code", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -153,7 +153,7 @@ func morphIn(at place) *Agent {
return edit.SetYAML(path, edit.KV{Path: "llm.model", Value: v})
},
Options: func(cur map[string]string) []Option {
return append(ownOptions("", cur["model"]), viaMagpieShared("morph", magpieID+"/")...)
return withVia(ownOptions("", cur["model"]), "morph", magpieID+"/")
},
}, {
// llm.reasoning_effort; unset, morph sends none
+1 -1
View File
@@ -119,7 +119,7 @@ func mothxIn(at place) *Agent {
return pair(v)
},
Options: func(cur map[string]string) []Option {
return append(mothxOwn(path, cur["model"]), viaMagpieShared("mothx", magpieID+"/")...)
return withVia(mothxOwn(path, cur["model"]), "mothx", magpieID+"/")
},
},
{
+1 -1
View File
@@ -153,7 +153,7 @@ func museAt(at place, cfg string) *Agent {
if c := cur["model"]; c != "" && !usesMagpie(c) {
own = append(own, Option{Value: c, Icon: museIcon(c)})
}
return append(group("Muse Code", own), viaMagpieShared("muse", magpieID+"/")...)
return withVia(group("Muse Code", own), "muse", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -167,7 +167,7 @@ func openChamber(home, cfg string) *Agent {
provider := openCodeKept(ocPath, func() any { return magpieProviderJSONFor("opencode", "opencode") })
opts := func(key string) func(map[string]string) []Option {
return func(cur map[string]string) []Option {
return append(ownOptions(auth, cur[key]), viaMagpieShared("opencode", magpieID+"/")...)
return withVia(ownOptions(auth, cur[key]), "opencode", magpieID+"/")
}
}
// stepped off magpie: its provider goes too, when nothing else in the
+1 -1
View File
@@ -478,7 +478,7 @@ func openClawAt(at place) *Agent {
return patch([]edit.KV{{Path: openClawModel, Value: v}}, nil)
},
Options: func(cur map[string]string) []Option {
return append(openClawOwn(keyWas, cur["model"]), viaMagpieShared("openclaw", magpieID+"/")...)
return withVia(openClawOwn(keyWas, cur["model"]), "openclaw", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -289,7 +289,7 @@ func penguinIn(at place) *Agent {
return dropMagpie()
},
Options: func(cur map[string]string) []Option {
return append(penguinOwnOptions(path, cur["model"]), viaMagpieShared("penguin", magpieID+"/")...)
return withVia(penguinOwnOptions(path, cur["model"]), "penguin", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -420,7 +420,7 @@ func plugged(home string, p *agentplug.Agent) *Agent {
return f.set([]edit.KV{{Path: d.Model, Value: v}})
},
Options: func(cur map[string]string) []Option {
return append(ownOptions("", cur["model"]), viaMagpieShared(id, magpieID+"/")...)
return withVia(ownOptions("", cur["model"]), id, magpieID+"/")
},
}},
// the catalog changed: what connect writes for the model may too
+1 -1
View File
@@ -189,7 +189,7 @@ func qoderAt(at place, b qoderBuild) *Agent {
return edit.SetJSON(path, edit.KV{Path: "model.name", Value: v})
},
Options: func(cur map[string]string) []Option {
return append(ownOptions("", cur["model"]), viaMagpieShared(b.id, magpieID+"/")...)
return withVia(ownOptions("", cur["model"]), b.id, magpieID+"/")
},
}, {
// the effort of the model in use, in its model.preferences
+1 -1
View File
@@ -406,7 +406,7 @@ func qwenIn(at place) *Agent {
return setProviders(false)
},
Options: func(cur map[string]string) []Option {
return append(qwenOwnOptions(path, cur["model"]), viaMagpieShared("qwen", magpieID+"/")...)
return withVia(qwenOwnOptions(path, cur["model"]), "qwen", magpieID+"/")
},
}},
}, path)
+1 -1
View File
@@ -393,7 +393,7 @@ func reasonixIn(at place) *Agent {
addNative(*state.Default)
}
addNative(cur["model"])
return append(group("Reasonix Studio", own), viaMagpieShared("reasonix", magpieID+"/")...)
return withVia(group("Reasonix Studio", own), "reasonix", magpieID+"/")
},
},
{Key: "effort", Label: "effort", Quiet: true,
+49
View File
@@ -41,6 +41,55 @@ func viaMagpieShared(agent, prefix string) []Option {
return builtOptions.shared(agent+"\x00"+prefix, func() []Option { return buildVia(agent, prefix) })
}
// withVia is append(own, viaMagpieShared(agent, prefix)...), the list a
// model field offers, kept while own reads the same and the catalog's list
// is the one kept: the append copied the whole catalog for each field of
// each agent, every poll, about 60 MB of what forty polls of the Agents
// page allocated with real accounts. Read only, as viaMagpieShared's.
func withVia(own []Option, agent, prefix string) []Option {
via := viaMagpieShared(agent, prefix)
if len(own) == 0 {
return via
}
key := [2]string{agent, prefix}
joinedOptions.Lock()
defer joinedOptions.Unlock()
if j, ok := joinedOptions.m[key]; ok && sameList(j.via, via) && slices.EqualFunc(j.own, own, sameOption) {
return j.out
}
out := make([]Option, 0, len(own)+len(via))
out = append(append(out, own...), via...)
if joinedOptions.m == nil {
joinedOptions.m = map[[2]string]joinedList{}
}
joinedOptions.m[key] = joinedList{own: out[:len(own)], via: via, out: out}
return out
}
var joinedOptions struct {
sync.Mutex
m map[[2]string]joinedList
}
type joinedList struct{ own, via, out []Option }
// sameList reports whether a and b are the one list kept: the same array,
// as long.
func sameList(a, b []Option) bool {
return len(a) == len(b) && (len(a) == 0 || &a[0] == &b[0])
}
// sameOption reports whether a and b read the same, field by field.
func sameOption(a, b Option) bool {
return a.Value == b.Value && a.Label == b.Label && a.Note == b.Note && a.Icon == b.Icon &&
slices.Equal(a.Icons, b.Icons) && a.Group == b.Group && a.GroupIcon == b.GroupIcon &&
a.Ref == b.Ref && a.Free == b.Free && a.Rate == b.Rate && a.RateWas == b.RateWas &&
a.Context == b.Context && a.Takes == b.Takes && a.Direct == b.Direct && a.Via == b.Via &&
a.Same == b.Same && a.Served == b.Served && a.Alias == b.Alias && a.FastFor == b.FastFor &&
a.Fast == b.Fast && a.OwnFast == b.OwnFast && a.UltraOK == b.UltraOK && a.Ultra == b.Ultra &&
a.own == b.own && a.sub == b.sub
}
// builtOptions is what viaMagpie built last, per agent and prefix. Each
// agent's model field offers it, and the window's drift poll asked every
// field's options of every agent each 15s: Claude Code's alone
+1 -1
View File
@@ -339,7 +339,7 @@ func snowIn(at place) *Agent {
return leave(to)
},
Options: func(cur map[string]string) []Option {
return append(snowOwnOptions(profiles, cur["model"]), viaMagpieShared("snow", magpieID+"/")...)
return withVia(snowOwnOptions(profiles, cur["model"]), "snow", magpieID+"/")
},
}, {
// basicModel, the light model Snow's summaries, compaction and
+1 -1
View File
@@ -626,7 +626,7 @@ func stepcodeIn(at place) *Agent {
return nil
},
Options: func(cur map[string]string) []Option {
return append(ownOptions(authPath, cur["model"]), viaMagpieShared("stepcode", magpieID+"/")...)
return withVia(ownOptions(authPath, cur["model"]), "stepcode", magpieID+"/")
},
},
},
+91
View File
@@ -0,0 +1,91 @@
package agent
import (
"reflect"
"slices"
"testing"
"unsafe"
"github.com/yetone/magpie/internal/provider"
)
// A model field's list is its own models then the catalog's: the append
// copied the whole catalog for each field of each agent on every poll.
// withVia keeps the list joined while the own models read the same and the
// catalog's list is the one kept, and joins it again when either changed.
func TestWithViaKeepsTheJoinedList(t *testing.T) {
syncHome(t)
if err := provider.Save(provider.Provider{ID: "oa", Name: "OA", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"gpt-5.5", "gpt-5.4"}}); err != nil {
t.Fatal(err)
}
own := func(v string) []Option { return []Option{{Value: v, Note: "own"}} }
want := func(o []Option) []Option { return append(slices.Clone(o), viaMagpieShared("pi", magpieID+"/")...) }
equal := func(a, b []Option) bool { return slices.EqualFunc(a, b, sameOption) }
first := withVia(own("m1"), "pi", magpieID+"/")
if len(first) < 3 || !equal(first, want(own("m1"))) {
t.Fatalf("the joined list is not own then the catalog: %+v", first)
}
again := withVia(own("m1"), "pi", magpieID+"/")
if &again[0] != &first[0] {
t.Fatal("the same own models joined the catalog again")
}
if n := testing.AllocsPerRun(20, func() { withVia(own("m1"), "pi", magpieID+"/") }); n > 60 {
t.Fatalf("a list already joined took %.0f allocations", n)
}
if cap(again) != len(again) {
t.Fatal("an append onto the kept list would write into it")
}
// own models that read otherwise, an icon among them, are joined anew
changed := own("m1")
changed[0].Icons = []string{"x"}
if got := withVia(changed, "pi", magpieID+"/"); &got[0] == &first[0] || !equal(got, want(changed)) {
t.Fatalf("own models changed since are not what is listed: %+v", got[0])
}
if got := withVia(own("m2"), "pi", magpieID+"/"); got[0].Value != "m2" || !equal(got, want(own("m2"))) {
t.Fatalf("own models changed since are not what is listed: %+v", got[0])
}
// a provider saved since: the catalog's list is built again, and so
// is the joined one
if err := provider.Save(provider.Provider{ID: "nb", Name: "NB", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"x"}}); err != nil {
t.Fatal(err)
}
got := withVia(own("m2"), "pi", magpieID+"/")
if !slices.ContainsFunc(got, func(o Option) bool { return o.Value == magpieID+"/nb/x" }) || !equal(got, want(own("m2"))) {
t.Fatalf("a provider saved since is not listed: %d options", len(got))
}
if got := withVia(nil, "pi", magpieID+"/"); !sameList(got, viaMagpieShared("pi", magpieID+"/")) {
t.Fatal("with no own models the catalog's list is not the one kept")
}
}
// sameOption reads every field of an Option: one added and left out of it
// would keep a joined list whose own models changed only in that field.
func TestSameOptionReadsEveryField(t *testing.T) {
typ := reflect.TypeFor[Option]()
for i := range typ.NumField() {
var a, b Option
f := reflect.ValueOf(&b).Elem().Field(i)
f = reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Elem()
switch f.Kind() {
case reflect.String:
f.SetString("x")
case reflect.Bool:
f.SetBool(true)
case reflect.Int:
f.SetInt(1)
case reflect.Float64:
f.SetFloat(1)
case reflect.Slice:
f.Set(reflect.ValueOf([]string{"x"}))
default:
t.Fatalf("Option.%s is a %s, which this test can't set", typ.Field(i).Name, f.Kind())
}
if sameOption(a, b) {
t.Errorf("sameOption doesn't read Option.%s", typ.Field(i).Name)
}
}
}
+1 -1
View File
@@ -380,7 +380,7 @@ func vscodeKindAt(k vscodeKind, dir string) *Agent {
if v := cur["model"]; v != "" && v != "auto" && !usesMagpie(v) {
own = append(own, Option{Value: v, Icon: modelIcon("", v)})
}
return append(group(k.name, own), viaMagpieShared(k.id, magpieID+"/")...)
return withVia(group(k.name, own), k.id, magpieID+"/")
},
}},
}, path, models, stashPath())
+13 -13
View File
@@ -441,7 +441,7 @@ var wslKinds = []wslKind{
// over several accounts magpie routes, so they are
// offered via magpie too, as on a live Codex (#1603)
if codexFailover() {
return append(group("OpenAI", options(ownCodex(), "")), viaMagpieShared("codex", "")...)
return withVia(group("OpenAI", options(ownCodex(), "")), "codex", "")
}
own := codexInMagpie(group("OpenAI", options(ownCodex(), "")))
return append(own, codexViaMagpieFor(own)...)
@@ -471,7 +471,7 @@ var wslKinds = []wslKind{
if key == "model" {
// the providers of its auth.json are the distro's files
return func(cur map[string]string) []Option {
return append(ownOptions("", cur["model"]), viaMagpieShared("pi", magpieID+"/")...)
return withVia(ownOptions("", cur["model"]), "pi", magpieID+"/")
}
}
return nil
@@ -482,7 +482,7 @@ var wslKinds = []wslKind{
asleep: func(key string) func(map[string]string) []Option {
if key == "model" {
return func(cur map[string]string) []Option {
return append(ownOptions("", cur["model"]), viaMagpieShared("omo", magpieID+"/")...)
return withVia(ownOptions("", cur["model"]), "omo", magpieID+"/")
}
}
return nil
@@ -493,7 +493,7 @@ var wslKinds = []wslKind{
asleep: func(key string) func(map[string]string) []Option {
if key == "model" {
return func(cur map[string]string) []Option {
return append(ownOptions("", cur["model"]), viaMagpieShared("prime-agent", magpieID+"/")...)
return withVia(ownOptions("", cur["model"]), "prime-agent", magpieID+"/")
}
}
return nil
@@ -560,7 +560,7 @@ var wslKinds = []wslKind{
return nil
}
return func(cur map[string]string) []Option {
return append(kimiOwnOptions("", cur["model"]), viaMagpieShared("kimi", magpieID+"/")...)
return withVia(kimiOwnOptions("", cur["model"]), "kimi", magpieID+"/")
}
}},
// Qwen Code's ~/.qwen, one settings.json of the same shape as this
@@ -572,7 +572,7 @@ var wslKinds = []wslKind{
return nil
}
return func(cur map[string]string) []Option {
return append(qwenOwnOptions("", cur["model"]), viaMagpieShared("qwen", magpieID+"/")...)
return withVia(qwenOwnOptions("", cur["model"]), "qwen", magpieID+"/")
}
}},
{id: "omp", name: "omp", dir: ".omp", bin: "omp", in: ompIn, version: true,
@@ -582,7 +582,7 @@ var wslKinds = []wslKind{
return nil
}
return func(cur map[string]string) []Option {
return append(ompOwnOptions("", cur[key]), viaMagpieShared("omp", magpieID+"/")...)
return withVia(ompOwnOptions("", cur[key]), "omp", magpieID+"/")
}
}},
{id: "crush", name: "Crush", dir: ".config/crush", bin: "crush", in: crushIn,
@@ -620,7 +620,7 @@ var wslKinds = []wslKind{
if c := cur["model"]; c != "" && !usesMagpie(c) {
own = append(own, Option{Value: c, Icon: modelIcon("", c)})
}
return append(group("Droid", own), viaMagpieShared("droid", magpieID+"/")...)
return withVia(group("Droid", own), "droid", magpieID+"/")
}
}},
// no bin: fx is also the JSON viewer's name
@@ -635,7 +635,7 @@ var wslKinds = []wslKind{
return nil
}
return func(cur map[string]string) []Option {
return append(miniMaxOwnOptions("", cur["model"]), viaMagpieShared("minimax-code", magpieID+"/")...)
return withVia(miniMaxOwnOptions("", cur["model"]), "minimax-code", magpieID+"/")
}
}},
// version: a dsh with no profile yet is told from one before profiles
@@ -651,7 +651,7 @@ var wslKinds = []wslKind{
for i := range own {
own[i].Direct = "DeepSeek"
}
return append(own, viaMagpieShared("dsh", magpieID+"/")...)
return withVia(own, "dsh", magpieID+"/")
}
}
if key != "effort" {
@@ -692,7 +692,7 @@ var wslKinds = []wslKind{
}
// the models of its config.toml are the distro's files
return func(cur map[string]string) []Option {
return append(atomcodeOwnModels("", cur["model"]), viaMagpieShared("atomcode", magpieID+"/")...)
return withVia(atomcodeOwnModels("", cur["model"]), "atomcode", magpieID+"/")
}
}},
// Snow CLI's ~/.snow, its profiles the distro's own; a stopped
@@ -737,7 +737,7 @@ var wslKinds = []wslKind{
if c := cur["model"]; c != "" && !usesMagpie(c) {
own = append(own, Option{Value: c, Icon: modelIcon("", c), Direct: "Google"})
}
return append(group("Antigravity CLI", own), viaMagpieShared("agy", magpieID+"/")...)
return withVia(group("Antigravity CLI", own), "agy", magpieID+"/")
}
}},
// Block's goose, by its folder alone: a goose command may be pressly's
@@ -799,7 +799,7 @@ func wslOwnAsleep(id string, keys ...string) func(string) func(map[string]string
return nil
}
return func(cur map[string]string) []Option {
return append(ownOptions("", cur[key]), viaMagpieShared(id, magpieID+"/")...)
return withVia(ownOptions("", cur[key]), id, magpieID+"/")
}
}
}
+1 -1
View File
@@ -128,7 +128,7 @@ func zedAtWith(dir, bin string, processes []string) *Agent {
if v := cur["model"]; v != "" && !usesMagpie(v) {
own = append(own, Option{Value: v, Icon: modelIcon("", v)})
}
return append(group("Zed", own), viaMagpieShared("zed", magpieID+"/")...)
return withVia(group("Zed", own), "zed", magpieID+"/")
},
}},
}, path, stashPath())