861bbef2d570b60c19380b4a29e8203ef69b0796
727
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1242367020 |
gui: the menu bar's idle tooltip splits today's tokens into input, output and cache (NextCommit on Discord)
With no cards ticked, the tooltip said only "Today: 6.3M tokens". It now says "Today: 6.3M tokens (912K in · 318K out · 5.1M cached)" over the cost and requests, as the usage:today card's tooltip has since #1984 (trayTokens, shared by both; cached left out when nothing was cached). Run: TestTrayIdleTip and the SNI tip case, updated. gofmt -l clean. Full suite: SUITE_LINE |
||
|
|
49d60394ef |
gui: the Mac's menu bar item shows its tooltip, which Wails never set there (NextCommit on Discord)
NextCommit (macOS, 0.1.1244) hovered the menu bar item for today's
tokens split into input, output and cache and saw nothing. Nothing was
shown at all: Wails v3.0.0-beta.24's macosSystemTray.setTooltip is a
no-op ("Tooltips not supported on macOS"), so neither the idle tip nor a
card's tooltip (usage:today already said "6.3M tokens (912K in · 318K
out · 5.1M cached)") ever reached a Mac. Linux has its own setTrayTip
(SNI); Windows keeps Wails'.
setTrayTip on the Mac now sets the status item's button toolTip on the
main queue (trayTipNative, mpTip in trayimage_darwin.go), returning false
while the item isn't up yet so it is tried again, as Linux's does.
Run: TestMacTrayTipIsSet (darwin, cgo): setTrayTip reaches the native
setter, false before the item is up, and a real NSStatusBarButton keeps a
multi-line tip whole. go vet: darwin (cgo, GUI) and -tags nogui for
darwin, linux and windows. Not tried: hovering the icon in a built app.
Full suite: SUITE_LINE
|
||
|
|
6f6b7d4077 |
gateway: a Codex request with web_search stays alive while its provider is queued, not cut at Codex's idle timeout (#2316, clxsh)
A request that offers web_search to a model that can't run it goes through
searchReply, which reads the provider's reply in rounds. That reader used
readSSE, so the provider's keepalives (": keepalive", response.in_progress)
were dropped, and relay waited for the first event past KStart before it
made the client's encoder. A provider queued for minutes sent the client
nothing but the holdWriter's comments, which Codex's idle timeout doesn't
count: it hung up at ~315s and asked again, losing its place in the queue.
The plain translated path has kept the client alive since #436.
Now askTranslated reads with readSSEAlive and, after keepaliveGap with
nothing else sent, hands its reader a KAlive event (nothing of the reply).
searchRounds passes it on without collecting it, the collector ignores it
(no reasoning block boundary moves), and relay takes it as the provider
being heard from: it begins the client's stream and sends the protocol's
own keepalive (response.in_progress, Anthropic's ping) when the client has
been quiet keepaliveGap. A provider that goes silent sends no KAlive, so
relayEvents' keepaliveLongest still ends the keepalives; an error before
any keepalive is still a status for the next account.
Test: clxsh's TestSearchQueueKeepsCodexAlive as filed (comments, progress,
cancel, silent). On the old code all four fail (pings=0 complete=false,
only comments reach the client); with the fix they pass, -count=3.
Run: go test -tags nogui ./internal/gateway -run
'Search|Keep|Alive|Relay|Zen|Draw|Probe|Held|Hold|Queue|Codex.*Stream|Translated'
ok (75s); gofmt -l clean; go vet -tags nogui ./internal/gateway on
darwin, linux, windows clean. Not tried against a real queued provider.
Full suite: SUITE_LINE
|
||
|
|
b9e5c28997 |
gui: a Library MCP server magpie can't check for a variable only its agent sets shows not checked, not a red error (#2308, ASD-max)
Codex's host-only codex_app (codex-app-tools, imported into the Library)
names ${CODEX_APP_TOOLS_PIPE_PATH} and ${CODEX_MCP_NODE_PATH}, which only
the Codex app sets when it starts the server. magpie's check expands them
from its own environment, finds them unset and returns novar before
starting anything. The page painted that red, the same as a server that
exited or doesn't answer, so a working server read as broken. Its tooltip
already said magpie can't check it there.
A novar result is now painted as not checked: a grey ring and muted
words ("CODEX_APP_TOOLS_PIPE_PATH, ... not set"), the same tooltip. Other
errors stay red. The check itself is unchanged: magpie doesn't start
codex_app with Codex's pipe, as the reporter's own probe shows Codex
turns away a peer that isn't its signed binary
(untrusted-code-signing-identity), and it doesn't learn the pipe's path.
Run: library-env-refs.test.cjs (Chromium and WebKit, en/zh/ja/de at
440px) now also checks the novar status isn't "err" and isn't the red
colour; with client.js put back to HEAD it fails. library-env-refs and
library-mcp-health pass (16). Go tests not run (no Go file changed; disk
under 6G free).
Full suite: SUITE_LINE
|
||
|
|
206dc24cd5 |
gui: with the Sessions page switched off, a latest session on Usage unfolds its details, not a click that does nothing (#2311, betacatZ)
Usage › Sessions' latest sessions open on the Sessions page. With that page switched off in Plugins › Built-in (the reporter's screenshot has no "All sessions" beside the search, which is hidden the same way), the row still looked like a link, with a chevron and a pointer, and a click returned without doing anything. Now, with Sessions off, the row is a button (aria-expanded) that unfolds the session's details in place, as a top session's do: time, folder, session id, the resume command, what each model spent, the file. One is open at a time, Enter and Space fold it, and nothing scrolls. With the page on, a row still opens there. Run: internal/gui/tests/sessions-usage-off.test.cjs (new, 12 cases: Chromium and WebKit, en and zh, 900 and 420px) passes; with page.js put back to HEAD its 4 Chromium "off" cases fail and the "on" cases pass. sessions-usage-open, sessions-paging, sessions-in-range, sessions-overview and builtins pass (84). Go tests not run here (disk under 6G free); no Go file changed. Full suite: SUITE_LINE |
||
|
|
75035fa202 |
gateway: Command Code's bare 400 (a trace id, no reason) hands a group's request to the next member, not ends it (#2313, lqisgod)
Command Code's Provider API answers some requests with
{"message":"invalid request error trace_id: <hex>","type":"invalid_request_error"}:
a 400 (a 422 the week before), no code, no param. retryable() read it as
the request's own fault, so a group stopped there and its later members
were never asked: six requests in a row on lqisgod's wb-flash group, while
the fourth member answered the same ~660K prompt that hour.
What it turns away is the request's size, not the key: lqisgod's A/B on
one agent conversation (~748K tokens of history and tool calls, same bytes
otherwise) answered 200 with max_completion_tokens 64000 and this 400 with
384000, the max output Command Code lists for the model, so history plus
asked-for output is over a limit below the 1M context it lists. Its own
tracker has more of the kind (CommandCodeAI/command-code#960, #976).
Another member whose model has room may take the same request, so it is
asked, as for a shape another API can take.
unsaidWords matches that message alone, as the vendor sends it, wrapped by
a client in front of it, or told on after a provider's name. It goes the
way shapeWords do (shapeRefused, retryable): the next member is asked once,
Command Code doesn't rest, and the last member's error reaches the agent.
No retry of the same member is added. Its overflow ("The input is longer
than the model's context length trace_id: …") and a refusal naming a param
aren't matched. The keyed "commandcode" preset and the moved plan go
through the same gateway decision.
Tested: TestGroupFailsOverCommandCodesBare400 (streamed group request,
reporter's literal body; the 422 and wrapped forms from #960/#952; overflow,
param and longer-message negatives). With fallback.go put back it fails:
"400 ... COMMANDCODE: invalid request error trace_id: ... (a 1, b 0)".
go test -run 'TestGroupFailsOver|Shape' ./internal/gateway passes.
Full suite: SUITE_LINE
|
||
|
|
94c70a2dd9 |
gui: the tray's Allowances cards say "Resets 14:26", not a bare ↻ that read as a button, and each card has the Usage page's own refresh (#840, hhh2210)
In the tray panel the first reset deadline was drawn as "↻ 14:26": text
with no click handler, which reads as a refresh to click (hhh2210 clicked
it). It now uses resetText, "Resets 14:26" / "重置于 14:26", as the
Usage page does; the other windows keep "Weekly Oct 31".
The tray cards also had no per-card refresh. They now get the main
window's quotaRefresh, the same single-card API and response-order
guard, at the start of the line under the account (the deadline, the
error, "Unlimited", or a balance's name): opened as the card is hovered
or the button is focused, spinning while it reads, closed taking no room
(the balance row's flex gap is closed with it). renderPanelQuota puts the
focus back on the button after the redraw. A failed read keeps the
figures and says the error in the footer, as on the Usage page.
Based on hhh2210's fork commit 9ea883ffb. Kept: the reset label, the
refresh on every tray card kind, the focus kept through the redraw, the
test's fixtures. Trimmed for the owner's UI restraint: the always-visible
24px button and the new "Updated N ago" row on every card (now hover-
revealed in the existing line, as on the Usage page), and the new status
texts (reading / cached, no new data / refresh failed / Claude's 30s
interval), which the Usage page's own refresh doesn't have either. No new
strings: "Resets {when}" and "Refresh this card" exist in every language.
Run (macOS arm64, Playwright 1.62.0, Chromium and WebKit):
- panel-quota-refresh.test.cjs, rewritten for this behaviour: 20/20,
en/zh/zh-TW/ja/de at 440 and 360px tray widths.
- Broken by hand, each red with its own message: the ↻ label back ("the
deadline says 重置于, got ↻ 14:31"); no refresh in the deadline line
("has its own refresh"); no focus restore ("the redraw keeps the
focus"); no .pq-card:hover rule (hover never opens it); the error card
without one ("kimi has its own refresh"); without the .pq-bn margin the
closed button moved the balance's logo ("relay's closed refresh moves
nothing").
- 68 GUI files that open the tray's Allowances or the Usage refresh
(every mode=panel file reading usage/quotas, usage-card-refresh,
quota-balance-error, usage-remote-*, quota-read-at): 943/944. The one
red, usage-fold chromium "the view didn't scroll" 184 !== 180, is red
alone on origin/main
|
||
|
|
ff2e6e2314 |
gateway: Cline's daily limit on one free model rests that model alone, until the time it names, not the whole key (#1398, wuasakura)
Cline answers a free model's daily cap with 429 "Daily free limit reached on model X. Try again in 23h 59m". failure() reads "daily" as quota, so the whole key rested for 15 minutes and every other free model on the account was refused without being asked; the reporter saw the account sent to the back of the list after one model's limit. The limit is per model by Cline's own words, and Cline's client treats it so (CLINE_FREE_MODEL_LIMIT_MARKER "free limit reached on model" and the "try again in" reset parse in cline/cline sdk errors.ts). So for a Cline provider (ClinePinnable: ClinePass, a cline.bot host, the Cline plugin) that refusal now rests restID() (that model) for the time it names (By "resets"). Another vendor's same words, and a Cline 429 that doesn't name a model's limit (5-hour/weekly, "Rate limit exceeded"), rest the key as before. No per-provider toggle: it would make account-wide 429s hit the account once per model, the risk-control pattern the gateway avoids. The Cline plugin's "usage limit reached: <body>" keeps the words (checked with node on its failure() for all three body shapes), so moved users get it too with no plugin change. Run on |
||
|
|
92ac1c878e |
search: the web search MCP server has a web_fetch tool that reads a page by its URL (#2286, blackrion)
An agent that mounted magpie's web search over MCP (Cursor, Claude Desktop) found pages it couldn't open: it has no fetch tool of its own. web_fetch (url, max_chars, offset) reads one. - The URL is the agent's, so the page is downloaded the way a caller's image is (publicClient): public addresses only, every resolved address checked and pinned, redirects (at most 5) checked the same, a request from this computer included; only http and https. 30 s and 5 MiB at most. - HTML is decoded from its charset (x/net/html/charset; golang.org/x/net added) and given as Markdown: title, headings, lists, links made absolute, code and pre; script, style, hidden elements dropped. Other text as it is; anything else, or a 4xx/5xx, is the tool's error. - 20000 characters by default (at most 100000) from offset, with the offset the rest starts at. - Each call reserves the gateway key's limit, as a search does. - The tool description is neutral (names neither magpie nor a vendor). - GUI: the MCP row's text names both tools (en, zh, zh-TW, ja, de). Docs: gateway-routing's MCP section, README (en, zh-CN). Run: go test -tags nogui ./internal/gateway -run 'WebFetch|SearchMCP'; GOOS=linux/windows go vet ./internal/gateway; gofmt -l clean. GUI: search-mcp, i18n-keys, gui-ja, gui-de, gui-zh-tw 32/32 (chromium + webkit). Broken by hand: webFetchClient = http.DefaultClient turns TestWebFetchOnlyPublic red (the local test server was reached). Tried by hand (a throwaway test, not committed) against go.dev/doc, en.wikipedia.org/wiki/Magpie and http://github.com/yetone (redirected to https; links come out by name, not the pinned address: the first try gave https://216.239.34.21:443/..., fixed by taking each redirect's URL from CheckRedirect), and an httpbin redirect to 127.0.0.1, refused. Full suite: SUITE_LINE |
||
|
|
ec13d1162a |
search: the search APIs are dragged into the order they are asked in, and each switches off without losing its key (#2286, blackrion)
The search APIs were asked in the order they were added, and the only way to keep one out of the chain (to try another alone, or rest one whose credit is nearly spent) was to remove it and paste its key again later. - provider: SearchAPI.Off; SearchAPIs() leaves an API switched off out, so neither a model's search nor the web_search MCP asks it. SwitchSearchAPI keeps key, URL and place; SetSearchAPI keeps Off. ArrangeSearchAPIs puts them in the vendors' order, refuses an unknown or twice-named vendor, and keeps one not named after them. RestoreSearchAPIs now puts a backup's APIs in the backup's order (one only here after them), so a restored order and Off come back as they were; sync already mirrors the list. - GUI: each API's row and its keys' row are one unit, dragged off its buttons with dragRows (as routing's groups, #779) or moved with Alt+↑/↓, renumbered at once, focus kept, redrawn as saved if the order is refused. A lib-switch per row posts {vendor, on}; one off is dimmed and says Off; Search first with counts only APIs that are on. The row's buttons wrap instead of running past a 420px window. - CLI: magpie search off|on <api>, move <api> <n>; the list says off. - POST /api/settings/search-api takes {arrange} and {vendor, on}. - Docs: gateway-routing "The search APIs' order, and one switched off", gui-shell, README (en, zh-CN). Run: go test -tags nogui ./internal/provider ./internal/cli ./internal/gui ./internal/gateway (TestSearch*) ./internal/backup ./internal/davsync; GOOS=linux/windows go vet of the touched packages; gofmt -l clean. GUI: search-order.test.cjs 16/16 (chromium + webkit, en/zh/ja/de, 1100/420), and search-api, search-first, search-instead, search-keys, search-mcp, searcher-pick, i18n-keys, gui-ja, gui-de, gui-zh-tw 100/100. Broken by hand: SearchAPIs without the Off filter turns TestSearchAPIOrderAndOff and TestSearchCLIOffAndMove red; the GUI counting off APIs for Search first turns search-order red. Full suite: SUITE_LINE |
||
|
|
4ad929fd4d |
gateway: a native compaction a fallback seals is recorded to it, and its next turn goes there with the compaction, not answered 200 without it (#2271, JasonBuildAI)
With native compaction on for a provider, Codex's compaction_trigger
goes to any candidate whose wire carries it, a fallback included. The
compaction watcher recorded the writer only when the candidate that
answered had native compaction on itself (`if s.compactsNatively(...)
{ sealedBy = &c }`), so a fallback's seal went unrecorded. The next turn
carrying it then either went to another provider, which refused the
foreign item, and magpie dropped it (withoutCompaction, guarded only by
`checkpoint == nil`) and answered 200 without the compacted history; or
went to the fallback translated, since keepsCompaction kept a sealed
compaction only for a provider set to compact natively, and the
translation left the item out.
Fix:
- the writer is recorded whoever answered: the watcher exists only when
the trigger was kept, so whoever answered sealed it;
- keepsCompaction also relays a sealed compaction to the provider
recorded as its writer (checkpointOf), whatever its own setting;
- checkpointError no longer says "native compaction is on for <writer>",
which isn't so for a fallback;
- docs/subsystems/gateway-routing.md says so.
Test: TestNativeCompactionFallbackSealStaysWithItsWriter (fa native,
falls back to fb, native off, which seals; a third provider). Broken by
hand, each part fails it:
- recording only native writers: the other provider answers 200 with
the seal dropped;
- keepsCompaction ignoring the record: the writer's next turn (Codex's
shape, offering web_search) goes translated without the seal;
- the old wording: the error says native compaction is on.
Run on the rebased head (origin/main plus #2274 and this):
go test ./internal/gateway/ -count=1, gofmt -l, go vet -tags nogui for
GOOS=darwin/linux/windows ./internal/gateway: see the ready note; all
green before this was handed over.
Full suite: SUITE_LINE
|
||
|
|
51d5b8d0b2 |
gateway: a Codex compaction's summary cut short or 429'd halfway fails over and rests the account, and one that keeps failing is held, not asked every 18s (#2274, huangzuomin)
Codex on antigravity/gemini-3.8-flash with context_management's
experimental mode asked magpie for 1169 summaries in 6 hours (8.44M
billed tokens), ending in 502 "compaction: the model wrote no summary".
Cause, in three parts:
- serve's holdWriter let the summary's stream through at its first
words, so Antigravity cutting it short ("the reply ended before it was
complete"), or a 429 "Individual quota reached" after some of it,
reached codexCompact as a 200 with an error: no failover, no rest.
- codexCompact took a summary that ended `incomplete`, or a body with
no response at all, as one.
- Codex's async compaction (codex-rs async_compaction) starts a
background compaction at every step while the conversation is over its
threshold and drops a failed one silently, so the history never
shrank and each step paid for the whole conversation again.
Fix:
- codexCompact marks its request askWhole; serve then holds the summary
stream to its end (holdWriter.wantWhole). A cut, an error event or
`response.incomplete` anywhere in it fails over to the next candidate
like a failure before content and rests the account as that would; a
model that reached its output limit rests nobody.
- With nobody left, the cut/incomplete summary is a 502 saying so, never
the words before the cut.
- compactFails (codex_compact_guard.go): after 3 failed summaries in a
row of one conversation (prompt_cache_key) on one model, each within
5 minutes, the next is answered 400 at once (Codex doesn't retry a
400) naming the last failure, until 5 minutes pass. A summary clears
it; 401/403 aren't counted. Decision: a 400 is the only answer Codex's
remote compaction stops on, and a per-conversation hold costs a user
whose model recovers at most 5 minutes, while the loop cost tokens.
- docs/subsystems/gateway-routing.md says so.
Run (worktree at origin/main
|
||
|
|
8a1b5916f3 |
sessions, usage, gui: one read of every call at a time, the Codex effort built once and kept, and the Sessions page asks for an overview once, so the app no longer grows to 85 GB (#2278)
On a long history (the reporter's: 68k call files in calls-v15, 415 MB;
42 MB usage.jsonl; 75k calls in 7 days), the app's main process grew to
85 GB in about 90 minutes and the gateway froze. `magpie serve` alone held
83-153 MB for 20 minutes (the reporter's follow-up), so the growth is in
the app's Sessions path:
/api/sessions/overview -> usage.CodexModelEffort -> LedgerOfAt ->
sessions.Calls(all history).
Why it grew:
- CodexModelEffort's cache key changes on every gateway write, and it
never kept an answer when usage.jsonl was missing or grew during the
build. So every /api/sessions, overview, /one and /manage ask with a Codex
session rebuilt the all-history ledger, gob-decoding every shard (only
64 stay in memory).
- Nothing joined concurrent asks.
- The page's 15s reload asked for an overview again while the last one
was still under way, so slow asks piled up.
What changes:
- sessions.Calls and the new AgentCalls go through sharedCalls. An ask
while the same read is under way waits for it and gets a copy, and
reads run one at a time.
- AgentCalls(since, "codex") reads Codex's files only. pruneCalls still
sees every file.
- CodexModelEffort is built from Codex's calls plus the gateway's records.
Only those name a Codex actor, and TestCodexModelEffortIsTheWholeLedgers
checks the answer equals the whole ledger's on a mixed Claude + Codex +
gateway fixture.
- One build per period at a time. An ask during a build gets the last
answer for the same home (root), or waits if there is none.
- The answer is kept when usage.jsonl is missing or grows during the
build.
- At most 8 periods are kept.
- page.js: sessOverview shares one promise per query, so the filter's ask
and the 15s reload's ask for the same overview send one request.
- docs/subsystems/gateway-sessions.md says this.
Reproduced (temporary test, not committed): a sandbox HOME with 62k
Claude Code session files, 5.9k Codex rollouts and 100k gateway records.
Sessions routes in-process, 4 rounds x 6 concurrent asks
(overview?days=0 and /api/sessions), a usage record appended every 300ms:
before (
|
||
|
|
d4244d5c19 |
gateway: a thinking budget the provider's Extra body adds is sent to Opus 5.5 as adaptive thinking, as an agent's is
forwardOnce turned a thinking budget into adaptive thinking for a Claude
that takes no budget (adaptiveThinking), then merged the provider's Extra
body (#1604). A budget written there, {"thinking":{"type":"enabled",
"budget_tokens":2048}}, went to claude-opus-5-5 as written, and Anthropic
answers that with 400. When the Extra body changed an Anthropic body, it
is fitted again (adaptiveThinking, then withoutRefusedShapes for the
display), so it goes as the agent's budget does. Found while looking into
(rc.44), not this.
TestExtraBodyBudgetFittedToAdaptiveModel: a fake that refuses
thinking.type enabled with Anthropic's words, Extra body with a budget,
a client sending no thinking. Broken by hand: with gateway.go reverted it
fails with that 400; with the fix, one request, thinking
{"display":"summarized","type":"adaptive"} and an effort.
Run at this head (rebased on origin/main
|
||
|
|
5ca37ef86b |
tray: Settings › Menu bar cost off shows magpie's today and 7-day totals as tokens alone, in the menu bar and its tooltip (BussanQ on Discord)
BussanQ asked for the menu bar's today card with the token count only.
A new Settings › Usage › Menu bar row, "Menu bar cost" (On by default,
segs, every OS, shown with or without cards since the no-card tooltip
says the cost too), saves settings.TrayNoCost. Off, trayMoney drops a
total's cost and its count of unpriced calls before trayTotalCard and
trayIdleTip see it, so the macOS cells and title, and the tooltip on
macOS, Windows and Linux, say the tokens and requests alone. A relay's
or subscription's balance card is money itself and stays. TrayNoCost is
per computer (KeepOwn, beside the other Tray* fields), and a change
redraws the tray (api.go). Translated in zh, zh-TW, ja and de.
Run:
- TestTrayNoCost (internal/gui): broken by hand (trayMoney a no-op) it
fails with label "Σ47M · $128 | Σ6.3M · $3.40+", want tokens alone,
plus the tooltip and idle tooltip.
- TestSync (internal/davsync) now sets TrayNoCost on one computer; with
TrayNoCost left out of KeepOwn it fails "b's menu bar: … TrayNoCost:true".
- tray-cost.test.cjs: Chromium + WebKit, en/zh/zh-TW/ja/de, widths 1100
and 420, Mac/Windows/Linux and no cards: 22/22 pass. With trayNoCost
dropped from the prefs it fails "a save of another setting keeps the
cost off". Also green: i18n-keys, tray-bird, tray-logos, tray-totals,
tray-usages, tray-usage-redraw, quota-pace, tray-inuse.
- gofmt -l clean; go vet ./... and -tags nogui for GOOS=darwin, linux,
windows clean.
- go test ./internal/tune ./internal/gui ./internal/settings ./internal/davsync
green at this head, rebased on origin/main
|
||
|
|
035c259a6d |
tune: Codex's compaction windows run to the model's own window or 1M, not the largest prompt seen (zhemu on Discord)
zhemu: Codex Desktop on a CLIProxyAPI provider's 1M GPT model, Settings ›
Long conversations at 750K; Usage › Context › "Other window…" stopped at
~412K. tuneOf took Codex's window as max(272K, the largest prompt seen),
so tune.Compact capped both the offered windows and the user's own value
at the largest prompt (~412K), whatever the model's window or the
user's setting.
Now codexWindow reads the window from magpie's catalog: a model with a
known window (typed or catalog) is offered up to it, and "now" is the
window magpie tells Codex (Settings' long-conversation value or the
model's own compaction, as codexcat writes it), 750K for zhemu. A model
whose window magpie doesn't know caps nothing short of 1M, and a mix
with one unknown is unknown. Codex's own models keep 272K or the
largest prompt. Claude Code is unchanged: only Claude models get the
advice, and other vendors' models use magpie's own window.
Run:
- TestTuneWindowsAreTheUsers (internal/gui), a custom provider with an
unknown window, 1M and 400K, on Codex and Claude Code. Old code:
"Codex on cpa/gpt-cpa-open: windows offered up to 410000; want
1000000" (and for 1m). Broken by hand: told dropped → "now 0, want
750000"; window=0 for unknown dropped → the mixed case fails.
- TestCompactUnknownWindowCapsNothing (internal/tune): old code "no advice".
- gofmt -l clean; go vet ./... and -tags nogui for GOOS=darwin, linux,
windows clean.
- context-tune.test.cjs (Chromium + WebKit): 70/70 pass.
- go test ./internal/tune ./internal/gui ./internal/settings ./internal/davsync
green at this head, rebased on origin/main
|
||
|
|
b00da3860c |
usage: a past cycle shows its own whole-window estimate, and a reset ends a dry run (#2009, #2010, NorethSea)
Ported from NorethSea's fork (abed2e224) and re-derived on main.
What it does:
- A known reset ends a dry run (a stretch where a window read 0% left), even
when the next poll sees the refill later. A stale dry reading taken after
its own reset no longer extends the run. Calls from the reset on are not
treated as "maybe paid from credits".
- A refill observed later than reset minus span
(QuotaPoint.StartsCycleAfter, the boundaries history sampling keeps)
starts what is reckoned. Calls before a fixed-deadline refill stay in the
cycle before it. A first reading is not a reset.
- Picking a past cycle in Usage > Allowances > Trends > Cycle asks
GET /api/usage/quotas/history/holds once per selection
(quotaCycleHoldsOf). The route asks no vendor. HistoricalWindowHolds
reckons each window at its own last reading in the cycle, using the
ledger and readings from before that reading. "Loading..." shows while it
is pending. An answer for a cycle no longer picked is dropped. The card's
Refresh, or an asked read, reckons again. The estimate's tooltip names the
window's start and the reading's time.
Changed from the fork:
- After a run closed at its reset, the fork reset lastLeft to zero. A
window that ran dry again before its next reset then opened a run from
time zero, which hid every window's estimate, the weekly one included.
The next run now starts no earlier than that reset.
TestWindowHoldsDryAgainAfterReset covers it (red with the fork's line).
- The fork narrowed the live card's Span to the observed refill. Span also
feeds provider.WithWindowStarts, so the window's Pace would have moved.
withSpansOf puts the card's spans back after reckoning. A span assertion
in TestWindowHoldsUsesObservedRefillStart covers it (red without it).
- The fork's historical snapshot dropped the card's Balance. That slipped
past the gate a live card has (holdsBounds), so a card that tells a
balance got past-cycle estimates. Balance is now kept. Covered in
TestHistoricalWindowHoldsUsesEachWindowsOwnReading (red without it). The
fork's fixture had a Codex card with a Balance, which no Codex card has.
- Main has since added HoldsWhy (#2045). The fork's own "Whole: not enough
reliable data" line and its .quota-holds-unknown CSS are left out. A past
cycle uses main's holdsUnknownLine and its reasons, as a live card does.
A window with neither an estimate nor a reason shows nothing, where the
fork showed its unknown line.
- withRecordedWindowStarts is ported to main's holdsBounds(start, end, why).
- quota-refresh-order.test.cjs's VM harness now stubs quotaCycleHolds,
which loadQuotas and quotaRefresh clear.
Left out: nothing else from the fork. Past prices aren't kept, so a past
cycle's cost uses today's API list prices (documented). Credits can't be
attributed per call, so none is attempted (documented).
What was run:
- gofmt -l: clean. go vet -tags nogui ./... for GOOS darwin, linux and windows.
- go test -tags nogui ./internal/usage ./internal/gui ./internal/provider:
ok.
- Each of the three fixes above was reverted by hand, and its test went red.
- GUI, Chromium and WebKit:
- quota-curve: 30/30. Also run at 1100 and 420 wide: 60/60 (all five
languages).
- Also: quota-*, i18n-keys, gui-de/ja/zh-tw, usage-card-refresh,
usage-refresh*, usage-stale-answer, usage-remote-cards,
usage-accounts*, usage-quota-head, usage-pack and usage-alert.
- Reds: quota-count-wrap and quota-name-translated are red in WebKit,
the same as on origin/main
|
||
|
|
758a4084ee |
sync: LAN sharing stays as each computer has it, so turning it on at home no longer turns it on at work (Lullaby on Discord)
Settings.KeepOwn now keeps LAN (sharing on the local network), AllowIPs (the addresses let in to it) and SessionTerminal (the Mac app a session resumes in) from this computer whenever a sync, a join, a Restore, an Undo or a backup file brings settings in. davsync's hashes blanks the same fields, so flipping sharing is no change to push. A backup restored onto a new computer leaves sharing off there: it opens the gateway to the network, so it is turned on by hand, like the port and proxy. The default sharing key is not per computer. It lives in the gateway-key store, which rides the settings part with LANKey and LANKeyID, so every computer holds the same key, and a second computer turning sharing on takes up that key instead of making another one (configureLAN finds it by LANKeyID or k.LAN). Audit of Settings, what stays synced and why: - already own: Window/WindowMaximised, UIFont/CodeFont, Proxy, Port, Dock/DockWindow, Lightweight, KeepAwake/KeepAwakeDisplay, Tray*, GatewayMode, NoWSLAgents, QuotaReads, NoAccountDiscovery, GatewayConversations. - made own now: LAN, AllowIPs (the address list belongs to the network this computer is on), SessionTerminal (another Mac may not have the app). - not in Settings: launch at login (internal/autostart, the OS's own setting) and the listen address (MAGPIE_ADDR, plus Port). Remote access through Tailscale etc. goes through those. - still synced: CORSOrigins (pages and extensions the user uses, and each still needs a gateway key), OTel, Redact*, update settings (NoAutoUpdate, AutoRestart, UpdateMirror, ChinaMirror), alerts, model and agent choices, Theme/Lang/TextSize. These are the user's preferences, not facts about one machine. Older magpie versions still take LAN from the bundle. Only new clients ignore it. Docs: sync-backup.md gets a "What stays on each computer" section, and gateway-routing.md says AllowIPs is per computer. README and site docs don't list what sync carries, and no GUI string does either, so they are unchanged. Run, on origin/main |
||
|
|
ef49011448 |
gateway: Stays: Auto keeps a conversation on Claude's 1-hour cache for the hour, not 5 minutes (#2302, j3r0lin)
affine called a conversation "cold" once its last reply was more than
cacheCold (5 minutes) ago, whatever the reply said of its cache. A Claude
reply that wrote with cache_control ttl "1h" (cache_creation's
ephemeral_1h_input_tokens, already parsed into Usage.CacheWrite1h; Claude
Code asks for it on a subscription) keeps that prefix for an hour, so the
next turn 5-60 minutes on lost its priority and could move to another
account or model that has none of the cache.
answered now keeps an hourCache on the stick: the tokens read plus the
1-hour write (Anthropic puts 1-hour breakpoints before any 5-minute one,
so what was read lies inside that prefix), and when. A later reply on the
same account and model that reads at least all of it starts the hour
again; one that reads less (moved, compacted) drops it. affine's "cold"
now needs both past 5 minutes and no warm hourCache (>= cacheWorth tokens,
within cacheHour). It is saved in affinity.json (cacheHour, cacheHourAt;
absent in older files, read as none). Sibling: keepsEffort, which lets a
group's effort drop only once the cache is lost, used the same 5 minutes;
turnRule now carries the same hourCache from ruleAnswered.
Vendors that report no 1-hour write never have an hourCache, so their
behaviour is unchanged; resting, spent, strict and the other reasons are
judged before this as before.
Tests: TestAffinityKeepsAnHourCachePastFiveMinutes (real server stack, an
Anthropic upstream reporting cache_creation: 1h write at 20 min -> cache,
at 59 min across a restart -> cache, at 61 min -> cold, 5-minute write at
6 min -> cold, a 1h write under cacheWorth -> cold), TestHourCacheAfter,
and two TestKeepsEffort cases. With affine's and keepsEffort's old
conditions put back, both fail ("an hour's write, 20 minutes on: ...
Why:cold, want cache"; "an hour's cache: warm at 20 minutes: false, want
true"); with the file's cacheHour left unread, the restart case fails.
Real data: the owner's usage.jsonl has 166 Claude subscription replies
with cache_write_1h > 0, e.g. cache_read 57901 + cache_write_1h 336, the
shape hourCache takes. Not tried live past 5 minutes against Anthropic.
Ran: gofmt -l, go vet -tags nogui for darwin/linux/windows on
internal/gateway, go test -tags nogui ./internal/gateway (full package).
Full suite: SUITE_LINE
|
||
|
|
3c921835d0 |
library: RTK switches on for OpenCode 2 with rtk 0.52 or newer, not "Not for OpenCode 2" (#2295, witt-bit)
The RTK tab blocked OpenCode 2 whatever rtk was installed: rtk's
OpenCode plugin used to be written for OpenCode 1 only, which OpenCode 2
refuses ("Plugin must export a default definition with an id and an
effect or setup function", rtk-ai/rtk#4311). rtk-ai/rtk#4187 (merged
10-12, first released in rtk 0.52.0, also in 1.0.0 and 1.0.1, the
reporter's) writes one default object with OpenCode 2's id and setup()
beside OpenCode 1's server(). Checked with gh: 0.52.0's and 1.0.1's
hooks/opencode/rtk.ts are byte-identical, 0.51.0's is the old named
export.
- openCodeBlocked: with OpenCode 2, blocked only when rtk is older than
0.52 or doesn't say its version; the reason now says to update RTK.
OpenCode 1 is unchanged with any rtk.
- openCodeHas: under OpenCode 2, an old plugin (no setup()) left from
before an rtk update counts as off once the rtk here is 0.52+, so
switching it on runs rtk init, which writes the new one over it. With
an older rtk it still counts as on, so it can be switched off.
- GUI: the OpenCode row's tag is "Update RTK" with OpenCode 2 reasons
(on: refuses this plugin, update or switch off; off: needs 0.52), in
en, zh, zh-TW, ja, de; the "Not for OpenCode 2" strings are gone.
- docs/subsystems/library.md says the same.
What was run:
- Real binaries in a sandbox HOME (throwaway test, not committed):
rtk 1.0.1 and 0.51.0 (aarch64-apple-darwin release tarballs) with the
real OpenCode 2.0.25 on PATH. rtk 1.0.1: row not blocked, SetRTK on
wrote an 8425-byte plugin with setup(), off took it out. rtk 0.51.0:
blocked "OpenCode 2.0.25 needs RTK 0.52 or newer, and this RTK is
0.51.0 …", SetRTK on refused, nothing written.
- Real OpenCode 2.0.25 in a sandbox HOME (its own service, stopped
after): rtk 1.0.1's plugin logs "loading plugin" with no error;
0.51.0's logs "failed to load plugin … Plugin must export a default
definition with an id and an effect or setup function".
- TestRTKOpenCode2 rewritten (fake rtk writes each version's real
plugin shape). Broken by hand three ways, each a FAIL: old rtk.go
(blocked: "RTK doesn't support OpenCode 2 yet …"), stale-plugin rule
dropped ("OpenCode 1's plugin under OpenCode 2 is listed as on"), gate
at 1.0 ("rtk 0.52.0 blocked for OpenCode 2").
- New GUI test library-rtk-opencode2.test.cjs: every language, 1100
and 420, on and off rows, Chromium and WebKit 21/21 each; red on the
old client.js/i18n.js. gui-de, gui-ja, gui-zh-tw, i18n-keys and all
library-*.test.cjs: 286/286 in Chromium and in WebKit.
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags
nogui ./internal/library; go test -tags nogui ./internal/library
under a temp HOME with pinned caches, on the rebased head.
Full suite: SUITE_LINE
|
||
|
|
e679f1106f |
cli: magpie plugin lists a plugin's tools and its page
The list said a gateway module's hooks, routings and onUsage, but nothing
for a plugin that gives tools (P4b) or a page (P4c), so such a plugin had
nothing under its row. Found in the combined P4 real-use run.
Tools are listed by their names on the plugin tools MCP server
(gateway.ToolNames), a page by its title and what it may read.
Run: TestPluginListSaysToolsAndPage, and internal/cli whole (ok). gofmt
clean; vet darwin, linux -tags nogui and windows = 0. Broken by hand:
without the tools line the test goes red ("aren't listed"), and without
the page line too ("isn't listed"). A `!e.Off` guard on the tools line
didn't change the test, since the host loads no plugin that is off, so
it was dropped.
|
||
|
|
3f913b3de6 |
plugins: a JS gateway plugin serves routings (strategies) and watches usage rows (onUsage); plugins/middleware is "JS gateway plugins" (P4)
A plugin's gateway module (magpie.middleware, or its alias magpie.gateway,
or a *.gateway.js file) may now export, besides onRequest/onEvent/onResponse:
- strategies: {name: (pool, seats, options) => order}. Each is a routing
"<short name>/<name>", registered with routes.Register while the plugin is
on and loaded and removed when it goes off or reloads. Seats are
routes.Seat in camelCase JSON. 20ms each; it fails open: a throw, a timeout
or a result that isn't an order of the seats means the listed order. The
failure is counted and logged, rate-limited. A file's name is made into a
routing-safe prefix.
- onUsage(row, options): gets an allow-listed usage row (no bodies, prompts,
error text, sessions or request ids). The rows come from a bounded queue
(1024) with one worker, off the request path; a full queue drops the row
and counts it, and a request never waits. 250ms each.
plugins/middleware is renamed "JS gateway plugins", with a new Sub
(en/zh/zh-TW/ja/de). It registers usage.Observe(middleware.Points()). Off,
no JS hook, strategy or onUsage runs. InUse is unchanged.
providers.json keeps a routing of the form <plugin>/<name> as saved
(provider.PluginRouting) in provider and group Save, whether or not a
plugin serves it now. Before this, `group set g routing=pick/last`
stored nothing.
GUI: the settings state carries jsRoutings. Provider and group routing
pickers offer the served ones, marked data-feature=middleware. A saved
routing that no plugin serves now shows as it is, with a hint. The
Plugins page's line shows routings, how often they were asked, onUsage
rows and dropped rows. The CLI accepts `group set <id> routing=<plugin>/<name>`.
`magpie plugin` lists a module's routings and onUsage; a strategy-only
module had printed nothing after "gateway middleware".
Docs: docs/subsystems/gateway-middleware.md (Routings and usage rows,
limits, verification) and plugin-runtime.md (P4: community plugins at
every point). site/public/docs plugins.html in en, zh and ja has an
example: internal/middleware/testdata/spread.gateway.js, which
TestDocsExample runs.
What was run (worktree on 4df1ba0c6, -p 2):
- gofmt -l: clean. go vet on internal/{middleware,cli,gui,plugin,provider}
and plugins/...: darwin, GOOS=linux -tags nogui, GOOS=windows; all
clean, run after the last Go change.
- go test, after the last Go change: internal/middleware ok,
plugins/middleware ok, internal/provider ok (210s), internal/cli ok
(203s). Earlier in the work: internal/plugin ok (385s), internal/pluginrt
ok, internal/gui (Go) ok (320s), and plugins/... ok. The first
plugins/... run printed a bare FAIL line that `tail` cut off before its
cause showed. The rerun was all ok; the cause is unknown.
- GUI, both engines (routing-*, group-*, builtins, i18n-keys, gui-de/ja/zh-tw,
plugin-middleware): 1220 tests, 1204 pass, 16 fail.
- routing-manual (4): mine. A group's own "manual" was offered a second
time as a routing no plugin serves. Fixed in client.js withJS. The
coordinator is rerunning routing-manual, keys-fold, group-fold,
intent-entry and routing-js alone in both engines, so that rerun is
not recorded here.
- routing-model-rest: red alone too, and red on untouched 4df1ba0c6
(3/20). It is #2115; I commented there with the webkit cases.
- group-member-weight webkit de 420 is #2387.
- group-from-model-add webkit zh: it passes alone 2 of 2. Under load it
waits a fixed 2s for the save post. Filed as #2388.
- routing-keys-fold (webkit zh/ja/de), routing-group-fold (goto timeout)
and routing-intent-entry (browser launch timeout 180s) are load
timeouts. The coordinator is rerunning them alone.
- routing-js.test.cjs (new) passed in chromium en and zh, before the full run.
Broken by hand, each test went red, then restored:
- the permutation check: TestStrategyFailsOpen;
- the queue's non-blocking send: TestOnUsageNeverBlocks ("Ledger waited
2.04s");
- the allow-list: TestUsageRowAllowList;
- unregister on off: TestStrategiesServedWhileOn and
TestStrategiesStopWithServe;
- the CLI pattern: TestParseRoutingStays;
- Observe in plugins/middleware: TestOnServesStrategies;
- PluginRouting in provider.go and in group.go: TestPluginRoutingKept;
- the prefix sanitizing: TestRoutingFromFileName;
- the CLI list line: TestPluginListSaysMiddleware;
- the GUI's data-feature mark and its unserved-saved entry: routing-js.
Real use: a sandbox HOME, the gateway served on 127.0.0.1:3682 by a
-tags nogui build, a fake vendor on 3681, and providers fa (key ka) and
fb (key kb) in group g. pick.gateway.js has strategy last (reverse) and an
onUsage that logs.
- `group set g routing=pick/last` stored it.
- A request to group/g reached the vendor with Bearer kb, and the
"usage-row fb m in=5 keys=17" line was logged.
- `plugin off pick.gateway.js`: Bearer ka (listed order), no onUsage,
routing still pick/last.
- `plugin on`: Bearer kb and onUsage again.
- `plugin builtin off middleware` says "in use and stays on", as InUse
should.
- Not tried: the GUI against that gateway, or a real vendor account.
|
||
|
|
64b0f3a201 |
plugins: a community plugin's own page in magpie's window, shut in a sandboxed frame (P4)
A plugin's package.json may declare magpie.page {title, file, icon} and
magpie.permissions.reads. While the plugin is on, its page gets a tab in a
"Plugins" group after the built-in pages, drawn in an iframe sandboxed to
allow-scripts only (an opaque origin: no cookie, no storage, no parent).
Its files come from /_magpie/plugin/<token>/ (HMAC of the spec with a
per-process secret) under a CSP with connect-src 'none' and
frame-ancestors 'self'; a path that leaves the page's folder, a symlink
out, or an off plugin's token is refused. The window's postMessage bridge
answers only that frame (event.source checked) with theme and language,
the plugin's own options.get/set (throttled), and the reads it declared;
any other read is refused in the window and again by the server, and no
read carries a secret. /api refuses Origin: null and frame/iframe
fetch-dest requests (noFramedAPI), so the frame never reaches the GUI's
API even with the cookie. A page that throws or never says hello shows
the kernel's broken-page state with Try again. The Plugins page shows the
page and what it reads before the plugin is turned on.
Docs: gui-shell.md, plugin-runtime.md (P4 section), site docs en/zh/ja
with an example plugin; i18n zh, zh-TW, ja, de; fixture in
internal/gui/testdata/page-plugin.
Run (worktree at base 4df1ba0c6, -p 2, one package at a time):
- go test -count=1 -timeout 45m: internal/gui ok, internal/plugin ok,
internal/pluginrt ok, plugins/... (budget groups middleware otel redact
rotation search) ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
- Playwright (chromium + webkit, 5 languages, narrow widths): plugin-page 4/4,
plugin-kernel 4/4, builtins 4/4, i18n-keys, gui-de, gui-ja, gui-zh-tw 3/3,
plugin-middleware 24/24, plugin-own-icon 22/22, plugin-options 22/22,
plugin-local 8/8, plugin-agent 22/22, click-scroll 22/22.
Broken by hand, each went red: CSP without connect-src; apiFramed always
false; the server's read check removed; the noFramedAPI wrap removed from
api.go (red through the real Handler); inside() letting every path
through; CORP same-origin re-added; in JS the client read check removed,
the ev.source check removed, and allow-same-origin added to the sandbox.
Without the Array.isArray guard on /api/plugin-pages, plugin-kernel,
builtins and plugin-middleware/own-icon/options went red (their mocks
answer a non-list) - that was found by the run, then fixed.
Real use: built magpie, `magpie web` on 127.0.0.1:3472 (gateway 3471) in a
sandbox HOME with the example plugin added. curl: the page file loads
with the CSP and no cookie, traversal and a bad token are 404, /api with
Origin: null or Sec-Fetch-Dest: iframe is 403 even with the cookie, an
undeclared read 403, a declared one 200. Chromium and WebKit at 1100 and
420: the page draws its declared read, the probe's fetch/absolute
fetch/top access/undeclared read are all refused, an <img> of /api is
refused, no page errors. Real use found that a
Cross-Origin-Resource-Policy: same-origin header blocked the frame's own
files (its origin is opaque); it is gone and a test guards it.
Not tried: the desktop (Wails) window. Market cards of plugins not yet
installed don't show a page's reads. The Playwright suite mirrors the
CSP in a mock route rather than the Go server (the Go tests and real use
cover the server).
|
||
|
|
6ac7032b4b |
plugins: a community plugin's tools reach every agent through magpie's MCP server /mcp/magpie/tools (P4 tool point)
A plugin's OpenCode `tool` hook ({tool: {name: tool({description, args,
execute})}}) used to reach no agent. Now the plugin host collects each
loaded plugin's tools, turns their zod args (v3/v4 shape or object; a
raw JSON Schema is kept) into JSON Schema, and runs one on a `tool`
call: arguments checked against the tool's own zod first (defaults
filled, a wrong one named), execute raced against ToolTimeout (55s,
ctx.abort fires), the answer as text.
The gateway serves them as an MCP server at /mcp/magpie/tools
(tools_mcp.go, guarded by serveMCP as the search one, 4 MiB body):
tools/list names each <plugin short name>_<tool>, at most 64 chars,
a shared name numbered _2; tools/call holds the call to the calling
key's limit through reserveFor and runs it with the calling agent.
The built-in plugin `tools` ("Plugin tools", Essential) serves
gwtool.PluginTools; off, nothing is listed, a call says the plugin is
off and the host isn't asked. InUse counts plugins that are on and
gave tools, from plugin-tools.json, which the host writes after each
load (whole, only on change), so it never starts Bun; the gateway's
KeepFresh watches that note too. Tool answers go to the calling
agent only, so masking doesn't apply (said in the docs).
The Plugins page lists an on plugin's tools by their MCP names, with
descriptions on hover and a button copying the server's address; a
plugin of tools alone has no Provider chip and isn't said to sign in
to nothing. Not done: a Library featured opt-in entry; wiring is the
copied address.
Docs: docs/subsystems/plugin-tools.md (new), plugin-runtime.md's new
"P4: community plugins at every point" section with the tool row, the
README index, usemagpie.ai/docs/plugins#tools in en, zh, ja with an
example. Strings in zh, zh-TW, ja, de. Example plugin:
internal/plugin/testdata/tools.
Run at this commit's tree (base 4df1ba0c6), each package alone, -p 2:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
over internal/plugin, gwtool, gateway, plugins/..., gui, pluginrt: ok
- go test ./internal/plugin -run Tool; ./plugins/...; ./internal/pluginrt;
./internal/gui -run 'Builtin|Plugins'; ./internal/gateway -timeout 45m
-run 'ToolsMCP|ServingGates|OwnMCPRejects|SearchOnAndOff|KeyLimitsOnAndOff':
all ok
- GUI, Chromium and WebKit: every plugin-*.test.cjs, i18n-keys,
builtins: 461/461 pass; plugin-tools.test.cjs (new) covers en, zh,
zh-TW, ja, de at 980 and 420 px
Broken by hand, each red, then restored:
- tools/list ignoring the gwtool gate -> TestToolsMCPOff
- tools/call ignoring the gate -> TestToolsMCPOff
- reserveFor removed -> TestToolsMCPHeldToKeyLimit (tool ran)
- collision suffix dropped -> TestToolsMCPServesPluginTools
- ToolsOn ignoring Off -> TestPluginTools
- host arg check removed -> TestPluginTools
- host timeout race not listening -> TestPluginTools (answered at
5.3s by Go's backstop; the test now bounds it at 4s, and the first
try at this break was a syntax error that proved nothing)
- GUI listing an off plugin's tools -> plugin-tools.test.cjs
Real use: a built magpie in a sandbox HOME (MAGPIE_ADDR 127.0.0.1:3491,
real Bun), the example plugin added with `magpie plugin add`. curl over
MCP: initialize, tools/list (4 tools, schemas), shout "HI HI (for
curl)", a missing argument as isError naming it, add {"sum":6.5}, fail
"it broke", a foreign Origin 403; plugin-tools.json written. Claude
Code (sandbox CLAUDE_CONFIG_DIR) `claude mcp add --transport http` +
`mcp list`: Connected. Not tried: a model calling a tool through a
real agent turn (no model in the sandbox). Binary and HOME removed.
|
||
|
|
2e2c890304 |
agent: Lody is detected by what Lody makes, its link only on loopback is guarded, and its row is tested in every language
Review of Leon Zhao's Lody import (the two commits before this):
- Detection: a bare ~/.lody or ~/.lody-oss another tool made counted as
Lody. Now the home folder counts only with an entry Lody makes there
(workspace-catalog.json, loro-repo, agent-binaries, code-collab-v2, all
in the owner's real ~/.lody). A Lody.app counts only with an ai.lody.
bundle id (the real /Applications/Lody.app is ai.lody.desktop, and
registers the lody scheme) or a plist that isn't XML. Electron's data
folder under os.UserConfigDir (Application Support / %APPDATA% /
~/.config, "Lody", "Lody OSS", "Lody Nightly") still counts as before.
A never-opened install on Windows or Linux has no folder and isn't
shown; said in agent-wiring.md.
- Security: TestLodyLinkCarriesNoSecret turns LAN sharing on and checks
the link holds magpie-lody and never the LAN key, every endpoint is
loopback http, and MAGPIE_ADDR pinned beyond loopback gives no link at
all (0.0.0.0, 127.0.0.1 and [::1] still give one).
- `magpie lody add` with no link (a LAN-pinned gateway) said it opened
Lody and opened ""; it now says why and opens nothing.
- Added *bool: every consumer re-read. The CLI and TUI use agent.Agent's
func (nil-safe), the GUI reads a.added == null, and Cindy's false is now
sent as "added":false. TestLodyImportHandoff also checks Cindy's row
says false and Lody's leaves added out; the handoff test's ~/.lody
holds a catalog file now and checks it is left byte for byte.
- The hint "Opens {name} to add magpie as a provider — confirm it there"
was already translated in zh, zh-TW, ja and de (the import button's
tooltip). import-row now runs in all five languages, asserts Lody's
exact translated line and that no added/not-added wording shows, and
checks both import rows fit a 420px window with no sideways scroll
(waiting for the header's segments to settle after the resize, which
overflow for ~300ms in WebKit en on main too).
Run (on origin/main
|
||
|
|
c6bd4e9707 |
agent: let Lody confirm local provider imports
Offer Lody a versioned import link for Claude, Codex, Pi, DSH,
Kimi Code, Grok and Bub. Export only loopback endpoints and the public
magpie-lody token. Leave Lody data untouched and show a confirmation hint
when the app exposes no public import-status reader.
Verified: go test -tags nogui ./... in a temporary HOME with pinned Go
caches; native, Linux nogui and Windows vet/build; gofmt and diff checks;
17 Chromium/WebKit import-row and locale checks. The actual Lody parser
accepted all seven targets with IPv4, localhost, IPv6 and canonical ports.
Negative controls: removing registration fails
TestLodyDetectionAndRegistration with "Lody missing from Agents";
removing URL handoff fails TestLodyImportHandoff with
"Lody import was not handed to the desktop". Restored tests pass.
Desktop launch and Linux/Windows runtime behavior were not exercised.
Cherry-picked onto main (
|
||
|
|
37fec12409 |
import: OpenCode's keys come in from its auth.json, Go's on OpenCode Go (@hu_xiaomi on X)
@hu_xiaomi on X asked whether magpie could pick up OpenCode Go's API key
by itself. OpenCode keeps what `opencode auth login` signs in to in
auth.json, in $XDG_DATA_HOME/opencode (~/.local/share/opencode when that
is unset, on Windows too). Its format and path were checked against
anomalyco/opencode v1.19.0, packages/opencode/src/auth/index.ts.
- OpenCode is now a source in the import picker (appReaders,
import_opencode.go). An "api" key comes in on the magpie preset with
the same id: opencode-go on OpenCode Go, opencode (Zen) on OpenCode
Zen, and a vendor's key (openai, anthropic, deepseek, openrouter, ...)
on that vendor's preset, the same way Alma's almaPresets work.
- auth.json keeps no address beside a key, so a key for a provider with
no preset is listed and skipped ("it has no base URL"). Sign-ins
(oauth: Claude Pro/Max, Copilot; wellknown: an enterprise server's
token) are listed and skipped with the reason the picker already
translates. No new GUI strings.
- OpenCode is read only when the user opens the picker. The Providers
page's automatic discovery leaves it out (DiscoverSources, the `asked`
flag), because the file holds every sign-in OpenCode has. magpie never
writes to it. OPENCODE_AUTH_CONTENT is not read.
- presetAt: the first preset at a host won even when a later one matched
the URL exactly. OpenCode Zen and Go share opencode.ai, so a Zen key
would have landed on Go. An exact match now wins.
- importSources: a source whose stat fails with anything but not-exist
(a folder magpie can't search) is found with an error, which means
unknown. Before, it read as "Not found".
- The picker's tab shows OpenCode's own mark (icons/opencode.svg).
- docs/reference.md describes the source.
Not added: an "use the key OpenCode has" offer in the OpenCode Go add
sheet, because no other app has one there (no sibling to follow).
Run (macOS, go1.26.8, worktree at
|
||
|
|
a1f7b8c13f |
plugin: gateway key limits are the Key limits plugin on the gateway's budget point (P3)
The last P3 point, after observer, router strategy, middleware and tool:
the budget point (internal/gwbudget). A plugin serves a Limiter while it
is on; the gateway asks gwbudget.Limiting before any request of a key held
to a limit goes to a provider (reserveFor: the chat APIs' keyLimited, the
search MCP server and the vision one). A request without a key, or of a
key with no limit, never asks it.
It fails closed. A key with a limit and no limiter served gets 503
gateway_key_limit_off, X-Should-Retry false, nothing sent, and a rejected
usage row. With none served, Limiting first asks the gateway's refresh
(pluginrt.Refresh, at most once a second, never from inside one), so a
limit set a moment ago turns the plugin on for the request that needs it.
A limit reached is the 429 gateway_key_limit with Retry-After and
X-Magpie-Limit-Reset, as before.
plugins/budget serves internal/budget's limiter (budget.Limiter). It is
Essential and in use while a gateway key has a limit, so it can only be
off while none has; a keys file that can't be read is an error, so it
stays on. KeepFresh watches the keys file too. What a key has used and
has left (/v1/magpie/limit, the Gateway page, the CLI) and budget.Append
stay in the core, so the ledger counts a key's use the same either way,
and the key editor's limit fields stay, since setting a limit is what
turns the plugin back on.
The builtins GUI test wheels to the Routing row as it did to Usage's: the
new row puts it below the fold in WebKit, where the page puts back a
scroll that isn't the reader's (scrollOnPurpose).
Run at this head (on origin/main
|
||
|
|
dd25997a45 |
codex: a client's access_programs and the account's extraBody reach the ChatGPT backend, and its refusal comes back as it said it (magpie-releases#18)
NonMirror (0.1.1239, OpenCode, codex/gpt-daybreak-blue-latest on a ChatGPT
sign-in): a top-level Responses access_programs never reached upstream,
and the codex provider's extraBody wasn't applied.
Cause:
- A Codex account is streamed upstream, so a whole (stream:false)
Responses request and every Chat or Messages request is translated
(parseResponses/parseChat -> Request -> buildResponses). Request had no
field for access_programs, so the rebuilt body dropped it. Only a
streamed Responses request, relayed through codexBody, kept it.
- WithExtraBody skipped every signed-in account, and withPicks didn't
copy the providers.json ExtraBody onto the account.
- writeError rewrapped every vendor error with code and param null, so
even a forwarded refusal lost what it was about.
- The backend refuses a program the workspace hasn't got inside a 200
stream (error event, invalid_request_error, access_program_not_enabled).
The whole-translated path answered that 502 api_error, and translated
streams wrote it as api_error, which holdWriter reads as 502: the same
request went three times, then to the other accounts, and every one
rested.
Fix:
- Request.AccessPrograms (Responses and Chat), built into the Responses
body as it came; a null is kept.
- A ChatGPT (Codex) account takes extraBody; store, tool_choice and
include stay magpie's (codexOwned). withPicks keeps ExtraBody.
- writeVendorError keeps the vendor's error.code and error.param on the
relayed, whole-translated and streamed-translated status-error paths.
- requestRefused: a Responses stream error/failed whose error type is
invalid_request_error carries status 400 and the vendor's error
(Event.Said). The whole path answers that 400 with code and param; the
Chat, Anthropic and Responses encoders write its type/code/param
(saidError). Read by the type, never by words.
- Codex CLI sends access_programs as a top-level object on its Responses
request (codex-rs ResponsesApiRequest.access_programs); OpenAI's Daybreak
guide documents the same field.
Run:
- New: internal/gateway/codex_access_programs_test.go
(TestCodexAccessProgramsReachBackend, TestCodexAccountTakesExtraBody,
TestAccessProgramsNullKept), passes -count=3.
- Broken by hand, each went red: buildResponses not emitting the field
(probe answered 200, the reporter's symptom); extraBodyTakes' Codex case;
withPicks' line; codexOwned emptied; writeVendorError ignoring the body;
the continuation site alone; retryable(400) true (asked twice, rested);
requestRefused returning nothing (502, asked 4 times, both accounts
rested); saidError a no-op (streamed: asked 4 times, rested); the whole
site back to 502 (same).
- go test -timeout 30m ./...: all 62 packages ok (gateway 1559s at load
~26; an earlier run at the default 10m timed out in gateway under that
load, not a failure). gofmt -l clean. GOOS=linux and GOOS=windows
go vet -tags nogui ./... clean.
Real account (sandbox HOME, own port 3486, copied auth.json with a dead
refresh token; owner's ChatGPT Pro account, model codex/gpt-5.6-luna):
- "__daybreak_forwarding_probe__": 400 invalid_value, param
access_programs.cyber ("Supported values are: 'standard',
'daybreak_blue', and 'daybreak_red'") on Responses whole and streamed,
Chat whole and streamed. The backend says invalid_value, not the
guide's invalid_access_program.
- standard: 200. null: 400 invalid_type.
- daybreak_blue (not enabled for this workspace): 400
access_program_not_enabled with param on Responses and Chat whole, the
error event with that code on Responses and Chat streamed; ~1s each,
one try (was 3 tries and a 502 before this change).
- The next plain request was served 200 by the same account: nothing
rested.
Not verified: the Daybreak model itself (not listed for this account),
so no 200 with daybreak_blue; OpenCode's own wire; the Messages route
against the real backend (fake backend only).
|
||
|
|
9d97fd0733 |
plugin: magpie's web search is the Search plugin on the gateway's tool point (P3)
The third P3 point after observer/rotation, groups and middleware: the
tool point (internal/gwtool). A plugin serves a tool by name while it is
on; the process serving the gateway gates on it (Gate in ListenAndServe),
and a process not serving the gateway (CLI, TUI) has every tool, as
before.
plugins/search serves gwtool.WebSearch. Off, magpie offers and answers no
search of its own: the stand-in web_search isn't given to a model that
can't search, the search MCP server and Codex's search in ChatGPT's place
say "turn the Web search plugin on", and neither a search API nor a Kimi
Code plan's own search service is asked. A vendor that searches by itself
is still sent its own web_search. It is Essential and stays on while a
search API is set up or a searcher is picked (InUse); a providers.json or
settings.json that can't be read counts as unknown, so it stays on.
Settings → Models' Web search section stays visible with the plugin off:
the plugin can only be off when nothing is set up there, and adding a
search API there is what turns it back on (as Privacy does for redact).
Run at this head (rebased on origin/main
|
||
|
|
35aa50cfb3 |
zhipu: a GLM Coding Plan key refused 200 in the platform's envelope reads as refused, in the test, the gateway and the quota card (@xanahopper on X)
On a Coding Plan with a key Zhipu refuses, Test showed OpenAI 401 and Anthropic 401 but Responses (https://open.bigmodel.cn/api/v1) a green check, and the 5h/weekly windows showed only "Allowance unavailable". Cause: /api/v1 (Zhipu's real Responses endpoint, docs.bigmodel.cn coding-plan/tool/codex) and /api/monitor answer a refused key HTTP 200 with {"code":1000,"msg":"身份验证失败。","success":false}. probe (endpoint Test, model tests, Detect) took any 2xx as ok, and the gateway handed the 200 to Codex as a reply, so no failover and no rest. - provider.ZhipuEnveloped: a 2xx JSON, non-stream, unencoded reply from open.bigmodel.cn or api.z.ai whose body is the envelope with success:false becomes {"error":{...}} under the status Zhipu's code table gives (1000-1005 401, 1113/13xx 429, 1220 403, 121x/1261/1301 400, else 502). Anything else passes through unchanged (64KB cap, body restored). Applied in probe and in the gateway's forwardOnce. - planquota: a refused key (envelope 1000-1005 or HTTP 401 from a Zhipu/Z.ai host) says "Zhipu didn't take this key (...): it has expired, was deleted, or is mistyped; paste a current one from <keys page>", and skips the team retry. The card shows it in en, zh, zh-TW, ja, de. - docs: providers-accounts and gateway-routing rows. Run at this head (before rebase, base |
||
|
|
03eb0633af |
library: an agent not installed is on no row but those of what it still has (@jiahao_jayden on X)
Library → Skills showed a chip for WorkBuddy on every row though it
wasn't installed ("一排有点密恐了"). WorkBuddy has no CLI and no detect
rule, so it counted as installed whenever ~/.workbuddy (or its
models.json) existed; that folder stays after the app is trashed, and
magpie itself writes models.json, mcp.json and skills/ there.
- agent: on a Mac WorkBuddy and WorkBuddy AI are detected by their apps,
each by its own bundle id (com.tencent.workbuddy.mac,
com.workbuddy.workbuddy-ai) in /Applications or ~/Applications
(macBundle). Off a Mac the folder still counts, as before.
- library: an agent that isn't a target but still has skills, servers or
hooks magpie gave it is held (Target.Gone). A sync takes edits from its
copies and then only takes things out of it; Read lists it with
gone: true while it has any, and not once it has none.
- GUI: a gone agent's chip is only on the rows of what it has, lit; a
click takes it away. All, the How-per-agent sheet and the pickers leave
it out; By agent lists it as "Not installed here" with Turn all on off.
No layout change. New strings in zh, zh-TW, ja, de.
Run at this tree (macOS, sandbox HOME, Go caches pinned):
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: clean. go build, GOOS=linux go build -tags
nogui, GOOS=windows go build: ok.
- go test -tags nogui -timeout 30m ./...: all ok (59 packages);
internal/gui rerun after the last string rename: ok.
- GUI: the 74 test files that open the Library, chromium and webkit:
563/563 each. library-gone-agents.test.cjs (new; 1100px and 390px, en,
zh, zh-TW, ja, de): 11/11 in both; i18n-keys.test.cjs: 3/3.
Broken by hand, each went red, then restored and green:
- old client.js: library-gone-agents fails "a chip for an agent not
installed on a row it has nothing on".
- workbuddyHere's Mac branch falling back to the folder:
TestWorkBuddyOnMacIsItsApp "no app, only the folders: WorkBuddy true,
WorkBuddy AI true".
- syncSkills' Gone guard off: TestGoneAgentListedToTakeOut "a sync gave
the gone hermes a skill again".
- held() returning nil: "hermes, holding a skill and a server, isn't
listed as gone".
- the gone sync steps skipped: "hermes, holding nothing, is still listed".
Not verified: the reporter's machine; WorkBuddy detection on Windows and
Linux (unchanged, still by folder); other agents detected by folder alone
(zcode, alma, grok-app, air, hanako, morph, grok) are unchanged. WorkBuddy
AI.app is installed on the owner's Mac without ~/.workbuddy-ai, so it now
shows as detected there.
|
||
|
|
01c41e8ba2 |
library: a skill probe's download goes when it is probed again or 15 minutes are up, and one a magpie that quit left behind goes at the next probe (#2321)
ProbeSkills kept each GitHub probe's download, a magpie-skill-* folder in
the temp dir, cached for 15 minutes. An expired one went only at the
*next* probe, so a magpie that quit, or a test that ended, left it there
for good. One go test ./internal/library left 22. This machine's temp dir
had 5477, and with old test homes they filled the disk under a full run
(gateway tests failed "no space left on device").
- keepProbe: each cached probe has a timer that removes its folder when
probeLife is up. A probe of the same input replaces it and removes the
old folder at once, outside the lock.
- sweepStaleDownloads, at each probe: a magpie-skill-* in the temp dir over
an hour old goes. No live one is that old, since a probe is kept 15
minutes and a fetch takes seconds.
- internal/library's TestMain gives the tests a temp dir of their own
(TMPDIR, and TMP/TEMP for Windows), ends the cached probes, and fails a
run that leaves a skill download there. A test binary started again by a
test keeps its parent's temp dir.
Run (on origin/main
|
||
|
|
4ac4d9ba99 |
plugins: the gateway's middleware point; JS middleware and privacy masking are built-in plugins, masking fails closed (P3)
P3's third point (docs/subsystems/plugin-runtime.md). internal/gwmw has two
places, each with its own failure policy:
- Agent: a middleware on an agent's request in its own API and on its reply.
serveAgent runs each registered one. The JS gateway middleware is the one
there (middleware.Chain), registered by the new built-in plugin
`middleware`. Its place, API, limits and fail-open are unchanged. InUse is
middleware.On(). Off, no middleware runs.
- Masker: what goes to a vendor, masked, and the values back in what comes
back. The new built-in plugin `redact` serves masking.Masker (in
internal/masking, since settings imports redact). InUse is masking.Wanted.
It fails closed: masking asked for with no masker serving, or a masker that
panics, is a 503 "nothing was sent" at every call site that masked before
(serve, count_tokens, embeddings and audio, transcriptions, images, video,
search stand-ins and their queries, the Codex backend).
With no masker, or with no agent middleware while plugins.json has one on,
the gateway asks pluginrt.Refresh, at most once a second. A setting or
middleware added a moment ago serves the request that needs it.
pluginrt.KeepFresh also watches plugins.json now.
Run (on origin/main
|
||
|
|
b1d02fa612 |
groups: the user's own routing groups are the groups plugin's, served only while it is on (P3 router strategy)
The groups plugin now owns the user's own routing groups at the router strategy point. The groups magpie finds (auto-<model>, one model several providers serve) stay core, as Smart does: a new install has groups off under Essentials, and taking those would silently drop cross-provider failover. planGroup and the walk over a group's members stay core too. - provider.GateGroups / ServeGroups (group_serve.go): the gateway holds the gate while it serves; the plugin holds ServeGroups while on. Gated with none served, groupsIn drops every group not Auto, so FindGroup, GroupFor, the catalog and /v1/models go without them. The CLI and TUI are never gated. Nothing derived from groups is cached past a call, so a flip is seen by the next lookup. - Gated and off, a lookup that finds a user group asks the gate's refresh (pluginrt.Refresh in the gateway) at most once a second, never re-entrantly, then looks again. Without this, `magpie group add` was 404 for up to 2s until KeepFresh turned the plugin on (seen in the sandbox). - plugins/groups and plugins/routing: InUse is provider.NamedGroups, the file's non-Auto, non-hidden groups read past the gate; an unreadable providers.json is an error, so the plugin stays on. Run before rebasing onto |
||
|
|
707fbb249d |
backup: a settings.json that can't be read stops a backup, an export and a sync, not carried as the defaults to every other computer (#2269, JasonBuildAI)
Collect read settings with settings.Load, which stands the defaults in for a file that is there but can't be read, or doesn't parse with no good .bak. A sync then pushed those defaults as "changed here", and every other computer brought them in over its own theme, language, text size, allow list and per-model settings; an export carried them too. Collect now reads through settings.LoadChecked and stops with its error, as it does for providers.json ( |
||
|
|
c7830731ca |
sessions: a session nothing was said in, which the Sessions page lists, opens and exports instead of "no such session" (#2273)
ListAgent lists a session assemble calls empty (no title, nothing
counted), so it can be cleared away, but Find searched only List(0) and
Get, and both drop it. The row's conversation, Markdown and Terminal
routes all go through Find, so they answered "no such session" for a row
the page itself shows. A real case is Codex's Image Session Helper: a
rollout with session_meta, settings, task_started and turn_aborted only.
Find now falls back to get(), which reports a session's files were found
even when assemble calls it empty, and fills it in the way ListAgent does
(listed(): Resume, Carry, Transcript), so Find finds every session
ListAgent lists. Get and List are unchanged: an empty session still
isn't in the main list and Get still says ok=false for it.
Run:
- TestFindEmptySession (internal/sessions) and TestEmptySessionOpens
(internal/gui), on a fixture made from the real aborted helper rollout
(paths and ids redacted). Both fail with Find's fallback broken by
hand (only taking ok sessions), and pass with it.
- gofmt -l clean; go vet for darwin, linux (nogui) and windows.
- go test -p 4 -timeout 40m ./... with pipefail, sandbox HOME, at
|
||
|
|
58651568b3 |
agent, sessions, provider: a state file that doesn't parse is kept aside, not written over as empty (#2263, ggbdpq)
applied.json, wsl.json and sessions-wsl.json were read as empty when they didn't parse, and the next save wrote that emptiness over them. What magpie had applied to each agent, the WSL distros and the WSL session listing were lost with no copy. stash.json already kept a bad file aside as .bad-<time>. Each of these now does the same through one helper, lastgood.KeepUnparsed, instead of a copy per file: - It does nothing when the file is missing or empty. - When the file doesn't unmarshal into the reader's own type (lastgood.Into[T]), it copies the file aside (KeepBad). - It stops the write when the copy can't be kept. This also fixes the issue's claim about stash.json. Stash judged a file with json.Valid, so `[]`, which a map reader takes as empty, was written over unkept. Its failed copy was only logged, and the write went ahead anyway. Both are fixed (TestUnreadStashArrayKeptAside), and gateway-hidden.json uses the same helper. Siblings found by going through every single-file JSON reader that takes a bad file as empty and then writes it whole: - stepfun-auth - login-returns - quota-history - balance-history - credits-daily - Claude Desktop tiers - plugin updates - usage's computer id - davsync's sync state Each now keeps a bad copy. Caches that are rebuilt from the vendor are left alone; docs/subsystems/providers-accounts.md lists them. Run: - gofmt -l, go vet (darwin -tags nogui, GOOS=linux -tags nogui, GOOS=windows): clean. - go test -tags nogui -p 4 -timeout 40m ./... with the other three commits of this push: see the last one's body. Broken by hand: on the code before this, these fail: - the issue's applied_keep_test.go and wsl_keep_test.go - TestUnreadStashArrayKeptAside - TestUnreadStateKeptAside (10 subtests) - the gateway, usage, davsync and plugin _keep tests TestKeepUnparsed and TestKeepUnparsedFailsWhenItCantBeKept cover the helper. I dropped a test, "not written when it can't be kept", for stash. It passed on the old code too, because a read-only folder also stops the atomic write. Not tried: a real WSL distro. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
919c8b934a |
gateway: a second answer to one call is dropped on the way to Gemini and Responses (#2262, ggbdpq)
A client that answers one tool call twice sent Google a call turn with more functionResponses than functionCalls, which Google refuses with 400, along with every later turn of the conversation. The Chat and Messages builds already keep the first answer (pairToolMessages, pairToolBlocks). The Gemini build (buildCodeAssistSent: Google sign-in, Vertex, a custom Gemini provider) and the Responses build (buildResponses) now leave the second one out before they build, with the images it carried (dropSecondAnswers). A call made again under the same id takes an answer of its own, and the request itself is left as it was, since a fallback builds from it again. This differs from the issue's patch. It dedups across the whole history in pairFunctionTurns, keyed by id, or by name when there is no id. Keying by name drops a real answer to a second call of the same function. Keying by id ignores a call made again under that id. The patch also left the duplicate's images in the turn and didn't cover Responses. Also fixed: parseGemini matched a functionResponse with no id to the latest call of that name, so two calls of one function were both answered as the second. Each now goes to the first call of that name still unanswered. pairToolItems (relayed Codex bodies) already keeps one answer per call and is unchanged. Run: - gofmt -l, go vet (darwin -tags nogui, GOOS=linux -tags nogui, GOOS=windows): clean. - go test -tags nogui -p 4 -timeout 40m ./... with the other three commits of this push: see the last one's body. Broken by hand: TestGeminiDropsASecondAnswer, TestSecondAnswerDroppedWithItsImages and TestGeminiClientUnnamedCallsAnsweredInOrder fail on the code before this. Not tried: against Google's or a Responses upstream's real API. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
226222118a |
agent: on Windows Claude Code and Codex are never taken for uninstalled by their folder, so neither shows "CLI not found" with its settings hidden (#1482, edussss)
edussss (Windows 11) on 10-15: "昨天早上的版本还能找到,今天早上更新后又找不到了". Their screenshot shows both Claude Code and Codex marked "CLI not found", with no model or effort pickers. v0.1.1231 listed both. Cause: |
||
|
|
af9bd6c3e2 |
gateway, routes, plugins: the routings besides Smart are the rotation plugin's, on the gateway's router strategy point (P3)
The second P3 extension point (docs/subsystems/plugin-runtime.md). A
router strategy orders one pool of routes: a provider's accounts or keys,
or the heads of a group's members. The gateway still lists the pool and
keeps rests, affinity, rules, pins and failover; a strategy only orders.
- internal/routes: Seat, Strategy{Order, Exact, ByUse}, Register (stacks,
the last serves), Find, Served, and Apply, which fails open: a strategy
that panics or answers what isn't a permutation leaves the pool in its
listed order, logged. Smart is the core's; Ordered, Rotate, LeastUsed,
Pace and Weighted are routes.Builtin, moved out of the gateway with the
rotate turns and the smooth weighted round (Round, MoveRound, Forget).
- plugins/rotation (Essential): registers routes.Builtin. InUse counts the
providers and groups providers.json routes by one of them
(provider.Routings), an unreadable file is an error, so it stays on. The
gateway's KeepFresh watches providers.json too.
- Off, a routing no strategy serves is its listed order, and routingOf
reads it as "order" wherever the core asks (a turn's mark, sinks, a
rotate group's sessions, a group's heads, weightedKept).
- GUI: the routing pickers (provider editor, Routing page pools and group
editor) mark the five as data-feature="rotation" (routingSegs), so off
they offer Smart alone. i18n zh, zh-TW, ja, de.
- Docs: plugin-runtime.md router strategy section, gateway-routing.md
(also drops a duplicated sentence about a lone key), reference.md.
Run in the worktree at this change (on origin/main
|
||
|
|
2b0037f41d |
sessions: a Claude Code, Qoder or Cowork project folder, a session's folder or a Hermes profile behind a junction is read, not skipped (#2268, JasonBuildAI)
On Windows os.ReadDir lists a junction as ModeIrregular, neither IsDir nor ModeSymlink, so a reader that goes into only IsDir() entries, or IsDir() and ModeSymlink ones, walked past a folder kept on another drive with a junction left in its place. ccFiles (Claude Code's own store, Qoder's, Qoder CN's and Cowork's) skipped such a project folder whole, a session's own folder (its subagents) and a workflow run's; HermesDirs skipped such a profile. Sessions and Usage lost all of them, silently. #2233/#2250 fixed walk roots (walkLinked); this is the entry check one level in. dirent.IsFolder is the one check now: an entry is a folder to read into when it is one, or when it is a symlink or irregular entry that os.Stat follows to a folder. A link to a file, a broken link and other irregular entries are none. It follows only the entry asked about; none of its callers recurses through one, so no visited set is needed. Used at every reader of an agent's folder that picks entries this way: - sessions: ccFiles' project, session-folder and workflow-run checks, HermesDirs' profile check, agyCallFiles' conversation check (IsDir only before, so even a symlink was skipped); - agent: hermesProfiles and ompProfiles (IsDir only), so a linked profile still gets magpie's provider and its own row; - library: desktopSkillRoots' org and account folders (IsDir only). Left as they are, on purpose: WalkDir copies, hashes and deletes in library and sessions/manage.go (they must not follow links), the relocate code (it tells a link from a folder on purpose), library's linkEntry (asks "is this a link", not "is this a folder"), magpie's own folders (calls cache, gateway logs, OthersDir, backups, Bun, Devin homes), and install/version detection (claudecode versions, VS Code extensions, Desktop's folder name, Hanako's agents). The issue's patch had sessions' own copy of library's linkEntry without a Stat; this is a shared package and Stat-checked, so an irregular entry that isn't a folder (a dedup or cloud placeholder file) isn't read as one. docs/subsystems/gateway-sessions.md says how the readers treat links. Run: - New tests make real links, a junction (mklink /J) on Windows and a symlink elsewhere: TestIsFolder; TestClaudeProjectFolderBehindALink, TestClaudeSessionFolderBehindALink and TestHermesProfileBehindALink (the issue's), TestClaudeWorkflowRunBehindALink, TestAgyConversationBehindALink; agent's TestHermesProfileBehindALink and TestOmpProfileBehindALink; library's TestClaudeDesktopSkillRootsBehindALink. - Broken by hand on macOS (IsFolder = e.IsDir()): all nine fail. Broken as before on the Windows box (IsDir() || ModeSymlink, no Stat): TestIsFolder and all eight reader tests fail there (e.g. "Claude session files behind a link: [], want [...]", "Hermes sessions behind a link: 1, want 2", "agy calls behind a link: 3, want 5"); with the fix all pass. Windows test binaries cross-built with go1.26.8 (windows/amd64, nogui) and run on the box with a fresh sandbox USERPROFILE/HOME/APPDATA/LOCALAPPDATA/TEMP per run. - Whole packages on the Windows box: dirent and sessions pass. usage, agent and library each have reds that fail the same with binaries built from origin/main |
||
|
|
3a0b61275f |
gui: the Sessions page nests subagents under their session and opens each one's conversation; Codex threads nest under their parent_session (#2261, infinitr0us)
Only main sessions sit at the top of the Sessions page now.
- A session with subagents shows an "N subagents" fold under its row. It starts folded.
- Unfolding neither opens the session nor moves the page.
- The rows are indented by the depth of the subagent that started them.
- Clicking a row opens its conversation in place, via /api/sessions/transcript?sub=.
- Codex threads with a parent_session nest under that session, to any depth.
- The parent chain is guarded against loops and capped at a depth of 8.
- A thread whose parent isn't listed stays at the top.
- A folder's count and its select-all include the nested threads.
- Searching opens the folds that hold matches. Opening a nested session from elsewhere opens its ancestors' folds.
- New strings ("{n} subagent", "{n} subagents") in zh, en, zh-TW, ja and de.
- No native select and no left-border accent. The nested list is a bordered card.
- docs/subsystems/gateway-sessions.md describes the subagents field, the sub= route and the page.
What was run, at this head before the rebase (
|
||
|
|
69d7ee33ae |
agent: Codex with magpie as its provider (magpie API, or a ChatGPT account the app holds) no longer reads as joined beside its sign-in (#2267, isymbo)
isymbo's ChatGPT account ran out for the week, they set Codex's sign-in to
magpie API and picked DeepSeek, and the Codex app still showed "Codex 和
工作使用额度已用完" and sent nothing. The Agents row said "重开 Codex
后,/model 中既有它自己的模型,也有 magpie 的模型": the ChatGPT state
they had just left.
The config was right (model_provider = "magpie", magpie's catalog), but
the codex.joined mark from an earlier Join stayed, and Joined() read it
whenever openai_base_url was magpie's, which it also is with magpie as the
provider. Joined is now false while magpie is Codex's provider; the mark
itself stays, so Sync still puts Codex back beside the sign-in once the
account has room (codex.out), as before.
Why the app blocks: ChatGPT.app 26.1007.21159's two composer gates (FN in
app-primary and Cui/kui's hardBlocked in app-initial) both require the
app-server's getAuthStatus authMethod to be "chatgpt" and
rate_limit.allowed false. With magpie as the provider the app-server
reports no ChatGPT auth, so neither gate applies, but the app reads it
from the app-server it started with: it has to be quit and reopened. The
row now says "Reopen Codex, then pick any model in /model". Asked the
reporter to restart and, if it still blocks, for versions and config.
Test: TestCodexProviderIsNotJoined joins, picks a magpie model, sets
magpie API (provider, not joined, still wired), back to ChatGPT (joined),
held by the app (provider, not joined), room again (joined). Red with
Joined: joined ("magpie API: joined true").
Run, both commits together on
|
||
|
|
bc470c6b63 |
agent: Claude Code's own ANTHROPIC_MODEL comes back when magpie steps out
Wiring Claude Code in deletes env.ANTHROPIC_MODEL (writeTiers), because it outranks a pick in /model. Unlike the tiers' models (#1050), the user's own value was never stashed, so Disconnect or Claude Code's own model left it gone for good. A Bedrock user like jw1dev keeps the Bedrock model id there, so after the previous commit put the switch back, Claude Code would come back on Bedrock without its model. ANTHROPIC_MODEL now joins claudeOwnEnv: it is stashed raw beside the endpoint and token when first routed from the user's own endpoint, put back by unroute, and forgotten with the rest. A value an older magpie wrote, at its own key, is still not kept (keyOurs), as before. Run: - gofmt -l: clean. - go vet ./internal/agent: native, GOOS=linux -tags nogui, GOOS=windows: clean. - go test -tags nogui ./internal/agent ./internal/gui: ok 4 times. One earlier run of the two together had internal/gui red, and only `tail -5` of it was kept, so the failing test's name was lost. It passed alone 3 of 3 and with internal/agent 3 of 3. Nothing in internal/gui reads claudeOwnEnv. - Targeted: ClaudeCloud, TestClaudeDisconnect, TestClaudePick, legacy, stand-in and T3 tests: ok. Broken by hand: before the fix, TestClaudeDisconnect's new "own env model" cases (with no settings model and beside one, [1m] kept; each by Disconnect and by default) went red. The bedrock fixture of TestClaudeCloudSwitchStepsAsideForMagpie now carries a Bedrock ANTHROPIC_MODEL and compares the whole env after. Not tried: WSL twins for real (the stash key goes through at.key as for the tiers). |
||
|
|
79fec406c6 |
agent, gui: a Claude Code provider switch (CLAUDE_CODE_USE_BEDROCK, …) steps aside while magpie is wired in and comes back after; one magpie can't take out is said (jw1dev on X)
jw1dev's ~/.claude/settings.json had CLAUDE_CODE_USE_BEDROCK=1. magpie wrote
ANTHROPIC_BASE_URL and its model ids beside it. Bedrock ignores the base URL,
so Claude Code went to AWS, Bedrock refused magpie's model, and magpie still
showed Claude Code as connected.
Claude Code 2.1.300's six switches (agentenv.ClaudeProviders: BEDROCK,
VERTEX, FOUNDRY, ANTHROPIC_AWS, ANTHROPIC_GOOGLE_CLOUD, MANTLE; on = 1, true,
yes or on, any case, trimmed):
- In a settings file magpie writes (user settings, WSL twins), a switch
that is on is taken out on every route that writes the wiring: connect,
model pick and Rewire/Reapply through writeTiers, and Sync. Its raw JSON
value is stashed (claude.cloud.<var>, under the distro id for WSL). It is
put back as written when magpie steps out (Disconnect, or the model set
back to default), unless the user set it again since. AWS_*/GCP
variables and a switch that is off stay.
- Where magpie doesn't write it (managed settings, ~/.claude.json's env,
the login shell's env), Check names the variable, the cloud and the
file. It reads them in Claude Code's own order: managed wins, then the
user's settings, then ~/.claude.json, then the shell. Two notice
templates, translated in zh, zh-TW, ja and de. The row's line and its
Reconnect pill now show a drift detail through tNotice.
- proc.LoginEnv reads the switches but never sets them in magpie's env,
and testenv unsets them.
- T3 Code: a switch is never carried onto magpie's instance. Its Check
says when the user's ~/.claude settings have one on. That Check first
checks the instance's ANTHROPIC_BASE_URL against the gateway (t3EnvOf),
as every agent's Check must for TestDriftUnwiredEveryAgent,
TestPortMovesEveryAgent and TestReverseProxyIsStillMagpie.
- Claude Desktop's Code tab runs with CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST,
under which Claude Code ignores these switches in settings, so nothing
changes there.
Run:
- gofmt -l: clean.
- go vet: native ./..., GOOS=linux -tags nogui, GOOS=windows: clean.
- go test -tags nogui ./...: every package ok except internal/agent, where
t3code's first Check (cloud only) failed the three every-agent tests
above. Fixed with the wiring check, then the whole internal/agent package
was rerun: ok (368s).
- GUI, Chromium and WebKit, 102/102 each: new claude-cloud-drift (5
languages, 1100 and 420px, file and shell notices), gui-de, gui-ja,
gui-zh-tw, i18n-keys, agent-notice-lang, agent-proxied,
agent-unreachable, cli-behind, menu-scroll, agent-connect,
agent-disconnect.
- Sandbox HOME (scratchpad dir, live ~/.claude untouched):
- Setup: real claude 2.1.300 with settings.json
{CLAUDE_CODE_USE_BEDROCK:"1", AWS_REGION, AWS_PROFILE}, a magpie-cloud
binary from this tree serving on 127.0.0.1:3487, a fake OpenAI
upstream on 3486.
- `magpie claude fake/fake-model` took the switch out and stashed "1".
- `claude -p "say hi"` printed PONG-FROM-FAKE-UPSTREAM, and the fake
logged POST /v1/chat/completions model=fake-model.
- `magpie claude default` left settings.json byte-for-byte the same as
before connect (cmp).
- Control: the switch put back by hand beside the wiring (the reported
state). Claude Code never reached magpie: the fake logged nothing.
Broken by hand, each went red:
- no dropClouds in writeTiers, then in Sync;
- putClouds returning at once, and putClouds writing over the user's own;
- no claudeCloud in Check;
- the T3 filter and the T3 Check;
- shellVars without ClaudeProviders;
- the tNotice calls taken out of the line and pill: claude-cloud-drift
went 17 red.
Not tried:
- A project's .claude/settings.json(.local) isn't read, because magpie
doesn't know where Claude Code runs.
- WSL and Windows were not run for real; tests only.
- Real Vertex, Foundry and AWS accounts.
- T3 Code and Claude Desktop with a switch, run for real.
- The drift shown in the real app window. The CLI has no drift output.
- The user's own ANTHROPIC_MODEL being lost across connect/disconnect is a
separate gap, fixed in its own commit.
|
||
|
|
94bceea4d2 |
lessons: fold 10-14 04:16 to 10-15 07:30 (275 commits, v0.1.1229 to v0.1.1244)
New lessons: an origin exemption judges every Origin a browser can send (#2242, #2256; seen 2x with the 10-10 rebinding case); a file another process rewrites may be half-written; a pinned hash or new download source is checked against the vendor and trusted as far as who can write it; a fixed date in a test is checked against every clock the code reads ( |
||
|
|
5618ade1e6 |
sessions: each reply in a session's conversation names the model its own line in the agent's file names (#2253, cnlove7777777-art)
Usage -> Sessions' conversation said only "Assistant", so which model wrote a reply couldn't be told, though the agents' files name it. - sessions.Part gains model (omitempty), set on assistant parts only, from the part's own line: Claude Code's message.model (the model that answered; none for its "<synthetic>" lines), Codex's turn_context.model (the model the turn was sent to; a /model between turns moves the next turn), Pi's and omp's message.model, OpenCode's modelID and OpenCode 2's model.id. - Kimi Code (its model is only on a usage.record written after the reply), Cursor (no model in the transcript) and gateway transcripts (GatewayTurn.Model is the model asked for, not the one that answered) name none. Nothing is guessed from nearby requests. - The reader (sessions client.js) says it muted after the role, once a reply at its first part and again only where it changes inside the reply; the tooltip is "Model: <id>" (an existing string, translated). ledSaid takes the model as an argument, so the Usage page's per-request content, whose row already names its model, is unchanged. No layout change: one muted span in the existing header line, ellipsized at narrow widths. Run: - TestTranscriptModelClaude/Codex/Pi/OpenCodeV2/OpenCodeFiles: all five fail on the old content.go/transcript*.go, pass on the new. - sessions-talk-model.test.cjs: 20/20 (chromium+webkit, en/zh/zh-TW/ ja/de, 1100 and 420). Fails on the old app.js/client.js, and with the once-a-reply rule removed by hand (label every assistant part). - sessions-talk, sessions-export, gateway-conversations, usage-ledger-content, usage-ledger-detail GUI tests: all pass. - go test -tags nogui ./internal/sessions ./internal/gui ./internal/gateway: ok. gofmt -l clean; go vet -tags nogui darwin/ linux/windows clean. Full suite for this push (#2257, #2251, #2254, #2253) at 53677ed8d: go test -tags nogui -p 4 -timeout 40m ./... with pipefail: every package ok. (An earlier full run caught davsync's TestSyncLibrary and profile's TestOldProfiles/TestProfileCarriesLibrary relying on a gone CLI after #2254; their sandboxes now have the CLIs, in #2254's commit.) Not tried: the real app against a live Codex rollout (fixtures follow the lines the readers already parse for usage). |
||
|
|
e413512d8e |
library: an agent whose CLI is gone (only its config folder left) is no Library write target, and nothing it already has is removed (#2254, ggbdpq)
After an agent is uninstalled, the Agents page shows "CLI not found"
(
|
||
|
|
c3bef99efd |
provider: magpie://import links take gemini=, and its host is named before adding (#2251, ggbdpq)
An import link could set chat=, responses= and anthropic= but not
gemini=, though the editor and the TUI take a Gemini base URL; a link
with only gemini= failed with "it needs chat=, responses= or anthropic=".
ParseImport now reads gemini= under the same base-URL rules, and the
error names it (ggbdpq's patch, with docs/reference.md and the en/zh
docs rows).
Its siblings that listed the three base URLs:
- the GUI's import dialog warned "Your prompts and this key will go to ;"
with no host for a gemini-only link: it names the Gemini host now;
- the site's handoff page (site/public/import.html) left it out of
"Sends to";
- the docs' link builder (en, zh, ja) had no Gemini field and didn't
count it as a base URL; the ja docs lacked the table row, and all
three said one of chat/responses/anthropic is required.
Run:
- TestParseImportGemini fails on the old importurl.go ("the link gives
no base URL: it needs chat=, responses= or anthropic="), passes now;
go test -run Import ./internal/provider/ ./internal/gui/: ok.
- import-link-gemini.test.cjs: 20/20 (chromium+webkit, en/zh/zh-TW/ja/de,
1100 and 420 px); against the old app.js the warning reads "will go to
;" and it fails.
- docs builder (en/zh/ja) and handoff page in Chromium from file://: a
gemini-only builder gives magpie://import?name=…&gemini=…, no errors;
the handoff page lists gem.example under Sends to.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
Not tried: a real magpie://import click through the OS handler.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|