Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
provider: a Remote magpie's model list follows the other magpie's, fetched every 10m (6igsteven on Discord)
yetone0152f6696615
diff --git a/docs/reference.md b/docs/reference.mdindex ff93ec06d..43531c2d4 100644--- a/docs/reference.md+++ b/docs/reference.md@@ -333,7 +333,7 @@ magpie provider models deepseek # re-fetch the vendor's list (add ids tomagpie provider models deepseek +deepseek-v4 -deepseek-chat # expose one more, take one out; the rest staymagpie provider models deepseek a b c # the whole list of models to expose, replacing it (all: the default)magpie provider refresh deepseek # re-fetch it, and drop picks it no longer has (the TUI: m)-magpie provider refresh-every relay 6h # the gateway fetches its list every 6h (1d, 30m; off; at least 10m)+magpie provider refresh-every relay 6h # the gateway fetches its list every 6h (1d, 30m; off; at least 10m; a Remote magpie 10m unless set)magpie provider auto-include relay 'gpt-*' 're:claude-.*' # a newly listed model these match is exposed (none clears)magpie provider test deepseek # one tiny request per API, with latencymagpie provider key deepseek sk-… # replace the keydiff --git a/docs/subsystems/providers-accounts.md b/docs/subsystems/providers-accounts.mdindex f6bee02fb..495d84f1d 100644--- a/docs/subsystems/providers-accounts.md+++ b/docs/subsystems/providers-accounts.md@@ -27,7 +27,7 @@ keys and accounts per request is in [Gateway routing and fallback](gateway-routi| A provider renamed | `Rename` (the editor's id field, `magpie provider set <id> id=<new>`) keeps the old id in `Was`, so a model still picked by it reaches the provider. Usage is recorded under the id a call went out by and never rewritten; whatever reads it names the provider by its id now through `UsageRenames().Of(id, time)`: the summary, the Requests page (its blocks, the probe rows, other computers' days), the Sessions tab's vias, window holds, `NewPricer`/`NewCoster` and the gateway's `loggedAnswers` (cybercaius on Discord: a renamed provider was listed under both ids). `Visit` hands records out as recorded, so `Of` is taken once. An id another provider takes later (a rename onto it, or `Save` of a new provider under it) moves from the first one's `Was` to its `Gave` with the time (`giveID`): calls recorded under it before then stay the first one's, later ones are the new one's. An id held by a provider or a subscription now is never renamed (`Renamed`), and `freeID` doesn't hand out an id in any `Was`, so adding a vendor again gets `-2`. Ids reused before `Gave` existed have no time and go to whoever holds the id now. A providers.json that can't be read keeps the last renames read, not none. The summary and Requests caches key on `Renames.Key`, the vias cache too. | [`rename.go`](../../internal/provider/rename.go), [`block_price.go`](../../internal/usage/block_price.go) || The list | `All` merges stored providers with `Accounts()`. An entry with no URL stores the user's picks for an account. The order is `file.Order`. Reads within one request share one build (`Hold`, #746). | [`provider.go`](../../internal/provider/provider.go) || Model picks | `Models` are the models the user picked for agents; none means the vendor's list, up to 24 (`Exposed`), unless the user chose Select none (`NoModels`, `magpie provider models <id> none`): then none of its models is served, not to agents, not to any routing group (auto groups included), not by a `provider/model` id, not as a classifier, while its balance and usage are still read (`ServesNone`, #1818). The editor's serves control names it Usage only, beside Vendor's list and Picked only, and the card says "usage only" (#2068); Picked only from there picks the models the vendor's list serves, to unpick from. A file without `noModels` reads as before, and a pick clears it. `Save` keeps beside new picks the models listed then (`PickedFrom`, `listedWith`), and the same picks saved again keep it. When the picks held every model listed then, one the vendor lists since is served first beside them (`withNewlyListed`, `Picks`); one listed then and left unpicked stays out. Picks saved before `PickedFrom` was kept are taken to hold every model when they hold every one released up to the newest of them (models.dev's `release_date`), so a Claude account whose user picked them all is served Haiku 5.5 (wakaka). The editor and the TUI start from `Picks`, so a later Save keeps the new model. While some picks are set aside (the list is known to be short), a save with new picks keeps the models the earlier `PickedFrom` had beside those listed now, so a model the user saw and left unpicked isn't new when that list has it again; a list short of no pick is taken as it is. A pick a list fetched again stops listing (`Refetch`, `KeepListsFresh`, and a plugin's hourly `KeepPluginsListed`) leaves `Models` for `Delisted` (`dropGonePicks`), not served, and goes back among the picks when a later list has it (`relistPicks`): Our Free Model's plugin lists its account channels' models only once its service has read them after a restart, and its free pools only while they answer, so each magpie update had its user pick every model again (多喝热水 on Discord). Every save keeps `Delisted` but for what it picks again (`delistedWith`); Select none clears it. A provider whose every pick is in `Delisted` serves none of its models (`waitsForPicks`), not the vendor's list. `KeepPluginsListed` asks again after `relistSoon` (5 minutes) when a list left a pick out. `TestPluginPicksComeBackWithTheirList`, `TestEveryPickDelistedServesNone` and `TestRelayPicksComeBackWithTheirList` cover it. | [`models.go`](../../internal/provider/models.go), [`provider.go`](../../internal/provider/provider.go) |-| List schedule and rules | A provider of the user's own (not an account, a plugin's or a decision-only one) can set `RefreshEvery` (`magpie provider refresh-every <id> 6h`, or 1d, or off, at least 10m) and `AutoInclude` (`magpie provider auto-include <id> 'gpt-*' 're:claude-.*'`, or none; a glob with `*`, or `re:` matching the whole id, both in any case (`compilePattern`; `(?-i)` inside a `re:` makes case matter); a plain id is refused) (#2135). The gateway (`magpie serve` or the app) looks each minute and fetches a list once `Fetched` is that old, through the same `Refetch` as Fetch models (`KeepListsFresh`); a failed fetch waits `min(every, 15m)`. `RefetchTaking` adds to the picks a model the fetch newly lists that a rule matches (`takeMatching`), starting from what is served now (`Exposed`), so nothing served is taken away and a model the user unticks stays out (it is not new to the next fetch). Setting the rules takes the current list's matches. Every save that doesn't set them keeps them, the window's editor among them; the editor has no fields for them yet. | [`autolist.go`](../../internal/provider/autolist.go), [`models.go`](../../internal/provider/models.go), [`providers_cli.go`](../../internal/cli/providers_cli.go) |+| List schedule and rules | A provider of the user's own (not an account, a plugin's or a decision-only one) can set `RefreshEvery` (`magpie provider refresh-every <id> 6h`, or 1d, or off, at least 10m) and `AutoInclude` (`magpie provider auto-include <id> 'gpt-*' 're:claude-.*'`, or none; a glob with `*`, or `re:` matching the whole id, both in any case (`compilePattern`; `(?-i)` inside a `re:` makes case matter); a plain id is refused) (#2135). The gateway (`magpie serve` or the app) looks each minute and fetches a list once `Fetched` is that old, through the same `Refetch` as Fetch models (`KeepListsFresh`); a failed fetch waits `min(every, 15m)`. `RefetchTaking` adds to the picks a model the fetch newly lists that a rule matches (`takeMatching`), starting from what is served now (`Exposed`), so nothing served is taken away and a model the user unticks stays out (it is not new to the next fetch). Setting the rules takes the current list's matches. Every save that doesn't set them keeps them, the window's editor among them; the editor has no fields for them yet. A Remote magpie with no `RefreshEvery` is fetched every 10m (`RemoteMagpieEvery`, `RefreshSchedule`), so a model the other magpie lists later (ZCode's GLM-5.3-Trial once its plugin read the gift, 6igsteven on Discord) is served without Fetch models; `off` set on it is kept as `"off"` and asks it only when told (`TestRemoteMagpieListFollowsTheOtherMagpie`). | [`autolist.go`](../../internal/provider/autolist.go), [`models.go`](../../internal/provider/models.go), [`providers_cli.go`](../../internal/cli/providers_cli.go) || Keys | Several keys per provider. Requests go to the first key that is on; the gateway moves on when it is out or rate limited. `Key` stays the first, so other code reads it as before. A key can be made for one protocol (`KeyProtocol`). A key made for a protocol its provider has no URL for is skipped (`perKeyBarred`); when every key is, the provider is still tried whole on the URLs it has, and the candidate carries `noURL` so it isn't quiet: Routing's row (`Weighed.NoURL`) says "key set to {api} only, no {api} URL · sent on the others", and the editor's key row shows a "No {api} URL" chip (`keyLacksURL`; #1702, `TestKeyForAProtocolWithNoURLIsSaid`, `key-nourl.test.cjs`). A key's value can be replaced in place (`ReplaceKey`, #1869: a key rotated at the vendor): it keeps its name, place, protocol, weight and on or off, and what was set for it by its fingerprint (`AccountModels`, `AccountProxies`, `AccountConcurrency`) and the gateway keys held to it (`access.ReplaceAccount`) move to the new one; the GUI's `keys/replace` also lifts its rests (`UnrestAll`). Its past requests stay under the old fingerprint, by the same name. A provider may hold thousands of keys (@NetRozee on X: a thousand froze magpie). Nothing goes over its keys once for each key: `KeysOn` drops a repeat by a set, a row's rest keys come from `RestKeys` (whether several are on, found once), and whether each key serves a model from `Serving`, which reads the lists once and keeps each model's keys as a set until the lists are read anew (`keyLists`). `KeysListed` and `ListsRead` count them for the tests (`TestProviderInfoListsKeysOnce`, `TestPerKeyReadsListsOnce`). A provider's keys have their balances, plans and remote limits read `keyReadsAtOnce` (8) at a time (`keySlots`); other providers' beside them. The editor's per-key proxy lines fold as its Accounts list does (`proxyLines`, `provider-many-keys-proxy.test.cjs`). Asking a key's models (`fetchPerKey`) still goes one key after another. | [`keys.go`](../../internal/provider/keys.go) || Google Vertex AI | `google-vertex` (`VertexPreset`, `IsVertex`) is a provider of the user's own with no key. `Provider.Vertex` holds `project`, `location` (`global`, `us`, `eu` or a region; `global` when empty), `credentials` (a file; empty for Application Default Credentials) and `impersonate` (a service account's email). Save refuses a key given it, then normalizes them (`Normal`) and checks each (`check`); `normalize` clears the four URLs and any key put in `providers.json` by hand, which stands in for neither a token nor a project and leaves the provider as found savable, so the provider's one address is `vertexBase`, `https://<host>/v1/projects/<project>/locations/<location>`, its host following the location (`vertexHost`). It speaks Gemini alone (`Speaks`, `Base`). It is `Ready` once that address can be made, never from a key or an account; until then the app, `magpie providers` and the TUI say it needs a project, and `magpie provider <id>` says how to give it one. `hasEndpoint` counts it as a provider of the user's own, not a subscription's picks. An import link naming it is refused (`ParseImport`): its project and credentials are the user's own, which no link hands over. `Sign` refuses any other address and sets the bearer token before the user's `Headers`; `AuthHeaders` gives it no key header. Its models are its location's (`vertexModels`, in `planModels`): the preset has `NoList`, because Vertex AI has no list that says what a location serves. The lists are in the [reference](../reference.md#google-vertex-ai). | [`vertex.go`](../../internal/provider/vertex.go), [`provider.go`](../../internal/provider/provider.go), [`account.go`](../../internal/provider/account.go), [`rename.go`](../../internal/provider/rename.go), [`models.go`](../../internal/provider/models.go), [`importurl.go`](../../internal/provider/importurl.go) || Vertex AI tokens | `vertexCredentialsFile` finds the credentials as Google's libraries find Application Default Credentials: the provider's `credentials`, else the file `GOOGLE_APPLICATION_CREDENTIALS` names, else `application_default_credentials.json` in gcloud's folder (`CLOUDSDK_CONFIG`, else `~/.config/gcloud`, `%APPDATA%\gcloud` on Windows); a `~/` that starts any of them is the home. `mint` reads three kinds: `authorized_user` (a refresh-token grant), `service_account` (an RS256 JWT, RFC 7523: `signed`) and gcloud's `impersonated_service_account`, whose `source_credentials` are minted and traded at IAM Credentials, along its `delegates`, for the account its `service_account_impersonation_url` names (`impersonationURL`: the token never goes to that URL's host). With `impersonate` set, the token those give is traded at IAM Credentials' `generateAccessToken` for a `cloud-platform` token of that account's, as gcloud's `--impersonate-service-account` does (`impersonateFor`); the credentials' account needs `roles/iam.serviceAccountTokenCreator` on it, which the 403 names. `vertexTokens` keeps one token per file and impersonated account, in memory only; requests made together mint it once, and those that waited through a mint that failed are given its error rather than each minting in turn (`mints`, `failed`). A mint cut short because its own request was given up on fails none of them: the next one mints. It is minted again within `vertexRefreshLead` (5 minutes) of expiry, or when the file's size or modification time has changed (gcloud signed in again). One mint, every exchange included, gets `vertexMintWait` (30 seconds). The file is only read. | [`vertex.go`](../../internal/provider/vertex.go), [`signin.go`](../../internal/provider/signin.go) |diff --git a/internal/cli/providers_cli.go b/internal/cli/providers_cli.goindex 680a9e866..92f661124 100644--- a/internal/cli/providers_cli.go+++ b/internal/cli/providers_cli.go@@ -889,7 +889,7 @@ func showProvider(p provider.Provider) error {kv("header", k+": "+muted.Render(p.Headers[k]))}if d := p.RefreshInterval(); d > 0 {- kv("refresh", "every "+p.RefreshEvery+muted.Render(" the gateway fetches its list by itself"))+ kv("refresh", "every "+p.RefreshSchedule()+muted.Render(" the gateway fetches its list by itself"))}if len(p.AutoInclude) > 0 {kv("include", strings.Join(p.AutoInclude, " ")+muted.Render(" newly listed models these match are exposed"))@@ -1942,7 +1942,7 @@ func refreshEveryCmd(rest []string) error {}}if d := p.RefreshInterval(); d > 0 {- fmt.Printf("%s · its model list is fetched by the gateway every %s (magpie serve, or the app, running)\n", p.Name, p.RefreshEvery)+ fmt.Printf("%s · its model list is fetched by the gateway every %s (magpie serve, or the app, running)\n", p.Name, p.RefreshSchedule())} else {fmt.Printf("%s · its model list is fetched only when asked (magpie provider refresh %s, or Fetch models)\n", p.Name, p.ID)}diff --git a/internal/provider/autolist.go b/internal/provider/autolist.goindex 3e8f0dd17..07bbcb12b 100644--- a/internal/provider/autolist.go+++ b/internal/provider/autolist.go@@ -65,13 +65,39 @@ func ParseRefreshEvery(s string) (time.Duration, error) {return d, nil}+// RemoteMagpieEvery is how often, as RefreshEvery writes it, the gateway+// fetches a Remote magpie's list when its user set no RefreshEvery. Its list is the other magpie's+// models as they are now: a model that comes there later (a ZCode gift+// plan's GLM-5.3-Trial, listed once its plugin read the gift; a provider,+// plugin or routing group added there) reached this magpie only when+// Fetch models was pressed in its editor, and a trial a day long could+// pass unseen (6igsteven on Discord, 10-24). It is a list on the other+// computer's magpie, read from its memory, so asking it often costs+// nothing a vendor sees. "off" (magpie provider refresh-every <id> off)+// asks it only when told, as before.+const RemoteMagpieEvery = "10m"++// RefreshSchedule is the schedule the provider's list is fetched on, as+// written: its user's, or a Remote magpie's default (RemoteMagpieEvery)+// when its user set none; "" for only when asked.+func (p Provider) RefreshSchedule() string {+ if !p.ownList() {+ return ""+ }+ if strings.TrimSpace(p.RefreshEvery) == "" && p.IsRemoteMagpie() {+ return RemoteMagpieEvery+ }+ return p.RefreshEvery+}+// RefreshInterval is how often the gateway fetches the provider's list by// itself: 0 for only when asked, and for one RefreshEvery can't be read.+// A Remote magpie with none set is fetched every RemoteMagpieEvery.func (p Provider) RefreshInterval() time.Duration {if !p.ownList() {return 0}- d, err := ParseRefreshEvery(p.RefreshEvery)+ d, err := ParseRefreshEvery(p.RefreshSchedule())if err != nil {return 0}@@ -107,6 +133,9 @@ func SetRefreshEvery(id, every string) error {p.RefreshEvery = ""if d > 0 {p.RefreshEvery = strings.ToLower(strings.TrimSpace(every))+ } else if p.IsRemoteMagpie() {+ // kept as said: none set is RemoteMagpieEvery for a Remote magpie+ p.RefreshEvery = "off"}return Save(*p)}diff --git a/internal/provider/autolist_test.go b/internal/provider/autolist_test.goindex 02ee67a02..b7b9cc38e 100644--- a/internal/provider/autolist_test.go+++ b/internal/provider/autolist_test.go@@ -309,3 +309,59 @@ func TestSaveKeepsTheListsScheduleAndRules(t *testing.T) {t.Fatalf("off left %q", p.RefreshEvery)}}++// A Remote magpie's list follows the other magpie's with no schedule set+// (6igsteven on Discord, 10-24): a model listed there later, ZCode's+// GLM-5.3-Trial once its plugin read the gift, is served here after+// RemoteMagpieEvery, not only after Fetch models in the editor. A relay+// with no schedule is still asked only when told, and a Remote magpie its+// user set off is too.+func TestRemoteMagpieListFollowsTheOtherMagpie(t *testing.T) {+ autolistHome(t)+ r := newRelayList(t, "zcode/GLM-5.2")+ if err := Save(Provider{ID: "office", Name: "Office", Preset: RemoteMagpiePreset, Chat: r.srv.URL, Key: "sk-magpie-office"}); err != nil {+ t.Fatal(err)+ }+ other := newRelayList(t, "x-1")+ if err := Save(Provider{ID: "plain", Name: "Plain", Chat: other.srv.URL + "/v1", Key: "sk-plain"}); err != nil {+ t.Fatal(err)+ }+ t.Cleanup(func() {+ listsTried.Lock()+ clear(listsTried.m)+ listsTried.Unlock()+ })+ now := time.Now()+ if got := refreshDueLists(context.Background(), now); !slices.Equal(got, []string{"office"}) {+ t.Fatalf("asked %v, want [office]", got)+ }+ r.set("zcode/GLM-5.2", "zcode/GLM-5.3-Trial", "zcode/GLM-5.3-Flash-Trial")+ if got := refreshDueLists(context.Background(), now.Add(5*time.Minute)); len(got) != 0 {+ t.Fatalf("asked %v before %s", got, RemoteMagpieEvery)+ }+ if got := refreshDueLists(context.Background(), now.Add(11*time.Minute)); !slices.Equal(got, []string{"office"}) {+ t.Fatalf("asked %v after %s, want [office]", got, RemoteMagpieEvery)+ }+ if ids := servedIDs(t, "office"); !slices.Contains(ids, "zcode/GLM-5.3-Trial") || !slices.Contains(ids, "zcode/GLM-5.3-Flash-Trial") {+ t.Fatalf("served after the other magpie listed its trial models: %v", ids)+ }+ if other.asked.Load() != 0 {+ t.Fatalf("a relay with no schedule was asked %d times", other.asked.Load())+ }+ // as `magpie provider show` and refresh-every say it+ if p, _ := Find("office"); p.RefreshSchedule() != RemoteMagpieEvery {+ t.Fatalf("a Remote magpie's schedule with none set: %q, want %q", p.RefreshSchedule(), RemoteMagpieEvery)+ }++ // set off by its user: asked only when told, and the off is kept+ if err := SetRefreshEvery("office", "off"); err != nil {+ t.Fatal(err)+ }+ if p, _ := Find("office"); p.RefreshEvery != "off" || p.RefreshInterval() != 0 {+ t.Fatalf("set off: every %q, interval %s", p.RefreshEvery, p.RefreshInterval())+ }+ n := r.asked.Load()+ if got := refreshDueLists(context.Background(), now.Add(2*time.Hour)); len(got) != 0 || r.asked.Load() != n {+ t.Fatalf("a Remote magpie set off was asked: %v", got)+ }+}