Commit Graph
2008 Commits
Author SHA1 Message Date
yetone 5241308212 settings: a day can start at 0 to 6 o'clock (ssharpcc on X)
Settings > Usage > "Day starts at" (dayStart, 0 to 6, default 0; also
magpie settings set dayStart 4). With 4, a call at 01:30 counts toward the
day before: the Usage page (summary, charts, heatmap, ledger day filter,
hour labels of Today) and the daily and monthly key caps (access.Window,
provider.SpendCap.Window).

internal/dayzone makes a time.Location whose midnight is the real day's
hour:00 (TZif built from the zone's own offsets, same DST instants), so
every place that cuts days by a Zone's midnight follows without edits;
usage.Zone returns it and the "now" reads use it too.

Run (mote): go test usage, settings, settingsapi, access, provider, gui,
dayzone, also with TZ=UTC and TZ=Pacific/Kiritimati; gofmt; go vet darwin,
linux nogui and windows; day-start, currency, number-units and i18n-keys
GUI files in chromium and webkit, en zh zh-TW ja de; TestCoreScriptBudget.
Broken by hand: TestDayStartsAfterMidnight red with 9 failures when the
hour is ignored. New tests: dayzone over 5 zones x hours 1/4/6 x two years
of days, usage, limit window, spend-cap window, day-start GUI.
Not tried: a real log history in a real window.
Not shifted, filed as #6314: the Sessions page, TUI sessions filter,
davsync shared per-day files, gateway_sessions day keys, credits_daily.
Rows are never stored in the shifted zone.
2026-11-12 18:31:50 +08:00
yetone d964031412 provider: a model's test can be sent to one chosen account or key (tmr11235 on X)
A provider with two or more accounts or keys that are on now offers
"Test on account..." in a model chip's right-click, an app menu (never a
native select) of those accounts' or keys' names. The pick is posted as
`account` with provider/test and pins the test (provider.TestOn,
accountNamed / keyNamed; an unknown or switched-off one is an error row,
not a silent fallback). Every result now names the account or key it went
to (Result.Account, set in probe), and the status line ends " - <name>"
for such a provider, whether the test was pinned or routing picked.
Test models and the CLI still test with routing's pick.

Core script budget raised 1,263,333 -> 1,263,700 (+367): the model chip
menu is core code and there is no page to move it to; the PLAY icon
literal was folded into one constant and the status call tightened first.

Run: gofmt clean; mote-run go test ./internal/gui ./internal/provider ok
(new TestModelTestPinnedToAKey, TestTestPicksNeedSeveral,
TestModelTestPinnedToAnAccount); model-test-account.test.cjs 10 of 10
(chromium and webkit, en zh zh-TW ja de) on mica. Broken by hand: with
the menu entry disabled the GUI test is 0 of 10. GUI batch model-*,
provider-*, i18n-*, gui-*: reds are the same on origin/main 2e92d71aa
(model-chip-steady, model-copy-id, provider-fetch-again, provider-max-
output, provider-many-keys, provider-mask, provider-typed, gui-de/ja),
all already filed (#4388, #4621, #3292, #6209, #5109, #4673, #5475).

Not tried: a real multi-account provider end to end; the CLI and the bulk
Test models button (unchanged); vet on windows/linux not rerun beyond the
earlier builds.
2026-11-12 18:09:14 +08:00
yetone 409581c053 routing: Least used first spends credits about to lapse first (kudi3699 on X)
kudi3699: a WorkBuddy account with a 5000-credit pack ending next March,
half used, plus check-in credits ending soon, was ranked by the whole
pool's used share in "Least used first", so it was never picked and the
check-in credits were lost. Smart (Renewal, Lapse) and Use before expiry
(Pace) already went by the plugin's runsOutAt/runsOut; Least used did not.

Allowance.Lapsing is what a window loses at RunsOut (RunsOutLeft of Of, at
most what is left) as points of the used share, fading to nothing a week
out; an amount not told is 0. routes.Seat.Lapsing at >= 0.5 points puts a
seat with room ahead of the rest, soonest Lapse first, then Used as before.
A seat at 90%+ is not helped. It is the shared runsOutAt/runsOut field, so
any plugin that sends it gets this. The WorkBuddy plugin already reports it
(0.2.27, the soonest pack incl. check-in rewards), so no plugin change and
no mover min change.

Run (mote): go vet routes/provider/gateway; GOOS=linux -tags nogui and
GOOS=windows vet; go test internal/routes, internal/provider (all),
internal/gateway -run "WorkBuddy|LeastUsed|Smart|Pace|Routing". Broken by
hand: urgent() forced false turns TestLeastUsedSpendsLapsingFirst and the
gateway test red. Not run: the full suite (started after the tag), real
WorkBuddy accounts, the plugin's bun tests (plugin untouched).
2026-11-12 17:56:38 +08:00
yetone ed08a03793 provider: moving only when accounts were last seen builds no catalog anew
An idle magpie rewrote logins.json every seenEvery (10 minutes) only to
move each account's Seen time, and the write called Changed(): every
held catalog was dropped and filememo forgot what it had read, so the
next dsh round (KeepDshWired, every 30s) built the magpie models again,
~42 MB of the 62 MB a real account's idle magpie allocated in five
minutes. Nothing built from the accounts reads Seen.

rememberLogins now writes such a file quietly (writeLoginsTold with
tell false): no Changed(), no filememo.Forget. A reader still finds the
file's new time and size; a request holding it reads the old bytes for
up to a second. A write that changes anything besides Seen is told as
before.

Found with a traced build on mote, sandbox HOME holding a real Codex
account: the stamp moved at 00:59:41 from
keepHooksToldOfSignIns -> SignInAlertsAt -> Accounts -> rememberLogins
-> writeLogins -> Changed.

Run (mica): go test -count=1 -timeout 45m ./internal/provider
./internal/agent ./internal/filememo ok; go vet for darwin, linux and
windows ok; gofmt clean. TestSeenOnlyWriteBuildsNothingAnew is red with
the write always told (tell true), green with this change.
2026-11-12 17:27:33 +08:00
yetone db9048829b provider: a vendor's 400 whose message is only "Bad Request" shows its type, code and param (FjTxw0Mz8wxBuye on X)
Codex on a Team account (gpt-6.1-sol, high reasoning) showed a bare
"Codex: Bad Request" with nothing of what the vendor refused. apiError took
the error object's message alone; when that message is only an HTTP
status's text, the error's own type, code and param now follow it.
Any message with words of its own is shown as before.

This does not find why that account is refused: no Team account was
available, and a Pro account takes the same request (gpt-6.1-sol, high,
a tool call, HTTP and socket). The next report shows the vendor's field.

Run: new TestAPIErrorBareStatusMessageGivesItsFields (red on the old
apiError, green after), internal/provider and internal/gateway whole at
this tree, go vet darwin, windows and linux nogui for provider, gofmt.
Not tried: a Team account; the GUI tests (no GUI file touched).
2026-11-12 17:03:53 +08:00
yetone b43c4eda80 provider: a plugin's kept icon found on disk isn't looked for again for a minute
/api/providers asks for every plugin provider's icon on each answer,
and each ask ran os.Stat on the icon's file. On a real account (26
providers) a CPU profile of 40 /api/providers calls on mote had
pluginOwnIcon's stat at 80ms of providersState's 420ms. A file found is
now taken to be there for iconSeenFor (a minute); one removed is looked
for, found gone and stored or fetched again once that has passed.

Run (mica unless named):
- go test -count=1 -timeout 45m ./internal/provider/ ./internal/gui/: ok
- go vet ./internal/provider/ with GOOS darwin, windows, linux: ok
- TestKeptIconNotLookedForEachAsk broken by hand (the seen check made
  never true): red, "the file was looked for within iconSeenFor and
  stored again"; green restored.
- Real account on mote (sandbox HOME, magpie web, 40 /api/providers
  under a 10s CPU profile): providersState 420ms -> 230ms of samples,
  pluginOwnIcon gone from the profile. mote was at load ~54, so the
  per-call wall time (11ms) moved within noise.

Not tried: the GUI suite (no GUI file changed).
2026-11-12 14:35:38 +08:00
yetone 4f38882c4c copilot: the window is the prompt Copilot takes, and Codex's entries say effective_context_window_percent (codealc on X)
Copilot's /models says capabilities.limits.max_prompt_tokens per account
(936000 for gemini-4-carbon); magpie dropped it and told agents models.dev's
1048576 for the id, so Codex sent prompts Copilot answered 400 to. The
window of a Copilot model is now that limit (models whose list says none keep
models.dev's); other vendors are unchanged, the field being read only in
copilotModels.

The model catalog magpie writes for Codex lacked
effective_context_window_percent, which every entry of Codex's own catalog
has (95); Codex 0.166 worked out no limit from such an entry and never
compacted. Magpie's entries now say 95, and a vendor-listed entry that
omitted it gets it.

Run: TestCopilotWindowIsThePromptItTakes, TestCodexCatalogSaysEffectivePercent
and the codexcat/provider tests via mote-run. Broken by hand: window set to 0,
and the percent left out; each new test goes red.
Not tried: Codex 0.166 itself against the catalog (Codex 0.165 is on this
machine; the live config was not touched).
2026-11-12 14:17:12 +08:00
yetone cc0d9c8b04 provider: a Gemini base typed without a version is kept as typed (JNDliuliuM on X)
GeminiBase gave every bare host /v1beta on Save (normalize), so a relay's
root typed in the editor came back as …/v1beta when reopened. Only Google's
own bare host (generativelanguage.googleapis.com) is given /v1beta now; any
other URL stays as typed. The detection (DetectBase), which proposes a base
rather than keeping one, still adds it (geminiVersioned). Siblings checked:
OpenAI/Responses bases are only trimmed on save (no /v1 added; fixV1 is the
5ba92aaf8 probe); the editor's respellURL runs only when the protocol is
switched or a URL pasted. Not changed: the Anthropic base still loses a
typed /v1 or /v1/messages, because requests add /v1/messages themselves and
the version would be sent twice.

Run (mote): TestGeminiBase and the new TestGeminiBaseSavedAsTyped red on the
old gemini_api.go/detect.go (relay root saved as …/v1beta), green after;
go test ./internal/provider ok; new GUI test provider-base-as-typed (save,
reload, reopen for gemini/openai/responses/anthropic) ok in chromium and
webkit, with provider-add-gemini, provider-base-api and provider-detect-draft
(46 tests; one failure seen on the first run was this file's own Escape
dialog, fixed by reloading). go vet darwin, linux, windows; gofmt clean.
Not tried: a real relay; the full suite runs after the tag.
2026-11-12 12:46:42 +08:00
yetone 04e38e6045 gateway: a reorder moves only its own provider's conversations, and tests forget it (#6249, #6262)
b70563ec6 kept one process-wide "accounts reordered at" stamp. affine
dropped any conversation's stick older than that stamp, so reordering
Claude's accounts in the GUI cost a running Codex (or any other
provider's) conversation its account and its prompt cache on the next
turn. In tests, any earlier SetAccountOrder set the stamp, and later
tests that backdate a stick to check an hour's cache saw it dropped:
TestAffinityKeepsAnHourCachePastFiveMinutes,
TestChatGPTConversationStaysPastFiveMinutes and
TestClaudeConversationKeepsItsAccountsCache went red in package and
subset runs (#6249, #6262, one cause).

The stamp is now per provider (provider.NoteReordered(id),
ReorderedAt(id)), and affine compares the stick only with the
reorder of the provider whose account it holds. fresh(t) and the
tests that reorder call provider.ForgetReorders.

Run (mica, darwin):
- go test -run 'Codex|Draw|Image|Keep|Relay|Reorder|Affinity|ChatGPTConversation|ClaudeConversation|AccountOrder|AccountRank' ./internal/gateway:
  ok 253s; the same run at origin/main FAILs in the three tests above.
- go test ./internal/provider ok 128s; ./internal/cli ok 46s.
- go vet darwin (provider, gateway, cli, gui), GOOS=windows (same),
  GOOS=linux -tags nogui (provider, gateway, cli): ok. gofmt -l: clean.
- Broken by hand: the new case "another provider reordered keeps it"
  on the old affinity.go answers "k1 k2 k2, want k1 k1 k1"; green now.

Not tried: the full suite, the GUI suite, a reorder with real accounts.
Not changed: `magpie accounts order` (internal/cli) notes the reorder
in its own process, so a running gateway never sees it and keeps the
old stick until it expires; that was so before this change too.
2026-11-12 12:28:56 +08:00
yetone 5ba92aaf86 provider: a typed base that serves chat is never given a /v1 (JNDliuliuM on X)
A custom provider whose API has no /v1 listed its models under
base/v1/models only; every models fetch then rewrote the saved chat and
responses URLs to …/v1 (fixV1), so the user's removal of /v1 came back each
time and requests went to /v1/chat/completions. fixV1 now POSTs an empty body
to base/chat/completions (or /responses) first; any answer but 404/405 (a 400
for the model, a 401) means the URL as typed has its endpoint and it is kept.
Only a base whose endpoint is missing and whose models sit under /v1 gets it.

Run (mote): new TestFetchKeepsTypedBaseThatServesChat red on the old code
(chat changed to …/v1), green after; go test ./internal/provider ok;
TestFetchAddsMissingV1 and TestArkBaseKeepsItsPath unchanged; go vet darwin,
linux, windows. Not tried: a real vendor; the GUI is unchanged (respellURL
only fills an empty URL), so no GUI run.
2026-11-12 11:38:52 +08:00
yetone 805e5c29a3 provider: six more plugins' sign-ins rotate before the host list is read (plugins #1027)
plugins #1027 made eight auth hooks say rotating: Cline, CodeArts (with
OfficeAce), Factory, MiniMax, Nous Portal, Qoder, SenseNova and WorkBuddy.
magpie reads that from the plugin host's list, but a sync that runs at
start can come before the list is read. rotatesKnown covers that window,
and it held only MiniMax and Qoder. It now holds all twelve provider ids,
so none of those sign-ins is carried to another computer by an early
Sync, backup or Restore. MiniMax and Qoder stay listed for the same
reason.

TestRotatingKnownBeforeHostList checks each id. With the old list put
back by hand it was red (workbuddy-ai and the others named).

Run on mica at this tree: go test -count=1 ./internal/provider/ ok
(128s); go vet ./internal/provider/ on darwin, windows and linux ok.
Not run: the full suite (it runs after the push, per the ship rule).
Not tried: a real sync between two computers.
2026-11-12 10:59:13 +08:00
yetone b70563ec6b gateway: a reorder of the pool counts at a conversation's next turn (Richyisaflower on X)
Auto affinity kept a conversation on the account that answered it by its cache, so an account moved down (or another made First) still took the next turn. SetAccountOrder, the login switch and the CLI switch now call provider.NoteReordered; affine drops a stick last answered before it, in Auto and not within a turn (Session and Strict keep it).

Run on mote: TestReorderedAccountsTakeTheConversationAtItsNextTurn red with the check off (k1 k1 k1), green with it; go test internal/provider, internal/cli ok; internal/gateway -run Affinity|Ordered|Stick|Reorder|Strict|Conversation|Fallback ok; go vet darwin, windows, linux nogui ok; gofmt clean.
Not tried: a real Codex account; GUI tests (no GUI file touched beyond the switch handler); the full suite (started after the tag). The image-quota half of the report is not fixed: no real refusal body was available.
2026-11-12 10:52:41 +08:00
yetone 9c9812ace7 remote magpie: a list wait behind Cloudflare is held, not asked once a second (y0ngb1n on X)
y0ngb1n runs magpie on a server behind Cloudflare and uses it from a local
magpie as a Remote magpie. Cloudflare's analytics showed /v1/models asked
~3.7k times an hour (one a second) since Nov 10, 175k in 7 days.

Cause: the follower (KeepRemoteListsFollowed, 11-06/11-08) waits at the
other magpie's /v1/models with X-Magpie-List-Wait and If-None-Match, and
the gateway holds the wait while the tag is the one named. Cloudflare
compresses the list and so turns its ETag weak (W/"ml-..."); the follower
sent that back, and modelsOnceChanged compared it exactly (tag != since),
so every wait was answered 200 at once. The tag it answered equalled the
follower's, so no refetch, only followGap (1s) before the next ask: a
request a second for ever, for as long as the local magpie runs.

Fix:
- gateway/models_wait.go: the wait compares the tag weakly (tagNamed, as
  listModelsTagged already does), so it is held to its end and answered 304.
- provider/remote_follow.go: a 200 that carries the tag the follower has,
  answered sooner than followQuick, is a wait that was not held (an older
  gateway behind such a proxy): the remote is left to its schedule
  (errListNotWaited, again after followOldAgain) as other non-waiting
  magpies are. Tags are compared without W/.

Run:
- Two magpie processes in sandbox HOMEs on mote (A serving, B a Remote
  magpie of A through a counting proxy that makes ETags weak, as
  Cloudflare does): old code 14-15 /v1/models per 15s on A, with the fix
  4 at start and none in the next 30s. Without the proxy's weakening the
  old code was already quiet (1 per ~50s), so the cause is the weak tag.
- TestModelsWaitNamedByAWeakTag and TestRemoteMagpieWeakTagNotAskedOver:
  each red with its half of the fix reverted (200 instead of 304; 32 asks
  in 400ms), green with it.
- go test -run 'TestRemoteMagpie|TestModelsWait|TestModelsList' on
  internal/provider and internal/gateway; gofmt; vet darwin, linux nogui,
  windows: clean. Full packages internal/provider (160s) and
  internal/gateway (929s) on mote at the head before the rebase: ok.

Not tried: the user's real Cloudflare; GUI.
2026-11-12 09:47:34 +08:00
yetone 908c9986cd templates: routing recipes — Plan first, Fastest first, Spread evenly (qhyqhy1s on X)
qhyqhy1s asked for best-practice templates in routing groups, as only
three were offered. The Routing page's template cards and Templates menu
(and `magpie group template`) now carry three more, each only a setting
the engine already has:

- Plan first (plan): the strongest model of up to three providers, the
  ones billed by a plan (Provider.BillingKind) ahead of pay-as-you-go
  ones. Not made when no provider is on a plan (NeedPlan).
- Fastest first (fast): the same members, routing "fast".
- Spread evenly (even): the one strongest model from up to four providers
  that serve it, routing "rotate" over all their keys and accounts.

Names, one-line descriptions and the new "Needs a subscription or token
plan" are in zh, zh-TW, ja and de. docs/subsystems/gateway-routing.md has
a Routing recipes section.

Run on mote at the pushed tree: go test ./internal/provider ./internal/cli
./internal/gui (Template|SizeOf|Group) ok; gofmt -l clean; group-template,
getting-started, i18n-keys and i18n-en-no-cjk GUI files, 98 tests, chromium
and webkit, 420px, every language, ok. Broken by hand: routing left unset
on Fastest first, TestRecipeTemplates red. Not tried: a real account
adding each template; the full GUI and Go suites are started after the tag.
2026-11-12 08:34:38 +08:00
yetone 3af8fe9cf7 gateway: a Claude account's Fable week used up rests Fable on it, not the account (kaitokiku on X)
Claude Code's refusal for a used-up window is "You've hit your limit" and
names no window, and its rate_limit_info may carry no rateLimitType (the
transcript's rejected row). restAfter read the account's windows as they
were cached before the Fable week filled (Fable 60%, nothing full), so
Pooled said no and the whole account rested for the refusal's time:
Opus, Sonnet and Haiku with it, though the other weekly quota was left.

A quota refusal on an account whose reading holds a window of some models
only that counts the model, none known full, now asks for the reading
again and narrows the rest to the model when it shows that pool full
(narrowWhenRead, as for an unread account, #2036). Every route rests
through restAfter, so Messages, Chat Completions, Responses and the group
fallback share it; Claude is not a plugin.

Run at this tree (mote): TestClaudeFableWeekRestsFableOnly red on the old
routing.go (rests the account), green with the fix; internal/provider,
gofmt, vet on darwin, linux and windows. Full internal/gateway follows.
Not tried: a real Fable-limited account; a usage reading that keeps
failing leaves the account resting whole, as before.
2026-11-12 08:27:46 +08:00
yetone 96c65e3e7d provider: WorkBuddy's mover min is 0.2.29 (plugins #1022, #1015)
0.2.29 pins WorkBuddy AI's free window at the reset a routed-past refusal names (yetihan, plugins #910, #1022). 0.2.28 lists an enterprise's custom: models (plugins #1015). Both are on npm (npm view --prefer-online: latest 0.2.29).

Ran: go test -count=1 ./internal/provider/ on mica, ok.
2026-11-12 08:12:42 +08:00
yetone 57855191f0 provider: a price looks its provider up without copying them all (#2278)
byIDOrWas, which every model's price (BasePriceIn, UserBasePriceIn)
and a few model preferences go through, read All(): a copy of every
provider, its keys, headers, models and account maps, to find one. A
Sessions poll prices every model of every call, so that was the next
largest allocator of a poll. It now looks among the shared providers
(sharedAll, as Find does) and clones only the one it found, which stays
the caller's to change.

Measured on mote with the owner's real account, 40 /api/sessions
polls, `magpie heap` alloc_space diff:
  before (w7): byIDOrWas 9.74 MB (All 9.74: its copies 5.7, sharedAll
  4.0)
  after  (w8): byIDOrWas 3.52 MB, all of it sharedAll's rebuild when
  the hold expires; All gone from the poll
CPU over 30 s of polling: 1.37 s (w7) -> 1.29 s.

Test: TestByIDOrWasCopiesOnlyItsOwn (new), 40 providers of 5 keys each
under Hold: a change to the returned provider doesn't reach the shared
ones, and the lookup allocates under a tenth of All. With the old
models.go it fails (1560 allocations, against 1560 for All).
Run on mica at 10c331531 plus this change: go vet ./internal/provider
for darwin, linux and windows clean; go test ./internal/provider ok
(130 s).
Not tried: Windows or Linux runs; the change is which list is read.
2026-11-12 05:30:42 +08:00
yetone 76c7742cf3 provider: the ZCode mover's min is 0.1.60 (plugins#1020)
zcode 0.1.60 (plugins 7c44d027) keeps the last coding plan key when reading it fails for a network reason (ECONNRESET, a timeout), or answers a wall that magpie sends once and then rests the account. Before, a thrown error was retried about 8 times over six minutes. Free first also no longer replays onto a coding plan whose usage read showed a window full. Raising the min lets keepMovedCurrent update every moved user.

npm view --prefer-online: 0.1.60 at the time of the change.
Run on mica: go test -count=1 ./internal/provider/ ok (129s). gofmt -l clean.
Not run: the full suite. This change is the min string only.

Reported-by: takomitkm
2026-11-12 03:30:27 +08:00
yetone 0d0a1a5678 balance probe: kept across restarts, Auto-detect switch, Detect again, not-detected line in the editor (#3146, Niapyaya on X)
A custom provider at a New API / Sub API / One API relay with no Balance URL
has its balance query found by magpie (provider/balance_probe.go). This keeps
what was found, or not found, in balance-probes.json (keyed by origins and a
hash of the key, written through temp-and-rename, an unreadable file read as
empty), so a restart does not probe again. The editor gets an Auto-detect
switch (NoBalanceProbe), a Detect again button (ForgetBalanceProbe) and a line
saying where the balance was found, or that none was, with the Balance URL
field as the way out. A found balance is a balance card on the Usage page.

Run at the rebased head (parent 6a3f162f0 = origin/main), on mica:
- gofmt -l: clean.
- go vet ./... (darwin), GOOS=linux -tags nogui, GOOS=windows: clean (at the
  previous base e6bf4adf1; go vet ./internal/... again at this head).
- go test -count=1 internal/provider internal/gui: ok, at this head.
- GUI, both engines, five languages: balance-found, gui-de/ja/zh-tw, i18n-keys,
  i18n-en-no-cjk, provider-billing, provider-detect*: all ok except gui-de and
  gui-ja "has every zh string" ({agent} twice in sessions' "isn't installed
  here"), which are red the same at e6bf4adf1 (filed).
- At e6bf4adf1, 79 provider/gui/i18n files: 80 reds, the same 80 on the
  unmodified base (provider-fetch-again #5232/#5057, provider-picks-stay
  #4397, provider-models-rest #4396, provider-typed #4673, menu-scroll #1550,
  provider-max-output and provider-many-keys filed with the rest).
Not tried: a real New API / Sub API relay with a real key; the full Go suite
(started after the tag).
2026-11-12 03:13:50 +08:00
yetone 4847a087fb provider, library: two package-level regexps compile on first use
TestNoEagerPackageRegexps (root package) was red on main: fc615339f
added aliWindowField in internal/provider/alibaba_usage.go and
e174b5515 added envName in internal/library/env.go, both with
regexp.MustCompile at package level. Both now use lazyre.New; each has
one call site (FindStringSubmatch, MatchString), which lazyre has.

Run (WSL magpie-desktop, origin/main 2bb201162 + this):
- red first, unchanged main: TestNoEagerPackageRegexps named
  env.go:57:15 and alibaba_usage.go:374:22.
- after: gofmt -l clean; go vet -tags nogui ./internal/provider
  ./internal/library ok; -run TestNoEagerPackageRegexps . ok;
  ./internal/library ok; -run 'Ali|Alibaba' ./internal/provider ok.
2026-11-12 02:14:21 +08:00
yetone a5e805f574 Codex: Ultrafast beside Fast in a group member, and a Fast/Ultrafast setting per model (kdajenks on X)
kdajenks (magpie 0.1.3739, Codex on ChatGPT Pro) could set Fast only from a
routing group's member row and had no Ultrafast there, and no way to set the
speed in the model's own settings. Ultrafast exists: Codex's catalog lists
the `ultrafast` service tier, the code already sent it for agent picks and
Codex's service-tier row, and the live account's service_tiers hold it.

- Group member: the button steps Standard speed, Fast, Ultrafast (where an
  account offers it, `ultraOK`), back to Standard. `Group.Ultra` is a subset of
  `Fast`, kept through rename, fold, share, gone-filter and the CLI
  (`magpie group ... ultra=`). The gateway marks the candidate `ultra`.
- Per model: `settings.ModelTiers` ("<provider>/<model>" to priority or
  ultrafast), `provider.SetModelTier` (refused where CanFast/CanUltra say no),
  `ModelPref.Tier` in Model settings (Standard speed / Fast / Ultrafast, in
  modellimits.js), and `magpie model tier <provider/model> [fast|ultrafast|usual]`.
  The gateway sends it on a direct pick for an agent with no fast pick of its
  own, through fastPick, so an account without Ultrafast gets priority. A group
  member goes as the group says.
- Docs: gateway-routing, providers-accounts, reference.

Run (mica, at the rebased head over a6d84e13a):
- gofmt -l clean; go vet darwin, linux nogui, windows clean.
- go test internal/provider, internal/settings ok; internal/gui and
  internal/cli ran: the one red of mine (TestSettingsSaveKeepsWhatItDoesNotSend
  wanting ModelTiers) is fixed in this commit; the others are not mine and
  red on a clean origin/main: TestEveryRouteHasACommandOrIsNamed (#6202),
  TestPanelHiddenByWailsMarksPageOutOfSight (#6203, not checked on main).
- internal/gateway ok (984s).
- GUI, chromium and webkit: new model-speed.test.cjs (30, five languages, 1200
  and 420px), plus model-*, group-*, fast-*, i18n-*, text-size,
  codex-service-tier, panel-*, routing-group*, routing-save* files. Red and not
  mine, same on a clean origin/main worktree: fast-pick and fast-ultra (#6201),
  group-editor-selected (#5049).
- New tests TestModelTierSentToEveryAgent, TestGroupMemberUltrafast,
  TestCleanModelTier, TestSaveGroupUltra.

Broken by hand: removing the gateway's model-tier branch and the candidate
`ultra` copies turned both gateway tests red; turning off the Ultrafast choice
in Model settings turned 20 of 30 GUI tests red; reverting the member button to
two states turned 10 of 30 red.

Not tried: a real ChatGPT account sending Ultrafast through the new setting;
the agent picker's bolt does not show a model-level default; Windows and Linux
GUI runs.
2026-11-12 01:56:26 +08:00
yetone fc615339f0 provider: Alibaba Cloud Token Plan quota read with the account's AccessKey; intl Token Plan preset (pppMathew on X, #2940)
Cause: a Token Plan sk-sp- key only authorizes inference. The plan's
usage sits on the Bailian console gateway, which wants a console token
(the key gets BailianGateway.Login.NotLogined) that Alibaba's own `bl` CLI
makes from the account's AccessKey through GenerateCLIAccessToken (ACS3
signed). magpie had no such path, so the usage card showed no quota.

Change:
- alibaba_usage.go: ACS3-HMAC-SHA256 signing, the console token (kept 20
  minutes per AccessKey and region, made again once on NotLogined), the
  personal plan's usage API, and per<N><Unit>Percentage/ResetTime read as
  5 hours / Weekly / Month windows. Hooked in as AccessKeyVendor "alibaba"
  (editor asks AccessKey ID and Secret, a keyless card says so),
  accountPlanOf (routing), PlanQuotas and the key card tag.
- Hosts: token-plan.cn-beijing.maas.aliyuncs.com (bailian-token-plan) and
  the new token-plan.ap-southeast-1.maas.aliyuncs.com preset
  alibaba-token-plan (Alibaba Cloud international Token Plan, #2940), also
  an OpenCode import target.
- Editor hint in zh, zh-TW, ja, de; docs (providers-accounts, reference).

Not covered: qwen-token-plan (Qwen AI platform) and qwencloud-token-plan
have no AccessKey route (browser-session console, #5829); team plans.

Run on mica at this tree: go test ./internal/gui ./internal/provider ok;
go vet darwin, linux nogui, windows on provider/gui clean; GUI files
i18n-keys, i18n-en-no-cjk, tencent-access-key, volc-access-key,
usage-access-key-card, tencent-cloud in chromium and webkit: 60 of 64 pass,
the 4 reds are tencent-cloud's "region clicked right after the strip
scrolled", red the same at origin/main 319753d89 (filed: #4321, #4399,
#4625). Broke it by hand: dropping the *100 on the percentage turns
TestAliReadWindows and TestAliPlanQuotas red.
Tests never reach the network (httptest behind a rewriting transport).

Not tried: no real Alibaba Cloud account, so neither the mint nor the
usage reply was seen live; the field names and the envelope come from the
official client's source. The international gateway host
(bailian-singapore-cs.alibabacloud.com) and the RAM-user case are the least
certain. The full suite was not run before the tag.
2026-11-12 01:20:52 +08:00
yetone 7e8214d60a tests: four reds on main from 85e6ec540, 5a475f90c and 0706d7a35 (#6187, #4457)
- library: TestEveryAgentInLibrary. 85e6ec540 added the Paseo agent with
  no Library target; it is listed as "not looked at (#5897)" like the
  other new agents.
- provider: TestAddSameKeyOtherFormat pinned OpenCode Go's Chat at
  /zen/go/v1. 5a475f90c moved it to /inference/go/openai/v1, the endpoint
  Go's docs name, and didn't run the package.
- provider: TestQuotaSpanCarriesEveryWindowField. 0706d7a35 (#6160) put
  Lane on QuotaSpan; the test's full window now sets it too.
- provider: TestKeptQuotaReportAsksNobody (#6187). The same commit gives a
  ChatGPT card an image row from what the gateway remembers, so the kept
  report has two windows; the test takes the image row and still asks
  that nothing is read.

0706d7a35 ran -run of its own tests only.

Run (mica): all four red at origin/main fe20e4dbd; with this change
./internal/provider ok (125s) and ./internal/library ok (113s), -tags
nogui -count=1. gofmt clean.
2026-11-12 00:17:30 +08:00
yetone 7b9ae7cf9c agent tests: Pi's group entry counts the group look-ups, not the process's bytes (#6178)
TestPiGroupEntryKeepsItsMembers (efdca11be) compared runtime.MemStats
TotalAlloc across five polls, which counts every goroutine the earlier
tests left running. Alone it passed; in a full ./internal/agent run, with
~1,000 tests before it, it was red on macOS CI and on mote. A bisect on
mote found no single test behind it: the red needs tests from both halves
of a 128-test set, so it is cumulative, not one leak.

provider.GroupsFound counts how often GroupFinder found a group's
members, and the test asks that five kept polls found none.

Run (mica): -run TestPiGroupEntryKeepsItsMembers green; with agents.go's
old provider.GroupFinder() loop put back by hand it is red ("found the
group's members 5 times"); ./internal/agent whole ok (200s);
./internal/provider's only reds were the three on main (fixed in the
next commit). gofmt clean.
2026-11-12 00:17:23 +08:00
yetone d3aecfe958 test models: a plugin model its vendor queued answers OK, saying the queue (Mr7Faith on X)
Qoder personal_standard: qmodel_latest (shown as Qwen4-Max-Preview) and
dfmodel were queued (503 "queued the request for qmodel_latest (this
plan's queue: p4, 1 ahead); try again in 60s"). The test sends
X-Magpie-Fallback so the plugin says the queue at once, and the probe
counted that 503 a failure: red all day, and Working only unpicked the
models. The id in the error is the model's own id (the listing's display
name changed), not a mapping bug. A queued model is served and an agent's
turn waits it out, so the probe now sets OK with Result.Queued, which the
chip's title shows.

Run on mote: go test -run TestPluginModelTest ./internal/provider ok
(TestPluginModelTestSaysQueued now wants OK + Queued; build-red on the old
test.go); go vet darwin/linux/windows ./internal/provider; GUI
models-queued, model-test-one, i18n-keys in chromium and webkit ok;
models-queued red without the app.js line. models-works-only is red on
origin/main c43314792 too (#4391). Not run: full suite, real Qoder account.
2026-11-11 23:54:16 +08:00
yetone b52c711142 Restore what 85e6ec540 reverted: it was committed on a stale index and took out b587eb306's and earlier work (webview2, library skills, opencode endpoints, quotas); this puts the tree at b587eb306 plus the Paseo agent only 2026-11-11 23:09:15 +08:00
yetone 85e6ec5406 agent: Paseo's Claude model picker lists magpie's models (@TheMist016 on X)
Paseo (getpaseo/paseo) starts the same Claude Code, but builds its own model
list: first-party models plus settings.json's `model` and a few
ANTHROPIC_*_MODEL variables (providers/claude/models.ts). It never reads
Claude Code's modelPicker, where magpie writes every model, so the rest were
not selectable in Paseo. Paseo's own ~/.paseo/config.json takes
agents.providers.claude.additionalModels ([{id,label,description}], checked
against protocol/src/provider-config.ts) and passes each id to Claude Code as
written.

New agent "Paseo" (detected by ~/.paseo or PASEO_HOME): its switch writes the
models Claude Code's /model lists (same ids, [1m] marks, names; only the ones
picked for it) there, marked "via magpie" in the description; the user's own
entries and keys stay, off takes out only magpie's, a sync refreshes when on.
Claude Code must be connected to magpie as well.

Run (mote-run, sandbox HOME in tests): TestPaseoAdditionalModels,
TestStateListsPaseo, internal/agentenv, internal/gui full package ok;
internal/agent full run red only on TestPiGroupEntryKeepsItsMembers, which is
red the same on origin/main 12cd456f2 (passes alone; filed). gofmt clean,
vet darwin, windows and linux nogui on internal/agent. Broken by hand: Set
writing no models goes red.
Not tried: a real Paseo daemon reading the file (checked against its schema
source only); GUI browser suites.
2026-11-11 23:08:39 +08:00
yetone 5a475f90c3 opencode go: each API goes to the endpoint Go's docs name, Gemini at /inference/go/google/v1beta (@jd04063221 on X)
Go's docs (opencode.ai/docs/console/go, Endpoints) give one URL per API
under /inference/go: /openai/v1, /anthropic, /google/v1beta. The preset
and the filled-in defaults still used /zen/go and Gemini's
/inference/go/v1.

The preset now gives the three; a preset provider saved with the older
URLs is moved on load; openCodeRoot reads the per-API forms; a Go URL in
the per-API form gets its siblings in that form. A URL the user gave stays.

Run (mote): go test -run 'OpenCode|Preset|PlanQuota|Balance|Go|Gemini'
./internal/provider ./internal/gateway ok; vet darwin/linux/windows ok.
Broken by hand: old opencode_endpoints.go/presets.go with the new
TestOpenCodeEndpointsFilledIn goes red on 6 cases.
Not tried: a real Go key (none here); old /zen/go routes still answer
(400 MissingSessionID unauthenticated), so URLs the user set keep working.
Full suite and GUI files not run before the tag.
2026-11-11 22:55:43 +08:00
yetone 93b855d90e remote quotas: a card is wanted by its whole provider path, not its first part (748975219 on X)
With only relay/strata/model enabled on a Remote, the cards of relay/kiro and
relay/codex still passed, since remoteCardWanted compared the first part of
the card's id alone. A card is now wanted when its id is the provider path of
an enabled model (its id less the last part) or a parent of it, whole parts
only (relay/kir never matches relay/kiro). A model listed with no provider
still leaves it unknown, so all shown. cardWantedFor holds the rule.

Run (mote): TestRemoteCardWantedByWholePath (two levels, three levels,
non-boundary prefixes, several models, one level, no provider) is red with
the first-part rule put back by hand, green with the fix; -run Remote in
internal/provider ok; go vet darwin/linux/windows ok; gofmt clean. Full
internal/provider: TestQuotaSpanCarriesEveryWindowField and
TestKeptQuotaReportAsksNobody are red, and red the same on origin/main
bbfa8501f without this change (open issues 4457/4190 and 3487).
Siblings: remoteOf and ThroughSelf take one leading part on purpose (a
remote's own id), unchanged. Not tried: a real multi-level chain of magpies.
2026-11-11 22:53:50 +08:00
yetone efdca11be3 agent: Pi's group entry keeps whether a member speaks Messages across polls
Pi's Drift is asked on every /api/drift poll, about every 12s on
every page. Each poll wrote the entry of the model the agent is set
to. For a routing group, piModelJSON found all of the group's members
again (GroupFinder, membersFound, resolveIn) only to see whether one
speaks Anthropic's Messages API, for #5037's short promptCache. With
the real-account copy on mote, an alloc_space diff of 55s with the
Sessions page open showed 21.7MB allocated, 17.1MB of it under Drift
(5 polls, ~3.4MB each), 16.1MB of that in this look-up.

provider.GroupHasNative answers it through keptOf: kept across
requests while the files' stamp stays the same, a minute at most, as
the catalog's other kept builds are. Outside a request it is found
afresh, as before. The entry is the same.

Test: TestPiGroupEntryKeepsItsMembers. Over successive requests, a
group's entry allocates under half of one provider.FindGroup: 3,600
bytes against 71,040 for a 40-member group. With the old agents.go it
is red: 72,672 against 71,040. TestPiGroupPromptCache and
TestPiGroupThinkingIsWhatPiRuns pass.
2026-11-11 22:26:07 +08:00
yetone 0706d7a35a usage: a ChatGPT card has an image row: used up until the refusal's reset, else unknown (#6160, hqqqqqqqh on X)
ChatGPT's image generation has a quota apart from the 5-hour and weekly
windows. Neither /wham/usage (additional_rate_limits is null) nor the reply
headers (x-codex-primary-*, x-codex-secondary-*) tell it, so no remaining
count exists to show. Each Codex account's card (Usage page, magpie quota
--json, /v1/magpie/quotas, /v1/magpie/quotas/cards) now has an "Image
generation" row (provider.WithImageLane, Lane "images", Text and Aside so
routing, holds, history, tray and statusline never see it): "Used up" with
the reset time while the image model rests on that account after a refusal
(the #2244 drawing-lane rest, whose time is the refusal's resets_at), and
"Unknown" otherwise. Never a share or a count. Shown in en, zh, zh-TW, ja, de.

app.js: a Text row's display now goes through t(), a same-length change, as
the core script budget has 1 byte of room.

Run (on mote): go test -count=1 -run 'TestWithImageLane|TestCodexImageRow'
./internal/provider ./internal/gateway ok; codex-image-row.test.cjs in
chromium and webkit at 900 and 390px in all five languages ok;
TestCoreScriptBudget ok; go vet darwin, windows, linux nogui on provider and
gateway ok; gofmt clean; 158 GUI files matching i18n/quota/usage/balance
names in both engines (result in the follow-up).
Broken by hand: the GUI test is red with app.js's display line put back to
the old form; the Go row tests are red with imageRestOf returning false.
Not tried: a real ChatGPT account hitting its image quota (the row is
driven by a faked refusal's rest); the generated-image count the issue also
asks for is not built.
2026-11-11 21:59:36 +08:00
yetone 8016205e3f provider: trust a self-signed server's certificate by fingerprint, for Remote magpie and any https address of your own (Zhangzhangi on X)
Zhangzhangi on X couldn't add a Remote magpie at a domain with a
self-signed certificate ("x509: "api.magpie.local" certificate is not
standards compliant") and asked for a skip-verification option. A
follow-up asked for the same on other self-signed hosts.

This adds a pin (trust on first use), not a blind skip. It is off by
default and kept per provider:
- Advanced → Server certificate → "Trust its certificate…" fetches the
  certificate the server shows (provider/peekcert) and lists its SHA-256,
  subject, issuer and expiry. "Trust this certificate" keeps the
  fingerprint as the provider's serverPin.
- From then on only that certificate is accepted (netproxy pinTLS:
  InsecureSkipVerify plus VerifyConnection comparing the leaf's DER
  SHA-256). Another one fails with PinMismatchError, saying the server
  showed a certificate other than the one trusted.
- The editor shows a red "Certificate not verified: only this one is
  accepted" with the fingerprint, and "Verify it again" drops the pin.
- The pin is set only on the provider's own hosts (provider.PinHosts):
  - every address of Remote magpie and of a provider added by URL;
  - for a preset (Ollama, LM Studio, OpenAI at your own box), only https
    addresses whose host is not one of the preset's or its regions' own
    hosts. A vendor's host never takes a pin.
  - Never for an account, Vertex or a subscription. Save refuses one
    elsewhere.
- The client certificate and Server CA still go only to the providers
  that took them before (TakesClientCert). A preset gets the pin alone.
- The editor's certificate rows (Client certificate and the new Server
  certificate) are drawn by a lazily imported tlscerts.js. The Client
  certificate row moved out of app.js with it, so the core scripts stay
  under TestCoreScriptBudget without a raise.

Run (Go 1.26.8):
- WSL magpie-desktop, before the rebase:
  - go test -tags nogui -count=1 ./internal/netproxy ./internal/provider
    ./internal/gui all ok;
  - GOOS=darwin -tags nogui vet of gui fails on traywindows_darwin_test.go's
    undefined trayImagePNG, the same at the base (a cgo-only helper).
- mote and mica, after the rebase on ab5824aee:
  - gofmt -l clean; node --check app.js;
  - go vet darwin (cgo), GOOS=linux -tags nogui, GOOS=windows: ok;
  - go test ./internal/netproxy ./internal/provider: ok.
- mote, at the final tree: node --check app.js and tlscerts.js; go test
  ./internal/gui -run 'Budget|ServerPin|InsecureTLS|ClientCert|OnDemand|Lazy'
  ok (TestCoreScriptBudget under 1,533,802) at the base ab5824aee.
  Rebased on fe5a0cf6d, TestCoreScriptBudget is red, as it is on that
  main alone: main's core is 1,534,708 (16ed1a952 took it to 1,535,318);
  this change takes it to 1,534,484, 224 bytes less (#5918, commented).
  The rest of the run above passes at the pushed head.
- mica, GUI files at the final tree, both engines inside each file:
  - green: provider-server-pin (54), mtls-settings (16),
    provider-insecure-tls (60), provider-socket (60), provider-http1 (60),
    i18n-keys, i18n-en-no-cjk, editor-advanced-align, provider-advanced-fold
    (50);
  - old-webkit: headerpresets.js not loaded (#6030) and Safari 15's :has()
    (#5919), both on main too;
  - menu-scroll: 24 of 24 red on /api/update/using, the same alone at
    origin/main fe5a0cf6d (#5982, commented).
  - Earlier flakes of provider-http1 beside another session's suite:
    #6159.
- Broken by hand, each red:
  - presets never take a pin: TestServerPinSaveChecks,
    TestServerPinPresetAtOwnServer, TestServerPinNoVendorHost;
  - vendor hosts pinned (the own-host check dropped):
    TestServerPinNoVendorHost;
  - client cert and CA sent to presets: TestServerPinPresetAtOwnServer;
  - the pin never compared: TestPinOnlyThatCertificate,
    TestServerPinRemoteMagpie.
  Restored: both packages ok.

Not tried:
- a real self-signed domain from the macOS app (httptest servers with
  their own certificates only);
- the Responses WebSocket dial (read only: it takes the same netproxy
  transport);
- go test ./internal/cli and the whole GUI suite before the tag (the
  full Go suite runs after it, under suite.lock).
2026-11-11 21:13:43 +08:00
yetone 19782923c5 codex: the compaction magpie makes can go on a model of its own (0neB1aze on X)
Codex's memories had a model of their own, its compaction did not. Codex's row has a compaction model square (compact_model, settings.CodexCompactModel), read by the gateway on each compaction (codexCompactTo, before codexCompact). Only a compaction magpie makes is moved: it asks for a plain-text summary any model reads back. One a ChatGPT account seals, or a pick that compacts natively, is left, since only the writing account reads it (#1099); a disabled, unserved or key-barred pick is left with a log line. The text sent to the model is unchanged.

Run on mote: TestCodexCompactOnItsOwnModel (red with the move taken out) and TestCodexCompactToLeavesNative; go test for gui, settings, settingsapi, agent, provider, gateway; darwin, linux and windows vet; the GUI files in both engines. Not tried: a real Codex session compacting on the chosen model.
2026-11-11 20:57:11 +08:00
yetone c9b1a708db provider: a test that Kimi Code's month ranks keys whose 5h and 7d tie (0xBCD18E on X)
The report asked for Kimi Code's monthly window on the card and as the basis
for choosing among keys. Both already ship: readKimiCode reads the month
(limit_month_total/limit_month_code, limits[] by length) since v0.1.2022,
and routing weighs a key by every window it reads (Allowance.Renewal ranks
biggest first, Pace takes the tightest budget window). No behaviour change;
this pins it with the reporter's case: synced 5h/7d, differing months.

Run: go test -run TestKimiMonthRanks ./internal/provider via mote-run, ok.
Not tried: breaking it by hand (test-only, no code changed); a real key.
2026-11-11 20:52:43 +08:00
yetone ab5824aeea gateway keys: a limit in total never resets by the period, only by Reset usage (Cyrus_4433 on X)
The Limit window menu gains "in total" (period "total", CLI: gateway-key limit <id> total). It counts from when it is set or last reset and ends a century off (access.Limit.Window), so only Reset usage starts it again; its 429 says it stays refused until reset or raised, the row reads "$0.00 / $300 · 总额" with no reset time, and a remote key's window is "Tokens/Spend in total" with no reset. Old settings files read the same (new period only). i18n in zh, zh-TW, ja, de; reference.md and gateway-routing.md say it.

Run: TestLimitTotal and TestTotalLimitNeverResetsByThePeriod, red on the old code (Valid refuses "total"); gateway-key-total.test.cjs red without the keys.js change (5 of 5). Not tried: a real key through a live gateway; full suite follows after the tag.

Run (before this push):
- gofmt -l clean; go vet darwin, linux (nogui), windows clean.
- go test: internal/access, internal/budget, internal/cli, internal/provider ok.
- Go tests for the total period are red on the old code (Valid refuses "total"); the GUI test is 0 of 5 languages passing without the keys.js change.
- gateway-key-total.test.cjs and i18n-keys: 9 pass in chromium and in webkit (zh, zh-TW, ja, de, en; 500px width; no native select).
- Full GUI suite on mica, chromium: 46 reds in files this change does not touch (accounts, Pi/OpenCode Go, panel sheet, check-in, Aside provider, API key theme, allowed addresses); none is a key-limit test. Webkit pass still running; reds are to be compared with origin/main and filed after.
- TestCoreScriptBudget is red on origin/main 2d12e8274 by 7 bytes (1,533,809 > 1,533,802); this change touches no counted core script (#5918).
Not tried: a real key through a live gateway; the full Go suite (started after the tag).
2026-11-11 20:35:13 +08:00
yetone 3f81fbf9a8 gui: plugin page inlining compiles its regexps on first use (#6145)
55dff77b4 compiled seven package-level regexps in pageinline.go with
regexp.MustCompile, so TestNoEagerPackageRegexps was red on main. They
now go through lazyre.New, like the rest of internal/gui.

Ran on mica at this tree (origin/main 817ccb56f + this change):
- go test -run TestNoEagerPackageRegexps . : ok (red in the full suite
  log at 6b4513082 before)
- go test -tags nogui ./internal/gui -run 'Inline|PluginPage|Page': ok
- GOOS=linux go vet -tags nogui ./internal/gui, GOOS=windows go vet
  ./internal/gui: ok; gofmt clean
Not run: the full suite or GUI suite (the change is a constructor swap).

Fixes #6145
2026-11-11 20:10:42 +08:00
yetone b1f5806cb3 gateway: Copilot's Gemini keeps a nullable union untyped, its Grok gets namespaces flat (yuushabu_buyinn on X, #4374)
Copilot's Gemini models still answered 400 "invalid request body" to Codex
Desktop after the oneOf rewrite. RoyShen12's live isolation on #4374: the
cause is geminiToolTypes writing `type: string` beside a nullable union
(move_thread_to_project.projectId = anyOf [string, null]); removing that one
field made the full request 200. For a Copilot Gemini on chat, a union node
(anyOf or oneOf, any shape, nullable or not, at any depth) now goes as its
client wrote it, without the parent type; its branches are typed as ever, and
every other Gemini route (Vertex relays, plugins) is unchanged.

Grok 4.7 behind Copilot (Responses) is turned away over a namespace tool
(mcp__codex_app) and over a function whose parameters are a root union
(automation_update); Copilot's word is a bare 400/422, so nothing teaches
the refusal-learner. For a Copilot Grok the namespaces go flat
(namespace__name, provider.GrokFlatBody, nothing else of the body touched)
and root unions become objects (ObjectRoot); the model's call to a flat name
gets its namespace back through the existing namespacedIn path. GPT on the
same /responses keeps its namespace and unions as they came.

Run (mote, -tags nogui): go vet gateway+provider; go test -run
'TestCopilot|TestGemini|TestGrok|TestObjectRoot' gateway and provider: ok.
New TestCopilotGeminiKeepsNullableUnionsUntyped (anyOf, oneOf, array items,
$ref'd nullable), TestGeminiTypesOtherVendorsKeepTheirs and
TestCopilotGrokTakesNamespacesFlat (GPT unchanged) are red with the two
wiring lines reverted by hand, green with them.
Not tried: a live Copilot account (the fakes refuse with the shapes
#4374's isolation recorded); the full suite, started after the tag.
2026-11-11 19:42:17 +08:00
yetone 6b45130829 sync: a plugin removed on one computer is removed on the others (dolacmeo on X)
Plugins rode the providers part and AddPlugins only adds, so a plugin one
computer removed came back from another that still held it and was sent up
again. davsync now keeps the plugins both sides had after the last sync
(state.Plugins, as sign-ins keep theirs); a name one side has since lost is
taken out of the server's list when it was removed here, and removed here
(provider.RemovePlugin) when it was removed there. A plugin added meanwhile
stays. A removal that fails (agent on magpie) is retried next sync. backup
now writes an empty plugin list as [] so "none" is told from "older magpie".

Run (mote): go test internal/davsync + internal/backup ok; vet darwin,
linux nogui, windows clean; gofmt clean.
Broken by hand: pluginPlan returning nothing turns
TestSyncPluginRemovalSpreads red (b keeps x after a removed it).
Not tried: real WebDAV server, two real machines, full suite before tag.
Siblings: MCP servers, skills, providers and search APIs are mirrored
(library.Put, provider.Mirror), so their removals already spread when one
side changed.
2026-11-11 19:34:40 +08:00
yetone b4fc29a6e4 gateway: a video reaches a model that takes one, on every API, and a group takes its members' kinds (#6135)
LingYingNX sent MiniMax's Messages video block through the MiniMax plugin
(a plugin is always sent a translated request). readAnthropic had no case
for "video", so the block was left out: the reply was 200, the request
billed, and the model never saw the video. Chat's video_url and a Chat
file of a video were left out the same way (#4101).

A video is now a File part with a video/* media type (video_input.go):
- read from Messages' video block, Chat's video_url, a Chat file of a
  video (nested, or the AI SDK's flat {type, data, mediaType}) and a
  Responses input_file of one;
- built as a video block on Messages, video_url on Chat, inlineData on
  Gemini's API (as before for Gemini);
- Responses has no shape for one: a latest-turn video translated there
  is a 400 that says so (unportableVideo in translate).
A latest-turn video for a model whose list says it takes no video is a
400 before any upstream is asked; one of an earlier turn is told of in
words (Request.videoOff, set in buildFor). A routing group takes the
union of its members' Inputs/Outputs (buildGroupEntries, #2898), so
/v1/models lists video for group/... when a member takes it, and a video
goes only to members that take one, else to unknown ones, else a 400
naming the group.

Not changed: PDFs (Messages document, Responses input_file of a PDF, a
Chat file of a PDF) stay as #5452 says; input_audio stays with #4101.

Ran (mote, at this tree): gofmt -l (nothing), go vet ./...,
GOOS=windows go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=linux go build -tags nogui, GOOS=windows go build,
go test -tags nogui -timeout 45m ./internal/gateway ./internal/provider:
ok gateway (1072s), ok provider (132s).
Rebased on origin/main c4a9856df (3d8510f32 changed Gemini's inlineData,
which passes a video as it is): go vet ./internal/gateway and the video,
group and Gemini media tests again, ok.
New tests: TestPluginGetsTheVideoBlock (the reporter's body shape to a
plugin), TestVideoReachesEveryAPI (Chat video_url / file / AI SDK file /
Responses input_file to Messages, Messages to Chat, Chat to Gemini,
Messages to Responses = 400, Messages relayed), TestVideoForAModelThatTakesNone,
TestGroupVideoGoesToMembersThatTakeIt, TestGroupInputsAreItsMembers.

Broken by hand, each red: the Messages video parse case (4 tests), the
Messages video build, Chat's video build, Chat's video_url parse,
Responses' input_file parse, unportableVideo, the single-model gate, the
group filter, buildFor's videoOff, and unionKinds (provider and gateway
group tests).

Not tried: a real MiniMax account or any real vendor with a video; the
plugin side is plugins#985 (opencode-minimax-auth 0.2.6). The full
suite runs after the push.

Reported-by: LingYingNX
2026-11-11 19:12:34 +08:00
yetone 4cc20f93c0 routing: a group says whether its requests are masked (1dwsdqwd2 on X)
Group.Redact: unset follows each member's provider (Send requests
unmasked), "on" masks as Settings say whichever provider, "off" sends
to every member as written. In a group in a group any "on" wins over
"off"; Settings with masking off still masks nothing. Every route that
reaches a group asks the same way: unredactedRoute (a provider's
fallback groups and provider.GroupsAfter), unmaskedMembers, maskedFor
and MaskRoute, and candidate.unmasked() for embeddings, images, video,
decide and count_tokens. A shared group never carries it (export and
import clear it; an import over a group keeps the old one). A save that
doesn't name it keeps it; "follow" clears it. The Routing group editor
gets a Masking row (menu, no select) in zh, zh-TW, ja, de, reusing core
strings; the Privacy page's unmasked warning counts groups set to off.

Run at the pushed head's parent (rebased on origin/main): gofmt -l, go
vet provider/gateway/gui, go test provider gateway gui cli (gateway ok
1091s, gui ok, cli ok); provider red only in
TestCancelledPluginSignInSavesNothing, open as #5047, green alone x10,
not touched here. group_redact_test.go broken by hand (UnmaskedBy's
on/off cases deleted): 5 tests red. group-redact.test.cjs: 5 languages
x 2 widths x chromium and webkit, 30 of 30; i18n-keys green.
Not tried: a real vendor request through a masked group.
2026-11-11 17:54:42 +08:00
yetone c36202ae5d routing: removing every found group turns found groups off, so no new one comes back (xwang_sh on X)
Found groups live only as removal records ({"id","hidden":true}) in
providers.json; removing them one set at a time left every model a
provider listed later to make a new group, and taking the records out by
hand brings the groups back. A user who removes every found group (the
Routing page's select-all Remove, `magpie group rm` of all) has set "none":
DeleteGroups now ends with SetAutoGroups(false) when no found group is left
shown. The removed records stay, found groups on again restores them as they
were. The GUI delete runs through agent.Reseat so an agent set to one is
moved to its model, as the found switch does.

Run on mote: go test ./internal/provider ./internal/gui ./internal/cli
./internal/tui all ok; go vet darwin, windows (provider, gui), linux
(provider) clean; gofmt clean. TestDeletingEveryFoundGroupKeepsThemOff is
red with the new branch disabled by hand ("on true, shown [auto-z]").

Not tried: a real GUI click-through; a hand edit of providers.json (the
records going back is by design, documented); WebDAV sync of a removal.
Full suite not run before the tag.
2026-11-11 17:53:05 +08:00
yetone 961427f122 codex: the ChatGPT app left on "hit a snag" after a switch off a used-up account is reopened without the Restart tick (RealZeroP27 on X)
RealZeroP27 (switch only, requests not through magpie, ChatGPT app on
macOS 27.2.1): when the account ran out and magpie signed Codex in to the
next one, the app showed "ChatGPT 遇到了问题 请重试" and only a manual
restart cleared it.

Cause: magpie did end the app-server (a switch off a used-up account
always does), and the signed-in ChatGPT app fails on the one it starts
next, a fault in the app (codex_app_crash.go, #4550). magpie reopens the
app on that page only with "Restart the Codex app" ticked, which ships
off (15acba534, Michael25651150), so the page stayed.

Now an end made for a used-up account (a switch off one, or the takeover
in; crashSpent) has the app quit and opened once on that page whatever the
tick says: the app was greyed on that account already and the page is all
its window shows. Every other end (route change, switch among accounts
with room) still waits for the tick. The page check (no composer, no turn
or request since) is unchanged. The Windows reopen when no app-server came
back (codexAppGotNone) is unchanged and stays tick-gated.

This partly reverses 15acba534's gate for the used-up case; a product
call. A quit of a working app is still never done unasked.

Run on mote at this head:
- go test -count=1 ./internal/provider ./internal/agent: ok.
- go vet ./internal/provider on darwin, GOOS=windows, GOOS=linux nogui;
  gofmt -l clean.
- TestCodexAppReopenedAfterASpentEndUnasked (switch, takeover) is new;
  TestCodexAppNotQuitUnasked now ends for a route change.
Broken by hand: spentEnd forced false -> the new test red in both subtests.

Not tried: the real ChatGPT app, the Windows box. No GUI file touched.
2026-11-11 17:12:44 +08:00
yetone aebcfb93f7 providers: GMI Cloud is a preset (aiandcloud on X)
aiandcloud asked for GMI Cloud. It is now a preset in Add: OpenAI chat
completions at https://api.gmi-serving.com/v1, the key as Bearer, its model
list read from /v1/models, the gmicloud icon the GUI already ships, and its
console as the keys page. Only Chat is set: GMI's quickstart and LLM API
reference (docs.gmicloud.ai) name no Responses or Messages endpoint. READMEs
list it; the icon is copied to the site.

Run: TestGMICloudPreset (preset fields, no Responses or Anthropic URL, an
import at the host becomes the preset) and go test ./internal/provider -run
'Preset|Import|Icon' on Linux (wsl-run); gofmt; GOOS=windows go vet of
internal/provider. No network in the test.
Broken by hand: not run (without the preset FromPreset errors).
Not tried: no GMI key, so no real chat call or model list; mote's disk is
full, so no macOS run; no full suite before the tag.
2026-11-11 16:42:53 +08:00
yetone cc588e7829 keys: a typed balance may be below 0, as a key the vendor let overdraw reads (AlanWang1027713 on X)
The balance a user types to calibrate a key (GUI pill, keyownbalance, magpie
provider key-balance) was refused below 0 with 'a balance is an amount from 0',
while the card itself already shows an overdrawn key as ≈-$1.84 after spending.
So a user whose vendor page said -1.84 could not type what it says. The bound is
now -1,000,000 to 1,000,000 in both currencies, in the GUI, the CLI parser and
checkOwnBalance (which also guards what is read from disk). A sign may come
before the currency's (-$1.84, -¥5) as well as after it. Credit that expires
stays above 0 (a grant is never negative). Refusal text and its zh, zh-TW, ja, de
strings say the new range.

Run (wsl-run, mote's disk is full): go test -run Own ./internal/provider green;
red on the old checkOwnBalance/ParseOwnBalance (5 parse cases fail). Not tried:
a real overdrawn key; macOS/Windows.
2026-11-11 16:33:41 +08:00
yetone fe8c05e0c8 agent: Claude's model variables hold Anthropic's own ids on Claude Code's own subscription, so Desktop's Code tab stops failing WebFetch (iryan_sun on X)
ANTHROPIC_DEFAULT_<TIER>_MODEL, ANTHROPIC_SMALL_FAST_MODEL,
CLAUDE_CODE_SUBAGENT_MODEL and the auto mode model stayed
"claude/claude-haiku-4-5[1m]" after the main model became an alias. A tier
variable can't be an alias of itself, so on this computer's own file a
Claude model of Claude Code's own subscription is now written as
Anthropic's bare id (provider.ClaudeBare): through magpie that id goes to the
same subscription (OwnRoute), and Anthropic knows it. Haiku has no 1M window,
so its [1m] mark is taken off. Read back, a bare Claude id is the
subscription's ref (ClaudeUnbare), so every field, the tiers' follow logic
and the gateway's stand-in read it as before.

Old files: a settings.json written with the prefixed ids is rewritten by the
next Sync (the check that already brought dashed spellings up to date), for
every user. Models of other vendors or a relay keep their ref: Anthropic has
no id for them. A distro's file and the claude-magpie launch file keep refs.

Run (wsl-run, Ubuntu, at the pushed head after rebasing on origin/main):
internal/agent -run "Claude|Tier|Folder" ok; internal/provider ok;
gofmt -l clean; go vet -tags nogui for linux, darwin and windows clean.
Before the rebase, the whole internal/agent package had two reds:
TestFolderVarsAreListed (BUN_INSTALL, fixed on main since) and
TestGrokInstalled (WSL2 binfmt, already #3548). Neither touches this change.
Real claude 2.1.316 with a fake upstream showed Desktop's
PROVIDER_MANAGED_BY_HOST sends the tier env as written, so prefixed ids go
to Anthropic.
Broken by hand: with ClaudeBare turned into a no-op,
TestClaudeModelVariablesAreAnthropicsOwnIDs fails on the bare ids and on the
Sync rewrite.
Not tried: the real Claude Desktop Code tab, a WSL distro user, real
accounts through magpie end to end. A non-Claude model or a relay-served
Claude model still has no Anthropic id, so its tier variable keeps the ref
and Desktop's Code tab still can't use it.
2026-11-11 16:02:17 +08:00
yetone 5a9b5720da library: a Remote magpie's skills and prompts can be used on the client (KoiLx0 on X)
A Remote magpie's editor has a new switch, Use its skills and prompts.
The remote serves its Library at GET /v1/magpie/library (local or shared
callers; a held key is refused; no MCP servers, which the MCP switch
already covers; borrowed items are never passed on). The client fetches
it every 10 minutes and once on switching on, and adds each skill and
prompt set as remote-<id>-<name>, recording a hash of what it wrote.
It only changes what still matches that hash: a skill or set of the
user's by the same name, one the user edited, and one the user removed
stay as they are; an update or drop moves the old copy to the backups;
switching off takes out what is unchanged. The first set becomes active
only when no prompt is active.

Run (wsl-run, magpie-wt/remote-library at the pushed head after rebase):
- go vet -tags nogui ./..., GOOS=windows and GOOS=darwin vet of library,
  provider, gateway, gui: clean. gofmt -l clean.
- go test ./internal/library ./internal/provider: ok. internal/gateway:
  TestReadOnlyKeyEveryRoute named the new route (fixed here, now ok);
  the package then ran to the end of a 30m wsl timeout on a slow box.
- TestBorrowRemoteLibrary and TestBorrowedSkillGoesWithTheRemote: broke
  by hand (the user's-own-skill guard turned off), TestBorrowRemoteLibrary
  went red with "kept []", restored.
- GUI remote-magpie.test.cjs (chromium + webkit): its new assertions for
  the switch pass, but the file is red on main before this change
  (#6099: line 160 and a layout assertion), so they ran in a copy with
  those two assertions relaxed. i18n tests ran in the same call.
Reds not mine: #6099, #6103 (TestSettingsSaveKeepsWhatItDoesNotSend).

Not tried: a real two-machine run; internal/gui and gateway full
packages to completion on wsl; Collect/Put (sync backups) still carry
borrowed items as ordinary ones.
2026-11-11 15:59:46 +08:00
yetone cfd49e36ae remote quotas: a Remote's cards follow its enabled models, one reading per account, loops dropped (748975219 on X)
A Remote magpie's quota cards ignored which models the Remote has enabled,
so providers it does not serve (Kiro, Codex) showed up, and an A to B to C
to A cycle grew paths like remote-B/remote-C/remote-A/remote-B/remote-C/kiro
with snapshots hours apart. catalog.Self() is random per run, so after a
restart the stale copies in other caches no longer looked like ours.

- catalog.loops: a magpie id repeated inside one Via is a loop, restart-proof.
- namedRemoteCards keeps only cards whose provider head is among the
  Remote's exposed model heads (none served: none; no list: all).
- CachedCards and RemoteCards keep one card per subscription account
  (kind, leaf provider, user): the newest complete reading, then the
  shorter path. Key plan and balance cards are not merged.
- keepRemoteCards evicts looped copies before caching.
- TestRemoteChainPassesOnCards: magpie3 now knows magpie2 alone, as the
  same account by two paths is shown once.

Run (WSL, magpie-desktop): gofmt -l clean, go vet linux and windows,
go test internal/catalog and internal/provider ok, gateway Remote/Quota
subset ok. Broken by hand: no enabled-model filter, no dedupe and no
repeated-id rule each turn TestRemoteCardsFollowEnabledModelsAndDedupe or
TestLoopsOnARepeatedMagpie red.
Not tried: a real A to B to C to A cycle in sandbox HOMEs (fake peer in
test), the GUI suite, win-run, the Usage page's own-versus-remote copies.
2026-11-11 14:50:03 +08:00
yetone 0c44b9ece4 agent: a dsh round builds the provider catalog once
keepDshWired's round ran outside any provider.Hold, so every
PublicRef, RenamedRef and Exposed it asked built every provider's
models again. With a real account, 158 MB of what magpie allocated in
its first minute was this round, 72.55 MB of it dshStartOnItsRoute's
four refs, all worked out before the first was looked up.

The round now holds the catalog for its whole run, and the start's
refs are worked out only when the one before isn't listed.
provider.EntriesBuilt exposes the build count for the test.

Test: TestDshRoundBuildsTheCatalogOnce gives the start an auto ref
no model has and counts catalog builds in a writing round. On the
old dsh.go it is red with 3 builds; with the change, 1.
2026-11-11 14:43:25 +08:00
yetone f5e1b10913 settings: longest context can hold a model's own window too (WJaunita45604 on X)
v0.1.3681's Longest context left a window the user set for a model, or "*"
on its provider, alone even when longer. Settings > Models > Routing now has
a menu beside the field: "Models without their own" (the default, as before)
or "Every model". In both modes the shorter of the cap and the user's own
window is told; they differ only when the user's own is longer (own keeps it,
every model brings it down). Settings.ContextCapAll, Settings.CappedOwn,
POST /api/settings/context-cap-mode {all}, magpie model context-cap all|own.
Applied in provider.windowIn (so /v1/models, catalogs, compaction), Codex's
CodexNativeWindow/CodexWindow (the list's ETag tag carries the mode) and the
gateway fallback window. i18n in zh, zh-TW, ja, de.

Run (wsl-run, mote's disk was full): provider (full), settings, settingsapi,
codexcat packages; cli -run ContextCap; gateway -run ContextCap|ModelsList;
GUI context-cap, i18n-keys, model-load, settings-places, settings-general in
chromium and webkit; TestCoreScriptBudget; gofmt; go vet nogui and
GOOS=windows vet. Broken by hand: windowIn's CappedOwn removed turns
TestContextCapAllHoldsTheUsersOwnWindowsToo red.
Not tried: the whole Go and GUI suites, a real Codex reading the list, macOS
or Windows runs, GUI in zh-TW/ja/de beyond the i18n-keys check.
2026-11-11 14:28:17 +08:00
yetone 4a7d222dc8 providers: an OpenCode Go key takes the usage cap an account does (@wanggenjidev on X)
Backend only; GUI follows. Tests: provider TestKeyTakesUsageCap, gateway TestKeyUsageCapPassesTheKeyOver (red with the hold removed by hand).
2026-11-11 14:18:10 +08:00