ac4af582301a4e8a29245dbba767eba31334ddf9
2027
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1a44670302 |
gateway: a long Codex session full of images is read up to 512 MB, and magpie's 413 says it is magpie's limit and to /compact (#1422, NeoPengZhile)
NeoPengZhile's Codex (signed in to ChatGPT, through /backend-api/codex/ responses) got "413 Payload Too Large: request body exceeds gateway limit" on all five reconnects in a long session that had read many images; a new session worked. Codex sends the whole conversation every turn, screenshots inline as base64, zstd-compressed; magpie's limit is on the decoded body and was 128 MB, while magpie compresses a ChatGPT turn again on the way out, so the backend sees about what Codex alone would send. The message didn't say whose limit it was or what to do. What changed: - request_bounds.go: defaultBodyLimit 128 MB -> 512 MB (decoded, which also sets the zstd decoder's memory cap). Every route that reads with the default gets it, keyLimited's read among them, so a limited key isn't held to the old number first. Routes with their own lower limit (System One 16 MB, a Claude subscription's 16 MB) keep it. - overLimit: magpie's own 413 says "request body is over magpie's gateway limit of 512 MB (decoded); the provider was not asked". - gateway.go writeError: the hint added to a 413 now says it is a byte limit, not the model's context, and to /compact (Codex, Claude Code) or start a new conversation. - request_bounds_test.go: TestRequestBodyTooLarge uses defaultBodyLimit+1 in place of a literal 129 MB. - docs/subsystems/gateway-routing.md says so. Run: go test ./internal/gateway/ -count=1 (ok, 354s), with the new TestImageHeavyCodexTurnIsRead (a zstd body of inline images decoding to 136 MB on Codex's backend path, read with the default limits) and TestOverLimitSaysWhoseAndWhatToDo; go test ./internal/gui/ (ok); go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows; gofmt -l. Broken by hand: the limit back at 128 MB -> TestImageHeavyCodexTurnIsRead fails with the 413; the old "exceeds gateway limit" message, or the old hint, -> TestOverLimitSaysWhoseAndWhatToDo fails. Not tried: the reporter's real session, or how big a turn the ChatGPT backend itself takes; the test's images repeat, so its wire size is far smaller than real screenshots'. Peak memory for a turn near 512 MB was not measured. |
||
|
|
c6da41b04c |
agent: an IDE plugin's ~/.copilot or ~/.qoder-cn isn't taken for the CLI (#1495, v5tech)
v5tech traced two agents listed with no CLI installed to the JetBrains
plugins that write the CLI's folder:
- GitHub Copilot's JetBrains plugin writes ~/.copilot (ide/, instructions/,
prompts/, agents/, skills/, hooks/; the paths are in its jar). Copilot
CLI was detected by that folder alone.
- Qoder CN's JetBrains plugin fills ~/.qoder-cn (its indexer in
shared_client/, app/, plugins/) and writes a settings.json holding only
{"enabledPlugins":{...}}, which is the CLI's Path, so the CLI was found
by its "config file".
What changed:
- Copilot CLI sets dirShared, as omp does for Pi's folder: settings.json
or the copilot command still finds it.
- Agent gets pathOwn: when set, the file at Path counts only if it says
the file is the agent's. Qoder (both builds, one qoderAt) sets dirShared
and pathOwn = !qoderPluginOnly: a settings.json that parses as an object
of enabledPlugins alone is the plugin's. Any other key, {}, or a file
that can't be read or parsed still counts (unknown is not "the
plugin's"), and so does qodercli / qoderclicn on PATH. The global build
is held to the same because the code and the plugin are shared; that
the intl plugin writes ~/.qoder the same way is by analogy, not seen.
- docs/subsystems/agent-wiring.md says so.
Run: go test ./internal/agent/ -count=1 (ok, 226s), including the new
TestCopilotFolderFromAnIDEPluginIsNotTheCLI and
TestQoderSettingsFromAnIDEPluginIsNotTheCLI (the reporter's folders,
then the command on PATH, then the CLI's own settings).
Broken by hand: Copilot's dirShared off -> the Copilot test fails; Qoder's
pathOwn nil -> both qoder subtests fail; Qoder's dirShared off -> both
fail.
Not tried: a real JetBrains plugin or Qoder CLI; WSL (its probe counts the
distro's folder and isn't changed; a Windows JetBrains writes the Windows
home, not the distro's).
|
||
|
|
bf60d32bde |
gateway: a key set to a protocol its provider has no URL for is said on Routing and in the editor, not passed over quietly (#1702, edussss)
edussss set a relay key to Responses only on a provider with a Chat URL
and no Responses URL. perKeyBarred skipped the key (no endpoint for its
protocol), every key was skipped, so the provider was tried whole and the
request went out on Chat with nothing saying why. The owner: it shouldn't
fall back quietly.
Requests are still served on the URLs the provider has (so working setups
keep working), but now it is said:
- fallback.go: perKeyBarred remembers the protocol of the first key it
skipped for having no URL, and the whole-provider candidate carries it
as noURL.
- trace.go: Weighed.NoURL, so the Routing page sees it.
- routing.js: the row and the activity line say "key set to {api} only,
no {api} URL · sent on the others".
- app.js/app.css: the editor's key row shows an amber "No {api} URL" chip
(keyLacksURL) with a title that says how to fix it.
- i18n.js: the three strings in zh, zh-TW, ja and de.
- docs/subsystems/providers-accounts.md: the Keys row says so.
Run: go test -run 'TestKeyForAProtocolWithNoURLIsSaid' ./internal/gateway/
(the reporter's case: upstream /v1/chat/completions with k-resp, NoURL
"responses"; with an Any key added it goes to k-any and NoURL is empty);
key-nourl.test.cjs in chromium and webkit, en/zh/zh-TW/ja/de, at 420 and
1000 wide, no click-scroll, no sideways scroll: 40 pass; with i18n-keys,
gui-zh-tw/ja/de, key-copy, key-weight, key-weight-fit, key-import,
routing-key-windows, routing-keys-fold, proto-menu-overflow, nokey-editor
and ledger-protocol: 174 pass, 0 fail.
Broken by hand: without the noURL mark the Go test fails (noURL = "",
want "responses"); with keyLacksURL/noURLWord removed chromium fails 20
of 20.
Not tried: a real relay, or the GUI against a live gateway.
|
||
|
|
d3d1605c2c |
sessions: Kimi Code's own calls reach Usage, read from its wire files (#1607, infinitr0us)
Usage counts the gateway's calls and the calls the agents' own session files record (sessions.Calls). Kimi Code had no reader, so its calls straight to api.kimi.com on Kimi's own sign-in never showed (the reporter's 47 k3 calls of one session on 2026-10-11). The reader (calls_kimi.go) is built from the redacted real wire files infinitr0us shared from two machines (protocols 1.0, 1.4, 1.5; text replaced, every id, model and number kept) and their notes from Kimi Code's source. It reads every agents/*/wire.jsonl under $KIMI_CODE_HOME/sessions, else ~/.kimi-code/sessions (as agent.KimiDir finds the new Kimi Code), main and subagents, ses_* folders included. One call per usage.record: inputOther, inputCacheRead and inputCacheCreation go to Input, CacheRead and CacheWrite, output as is, the record's own model and time. Nothing is paired with step.end, since 1.4 and 1.5 write them in opposite orders and the June 1.4 build has no messageId or llm.request. A model beginning "magpie/" (magpie's own entry in Kimi's config) is skipped: the gateway counted it. kimi fork copies the parent's records unchanged, so a call is keyed by agent (agentId, else its agents/<id> folder), time, model and usage, and Calls counts a key once. It is a whole-file call source (callSources, wholeCallReaders) and the folder is watched (Dirs). The subsystem page gets the list of call readers. Fixtures (testdata/kimi-code) are the reporter's files cut to the lines a call is read from, each line verbatim (50 KB; one of the July session's eight agents kept). Run: the reader over the reporter's whole, untrimmed files gives exactly their README's totals (32/2,841,972/12,283; 151/7,025,587/122,782; 6/147,822/2,009; 10/338,328/2,176; 0 for the four others). TestKimiCodeCalls (both homes), TestKimiCodeSkipsCallsThroughMagpie, TestKimiCodeForkCountsOnce, TestKimiCodeBrokenFiles (cut mid-record, empty, junk, null/negative/timeless usage) pass. Broken by hand, each goes red: no magpie skip, no key, key without agent, no negative or time guard, main only, KIMI_CODE_HOME ignored, cache read dropped. go test -tags nogui ./internal/sessions ./internal/usage ./internal/cli ./internal/gui under a sandbox HOME, gofmt -l, go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet. Not tried: a live Kimi Code run (fixtures are the reporter's real files, not a sandbox capture), a successful call through magpie (the magpie-routed record in the test is the reporter's quoted 1.5 line with a magpie/ model), a compaction record (usageScope "session", none in the files), Kimi Code in WSL (not read), Windows paths at runtime. A subagent's calls carry the session but no Subagent field. Thanks to infinitr0us for the write-up from Kimi's source and the redacted wire files. Reported-by: infinitr0us |
||
|
|
a43fa6809b |
library: two changes in one millisecond each get a backup folder of their own (#1743)
liubing reported on #1743 that TestRemoveFoundEntryEveryFormat failed in a full run on Linux, the backup read holding another format's content, on an unmodified main too. The backup folder was named by the millisecond and taken as this change's own: a second change in the same millisecond wrote into the first's folder, its file kept under its folder's name since the first's held the name, and the copy at the name the change wrote was the other change's. The test's loop runs one change per format, all named config.json, and on a fast machine two land in one millisecond. A user's two quick changes did the same: the backup the second change named wasn't its own. freshBackup makes the folder with os.Mkdir, adding -2, -3... when the millisecond's is taken. pruneBackups' sort keeps them in order. Siblings checked: the skill backups (keepLibrarySkill, keepReplaced, setAside, carry's and RemoveSkills' aside) use per-skill paths under the stamp; setAside already steps past a taken name, and the others only collide on the same skill in the same millisecond, where move fails loudly rather than mixing; they are left as they were, since a folder each would split one change's skills over many folders. Run: go test -tags nogui ./internal/library/ ok on macOS and in Docker golang:1.26.8 GOTOOLCHAIN=local (also -count=30 of the two tests). The original red didn't show in Docker in 100 runs; it was reproduced by injecting a minute-wide stamp, which turned TestRemoveFoundEntryEveryFormat red on the old code and leaves it green with the fix. Broken by hand: os.Mkdir -> os.MkdirAll (no claim on the folder) turns TestBackupsInOneMillisecond red. |
||
|
|
9935119f1d |
sessions: search finds Cursor and OpenCode sessions read from their stores, and a Cursor chat's system prompt isn't shown as said (#1743)
Follow-up to liubing's #1743 patch, which put cursor and opencode in HasTranscript. That moved their search from magpie's recorded transcript to SearchSession, whose byte prefilter (mayHold) reads s.Path. For these agents s.Path isn't the conversation: - OpenCode's JSON storage: the session info file, without messages, so every word missed; - OpenCode's and Cursor's SQLite stores: the newest pages are in the -wal, so a live chat's latest turns missed. linesFile now skips the prefilter for them (a Cursor .jsonl still gets it). cursorTranscript also handed the CLI store's system message ("You are a coding agent.") to the transcript as a said part; system messages are skipped, as the listing already does. The patch's tests commit left TestSearchSessionWithoutATranscript red (it used cursor as the agent without a transcript; now gemini). sessions-empty-range.test.cjs runs in every language, de at 420px. Run: go test -tags nogui -count=1 ./internal/sessions/ ok, and -race ok; sessions-empty-range 10/10 (Chromium+WebKit, en zh zh-TW ja de); sessions-today/overview/toolbar/search/manage/calendar-fill/paging GUI tests pass. Broken by hand: prefilter always on -> TestSearchOpenCodeFiles and TestSearchCursorLiveChat red; system skip removed -> TestSearchCursorLiveChat red. Also broke the patch itself: editor files not appended, readOnly Delete guard, stats message dates, CLI dedupe, HasTranscript entries, parseCursor readOnly dispatch, and the "All sessions" button (via MAGPIE_TEST_APP_JS); each went red. Co-authored-by: liubing <lb0806@foxmail.com> |
||
|
|
1cd8140047 |
sessions: read Cursor editor history and Cursor/OpenCode conversations (#1743)
Discover editor project transcripts and cursorDiskKV histories without modifying the source. Share one SQLite/WAL snapshot across a scan, refresh metadata changes, deduplicate CLI histories, and reject deletion of read-only sessions. Count message-only sessions and expose an all-dates action when a filter hides existing history. Read Cursor CLI text, reasoning and tool parts, and OpenCode v1/v2 transcripts through the existing transcript API. |
||
|
|
296b63f8d6 |
usage, gateway: tests for the #1463 rebase: a priced row keeps its reasoning evidence, and a summary after an endpoint fallback stays hidden
Follow-up to congee949's rebased dfc24632 (#1463, streamed reasoning speed). - TestPricedRowKeepsReasoningEvidence: the Requests page reads gateway rows through blockPricer, which sets swapKnown (64) on every row. The patch put ReasoningHidden on bit 64 too; on main that would have read every priced row as hidden, so a tool-only reply with no reasoning, and paced visible reasoning, lost their speed on the Requests tab. The rebase gave ReasoningHidden its own bit (256, Flags widened to uint16); this test prices visible, tool-only and hidden rows, raw and packed, and checks the flag and the speed read back. - TestSummaryAfterEndpointFallbackStaysHidden: a Messages client, a model answered on /responses after /chat/completions said it isn't served there. call.To still reads Chat, so hidesReasoning(call.To) doesn't see the summary; only streamTranslated's summaryUpstream marking does. With no reasoning count the 1500 output tokens were otherwise timed from the first summary delta. Nothing covered that marking before. - reasoning-speed.test.cjs: the "no reasoning: 500 in 5 s" comment had been joined onto the redacted row; put back on its own row. - docs/subsystems/gui-shell.md: the flag bit, the fallback marking, the two tests. Run: go test -tags nogui -count=1 ./internal/usage/ and the gateway's reasoning tests; reasoning-speed.test.cjs in Chromium and WebKit (en, zh, zh-TW, ja, de), 10/10. Broken by hand: rowReasoningHidden = 64 turns TestPricedRowKeepsReasoningEvidence red (visible and tool-only rows read hidden, 0 tok/s); summaryUpstream forced false turns TestSummaryAfterEndpointFallbackStaysHidden red (1500 tokens in 314 ms). Co-authored-by: congee949 <c86474321@gmail.com> |
||
|
|
2d3b33bb78 |
usage: time tool-only replies only with visible reasoning evidence
Revises #1463 after the hidden-reasoning inflation review. Keep answers separate, retain evidence in routes and cached ledger rows, and exclude sealed or summary-only reasoning even without a token breakdown. Sync the backend and both GUI formulas. Checked real WorkBuddy DeepSeek, Codex and Claude bridge responses in an isolated HOME; sanitized timings and failures are in docs/verification. Chromium/WebKit speed regressions pass (20 tests, five languages). New edge regressions and loop-order check pass under race repetition. Restoring the old formula or removing the hidden guard fails TestVisibleReasoningSpeed. macOS/Linux/Windows vet/build pass. Full-suite verification is recorded in the issue at this head; inherited proxy/Bun 1.3.14 failures are retained, with clean Bun 1.4.2 rerun in progress. No installed app replacement. Rebased onto main by yetone (#1463). Conflicts with main's Own/Retried/ Queued/Tries row fields, HandedOn and the Codex speed floors were resolved by keeping both. The packed row's ReasoningHidden bit was 64, which main has since given to block_price.go's swapKnown, and main's rowHandedOn took 128, filling the uint8: Flags is now uint16 and ReasoningHidden is bit 512 (rowReasoningHidden; #1874's rowOwnCost took 256), read back in row(). The docs/verification notes and their sample JSON are left out of the tree; they stay on the contributor's branch and the issue. Run after the rebase: go test -tags nogui ./internal/usage/ and the gateway's reasoning/speed/TTFT tests, ok. |
||
|
|
cc93b566e2 |
gateway: Zed's test still checks is_error true on a real result, beside the mended orphan (#1558)
What changed: d1d45dd3 made TestZedToolResultSaysIsError's toolu_2 result an orphan turned to text, and its assertion went from [false true] to [false]: nothing checked any more that a result with is_error true goes to Zed's cloud with it (yetone/magpie-releases#9). The fixture's assistant now makes toolu_2's call, so both real results keep [false true], and a separate toolu_9 result with no call checks the orphan goes as its text. The pairing tests also check the synthetic result is is_error, and a new TestMessagesSecondAnswerDropped checks a call answered twice keeps only its first answer. docs/subsystems/gateway-routing.md gets a bullet for the Messages build's mending, beside the Gemini and Responses ones. Why: the patch's tests passed with is_error dropped from the synthetic result and with the second-answer rule removed. Run (sandbox HOME, private GOCACHE): - go test -tags nogui -run 'TestMessages|TestZed' ./internal/gateway/: ok - pairToolBlocks call removed: the six TestMessages tests and TestZedToolResultSaysIsError fail ("is_error: [false true false]", "what the lost result said is not kept"). - IsError dropped from the synthetic result: TestMessagesUnansweredCall GetsSyntheticResult fails. The duplicate's continue removed: TestMessagesSecondAnswerDropped fails ("user[A,A]"). Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
44b5b2b96b |
provider: a Claude usage ask invalidates an older read even in the same clock tick
Refs #1228. The original test fails with "a reading from before the ask
was kept". A temporary diagnostic measured identical UnixNano values for
the read's start and the later ask; that diagnostic is not shipped.
What changed:
- Count both whole-page and manual-card Claude asks with a generation.
Advance it under subscription then login cache locks, so publication
cannot check the old generation and then commit after the ask.
- Capture the generation before launching LoginUsage/SubscriptionUsage;
reject an older account read or leave the cards due for another read.
- Record each Claude /usage run's ask generation. Keep timestamps, the
zero sentinel, floor, idle behavior, saved-account scope and fallbacks.
- Document ordering and lock ownership in the providers/accounts design.
No tests, routing.go, account files or dependency versions changed.
Run on upstream
|
||
|
|
d4c2512d2d |
usage: apps report their own calls with POST /v1/magpie/usage/requests, backfill included (#1874)
What changed
- POST /v1/magpie/usage/requests (internal/gateway/usage_ingest.go) takes
one record or an array, in usage.jsonl's shape:
- the post may carry up to 5000 records and 32 MiB;
- t, agent, provider, model and rid are required.
Each field is checked: unknown fields, quoted numbers, negative or absurd
counts, a status outside 100-599, a cost over 10000 USD, and a t more
than an hour ahead or before 2000-01-01T00:00:00Z. Any fault refuses the
whole post with a 400 that names error.index and error.param, and nothing
is written. A past t is otherwise taken as given, so history can be
backfilled. The reply gives accepted and skipped counts and each
record's index, rid and status.
- Access: lanGuard's rule (this machine, or another with a key while
shared, behind the Host check). A browser page also needs a key, since
corsGuard lets localhost pages and Origin null through. A held key is
refused.
- usage.IngestReported writes under usage.mu to the same file as
usage.Append. Rows carry source "reported" and no caller key. A rid
already reported is skipped, as is one repeated in the post. The set of
reported rids is read back from the log: one scan after a restart (lines
without the reported mark aren't parsed), then only what was appended.
- Pricing: a record with cost keeps it (Record.OwnCost, the rowOwnCost
flag; packed flags widened to uint16). Otherwise it is priced at
magpie's prices.
- Display:
- SourceReported is a source of its own: RequestPage.Reported,
?via=reported, and Ledger now honours via.
- The Requests tab gains a fourth cell "reported by apps", shown once
there are some, and a "Reported" badge (en, zh, zh-TW, ja, de).
- Nothing live: Record.IsReported keeps reported rows out of:
- a key's budget/spend limit (budget.counts);
- window holds, and the log start that decides whether a window can be
reckoned (logSnapshot.firstOwn);
- gateway sessions and Vias;
- Codex's sealed answers and remembered model.
There is no OTel span, rate limit, rest or alert for them.
- Docs: gateway-sessions.md, reference.md (with a curl), integrating.md,
site integrate.html (en, zh).
Why: the reporter's apps call vendors directly, and their usage (and
history) should show on the Usage page without becoming live traffic.
Run, in a worktree with sandbox HOME and a private GOCACHE
- gofmt -l: clean.
- go vet ./...: darwin, GOOS=linux -tags nogui, and GOOS=windows.
- go test internal/usage, usageapi, budget, gateway, gui: ok.
- -race -count=3 of the new usage/gateway tests: ok.
- GUI with playwright 1.62.0:
- usage-ledger-reported.test.cjs, 26/26 in chromium and webkit (5
languages, 1180 and 420 wide, light and dark);
- usage-ledger*.test.cjs, ledger-*.test.cjs, usage-sum-whole,
usage-unpriced-sum and i18n-keys: all pass.
- Timings with 200k reported rows (47 MB log, darwin):
- 40 posts of 5000 took 0.40 s (worst batch 18 ms);
- the first post after a restart took 0.45 s (rid rescan), a later one
1.6 ms;
- the cold index build took 2.1 s (as for gateway rows);
- page all took 27 ms warm, page 30d 39 ms, all via=reported 0.53 s;
- summary all took 215 ms, 30d 20 ms.
Broken by hand, each went red, then restored
- Go: dedupe against stored rids; the restart scan; CostAt ignoring own
cost; the block pricer overwriting own cost; the Reported split;
fromBrowser's key rule; skipping bad records instead of refusing; the
max-records and body limits; the ingest lock (race); both locks;
firstOwn -> first; the IsReported guards in windowHolds,
buildGatewaySessions, buildVias, budget.counts and loggedAnswers.
- GUI: the fourth cell, the --vias column count and the badge class.
Not shown red on its own: the remote-no-key and evil.example refusals come
from lanGuard and corsGuard before the handler, so breaking only the
handler's own check stays green. The codex_memory guard is not tested
alone: a reported row has no Requested there anyway. Not tried: a real
client against a live gateway, Windows/Linux runs of the tests, the full
GUI suite.
|
||
|
|
abdc4b113d |
netproxy, provider, gateway: every request to the ChatGPT backend goes over HTTP/1.1, magpie's own too, not only the gateway's turns (#1700)
|
||
|
|
d0e412e7a6 |
library: a checked MCP server's PWD is home too, and #1727's cwd test holds on macOS (#1727)
The previous commit starts the check's server in home. Its own test failed on macOS with that fix in: the child reported /private/var/folders/.../magpie-test-home-N and HOME was /var/folders/.../magpie-test-home-N, the same folder spelled through macOS's /var symlink, compared as strings. The test now compares the folders with os.SameFile. exec sets PWD to Dir by itself only when Env is nil, and the check sets Env, so the server ran in home with PWD still naming magpie's own folder; a shell-script server that reads $PWD would see the folder the fix moved it out of. The check now sets PWD=home with Dir (not on Windows, which doesn't use PWD, as exec does), before the server's own variables so one it sets still wins. The two subtests now give each run a home of its own (t.Setenv HOME and USERPROFILE) and move the process with t.Chdir, so the "needcwd" fake's ./logs goes with the test instead of staying in the package's shared test home, and nothing is left in another cwd when a subtest fails. The read-only-cwd subtest also checks that ./logs landed in home: Windows doesn't enforce a folder's read-only bit, so that is what makes it fail there without the fix. Run (sandbox HOME, private GOCACHE): TestCheckStdio -count=3 on macOS; the whole internal/library package. Broken by hand: without cmd.Dir both subtests fail (wrong folder; "mkdir logs: permission denied"); without the PWD line the cwd subtest fails on its PWD. On the Windows box (windows/amd64 test binary): TestCheckStdio passes, and without cmd.Dir both subtests fail there too (the server ran in the test's temp cwd, and ./logs wasn't in home). Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com> |
||
|
|
f31ae38aeb |
provider: Xiaomi MiMo is priced at xiaomi's list price, not its Token Plans' $0, and pay as you go looks only in xiaomi (#1873)
mengyianx found every pay-as-you-go MiMo call counted at $0.000: models.dev's xiaomi-token-plan-cn, -sgp and -ams list all nine models at cost 0 (the plan's per-token charge, not the model's price), the preset's catalog was "xiaomi-token-plan-cn, xiaomi" at every region, and catalog.PricedBy takes the first catalog with a cost field. makerCatalogs puts the plan catalog ahead of xiaomi too, so the maker fallback gave $0 as well. What changed: - membershipCatalogs (never read for a price) gains the three xiaomi-token-plan catalogs, as #1370 did for Kimi Code. That covers ListPrice, MakerPrice and PricedName through makerPriceCatalogs. kimiCodeMember now checks a list of Kimi Code's plans of its own (kimiCodePlans), so a Xiaomi provider isn't taken for Kimi Code and its ids aren't mapped to Kimi's. - Each Xiaomi region names its own catalog: plan-cn/sgp/ams "xiaomi-token-plan-<r>, xiaomi", pay as you go "xiaomi" alone. A plan user is priced at the API-equivalent price, the same meaning as #1370. - PricedBy is unchanged: a catalog that lists a model at $0 still prices it at $0 (nvidia, modelscope have truly free models). - docs/subsystems/providers-accounts.md says so. Providers saved before this: the preset's own catalog stays "xiaomi-token-plan-cn, xiaomi", the same string an existing provider saved with the old default holds. normalize already lets a catalog that equals the preset's or one of its regions' follow the region the provider is at (the Tencent Cloud mechanism), on every read, so an old default at pay-as-you-go reads as "xiaomi" and at Singapore as "xiaomi-token-plan-sgp, xiaomi"; nothing is written to providers.json until the user next saves it. Any other catalog the user typed is kept as typed, and is priced right anyway because the plan catalogs are out of pricing. The one value that can't be told apart is a bare "xiaomi" typed at a plan region (the issue's workaround, which was for pay as you go): it equals the pay-as-you-go region's catalog, so it reads as that plan's "xiaomi-token-plan-<r>, xiaomi". Its prices are identical either way; only the model-metadata lookup order differs. That is the existing rule for every preset with region catalogs, kept rather than special-cased. Siblings: scanned the models.dev cache (read only) for catalogs whose priced models are all or mostly $0. Of those, only kimi-code-plan-* and xiaomi-token-plan-* are named by any preset or region. stepfun's *-step-plan catalogs carry no cost at all, so they never shadowed a price. alibaba/minimax/zai/zhipuai/volcengine/tencent coding and token plan catalogs are all-$0 on models.dev but no preset uses them. Tests (internal/provider/xiaomi_price_test.go, fixture testdata/xiaomi_catalog.json cut from models.dev's real entries): - TestXiaomiListPrice: every region, the old default, a user's own catalogs: mimo-v2.6-flash $0.14/$0.28/$0.0028, mimo-v2.6-pro $0.435/$0.87/$0.0036; MakerPrice; EffectivePrice of a saved provider; a relay's own $0 model ahead of xiaomi stays $0; a Xiaomi provider is not a Kimi Code member. - TestXiaomiRegionCatalogs: each region resolves to its catalogs from the preset's, the old default and another region's; import links at each region; FromPreset; a user's catalog kept at two regions. Broken by hand, each red, then restored: - membershipCatalogs back to Kimi only: TestXiaomiListPrice FAIL, plan regions and MakerPrice at $0. - region catalogs removed: TestXiaomiRegionCatalogs FAIL (api with the old default stays [xiaomi-token-plan-cn xiaomi], imports at sgp/ams get cn's). - both: TestXiaomiListPrice FAIL, api with the old default at $0 (the reported bug). - kimiCodeMember on membershipCatalogs: FAIL "a Xiaomi Token Plan provider counts as a Kimi Code membership". - PricedBy's exact match skipping all-zero costs: FAIL "relay mimo-v2.6-flash: ... want its own $0". Run: gofmt -l (nothing); go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows; go build on all three; go test -tags nogui -count=1 ./internal/provider ./internal/catalog ./internal/cli ./internal/gui ./internal/usage, all ok, in a sandbox HOME with pinned caches. Real use: built binaries before and after, sandbox HOME with a copy of the real models.dev cache and a providers.json holding the reporter's saved state. `magpie model price xiaomi/mimo-v2.6-flash` printed $0/$0 before and $0.14/$0.28 after; an old-default provider at Singapore went $0 -> $0.14/$0.28 and shows catalog "xiaomi-token-plan-sgp, xiaomi"; one with the user's "openrouter, xiaomi" kept it; providers.json was byte-identical afterwards. Not tried: a real MiMo key or call, the GUI editor's region switch, the full go test ./... suite. Co-authored-by: mengyianx <106875577+mengyianx@users.noreply.github.com> |
||
|
|
841af36bfc |
gateway: models the user disabled are refused on every route, and leave every list (#1867)
oxsean asked for one place to turn a model (claude-fable-5) off for good:
not reached by a direct request, an old session, a routing group member,
a fallback, a sub-agent, count_tokens or a decision model.
What changed:
- settings.DisabledModels: patterns, an exact id or a glob (* any run, /
included; ? one), matched ignoring case against provider/model, the
bare id and its last segment (provider/disabled.go). Empty by default,
so nothing changes for anyone who doesn't set it.
- Lists: buildEntries (entriesOff) leaves a disabled model out of the
catalog, so /v1/models, agents' model files and pickers, Codex's list
and every group go without it; membersIn skips it as a member, Deciders
as a decision model; codexModels drops Codex's own disabled slugs and
codexListTag changes so Codex refetches.
- Requests (gateway/disabled.go): 403 "model <id> is disabled in magpie"
in each API's error shape, at #882's choke points: serve (idOff),
perKeyBarred (no candidate: group next member, provider Fallback),
count_tokens and Gemini :countTokens, serveSystemOne,
serveDecisionGroup and postDecide, draw/video/embeddings, and
codexBackend for Codex's own bare models. A group with a member left
goes on without it; one with none left is refused naming them. A bare
id the catalog no longer has is refused as disabled, not 404. A Codex
sub-agent pick onto a disabled model stays on its lead's model.
- An unreadable settings.json is never "none disabled": the list read
last stays; with none read, every request is refused; nothing is
written over the file.
- CLI: magpie model disable <model|glob>..., enable ..., disabled
(list-disabled).
- GUI: Settings > Models > Disabled models: each pattern with the models
it matches now and Enable; Disable... opens the model picker, which
also takes a typed glob. Says only requests through magpie are covered.
POST /api/settings/disabled-models; POST /api/settings keeps the list.
Strings in zh, zh-TW, ja, de.
- docs/subsystems/gateway-routing.md: Disabled models section.
What was run (worktree at origin/main
|
||
|
|
1f0ff81dfc |
agent: Grok App's own route picked in magpie is taken, and Disconnect can put one back; a sync that isn't connected writes nothing (#1625)
Follow-up to fjrtdk's commit before this one, which this keeps: magpie never names itself as Grok App's route. - Set refused every own route (errGrokAppRoute) while Options still offered them, so the picker showed choices that only errored. It also broke Disconnect: when unwire leaves no route (Use set it to magpie, nothing stashed), Disconnect sets connect.was's route back through Set, got the error and stopped half done. An own route now takes magpie's channel out and is written as [models] default, the way picking another provider leaves magpie on other agents. That route can't be magpie, so the App's sign-in is never touched. - Sync ran rememberRoute/releaseRoute before checking for the channel, so every user with Grok App installed but not connected got stash entries. Now it returns before them unless the channel is there or the route is still magpie (an older magpie's takeover to put back). - Check again warns when the route is magpie and the channel is gone, which that commit dropped. - The notice uses the App's own labels (Settings › Account, Use; ja 「使う」, de Einstellungen › Konto / Verwenden, from grok-app 0.2.40's settings.nav.account and prov.useThis) and says a chat can pick magpie's models in its model picker (composer_prefs_set, which doesn't move the route). - Sibling: rtk init has no grok agent for Grok Build either (rtk 311ebcb agents: claude codex copilot cursor droid gemini hermes opencode pi trae vibe antigravity), so Grok Build is in rtkNoHook too. Run: gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows clean; go test ./internal/gateway ./internal/agent ./internal/library -count=1 pass; node --test i18n-keys and agent-notice-lang pass. Broken by hand: that commit's grokapp.go fails TestGrokAppOwnRouteStays, TestGrokAppDisconnectPutsTheRouteBack and TestGrokAppSyncUnconnected; dropping the Check branch fails TestGrokAppSyncUnconnected; dropping rtkNoHook["grok"] fails TestRTKNoHookGrokBuild. Not tried: the Grok App GUI itself; the config format and behaviour are from grok-app 0.2.40's source. Co-authored-by: fjrtdk <fjrtdk@gmail.com> |
||
|
|
ea3d480edf | agent: Grok App keeps its own route; magpie is a custom provider under Accounts, and the Library writes instructions, MCP and skills on agent-home (#1625) | ||
|
|
125dad5cbb |
gateway: a codex provider used only through routing groups keeps the ChatGPT account's own models out of Codex's list (#1602)
With Codex signed in to ChatGPT, Codex asks magpie's /backend-api/codex/models
for its list, and codexModels passes the backend's own models through,
narrowed only by the codex provider's picks (CodexNativePicked) and the
Agents page's hides (CodexNativeHidden, built from Catalog()). A provider
set to "Only through routing groups" (Provider.Unlisted) has none of its
models in Catalog(), so neither filter saw them: all of the account's
models stayed in Codex's picker, and the Agents page had no Codex group to
hide. Every other agent's list is Catalog-based and already left them out.
provider.CodexNativeUnlisted says which of the account's models are kept
out of agents' lists: every one when the codex provider is Unlisted, and by
slug those a group with Unlists names. codexModels drops them (hidden
entries such as codex-auto-review stay, as with picks; a Codex reached for
failover alone keeps them, as it is handed no groups), spawnChoices drops
the same ones from spawn_agent's list, and CodexListTag carries them so
Codex refetches. gateway-routing.md says so.
Test: TestCodexModelListUnlistedForGroups (a group unlisting gpt-5.5 takes
gpt-5.5 alone; the provider Unlisted takes gpt-6-sol and gpt-5.5 and keeps
codex-auto-review; ETag changes; spawn_agent offers neither; own-only keeps
them). With codex_backend.go and codex_spawn_models.go reverted it fails on
all three checks. Not tried with a real ChatGPT sign-in and Codex app.
Run (sandbox HOME, private GOCACHE, worktree at origin/main
|
||
|
|
97dfed0f3e |
library: a site's well-known kit of skills is one group, by the lock's sourceBaseUrl (#1862)
WardLu (#1862): skills that `npx skills add` got from a site's /.well-known/agent-skills/ index were one group per skill. That was Feishu's lark-base, lark-doc and lark-sheets, and Fish Audio's fish-audio-api and fish-audio-sdk. readSkillLock grouped them by each skill's own sourceUrl (".../lark-base.tar.gz", ".../fish-audio-api/skill.md"). Now a lock entry with sourceType "well-known" is grouped by its sourceBaseUrl, read as host/path (wellKnownBase/siteOf): - the user, query and trailing slash are dropped, and the host is lower-cased without "www."; - so Feishu's three are open.feishu.cn/lark-cli/skills/regular and Fish Audio's two are docs.fish.audio; - a kit on the same host with a different base URL stays apart. Hosts are not merged. Fallbacks: - an older lock with no sourceBaseUrl takes the part of its sourceUrl before /.well-known/; - an entry with neither is grouped by its sourceUrl, as before. Two things this new key would otherwise get wrong: - Group again (RegroupSkills) tried every owner/repo-shaped key on GitHub. A kit one folder down a site (docs.example.com/kit) has that shape, so a key whose owner has a dot is skipped now. GitHub owners have no dot. - the heading's link sent a key with no path ("docs.fish.audio") to github.com. repoURL now opens it at https://docs.fish.audio. Run: - go test ./internal/library (all pass). New TestWellKnownKitGrouped uses the issue's base and source URLs for 3 Feishu + 2 Fish Audio skills, plus another kit on open.feishu.cn, an entry with no base, and a docs.example.com/kit kit that Group again must not fetch. - With the well-known branch disabled it fails, with the reporter's five one-skill groups. - With the dot check removed it fails on a GitHub fetch. - new TestWellKnownBase: a table of base and source forms. - skill-repo-groups.test.cjs now has a docs.fish.audio group that opens the site. It fails with origin/main's assets, which say "on GitHub". It and skill-regroup/skill-groups pass in chromium and webkit. - gofmt -l; go vet for darwin, linux -tags nogui and windows on internal/library. Not run: the reporter's real ~/.agents/.skill-lock.json. The issue quotes only these three fields of it. A row's own link still isn't its sourceUrl. |
||
|
|
9a34a784dc |
library: Collapse all / Expand all for the skill groups (#1862)
WardLu (#1862) asked for a way to fold every skill group at once in a library of many groups. Library > Skills now has a Collapse all / Expand all button beside the sort (foldAllButton in library.js): - without a filter it sets every shown group's kept fold (magpie.libSkillFolds), the same as clicking each heading; - while filtering it folds or opens only the groups the filter shows, until the filter changes (unfiltered), and leaves the kept folds alone; - it says Collapse all while any shown group is open, else Expand all; - it is hidden with fewer than two groups (A->Z, or a filter only one group matches); - a part inside a group keeps its own fold, and nothing is sent. skillHits/groupFolded pull out the rules drawSkills already used, so the button and the headings can't disagree. Strings in en, zh, zh-TW, ja, de. docs/subsystems/library.md's Skill groups row describes it. Run: - new internal/gui/tests/skill-fold-all.test.cjs: chromium and webkit, en/zh/zh-TW/ja/de, at 640 and 1180. 22/22 pass, three times. With origin/main's assets it fails in every case (no button). - the skill-*, library-* (skills side), pick/remove/import skill tests and i18n-keys, at concurrency 4: everything passes except pick-skills.test.cjs in WebKit. That test is red with main's own assets too (#1672, being fixed separately). - screenshots in German at 640 and 1180: the button sits in the heading row and wraps with it. Not run: a real library with many groups in the app window. I didn't check by hand that the scroll check fails when something scrolls. |
||
|
|
76c6580ea6 |
gui: a skill group's agent chips count only the skills magpie decides, and a row's chip for one an agent reads from ~/.agents/skills itself is locked (#1862, WardLu)
A skill kept in ~/.agents/skills is had by every agent that reads that
folder itself (SkillView.Always), whatever is ticked. Its row's chip said
so only on a click, greyed like a chip that can't take the skill, while
the group's chip counted s.agents alone. Turning the group off for Codex
then said "off for Codex" and left the row lit.
What changed:
- groupChips (group headings, parts and the Select bar) counts, gives and
takes only the skills magpie decides for each agent. agents-some is
sent, per agent, the names it doesn't read itself, so a skill Codex
reads from the shared folder is never sent for Codex.
- A chip whose agent reads only some of them itself says how many, in its
tooltip. After a click, the status says "Codex still reads 1 of them
from ~/.agents/skills itself".
- An agent that reads every one of them itself has a lit, locked chip, as
the row's is. It sends nothing, and a click says why.
- The group's heading says "N in ~/.agents/skills", with a tooltip naming
the agents that read it, before any click.
- A row's locked chip is lit, with a small lock on its corner, rather
than greyed out at .35.
- Nothing deletes from the shared folder or touches another agent's
config. Servers and hooks keep their own reach rules unchanged.
- Strings in zh, zh-TW, ja and de. docs/subsystems/library.md (Skill
groups) says it.
What was run:
- New skill-group-shared.test.cjs, in Chromium and WebKit; en, zh, zh-TW,
ja and de; 640px and 1180px:
- heading note;
- partial chip tooltip;
- the locked row chip's opacity and its lock;
- the post sent, the status, and parents and rows agreeing after a
click;
- All;
- a fully locked group chip sends nothing;
- no sideways scroll.
22/22 pass, twice. It fails on the old code (no heading note; Codex is
sent mango too).
- group-skill-chips, skill-parts, skill-groups, shared-skills,
every-skill, library-all, i18n-keys, library-own-folder,
skill-repo-groups, library-pick-remove and library-null-agents pass in
both engines.
- pick-skills is red in WebKit on origin/main's own assets too, the same
as here. It is out of date since
|
||
|
|
091593f7d3 |
gateway, gui: a WorkBuddy account the vendor restricted (403 11140) rests 2 hours as restricted, and Routing names the appeal as the way back (#1849)
WorkBuddy answers an account it restricted for unusual activity with
403 {"code":11140,"msg":"request illegal","displayMsg":{"en":"Your
account has been restricted due to unusual activity",...}}. failure()
read it as an unknown failure, so the account rested 1-10 minutes and
was asked again, refused, all day.
What changed:
- provider: WBRestricted knows the refusal by code 11140 (top level,
data or error; number or string; whole, so 111400 isn't it) or by its
displayMsg words. wbExplain ends the built-in's error with
WBRestrictedHint.
- gateway: a new failRestricted ("restricted") rests restrictedRest, 2h:
one refused request per account per 2h, and a lifted restriction (or a
misread refusal) comes back the same afternoon; Unrest lifts it at
once. It is read from the hint in the error (restrictedSaid; both the
built-in and the plugin translate the vendor's body before failure()
sees it, so the raw JSON never reaches it in a chat try), or from the
raw body only for a WorkBuddy candidate (restrictedRefused,
isWorkBuddy), since another vendor's 11140 is its own. Bare "request
illegal" is not matched. 11128 stays promptRefused and rests nobody.
The stale-allowance shortcut skips it, as it does model refusals.
drawsWorkBuddy now uses isWorkBuddy.
- plugin: @magpie-community/opencode-workbuddy-auth 0.1.17 (plugins
caf3908) ends the error with the same hint; the mover's min is 0.1.17
so keepMovedCurrent brings moved users to it.
- gui: Routing labels the try "account restricted by the vendor", says it
rests because only the vendor lifting it brings it back and to appeal,
shows the hint translated, and the account's row has "The restriction
is lifted — try it again" (POST /api/gateway/unrest). en, zh, zh-TW, ja,
de.
- docs/subsystems/gateway-routing.md says the above.
Run: gofmt -l (clean); go vet darwin, GOOS=linux -tags nogui, GOOS=windows
on gateway, provider, gui; go test ./internal/gateway ./internal/provider
./internal/gui (ok). New Go tests use the reporter's literal body through
the vendor's shape, the built-in's and the plugin's, a string code and the
words alone; another vendor's 11140, a non-WorkBuddy account with the same
body, 11128/14018/111400 not restricted; an e2e through the fake plugin
host where the restricted account is skipped by the next request.
Broken by hand, each went red: rest case removed, restrictedSaid removed,
the match unscoped, the raw match removed, the provider hint removed.
GUI: routing-wb-restricted (chromium and webkit x en/zh/zh-TW/ja/de x
1100/420px, 20 pass), routing-wb-refused, i18n-keys; after the rebase
every GUI test of the Routing page (107 files, both engines): 103 green.
The 4 red ones fail the same in WebKit on origin/main
|
||
|
|
5ca9dc19db |
usage, gui: a model says how many of its replies were ended for looping (#1858)
#1858 asked for recovery across turns when a model loops. magpie is a gateway and can't rewind the agent's session, so that is not planned now. What it can do is let the reader see which model loops. Each reply the loop guard ends (#1359) is logged with err_type "reply_loop", but Usage only counted it among the failures. usage.LoopErrType is now that type (the gateway's loopErrType is it), and Totals.Loops counts, among the failed requests, those ended for looping. A handed-on try is still no request. The Overview's model, agent, account and key rows and the Requests ranking say "{n} looped" beside "{n} failed", and the ranking's "Other" adds them up. Translated into zh, zh-TW, ja and de. Run: TestLoopsCountedPerModel (Overview groups, the ledger sum and Breakdown; red with the increment removed). go test ./internal/usage ./internal/gateway ./internal/gui; gofmt -l; go vet on darwin, linux -tags nogui and windows. The new usage-loops.test.cjs ran in chromium and webkit, 5 languages at 360 and 1100px, 20 pass; it fails 10 of 10 on HEAD~ assets. usage-*, ledger-*, own-requests, i18n-keys and gui-zh-tw/ja/de in both engines: 565 pass. Not run: a real looping model through the gateway (the logging path is unchanged from #1359). |
||
|
|
0102915fe0 |
gui: Tuned for you lets a compaction window be picked, each with its estimated extra tokens and compactions (#1860)
MrMengJ applied the advised 200K auto-compaction window and wanted 250K or 300K instead, seeing what each costs against the cheapest. A compaction row now has "Other window…", which opens the app menu (never a native select) with every value of the curve the card already replays. Each says its estimated extra tokens over the fewest (or "Fewest tokens" / "As few tokens") and about how many compactions it would have made over the range. The head says it is estimated from the reader's calls. The one picked is put in through /api/tune/apply like Use, with Undo. tune.Point gains compacts, counted by the same replayCompact that prices the point, so tokens and compactions come from one model. Run: go test ./internal/tune ./internal/gui; TestCompactCurveCountsCompactions (compactions fall as the window grows; the last point is close to Facts.Compacts). gofmt -l; go vet internal/tune on darwin, linux -tags nogui, windows. GUI: context-*, gui-zh-tw/ja/de, compact-at, click-scroll, i18n-keys in chromium and webkit, 144 pass. The new context-tune test covers 5 languages at 360 and 1100px: menu inside the window, 300K ticked, notes for 250K and 160K, picking 250K posts apply with no page scroll, Escape posts nothing. On HEAD~ assets context-tune fails 22 of 23. Not run: against a real Claude Code settings.json (the apply path is unchanged from Use). |
||
|
|
6e5f4fc97f |
gui: Tuned for you names its advice "Fewest tokens" and says a compaction window is a token estimate, not what the agent keeps (#1854)
cnlove7777777-art: the card called 230K -> 150K "best for you" on token savings alone, while compacting sooner may lose more of a long coding task. A retention benchmark isn't built now; the card says what it measures instead: - the advised value's label is "Fewest tokens", not "Best for you"; - a compaction row that advises a change adds "A token estimate only: it doesn't measure how well the agent keeps the task after a compaction. The lower the window, the more often it compacts." Not on a window already the leanest, nor on the cache lifetimes. - zh, zh-TW, ja, de translations; agent-wiring.md says the same. Run: context-tune.test.cjs (new assertions on label and caveat) passes in Chromium and WebKit, 360 and 1100 wide, en/zh/zh-TW/ja/de; on origin/main's assets it fails 11 of 12. context-*.test.cjs, gui-zh-tw, gui-ja, gui-de, compact-at, i18n-keys: 99 pass, 0 fail. Not tried in the real app window. |
||
|
|
8b9d63f58a |
usage: a cost total says how many calls it couldn't price, never reads them as free (#1856)
cnlove7777777-art's Kimi K3 Auto and GLM-5.3 Max calls had "no price",
and Usage's sum counted them as $0 with nothing beside it but a "+" and a
tooltip. Now every total that sums cost says the count:
- GUI: Overview's and Requests' heads read "≈$0.001+ 2 calls unpriced";
with nothing priced, the count alone (Requests showed nothing at all
before). Overview's calls tile adds "2 unpriced". Sessions, which prices
by model, says "1 model unpriced" in its head and cost tile. The count
stays at every width: the narrow and .tight rules no longer hide it,
and the head goes tight when the count would be cut, sum or not.
"no price for these models" is no longer shown, its key removed.
- CLI `magpie usage`: "≈$0.001+ (2 calls unpriced)". TUI Usage page: the
same after its cost.
- docs/reference.md: unpriced calls are left out, said beside the total;
magpie doesn't guess a variant's price from a similar name.
No variant price is mapped: models.dev lists neither "Kimi K3 Auto" nor
"GLM-5.3 Max", Zhipu's "Max" is a Coding Plan tier, and -fast variants
are 1.5x their base, so a suffix strip would be a guess. The existing
per-model price override (provider editor, `magpie model price`) covers it.
Run: go test ./internal/cli ./internal/tui ./internal/gui (ok);
TestUsageSaysCallsUnpriced and TestUsagePageSaysCallsUnpriced fail with
the fix taken out. usage-unpriced-sum.test.cjs (new) passes in Chromium
and WebKit, en/zh/zh-TW/ja/de, 360-1240px, and fails 5 of 5 on
origin/main's assets. Related GUI files (every test naming usageCost,
unpriced, effective prices, usage-head or "{n} failed", plus i18n-keys,
gui-zh-tw/ja/de, number-units, text-size, usage-ledger, ledger-protocol,
usage-range, mobile-web, phone-web, view-no-sideways): 655 pass; the
WebKit text-size foot case and routing-sessions fail the same run alone
on origin/main
|
||
|
|
2c30e5cee7 |
usage, gui: revert def3a41e3 until Fallmonkey says what context it missed
Fallmonkey asked on Discord (#feedback, 10-12 19:55) to hold the
single-call Codex threshold: "先别做?感觉你漏掉context了". It is not in a
release yet, so take it off main until the rule is agreed, rather than
ship a speed rule its own requester has paused.
This reverts commit
|
||
|
|
e0ecf01610 |
mcpauth: an MCP server's own OAuth app is called back at Claude Code's http://localhost:<port>/callback, so an app made for Claude Code signs magpie in as it is (新v学员 on Discord)
What changed:
|
||
|
|
05ef7bcec7 |
gateway: Cursor's built-in shows the model a tool's images, in the message after its results (#1861)
Found while checking every translation of a tool's images for #1861. cursorMessages wrote a tool result's text alone, so an image Codex's view_image (or any tool) returned never reached a model behind the Cursor built-in. Cursor's plugin already gets it, since magpie hands it a Chat body (seeLater: the result says the image follows, and a user message after the results carries it). The built-in now does the same: a result with images says "[The tool returned an image; it follows in the next message.]", and a user message after the results holds "[From the result of <name> (tool call <id>):]" and each image as Cursor's image block (cursorImage, the same block a user's own image already used). gateway-routing.md names Cursor among the translations. TestCodexToolImageCursor, from codex-rs 0.162's view_image output, fails on the old cursor.go and passes now. Run: gofmt -l; go vet darwin, linux -tags nogui, windows on internal/gateway; go test -tags nogui ./internal/gateway ./internal/provider (sandbox HOME, ok). Not tried: a real Cursor account. Whether Cursor's backend shows the model an image in a user message that follows tool results is taken from how it takes a user's own image, not seen. |
||
|
|
285e17b061 |
provider: a moved Kiro shows the model a tool's images, Codex's view_image among them (#1861)
simonsmh (v0.1.1215) saw Codex's view_image and screenshot results come back empty on a Kiro subscription. magpie hands Kiro's plugin an Anthropic body whose tool_result holds the image as a base64 image block, but the plugin (@magpie-community/opencode-kiro-auth up to 0.1.8) read only a tool_result's text, so the image was dropped and the model was told "(no output)". #369 had fixed this in the built-in for Claude Code; the plugin never got it. Kiro plugin 0.1.9 (magpie-community/plugins 66facac) sends a tool's images with the userInputMessage that answers the call, latest images only, as the built-in does. This raises the mover's min to 0.1.9, so keepMovedCurrent updates every moved user. tool_images_1861_test.go builds the request from what codex-rs 0.162 sends (FunctionCallOutputContentItem, view_image's input_image data: URL with detail "high") and checks the handoff to the plugin (the image in the tool_result, bytes intact) and the built-in Kiro body. Both pass on the old code too: the bug was in the plugin, whose tool-images.test.mjs fails 3 of 4 on 0.1.8. gateway-routing.md says how a tool's images reach the model on each translation. Run: gofmt -l; go vet darwin, linux -tags nogui, windows on internal/gateway and internal/provider; go test -tags nogui ./internal/gateway ./internal/provider (sandbox HOME, ok); the plugin's bun test (1152 pass) and scripts/check.mjs; npm view on registry.npmjs.org shows 0.1.9. Not tried: a real Kiro account, or real Codex against it. |
||
|
|
d01635797a |
gui: a window made wider or narrower keeps the reader where they were, or at the foot, while the page is laid out again, so Settings no longer ends 6px short of its foot across the sidebar's width in WebKit (#1672)
Cause: |
||
|
|
def3a41e36 |
usage, gui: a Codex turn of one call is measured only over a second and 100 tokens after its first token, else told as the least it wrote over the whole turn (Fallmonkey on Discord)
Fallmonkey's repro: a Codex turn whose first token came at 6.8 s (the model working) and the rest 0.2 s later in one network push read as thousands of tok/s from its session file. The promised rule, now in: - A Codex turn of one call read from its session file (source "log", turn TTFT known) tells a measured speed only when the window after its first token is 1 s or more and its body 100 tokens or more (usage.CodexWindowMs, CodexBodyTokens; Row.Decode, app.js ledDecode). - The floor from |
||
|
|
da085e3f78 |
gateway: joinToolRuns leaves the model's own step and every call-carrying item in place, and a result written before its call opens no run (#1752, #1822)
What: follow-up to Edward4226's joinToolRuns (previous commit), after review
against Codex rust-v0.162.1 and the code around it.
- An item carrying a call_id is never moved, whatever its type. Before, only
function_call/custom_tool_call/tool_search_call counted as calls, so a
local_shell_call (or any call type Codex adds) inside a run was moved after
results, its own output's among them.
- Before the run's first result, what the model wrote between its own calls
(reasoning, assistant text, a hosted tool's call) stays where it is. Before,
[call_a, reasoning, call_b, out_a, out_b] sent the reasoning after the
results, where it reads as the next step's: DeepSeek, whose step must lead
with its reasoning (reasonFirst,
|
||
|
|
accc8c0903 |
library: an MCP server whose sign-in has no client registration (GitHub's) is signed in to as the user's own OAuth app (新v学员 on Discord)
What changed: GitHub's remote MCP server (api.githubcopilot.com/mcp/)
points to https://github.com/login/oauth, whose metadata has no
registration_endpoint, so magpie's sign-in, which always registered
itself (DCR), could never sign in to it. A server now carries an
optional OAuth app, `oauth: {clientId, clientSecret, callbackPort}`,
Claude Code's names for --client-id/--client-secret/--callback-port
(oauth.clientId in its .claude.json). mcpauth.StartWith signs in as
that app without registering: PKCE S256, a loopback callback
http://127.0.0.1:<port>/callback (any port unless callbackPort is set),
client_secret_post with a secret (basic only when the server lists
basic alone), "none" without one.
Without an app, a server with no registration endpoint now fails with
mcpauth.ErrNoRegistration, which says to make an OAuth app with the
vendor (GitHub's under Settings > Developer settings > OAuth Apps, with
http://127.0.0.1/callback) and give it under "OAuth app" in the editor.
The editor opens those fields with Client ID focused when that error
comes back. Filling them makes Sign in read "Save and sign in", and
Cancel asks before dropping them, as the earlier Cancel fix does.
GitHub answers token errors with 200 and {"error": ...}; tokenRequest
now reads a 2xx body with `error` as the error, and bad_refresh_token /
incorrect_client_credentials count as a dead sign-in as
invalid_grant/invalid_client do.
Secrets: the client secret sits in library.json like header and env
values. A backup without keys blanks it; WithSecrets puts this
computer's secret back only for the same client ID. No agent file is
given the app. The TUI editor, which doesn't show it, keeps it on save.
check() keeps it only on an HTTP server, requires a client ID when a
secret or port is given, and a port 1-65535.
Run (worktree at
|
||
|
|
55e81bce40 |
gui: Cancel in an MCP server's editor leaves the server as saved, after a Sign in too (新v学员 on Discord)
GitHub's remote MCP server, brought in from CC Switch with its token as an Authorization header: removing the header, picking Sign in, then Cancel (even with Discard asked and picked) left the header removed in library.json and every agent's file. Cause: Sign in calls ready(), which saved the whole form whenever its name, transport, URL or headers differed from the saved server. The sign-in (mcpauth.Start) uses only the name and URL, so the headers never needed saving for it. Now ready saves only when the sign-in is to another server than the saved one (new, name, transport or URL changed); the button then reads "Save and sign in" (zh, zh-TW, ja, de), and what it saved becomes the form's saved state, so Cancel doesn't offer to discard what is already written. Audited the page's other sheets for the same thing: the hook editor, paste-many, the server sheet, the skill how-to, By agent (Done only) and the confirm dialogs save nothing before their own Save. Env and command arguments in this editor only ever saved through Save; the new test covers them too. Run: - New mcp-editor-cancel.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 390 wide, 22/22 twice. Broken by hand each: the old headers-count rule, the saved state not updated after the save, and the button not saying it saves; each 0/11 in Chromium. - mcp-signin (updated for the new label), mcp-signin-health, library-mcp-health, library-mcp-copy-config, library-servers-bulk, library-env-refs, i18n-keys, ux-safety: pass. - library-mcp-tools and library-mcp-tool-switch have WebKit reds (the footer over the clicked switch) that come and go, 1 to 7 per run, the same with this commit's parent's assets. - Sandbox HOME, rebuilt magpie web: header removed, Sign in (GitHub answered with its no-registration refusal), Cancel, Discard: the header is still in library.json and ~/.claude.json, and no save request was sent. |
||
|
|
eb1fab34c7 |
library, gateway: an MCP server magpie is signed in to no longer shows "Signed in" beside "needs sign-in" (新v学员 on Discord)
What was wrong, reproduced in a sandbox HOME with mcpauthtest's fake OAuth server behind a sandbox magpie: - A server no agent has is checked only on a click (#1597). Clicked before its sign-in it said "needs sign-in"; after signing in, the page rechecked only servers in use, so the row kept that result beside the new "Signed in" tag. The page now rechecks any server it has a result for once its key (sign-in included) changed. - The check sent magpie's token but never renewed it on a 401, so an expired access token with a good refresh token read "needs sign-in" beside "Signed in". checkHTTP now renews once and asks again, as the gateway's relay does. - A server that refuses even a just-renewed token was still "Signed in". mcpauth.Rejected marks such a sign-in run out, from the check and from the gateway's /mcp/<name> relay; ServerHealth.SignIn carries the status back (only for a server magpie has a sign-in record for) and the row's tag turns to "Sign-in ran out". mcpauthtest.Fake gains RefuseTokens for the last case. Run: - go test -tags nogui ./internal/mcpauth/... ./internal/library ./internal/gateway (HOME and GOCACHE in scratch): ok. - gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on the touched packages: clean. - New TestCheckRenewsMagpiesSignIn, TestCheckSaysSignInRanOut, TestMCPProxyRefusedAfterRenewalRunsOut. Broken by hand: renewal removed from checkHTTP, Rejected removed from the check, and from the gateway; each went red. - New mcp-signin-health.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 390 wide, 22/22. Each of the two library.js changes reverted on its own: 0/11 in Chromium. library-mcp-health, mcp-signin and i18n-keys pass. - Sandbox repro before and after with the fake server: both cases now show one tag; forget+revoke shows "Sign-in ran out · needs sign-in". Not run: a real vendor's server refusing a renewed token; the fake stands in for it. |
||
|
|
689edbd6be |
gateway: a Codex subagent refused for a sealed task is told the task itself is sealed, which fork_turns="none" doesn't change (#1855, hanekoo)
hanekoo's Codex Desktop lead on gpt-6.1-sol (Codex's own ChatGPT sign-in)
spawned a subagent on antigravity/gemini-3.8-flash with fork_turns="none"
and got the sealed-task refusal, which read as if the lead's turns were
the problem and fork_turns="none" should have avoided it.
What Codex rust-v0.162.0-alpha.17.2 sends (read from its source, not the
reporter's bytes, which aren't available): spawn.rs's fork_mode is None
for "none", so no turn of the lead's is copied in. The subagent's task is
spawn_agent's `message` argument; the ChatGPT backend returns it sealed
(the function call's encrypted_function_args), router.rs's direct_source
makes it ToolCallSource::Direct, agent_message_from_tool makes it
AgentMessage::Encrypted, and to_model_input_item writes it as the
agent_message's encrypted_content under the NEW_TASK header. So the one
sealed thing in the subagent's first request is the task itself: there is
nothing magpie can leave out and still give the subagent work, and no
request flag in Codex asks the backend for plaintext arguments. The
refusal stays; it now says why.
- codex_backend.go: sealedTaskItself, added to all three sealedTaskError
variants (lead unknown / Codex's own sign-in, a relay that sealed it,
plugins#70's earlier chat provider): what is sealed is the task the
spawning agent wrote in spawn_agent, and fork_turns="none" keeps only
the lead's turns out, not the seal. The existing advice (the lead's
model for the subagent, or a lead not on the ChatGPT backend) stays.
- docs/subsystems/gateway-routing.md: the same, under sealed tasks.
- sealed_fork_none_test.go: the fork_turns="none" first request rebuilt
from Codex's source (developer + environment_context + the sealed
NEW_TASK with Task name/Sender lines), a lead first on Codex's own
sign-in, the subagent on a chat provider. It is refused before the
provider is asked, with no ciphertext in the reply, and says the task
itself is sealed whatever fork_turns says.
Run: with the old codex_backend.go put back,
TestSealedTaskWithForkTurnsNoneSaysTheTaskItselfIsSealed fails ("the
refusal doesn't say the task itself is sealed whatever fork_turns
says"); with the change it passes. gofmt -l (empty), go vet / GOOS=linux
-tags nogui / GOOS=windows go vet ./internal/gateway, go build, GOOS=linux
-tags nogui and GOOS=windows go build ./..., go test -tags nogui
./internal/gateway (ok, 353s) under a sandbox HOME with a private GOCACHE.
Not run: the whole `go test ./...` (only the gateway package changed);
no real Codex Desktop or ChatGPT account was used, so the reporter's
bytes are not reproduced; the GUI's sealedKept text is unchanged. The
502 "context canceled" on gpt-6.1-sol in the report is Codex's own
sign-in request most likely cancelled by Codex itself (the client went away), a separate
request, and wasn't chased.
|
||
|
|
248a68598c |
gateway, provider, gui, cli: a key+URL provider may be sent the agent's own User-Agent in place of magpie's (#1851)
Every forward went with User-Agent magpie/<version>. A coding plan that serves only the agents it names (pi, OpenCode, Claude Code…) knows them by their User-Agent, so it turned magpie away. What changed - provider: PassUserAgent (passUserAgent in providers.json), off by default. PassesUserAgent takes it only for a key+URL provider: never a signed-in account, a plugin's, or a vendor whose own client magpie goes as (OwnClient: OpenCode, Cline, Kilo, another magpie). A copy keeps it. - gateway: userAgentFor in forwardOnce (chat, Anthropic, Responses, Gemini, count_tokens) sends the inbound User-Agent unchanged where the provider passes it on. It sends magpie's where it doesn't, where the agent sent none, and on magpie's own requests (magpiesOwn: magpie/…, magpie-router/vision/search, the image tool's "<client> magpie-image/1", which is built from MCP clientInfo, not a User-Agent). magpie never invents another client's. The claude-cli/Codex header copies, the OpenCode/Cline/Kilo overrides and account signing run after it as before, and the user's header.User-Agent is put on at signing, so it wins. - gateway: embeddings, images and videos (retrieveFrom, sendWith, remoteVideoContent) now stamp the same for a key+URL provider through stampUA, from the caller's User-Agent kept on the request ctx (caller.ua, withCaller). Before, they went with Go's default (Go-http-client/1.1). Account and remote-magpie paths are untouched. - cli: `magpie provider set <id> user-agent=agent|magpie`, refused for a signed-in account; `magpie provider <id>` shows it. - gui: the provider editor's User-Agent row, "Send the agent's own User-Agent", with an explanation, for a provider with a key only (the JSON says ownClient for presets and providers); en/zh/zh-TW/ja/de. The TUI only adds presets, so it has no field for this. - docs: reference.md (provider set) and subsystems/gateway-routing.md. What was run - gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows. - go test -count=1 ./internal/gateway ./internal/provider ./internal/cli ./internal/gui: all ok (sandbox HOME, private GOCACHE). - TestUserAgentPassedOn covers 7 routes (messages, count_tokens, chat, responses, gemini, embeddings, images) x off / on / on with no UA / on with magpie-router/1 / on with the image tool's UA / the user's header with it on and off. TestUserAgentAccountUntouched: a Factory account with passUserAgent in providers.json is still asked as factory-cli/. Also TestUserAgentClaudeCodeAsBefore, TestUserAgentFor, TestPassesUserAgent, TestAddCopyPassUserAgent, TestProviderUserAgentPair. - Broken by hand, each went red: forwardOnce back to magpie's UA (5 routes red); stampUA removed from embeddings/draw (both red, seen as Go-http-client/1.1); PassesUserAgent ignoring accounts/OwnClient; magpiesOwn dropped (the internal UAs leaked on all 7 routes); the GUI row shown for OpenCode and Save not posting it. - provider-user-agent.test.cjs: 60/60 in chromium and webkit, en, zh, zh-TW, ja, de, at 900 and 440 wide. The provider/editor/add/i18n GUI tests in chromium: 244/244. Not run - Not tried against a real coding plan that checks User-Agent, nor with a real agent through a live gateway. Videos have no test of their own (they go through sendWith, which the images test covers). - The GUI suite was not run in full; the Windows box was not used. |
||
|
|
a4385e0999 |
gui: the Library's Select bar removes the skills, servers or hooks picked, a whole group at once with its header's box (#1852)
What: Select's bar on the skills, servers and hooks pages gets Remove…
(red, beside Clear). It asks first, as Remove all does, naming the count
("Remove 3 skills?", or "Remove pack-a?" for one), and posts only the
picked names to the existing remove-all endpoints (RemoveSkills /
RemoveServers / RemoveHooks), so each goes exactly as its row's Remove
would: same backups, only magpie's own copies. A group's or part's header
box (already there in Select) picks the whole group, so an outdated group
goes in one step. Groups have no menu, so no "Delete group…" item was
added.
A name that wasn't removed stays picked, its row's second line shows
"Not removed: <error>" in red, the status names it ("notes removed ·
stuck wasn't removed: …"), and nothing reports success for it. When every
name fails the endpoint answers 400: the sheet stays open with its button
enabled again. The label stays "Remove…" whatever the count (the count is
beside it and in the sheet): "Remove 3…" rewrapped the bar at 440px in
ja and moved the box under the pointer (library-servers-bulk caught it).
No Go change: the batch removals already reported Unremoved per name.
Strings in zh, zh-TW, ja, de. docs/subsystems/library.md says it.
Run: new internal/gui/tests/library-pick-remove.test.cjs (Playwright
1.62.0, chromium and webkit, en/zh/zh-TW/ja/de, 1100 and 390 px): group
box picks 3, Cancel posts nothing, Remove takes 3 and leaves the rest, a
partial failure keeps the failed one picked with its error, a total
failure keeps the sheet; every click checked for no scroll and nothing
moving. Red by hand: dropping every name from picked after a partial
failure, and dropping the partial-failure status. With it, both engines:
library-servers-bulk, library-hooks, i18n-keys, gui-de, gui-ja,
gui-zh-tw, click-scroll, group-pick-filter, remove-found-skill,
library-items, remove-all-skills: 60/60 pass. library-servers-bulk
chromium failed once in a parallel run, then passed 3/3 alone and 2/2 in
the same parallel run on this tree and on origin/main.
Not run: pick-skills.test.cjs is red in webkit (en, zh: the click on the
"pdf" row times out) on origin/main
|
||
|
|
6669d497d0 |
gui: an account's seat on the Routing stage tells each of its windows and when each resets in its tooltip (#1835)
A seat on the stage says the fullest window's figure while idle
("40% used · renews in 2h"), and what it is doing while it answers. The
other windows, and their resets, weren't anywhere on the stage. Its
tooltip, which held only its id, now adds one line a window, the same
lines Accounts and keys shows (winsOf, the Usage page's readings,
#1833). It is a tooltip rather than a second line on each seat because
the stage is the live picture of a request, and a line more on every
seat would crowd it. Live only.
docs/subsystems/gui-shell.md: under Routing account windows.
Run: tests/routing-seat-windows.test.cjs (new), chromium and webkit,
en, zh, zh-TW, ja, de at 1100 and 420px: the answering seat's title is
its id and both windows, and the seat whose only card is another
computer's keeps its id alone. 22/22 pass, and 11 of 11 fail in chromium
with routing.js as before. Not tried with a real account.
|
||
|
|
0801c7bb02 |
gui: Routing's Accounts and keys has a refresh beside its heading that reads the accounts' allowances again, by hand only (#1834)
The windows each account shows (#1833) are the Usage page's readings, read the ordinary way when Routing opens. To see them fresh one had to go to Usage and back. The icon button beside "Accounts and keys" makes the asked read Usage's Refresh now makes (loadQuotas(true), /api/usage/quotas?asked=1). It turns while the read is on its way, a click then asks nothing more, and the rows are drawn from what comes back. There is no timer: nothing reads again by itself, as #1518 has allowances read only when asked. It shows only live, with a subscription account listed. Its tooltip is new ("Read the accounts' allowances again", in zh, zh-TW, ja, de), and its label reuses "Refresh now". docs/subsystems/gui-shell.md: under Routing account windows. Run: tests/routing-read-allowances.test.cjs (new), chromium and webkit, en, zh, zh-TW, ja, de at 1100 and 420px: title and label, on the heading's line, opening reads only unasked, one asked read on click with the button busy until it lands, a second click while busy asks nothing, the windows show the new reading, the view doesn't move, and no asked read in 2.5s after. A list of keys only has no button. 24/24 pass, and 11 of 12 fail with routing.js, routing.css and i18n.js as before. gui-ja, gui-zh-tw, gui-de, i18n-keys and routing-account-windows pass. Looked at in screenshots at 1100px (en) and 420px (ja). Not tried with a real account. |
||
|
|
6627ddd54b |
gui: a subscription account in Routing's Accounts and keys shows each of its windows and when each resets, as the Usage page read them (#1833)
The list said one figure for an account, the window routing went by. A
Claude account's 5 hours and 7 days, or Codex's, each with its reset, are
now on a line under it ("5 hours 40% used · resets in 2h"). cardOf matches
the route's account to app.js's quotas: a subscription card of this
computer (no from) whose provider is the account's agent (a plugin's
provider id) or its provider, and whose user is the account's, ignoring
case. Nothing new is read from vendors: opening Routing asks
/api/usage/quotas in the ordinary way when the readings are missing or
over a minute old, never ?asked=1. A kept day's list shows none, as its
requests were weighed by readings long gone.
loadQuotas now treats an answer that isn't a list of cards as a failed
read and keeps what it had. Routing reading quotas showed it: a page given
{} stored it and renderQuotas threw on quotas.some.
docs/subsystems/gui-shell.md: Routing account windows.
Run: tests/routing-account-windows.test.cjs (new), chromium and webkit,
en, zh, zh-TW, ja, de at 1100 and 420px: exact window lines, none for an
account whose only card is another computer's, no overflow, no asked
read. 22/22 pass; fails with app.js, routing.js and routing.css as
before. Looked at in a screenshot at 1100px (en) and 420px (de). All 60
routing-*.test.cjs and click-scroll: 636 pass, 5 fail, all in WebKit in
routing-group-fold (en, ja, de) and routing-sessions (en), which fail the
same alone on the old assets at
|
||
|
|
403f3845e2 |
gateway: Codex's spawn_agent names every model also when Codex hands it to the lead through a tool search, as it does on 0.162 (Gearclickist on Discord)
Gearclickist, after v0.1.1214: the lead still saw only five models for
its subagents. v0.1.1214 (
|
||
|
|
50adf78e66 |
gateway, gui: the web searcher picked in Settings is never handed on to another provider, and one that answered without searching is said so (Gearclickist on Discord)
Cause: Gearclickist picked the Grok subscription's grok-4.7 in Settings ›
Web search. Their grok rows were about 1.3k tokens. That is the size of a
Grok request that ran no search. With the tool and searching, our real
Grok account gives 6k-66k input every time, and /models says
supports_backend_search for all four models. So on their account Grok
answered from what it knew. searchWith read that as "found nothing", and
modelSearch handed the search to the next of Searchers() by rank: Codex's
gpt-6-astra, a pricier subscription model they never picked.
Change:
- modelSearch: a searcher named in Settings gives way to no other
provider. Its error goes back to the model ("no other provider searches
in its place"), and webSearch then asks the search APIs, if any are set
up. Automatic keeps its fallback (#669) with the Routing row that says
why.
- searchWith tells a reply with no server_tool_use or
web_search_tool_result (errNotSearched) apart from one that searched and
named no page (errFoundNothing). CallFor gets notSearched.
- namedFailed/SearcherFailed keep the named searcher's last failed search,
cleared by its next success or by picking another searcher.
/api/settings returns it as searchFailed.
- Settings › Web search puts a warning at the start of the row's help
(before the ellipsis) naming the searcher, when, and why ("answered
without searching the web, so its account or plan may not offer web
search"). The help text now says a picked provider is never replaced by
another provider. The Routing row (kindWhy) says not-searched too.
zh, zh-TW, ja and de strings added.
- docs/subsystems/gateway-routing.md rewritten for the rule.
Run (worktree on origin/main
|
||
|
|
91e7ef56af |
settings, gateway, gui: a browser extension is listed among the web pages that may call magpie by its origin, chrome-extension://<id> and the like (#1051, SkyAerope on Discord)
What: Settings › Network and sharing › Web pages now takes a browser
extension's origin besides http(s) ones: chrome-extension://<id>
(Chromium, the id 32 letters a-p), moz-extension://<uuid> (Firefox's
Internal UUID) and safari-web-extension://<uuid> (Safari). cleanOrigin
takes only those three schemes, only with an id of that browser's shape,
lower-cased and with a trailing "/" let go; a bare scheme, a wildcard, a
path, a port, user info, a query or another browser's id shape is
refused. The GUI maps the new refusal to the same message, which now
names the extension form, in en/zh/zh-TW/ja/de, and a listed origin
wraps instead of being cut (an extension's runs to 50-60 characters and
was ellipsized at a 440px panel). The 401 a listed caller gets without a
key names extensions too. Docs: gateway-routing.md, the settings field.
Why: an extension without host_permissions (Sider and the like) is held
to CORS; the gateway never answered its preflight, since its origin
couldn't be listed. Nothing else in the access rules changes: corsGuard
treats a listed extension exactly as a listed page (preflight answered,
every call needs an enabled gateway key or gets 401, even on loopback),
an unlisted extension passes with no CORS headers as before (foreignPage
still only judges http/https), and lanGuard's rebound/Host checks, the
allow list and every other route guard are untouched.
The Origin each browser sends was checked, not guessed: real Chromium
(below) sent Origin: chrome-extension://<32 a-p>; Firefox's is
moz-extension://<Internal UUID> (Gotify's and others' CORS docs list
it); Safari's is safari-web-extension://<lowercase uuid>, per Apple's
developer forums (thread 654839), where an Apple engineer notes the uuid
changes on each Safari launch, so a Safari listing lasts until it
restarts (said in the doc). A content script's fetch carries the page's
origin (MDN), so only extension pages, popups and workers are covered.
Run, at
|
||
|
|
7d05a00f5f |
gui: a tab picked in the sidebar opens at its top, not where the tab before was left (#1844)
Usage, Library, Plugins and Settings list their tabs under the page in the sidebar (navSubs), and a page's tabs share its one scroll. A row only clicked the page's own tab, so scrolled to the foot of Settings › General and Allowances picked, Allowances showed at its foot; Library › MCP servers and Skills the same. A row that picks another tab now clicks it and scrolls the page to its top through scrollOnPurpose with the row's own click. The tab already open, picked again, leaves the page where it is. The page's own strip (the header's tabs) and switching between pages are unchanged. sidebar-tab-top.test.cjs (Chromium, WebKit, en, zh) fails without the change, 6 of 6: "Allowances opens at its top", 177 (en) and 228 (zh) instead of 0; with the Settings part left out, "Skills opens at its top", about 2100 instead of 0. It passes 6 of 6 with it. go test -tags nogui ./internal/gui in a temp HOME passes. |
||
|
|
60808fd9cf |
usage, gateway, gui: magpie's own requests are told apart from the agent's, and a classifier on a subscription says it asks it every turn (#1839)
kensenzhao saw a subscription's allowance spent by requests the agent
didn't make: a routing group's classifier, set to a subscription's model,
asks it as every turn begins, and those calls looked like the agent's own.
What changed
- usage.Group has an own share (calls, tokens, cost) of the calls magpie
made by itself, filled for models, keys and accounts. Record.ByMagpie
is the test: agent "magpie", or one of its own User-Agents
(magpie-router/1, magpie-search/1, magpie-vision/1) where the agents
aren't loaded. The calls still count in the group's totals, as they
went to the same key or account. A group with none sends no "own".
- The classifier's calls are Kind "routing": callKind marks RouterAgent's
requests, and the decision model's record (Jev / System One) is written
with it. A "Routing classifier" purpose names them in the ledger.
- Usage page: magpie's row among the agents and its ledger rows carry a
"magpie's own" mark; an account's, key's or model's row adds "{n} by
magpie itself"; an account's card says how many of the period's
requests were magpie's own, drawn again once the summary arrives after
the allowances.
- Routing page: /api/groups marks a model a subscription account serves
(modelRef.Sub, servedRef). Beside a classifier on such a model, or a
group whose first member is one, the editor says every turn starts
with a request to that subscription, two when it picks both intent and
effort in words. A classifier on a key or a free model says nothing.
- New strings in zh, zh-TW, ja and de. The mark is a muted chip with an
even border all round (no left stripe).
Tests
- TestSummaryCountsMagpiesOwnCallsApart, TestByMagpie (usage).
- TestIntentRoutesATurn and TestJevPicksTheIntent (gateway) now check
the classifier's records are Kind routing and magpie's own, and the
agent's records are not.
- TestServedRefSaysASubscription (gui).
- own-requests.test.cjs: Chromium and WebKit, 1100 and 390 wide,
en/zh/zh-TW/ja/de, the API faked; no click scroll, no sideways page.
- Broken by hand, each turned its test red: addOwn counting nothing;
callKind's routing case removed; decide.go's Kind blanked; the ledger
mark, the agents' mark, the "{n} by magpie itself" line, the card's
line, its redraw after the summary, the Routing hint, its group case
and modelRef.Sub each removed.
Run: gofmt -l; go vet on darwin, linux -tags nogui and windows; go test
for usage, access, catalog, gui (-tags nogui) and gateway in full; the
GUI tests above, the ledger, routing-intent and translation tests.
Not done: the warmups (warmClaude/askClaude) write no usage record at
all, so they can't be marked; that is left as it was. Not tried with a
real subscription classifier against a live account.
|
||
|
|
8653bead72 |
usage, gui: a usage record and a request's details carry its cache read and cache creation beside in and out (#1839)
kensenzhao asked for usage.jsonl and the Usage page's request details to
carry cache read and cache creation tokens beside input and output.
What changed
- usage.Record's cache_read and cache_write are written on every record,
0 too (they were omitempty), so a prompt that missed the cache reads as
that rather than as a record that kept no cache. A record from before
has neither and reads as 0, as it did. Input still holds neither.
- Every route already filled them; this pins it per wire format:
Anthropic messages, OpenAI Chat (prompt_tokens_details.cached_tokens and
DeepSeek's prompt_cache_hit_tokens), Responses
(input_tokens_details.cached_tokens) and Gemini
(cachedContentTokenCount), relayed and translated, whole and streamed,
a plugin's fetch, and the Claude subscription bridge. System One's
decision calls report no cache and are left as they are.
- A request's details in the ledger have a Tokens row at every width:
"{i} in · {o} out · {r} cache read · {w} cache creation", plus the
5-minute/1-hour split when known. Before, the cache showed only as
"{w} written · {r} read" when non-zero, so a missed cache said nothing.
That string is gone; the new one is in zh, zh-TW, ja and de.
Prices and quotas: the JSON tag is the only change to the record, so the
cost math (CostAt -> CostSplit reads CacheRead/CacheWrite/CacheWrite1h),
Totals' cache sums, budget's CacheReads and access/limit's token windows
read the same values as before. Checked by reading each and by the usage,
access and catalog tests passing unchanged.
Tests
- TestRecordAlwaysCarriesCacheTokens (usage): 0s written, old records read.
- TestUsageRecordsCacheTokensOnEveryRoute, TestPluginUsageRecordsCacheTokens,
TestClaudeSubscriptionUsageKeepsCacheTokens (gateway): each wire format,
whole and streamed.
- ledger-cache-tokens.test.cjs: Chromium and WebKit, 1100 and 390 wide,
en/zh/zh-TW/ja/de; usage-ledger-detail.test.cjs updated for the row.
- Broken by hand: putting omitempty back and dropping the Tokens row each
turned its test red. The gateway route tests pin what the routes
already did; they don't fail on the code before this commit.
Run: gofmt -l; go vet on darwin, linux -tags nogui and windows; go test
for usage, access, catalog, gui (-tags nogui) and gateway in full; the
GUI tests above plus the translation tests. Not run: a real vendor
request to see its cache figures land in usage.jsonl.
|
||
|
|
d0c587aeed |
gateway: a tool call a model wrote into the text of a Chat reply asked for whole is made the call it is, as a streamed one is (#1845)
A request with stream:false relayed to a Chat upstream had its reply mended by chatWhole, which only flattened typed content (#483). The rescue of calls written into the text (textcalls.go, #823) ran only in textCallTidy, on a stream. So a DeepSeek reply whose content was its DSML <|DSML|invoke name="Bash">… reached the client as that text with finish_reason stop, and the agent ran nothing; the same request streamed got a real tool_call (#1845, cline-pass/deepseek-v4.1-flash). chatWhole now gets the request's tool names and, for each choice, wholeTextCalls reads the content with the streaming parser (textCallAt + parseTextCalls), so the same formats are taken: Hermes' <tool_call>, DSML, the half-Hermes <parameter> form (#917) and GLM's (#906). The text before the first block is kept (null when none), the tags go, the calls become tool_calls with call_text_ ids and finish_reason becomes tool_calls. As in the stream: a reply that made a call itself, a block naming a tool not offered, arguments that can't be read, or no tools offered leave the reply as it came; tags and nothing else are dropped. A cheap check (tool_call or DSML in the bytes, escaped brackets included) keeps other replies byte for byte. chatWhole is now also used for a whole reply under text/plain or no type, which eventStream had found isn't a stream; before, only JSON types were mended. Routes checked: Chat relayed whole (fixed); a streamed request a vendor answered whole goes through chatWhole before wholeAsStream (fixed by the same, tested); Responses and Anthropic translations of a Chat upstream, streamed and whole, a plugin's, and a Chat request for one body asked streamed (DashScope) all go through textCallSee already (tests added). A relayed Responses or Messages upstream's text isn't read for calls, streamed or whole; unchanged. Run (Go 1.26.8, sandbox HOME, private GOCACHE): - New TestTextWrittenCallWhole (the issue's DSML, after text, Go-escaped brackets, text/plain, Hermes, #823's junk, #917's param, GLM, wrapped invoke, two calls; left as text: no tools, unknown tool, cut short, lookalike, empty content, plain; tags only; beside a native call; truncated body; empty body), TestTextWrittenCallWholeTranslated, a case in TestQuietWholeReplyStreamed and a chat-whole subtest in TestPluginTextWrittenCall. - Broken by hand: chatWhole without names turns 11 subtests of TestTextWrittenCallWhole and the TestQuietWholeReplyStreamed case red; leaving finish_reason alone turns them red on "finish stop"; the old JSON-only gate turns the text/plain case red; turning textCallSee's rescue off turns the translated and plugin tests red. - gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. go test -tags nogui ./internal/gateway in full: ok (363s). - Real: no ClinePass key here, so the reporter's request went through this branch's gateway in a sandbox to DeepSeek's own API (deepseek/deepseek-flash), 5 runs each way. One stream:false reply in DSML came back as tool_calls Bash {"command":"ls /tmp"}, finish_reason tool_calls. Other runs the model wrote other markup (<|tool▁calls▁begin|>…, <|invoke name="Bash"|>) that neither the streamed nor the whole rescue reads, streamed or not; not changed here. Not run: the full go test ./... (only internal/gateway), Windows and Linux test runs, ClinePass itself. |