agent: a catalog sync leaves a magpie provider the user wrote alone while the agent isn't connected

yyddbds on Discord: in Xiaomi MiMo they added a custom provider pointing
at magpie and picked a few models by hand. MiMo's switch on the Agents
page was off, yet after an update the provider held every one of
magpie's models. SyncCatalog runs at each start and update and on every
catalog change, and MiMo Code's Sync (openCodeLike) brought any
provider.magpie block up to the catalog whether magpie wrote it or not.
magpie's default went over a list the user set.

An Agent whose Sync does nothing but keep a block of magpie's name up
to the catalog is now ListOnly, and SyncCatalog runs it only while the
agent is Wired, which is what the Agents page's switch shows. The same
sync was in every sibling, so ListOnly is on all of them: openCodeLike
(OpenCode, MiMo Code and their WSL forms), piLikeKeyed (Pi and forks),
Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi,
MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenPencil, Penguin, Qwen
Code and T3 Code. Left out on purpose: Codex, Claude, Grok and Hermes,
whose Syncs also repair while not connected (Hermes keeps its bots'
magpie provider current) and have their own gates.

Trade-off: a list magpie wrote while connected doesn't follow the
catalog while the agent runs a model of its own (switch off); it does
again once a model of magpie's is picked. Users whose list was already
written over: magpie keeps no copy of the old list, so it stays full;
from this release on it is left alone, and they trim it once by hand
(or connect the agent in magpie and use its model list's Pick).

Tests: TestCatalogSyncLeavesAHandWrittenMagpieBlock (MiMo, Pi and Crush
with a hand-written magpie block stay byte for byte; connected, MiMo's
list follows the catalog; disconnected and written by hand again, left
alone; a magpie model picked in MiMo, followed again).
TestListOnlyAgentsReadConnected: every ListOnly agent magpie connects
reads as Wired (n >= 15), so none of them loses catalog updates.
Fixtures of TestSyncCatalogRewritesAgentLists,
TestModelNameAndLevelsReachAgentFiles, TestSuffixModesReachAgentFiles
and TestPiKeepsTheirKeysInMagpiesProvider, and internal/cli's
TestSaveAnswersBeforeTheAgentsSync (its Pi settings were {}), now have
Pi connected (settings.json defaultProvider magpie), as a block magpie
wrote implies.
docs/subsystems/agent-wiring.md says the rule.

Run (mote, sandbox HOME via the tests' syncHome/codexHome):
- old code + the new test: red (MiMo, Pi, Crush written over; after
  Disconnect written over).
- broken by hand: ListOnly dropped from openCodeLike: red on MiMo
  (lines 52, 82); the Wired gate in SyncCatalog replaced with true: red
  on all three.
- go test -tags nogui -count=1 ./internal/agent: ok.
- gofmt -l clean; go vet ./... for darwin, GOOS=linux and GOOS=windows:
  ok.
- full suite, go test -tags nogui -count=1 -timeout 45m ./... at base
  3bebc3839 (logs kept in the worktree): every package ok but
  internal/cli (TestSaveAnswersBeforeTheAgentsSync, mine, fixture fixed
  above, then ok alone) and internal/gateway: TestAntigravityTurned*,
  TestAntigravityTurnsCodexsGPT5ThreadAwayOnce and
  TestCodexSpentGrokFailingIsTold, red the same on a fresh origin/main
  b26fa0903 copy, filed as #4362.
- rebased on e8d42c02d: vet (darwin, linux, windows) of internal/agent and
  internal/cli, and go test of internal/agent, internal/cli,
  internal/library and internal/gui: all ok. Pushed on 764a032f6,
  whose three commits since touch gateway, usage, provider and chat only.

Not tried: the real Xiaomi MiMo desktop app (the fixture is the OpenCode
shape MiMo Code writes; whether the reporter's provider id is literally
"magpie" is unconfirmed: a provider of another id was never touched).
Lists already written over are not restored.
This commit is contained in:
yetone
2026-10-30 14:25:38 +08:00
parent 764a032f6f
commit 0911a65e7d
26 changed files with 166 additions and 8 deletions
+1
View File
@@ -44,6 +44,7 @@ something else shows up as drift.
- magpie only removes what it wrote. Anything else in an agent's config stays as it was.
- agy's shell function (`update.ShellFunction`, [`shellfn.go`](../../internal/update/shellfn.go)) sits between `# >>> magpie agy >>>` and `# <<< magpie agy <<<`, the only lines magpie writes or takes out of a profile. The profiles are those `cliProfile` names (zsh's in `ZDOTDIR` when set, bash's, fish's `config.fish`), plus PowerShell 7's and Windows PowerShell's on Windows when their execution policy runs a profile. A missing profile is made only for the shell a terminal opens. Only a file inside the home is written, writes go through temp-and-rename, and a profile that can't be read is left alone. Picking one of magpie's models and every `Sync` on one put it there, which covers users wired before it existed. Stepping out and a `Sync` off magpie take it out. agy in a WSL distro gets the function in the distro's own profiles (`agyDistroProfiles` in [`agy.go`](../../internal/agent/agy.go), through `update.ShellFunctionAt`): `~/.bashrc`, `~/.zshrc` and `~/.config/fish/config.fish` where each is, and the profile of the login shell the distro's `/etc/passwd` names (bash when it names none) made where it isn't. The distro's `ZDOTDIR` and `XDG_CONFIG_HOME` aren't read. No magpie runs there, so the function (`agyDistroFunction`) reads `settings.json`'s model with `sed` and carries the gateway's address as the distro reaches it (`place.gw`, Windows' under NAT) and the key it takes from there (`agentKeyAt`, the WSL key under NAT). `Sync` writes it again, so an address WSL changed on a restart follows, and until then `Check` reports a function naming another address. A user's own `alias agy` still wins over it. A terminal opened before the change still needs the `Launch` command.
- A sync brings magpie's models up to date, not where the agent reaches magpie. Every `Sync` that `SyncCatalog` runs (each start and update of magpie, a provider added, and a plugin signed in to, out of or renewed, or listing other models than the last time: `plugin.OnChange` and `plugin.OnListed` call `catalog.Touched`, #2373) goes through `synced`, which passes each file written through `kept.away` (`edit.Filtered`, [`keptaway.go`](../../internal/agent/keptaway.go)). The filter sees every file written through `edit` while it is on, from any goroutine and under whatever lock the writer holds, so it takes none a writer may hold: the gateway's address and the LAN key are read before it is on (`keeping`), and magpie's own files (`magpieFile`: its folder as named or where its links lead, such as a `~/.config` linked into a dotfiles repo) are left as they are (ylorn on Discord: `settings.Save` under the settings' lock reached a filter that read the settings, and the app hung ~10s after every start; `TestOwnWritesDuringASyncWithALinkedConfig`). In a file without the gateway's own address, whose magpie the user pointed at an address on another machine (a NAS's, or this machine's LAN address), and with no address a WSL distro was seen at, that address stays in place of `gateway.URL()`, with the path before magpie's every URL at it had (`awayPath`: a reverse proxy's `/magpie`; on loopback, a local proxy's route where magpie answered or hasn't been asked), and so does the key that went with it in place of magpie's own (coeo91 on Discord: the base URL went back to 127.0.0.1 after an update or restart). An address on this machine's loopback follows the gateway; with more than one address or key gone, the write is left as it is. Picking a model in magpie still points the agent at this magpie, but for Claude Code at a proxy to it (above). ZCode and WorkBuddy keep such an address in their own writers too (`zcodeAddress`, `buddyWriteAt`).
- An agent whose `Sync` does nothing but bring a block of magpie's name up to the catalog is `ListOnly` (OpenCode, MiMo Code and the other OpenCode forms, Pi and its forks, Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi, MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenPencil, Penguin, Qwen Code, T3 Code). `SyncCatalog` runs it only while the agent is connected (`Wired`), as its switch on the Agents page says: a custom provider the user named magpie in the agent, with a few models picked by hand, was written over with the whole catalog at every start (yyddbds on Discord, Xiaomi MiMo; `TestCatalogSyncLeavesAHandWrittenMagpieBlock`). A list magpie wrote while connected waits, while the agent runs a model of its own, until a model of magpie's is picked again. Every `ListOnly` agent magpie connects reads as `Wired` (`TestListOnlyAgentsReadConnected`). Agents whose `Sync` also repairs while not connected (Codex, Claude, Grok, Hermes' bots) are not `ListOnly`. magpie keeps no copy of a list it wrote over before this, so such a list stays full until the user trims it.
- `SyncCatalog` holds the catalog it builds (`provider.Hold`), the plugins' providers and sign-ins among it, for up to a second. Those `catalog.Touched` drops are told in the background, so a plugin change also drops what is held at once (`plugin.OnChangeNow`, [`hold.go`](../../internal/provider/hold.go)): the host's "auth" event is read before its reply to the sign-in that saved it, and a look at the accounts once the sign-in returns sees it (#2449: `magpie plugin login` found no account while a sync ran; `TestHeldGoesWithAPluginChange`).
- JetBrains Air's `magpie-opencode.json` keeps user-added fields in `provider.magpie`, including nested options, on sync and model picks (`air` in [`air.go`](../../internal/agent/air.go), using `theirsKept` in [`sync.go`](../../internal/agent/sync.go)). The gateway fields and complete model list are still replaced, so removed models leave the list.
- In every OpenCode-shaped config (OpenCode, DevEco, Air, OpenChamber; `openCodeKept` in [`agents.go`](../../internal/agent/agents.go)), a variant the user put on one of magpie's models stays through a sync, and so does one they wrote over under a name of magpie's. A variant exactly as magpie writes it under its name (`openCodeVariant`) is magpie's, so one the model no longer has goes (#2379, `TestOpenCodeCodexFastVariants`).
+10
View File
@@ -153,6 +153,16 @@ type Agent struct {
// rather than asking the gateway, rewrites that list as the catalog is
// now — where magpie wrote one; nothing else changes (see SyncCatalog).
Sync func() error
// ListOnly: Sync does nothing but bring a block of magpie's name in the
// agent's files up to the catalog. A catalog sync runs it only while
// the agent is connected (Wired), as its switch on the Agents page
// says: switched off, nothing of magpie's writes its files. A custom
// provider the user named magpie in the agent, with a few models picked
// by hand (yyddbds on Discord, Xiaomi MiMo), was written over with the
// whole catalog at every start. A list magpie wrote while connected
// waits, while the agent runs a model of its own, until a model of
// magpie's is picked again.
ListOnly bool
// Unwire, for an agent whose fields' default is the agent as installed
// rather than what it had before magpie (Codex, Claude Code, Gemini
// CLI), takes magpie out of its config and puts back what the stash
+5 -1
View File
@@ -943,6 +943,7 @@ func openCodeLike(at place, id, name, icon, bin, dir, auth string, ua []string,
return wiringOff(name, path, func(k string) (string, bool) { return edit.GetJSON(path, "provider."+magpieID+".options."+k) },
"baseURL", at.v1(), "apiKey", openCodeKeyAt(id, at.gw()))
},
ListOnly: true,
Sync: func() error {
// a model of magpie's chosen, but its provider gone from the
// file: put it back, or the agent has nothing to send it to
@@ -1266,6 +1267,7 @@ func piLikeKeyed(at place, id, name, dir string, key func() string) *Agent {
return wiringOff(name, modelsPath, func(k string) (string, bool) { return edit.GetJSON(modelsPath, "providers."+magpieID+"."+k) },
"baseUrl", at.v1(), "apiKey", key())
},
ListOnly: true,
Sync: func() error {
if err := syncJSON(modelsPath, "providers."+magpieID, block); err != nil {
return err
@@ -1395,7 +1397,8 @@ func gooseIn(at place, cfg string) *Agent {
return wiringOff("Goose", provider, func(k string) (string, bool) { return edit.GetJSON(provider, k) },
"base_url", at.v1(), "headers.Authorization", "Bearer "+gooseKey(at))
},
Sync: func() error { return syncGooseProvider(provider, at) },
ListOnly: true,
Sync: func() error { return syncGooseProvider(provider, at) },
// goose loads custom_providers when it starts
Notice: func() string {
if p, _ := gooseActive(path); p == gooseProviderID && Running(`Goose\.app/`, `(^|/)goose( |$)`) {
@@ -1676,6 +1679,7 @@ func crushAt(at place, path, data string) *Agent {
return wiringOff("Crush", path, func(k string) (string, bool) { return get("providers." + magpieID + "." + k) },
"base_url", at.v1(), "api_key", at.gwKey())
},
ListOnly: true,
Sync: func() error {
return syncJSON(path, "providers."+magpieID, provider)
},
+1
View File
@@ -174,6 +174,7 @@ func air(home, cfg string) *Agent {
return wiringOff("Air", ocPath, func(k string) (string, bool) { return edit.GetJSON(ocPath, "provider."+magpieID+".options."+k) },
"baseURL", gatewayV1(), "apiKey", hereKey())
},
ListOnly: true,
Sync: func() error {
return syncJSONInOrder(ocPath, "provider."+magpieID, provider)
},
+1
View File
@@ -115,6 +115,7 @@ func atomcodeIn(at place) *Agent {
ID: "atomcode", Name: "AtomCode", Icon: "atomcode", Spelled: prefixed, NoNames: true,
UA: []string{"atomcode"},
Bin: "atomcode", Dir: dir, Path: path,
ListOnly: true,
Sync: func() error {
ts, err := edit.TOMLTables(path)
if err != nil {
+1
View File
@@ -42,6 +42,7 @@ func commandCodeIn(at place) *Agent {
ID: "commandcode", Name: "Command Code", Icon: "commandcode", Aliases: []string{"command-code", "cmd"}, Spelled: prefixed,
UA: []string{"command-code", "commandcode"},
Bin: "command-code", Dir: dir, Path: path,
ListOnly: true,
Sync: func() error {
return syncJSON(providers, "provider."+magpieID, theirsKept(providers, "provider."+magpieID, ccProviderJSON, "models"))
},
+1
View File
@@ -209,6 +209,7 @@ func droidIn(at place) *Agent {
// droid's requests to a custom model carry factory-cli/<version>
UA: []string{"factory-cli"},
Bin: "droid", Dir: dir, Path: path,
ListOnly: true,
Sync: func() error {
for _, c := range droidCustoms(path, droidModels) {
if strings.HasPrefix(c.id, droidID) {
+2 -1
View File
@@ -62,7 +62,8 @@ func fxIn(at place) *Agent {
Dir: dir, Path: path,
// ~/.fx is where its settings are. No command: `fx` is a common name
// (the JSON viewer has it too), as in WSL (wsl.go).
detect: func() bool { return agentDir(dir) },
detect: func() bool { return agentDir(dir) },
ListOnly: true,
Sync: func() error {
return syncJSON(path, "providers."+magpieID, func() any { return fxProvider(fxModels(path)[magpieID]) })
},
+1
View File
@@ -293,6 +293,7 @@ func jcodeAt(at place) *Agent {
}
return ""
},
ListOnly: true,
Sync: func() error {
c, err := jcodeRead(path)
if err != nil {
+1
View File
@@ -261,6 +261,7 @@ func kimiIn(at place) *Agent {
ID: "kimi", Name: "Kimi Code", Icon: "kimi", Aliases: []string{"kimi-code", "kimi-cli"}, Spelled: prefixed,
UA: []string{"kimicli"},
Bin: "kimi", Dir: dir, Path: path,
ListOnly: true,
Sync: func() error {
t, err := edit.GetTOMLTable(path, providerTable)
if err != nil || t == nil {
+117
View File
@@ -0,0 +1,117 @@
package agent
import (
"path/filepath"
"strings"
"testing"
"github.com/yetone/magpie/internal/provider"
)
// yyddbds on Discord: in Xiaomi MiMo they added a custom provider pointing
// at magpie and picked a few of its models by hand. MiMo wasn't connected
// on magpie's Agents page, yet after an update the provider had every one
// of magpie's models: the start's catalog sync wrote magpie's whole list
// over any block named magpie. Magpie's default never goes over a list the
// user wrote; one magpie wrote still follows the catalog.
func TestCatalogSyncLeavesAHandWrittenMagpieBlock(t *testing.T) {
home := syncHome(t)
if err := provider.Save(provider.Provider{ID: "added", Name: "Added", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"m2"}}); err != nil {
t.Fatal(err)
}
cfgDir := filepath.Join(home, ".config")
mimo := filepath.Join(cfgDir, "mimocode", "mimocode.json")
// as the app writes a custom provider: magpie's address, a key, the
// models the user picked; the model they run is MiMo's own
own := `{
"model": "mimo/mimo-v2.5-pro",
"provider": {
"magpie": {
"npm": "@ai-sdk/openai-compatible",
"name": "magpie",
"options": {"baseURL": "http://127.0.0.1:3425/v1", "apiKey": "sk-mine"},
"models": {"relay/glm-4.6": {"name": "GLM 4.6"}}
}
}
}
`
writeFile(t, mimo, own)
// a sibling on the same sync: Pi with a magpie provider written by
// hand in models.json, its default its own
piModels := filepath.Join(home, ".pi", "agent", "models.json")
piOwn := `{"providers":{"magpie":{"baseUrl":"http://127.0.0.1:3425/v1","api":"openai-completions","models":[{"id":"relay/glm-4.6"}]}}}`
writeFile(t, piModels, piOwn)
writeFile(t, filepath.Join(home, ".pi", "agent", "settings.json"), `{"defaultProvider":"anthropic","defaultModel":"claude-x"}`)
// and Crush
crushCfg := filepath.Join(cfgDir, "crush", "crush.json")
crushOwn := `{"providers":{"magpie":{"type":"openai-compat","base_url":"http://127.0.0.1:3425/v1","models":[{"id":"relay/glm-4.6"}]}}}`
writeFile(t, crushCfg, crushOwn)
SyncCatalog()
if got := readFile(mimo); got != own {
t.Errorf("MiMo's own magpie provider written over:\n%s", got)
}
if got := readFile(piModels); got != piOwn {
t.Errorf("Pi's own magpie provider written over:\n%s", got)
}
if got := readFile(crushCfg); got != crushOwn {
t.Errorf("Crush's own magpie provider written over:\n%s", got)
}
// connected through magpie, the list follows the catalog
a := mimocode(home, cfgDir)
if err := a.Connect(); err != nil {
t.Fatal(err)
}
if err := provider.Save(provider.Provider{ID: "later", Name: "Later", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"m3"}}); err != nil {
t.Fatal(err)
}
SyncCatalog()
if got := readFile(mimo); !strings.Contains(got, `"later/m3"`) || !strings.Contains(got, `"added/m2"`) {
t.Errorf("a connected MiMo's list not kept current:\n%s", got)
}
// switched off on the Agents page, then a provider of that name
// written by hand again: it is the user's
if err := a.Disconnect(); err != nil {
t.Fatal(err)
}
writeFile(t, mimo, own)
SyncCatalog()
if got := readFile(mimo); got != own {
t.Errorf("after Disconnect, MiMo's own magpie provider written over:\n%s", got)
}
// a model of magpie's picked in MiMo connects it: the list is
// magpie's again
connected := strings.Replace(own, `"mimo/mimo-v2.5-pro"`, `"magpie/relay/glm-4.6"`, 1)
writeFile(t, mimo, connected)
SyncCatalog()
if got := readFile(mimo); !strings.Contains(got, `"later/m3"`) {
t.Errorf("a connected MiMo's list not kept current:\n%s", got)
}
}
// A catalog sync runs a ListOnly agent's Sync only while it reads as
// connected: every one of them connected by magpie reads so, or its list
// would never follow the catalog again.
func TestListOnlyAgentsReadConnected(t *testing.T) {
codexHome(t, "", "")
n := 0
for _, a := range All() {
if !a.ListOnly || a.WSL != "" {
continue
}
n++
if err := a.Connect(); err != nil {
t.Errorf("%s: %v", a.ID, err)
continue
}
if !a.Wired() {
t.Errorf("%s connected but not Wired: a catalog sync would skip its list", a.ID)
}
}
if n < 15 {
t.Fatalf("only %d ListOnly agents", n)
}
}
+1
View File
@@ -114,6 +114,7 @@ func miniMaxAt(at place, dir string) *Agent {
ID: "minimax-code", Name: "MiniMax Code", Icon: "minimax-color", Aliases: []string{"mcode"}, Spelled: prefixed,
UA: []string{mcodeUA, "minimaxcode"},
Bin: "mcode", Dir: dir, Path: path,
ListOnly: true,
Sync: func() error {
if _, ok := edit.GetYAMLText(path, mcodeEntry); !ok {
return nil
+2
View File
@@ -24,6 +24,8 @@ func TestModelNameAndLevelsReachAgentFiles(t *testing.T) {
}
piModels := filepath.Join(home, ".pi", "agent", "models.json")
writeFile(t, piModels, `{"providers":{"magpie":{"name":"magpie","models":[]}}}`)
// Pi runs a model of magpie's: connected, so its list follows
writeFile(t, filepath.Join(home, ".pi", "agent", "settings.json"), `{"defaultProvider":"magpie","defaultModel":"relay/glm-4.6"}`)
codexDir := filepath.Join(home, ".codex")
codexCat := filepath.Join(codexDir, "magpie-models.json")
writeFile(t, filepath.Join(codexDir, "config.toml"), "model = \"relay/glm-4.6\"\nmodel_provider = \"magpie\"\nmodel_catalog_json = '"+codexCat+"'\n")
+2 -1
View File
@@ -77,7 +77,8 @@ func mothxIn(at place) *Agent {
return wiringOff("MothX", path, func(k string) (string, bool) { return edit.GetJSON(path, "providers."+magpieID+"."+k) },
"baseUrl", at.v1(), "apiKey", key())
},
Sync: func() error { return syncJSON(path, "providers."+magpieID, block) },
ListOnly: true,
Sync: func() error { return syncJSON(path, "providers."+magpieID, block) },
Notice: func() string {
if p, _ := get("defaultProvider"); p == magpieID && Running(`(^|/)mothx( |$)`, `(^|/)vibecoding( |$)`) {
return noticeMothx.String()
+1
View File
@@ -455,6 +455,7 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
// a role's thinking level is omp's, after whichever model it is on;
// a list of models is the user's own
SplitSuffix: ompSplit,
ListOnly: true,
Sync: func() error {
models := pick("models")
if err := syncYAML(models, "providers."+magpieID, func() any { return ompProvider(models) }); err != nil {
+1
View File
@@ -206,6 +206,7 @@ func openChamber(home, cfg string) *Agent {
return wiringOff("OpenChamber", ocPath, func(k string) (string, bool) { return edit.GetJSON(ocPath, "provider."+magpieID+".options."+k) },
"baseURL", gatewayV1(), "apiKey", hereKey())
},
ListOnly: true,
Sync: func() error {
if _, ok := edit.GetJSON(ocPath, "provider."+magpieID); !ok && usesMagpie(s.model(), s.small()) {
return edit.SetJSON(ocPath, edit.KV{Path: "provider." + magpieID, Value: provider()})
+2 -1
View File
@@ -416,7 +416,8 @@ func openClawAt(at place) *Agent {
return atomic(&Agent{
ID: "openclaw", Name: "OpenClaw", Icon: "openclaw", Spelled: prefixed, NoNames: true,
Bin: "openclaw", Dir: dir, Path: path,
Notice: func() string { return noticeOpenClaw.String() },
Notice: func() string { return noticeOpenClaw.String() },
ListOnly: true,
Sync: func() error {
s, err := openClawRead(path)
if err != nil {
+1
View File
@@ -49,6 +49,7 @@ func pencil(home string) *Agent {
}
return ""
},
ListOnly: true,
Sync: func() error {
return syncJSON(path, key, theirsKept(path, key, func() any { return pencilProviderJSON(gateway.URL()) }, "models"))
},
+2 -1
View File
@@ -193,7 +193,8 @@ func penguinIn(at place) *Agent {
Dir: filepath.Dir(root), Path: path,
// the desktop app, on this machine (a distro has none): installed
// and not opened yet, it has made no ~/.penguin
sign: func() bool { return at.spell == nil && (&Agent{ID: "penguin"}).HasApp() },
sign: func() bool { return at.spell == nil && (&Agent{ID: "penguin"}).HasApp() },
ListOnly: true,
Sync: func() error {
t, err := edit.GetTOMLTable(path, providerTable)
if err != nil || t == nil {
+1
View File
@@ -318,6 +318,7 @@ func qwenIn(at place) *Agent {
// openaiContentGenerator/provider/default.ts buildHeaders)
UA: []string{"qwencode"},
Bin: "qwen", Dir: dir, Path: path,
ListOnly: true,
Sync: func() error {
for _, c := range qwenCustoms(path) {
if c.ours {
+2
View File
@@ -32,6 +32,8 @@ func TestSuffixModesReachAgentFiles(t *testing.T) {
}
piModels := filepath.Join(home, ".pi", "agent", "models.json")
writeFile(t, piModels, `{"providers":{"magpie":{"name":"magpie","models":[]}}}`)
// Pi runs a model of magpie's: connected, so its list follows
writeFile(t, filepath.Join(home, ".pi", "agent", "settings.json"), `{"defaultProvider":"magpie","defaultModel":"relay/glm-4.6"}`)
codexDir := filepath.Join(home, ".codex")
codexCat := filepath.Join(codexDir, "magpie-models.json")
writeFile(t, filepath.Join(codexDir, "config.toml"), "model = \"relay/glm-4.6\"\nmodel_provider = \"magpie\"\nmodel_catalog_json = \""+tomlString(codexCat)+"\"\n")
+1 -1
View File
@@ -52,7 +52,7 @@ func SyncCatalog() {
unhold := filememo.Hold()
renaming := setToFoundGroups()
for _, a := range All() {
if a.Sync != nil {
if a.Sync != nil && (!a.ListOnly || a.Wired()) {
_ = synced(a.Sync)
}
// a field magpie set to a found group's id before (autoref.go)
+2
View File
@@ -49,6 +49,8 @@ func TestPiKeepsTheirKeysInMagpiesProvider(t *testing.T) {
}
}
`)
// Pi runs a model of magpie's: connected, so its list follows
writeFile(t, filepath.Join(home, ".pi", "agent", "settings.json"), `{"defaultProvider":"magpie","defaultModel":"relay/glm-4.6"}`)
SyncCatalog()
p := providerAt(t, piModels, "providers")
compat, _ := p["compat"].(map[string]any)
+3
View File
@@ -229,6 +229,9 @@ func TestSyncCatalogRewritesAgentLists(t *testing.T) {
home := syncHome(t)
piModels := filepath.Join(home, ".pi", "agent", "models.json")
writeFile(t, piModels, `{"providers":{"mine":{"baseUrl":"http://x"},"magpie":{"name":"magpie","models":[]}}}`)
// connected: a block of magpie's name in an agent not on magpie is the
// user's own (TestCatalogSyncLeavesAHandWrittenMagpieBlock)
writeFile(t, filepath.Join(home, ".pi", "agent", "settings.json"), `{"defaultProvider":"magpie","defaultModel":"relay/glm-4.6"}`)
crushCfg := filepath.Join(home, ".config", "crush", "crush.json")
crushBody := `{"providers":{"mine":{"base_url":"http://x"}}}`
writeFile(t, crushCfg, crushBody)
+2 -1
View File
@@ -67,7 +67,8 @@ func t3code(home string) *Agent {
Dir: base, Path: path,
// ~/.t3 is made at its first start; a Mac app never opened yet is
// found by its bundle. No command: `t3` is a common name.
detect: func() bool { return isDir(base) || t3App(home) },
detect: func() bool { return isDir(base) || t3App(home) },
ListOnly: true,
Sync: func() error {
return syncJSON(path, t3Instance, func() any { return t3Merged(path, gateway.URL()) })
},
+2 -1
View File
@@ -50,7 +50,8 @@ func TestSaveAnswersBeforeTheAgentsSync(t *testing.T) {
if err := os.MkdirAll(dir, 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(dir, "settings.json"), []byte(`{}`), 0o600); err != nil {
// Pi runs a model of magpie's: connected, so a sync writes its list
if err := os.WriteFile(filepath.Join(dir, "settings.json"), []byte(`{"defaultProvider":"magpie","defaultModel":"a/m1"}`), 0o600); err != nil {
t.Fatal(err)
}
fifo := filepath.Join(dir, "models.json")