c7c19d49d57f0c2b745dec355bbe202d149e328b
5705
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c7c19d49d5 |
provider: asking whether a model decides copies no list
DecidesModel answered for a remote magpie, and for a provider that lists
its decision models (OpenRouter's), by building decideListed's whole
list (catalog.Live copies every chat model) and scanning it. Every model
of such a provider is asked this from available(), pluginDecisions and
the decider list, so a list of n models was copied n times per look:
0.43 GB of the 4.1 GB a real config allocated over 20 polls of
/api/drift, /api/state and /api/providers (v0.1.2430,
DecidesModel -> decideListed -> catalog.Live -> catalog.Chat).
It now looks the model up in the list as kept (catalog.LiveByID, which
readLive indexes once per read), and catalog.LiveListed says whether the
list has any model, for the Jev fallback decideListed has. The answers
are decideListed's: a remote magpie's models its list marks Decides; a
listed decision list's models; with none listed, OpenRouter's Jev unless
the server marks its own.
TestDecidesModelCopiesNoList: 2000 decision models, each ask under a
twentieth of the list's bytes, for both kinds, and the answers above.
Red on the old code (an ask 869,336 bytes, the list 869,829).
Run at
|
||
|
|
88a0262bf2 |
claudetui: Claude Code's first-run notes send the run to -p at once, not after 45s
A config folder whose onboarding isn't done (one only -p was run in,
given CLAUDE_CODE_OAUTH_TOKEN) has the interactive mode show "Security
notes: … Press Enter to continue". The helper knew the sign-in screen
but not this one, so it waited out ReadyWait (45s) before running -p.
Now firstRun is matched like signIn: the run is -p at once and the
start is marked broken. Agreeing to the notes is left to the user.
The match is on the screen's words with any space between them one
(strings.Fields): the real 2.1.316 screen didn't match a plain regexp,
since Claude Code draws some spaces by moving the cursor.
Run:
- mote: go test ./internal/claudetui -count=1 ok; go vet for darwin,
windows, linux; gofmt clean.
- Broken by hand: with the case off, TestShimFallsBackToPrint/first-run
notes goes red ("wrote 0 lines of 1 in 30s").
- Real, on xiaomi-gpu (Windows 11), Claude Code 2.1.316 (official dist,
sha256 checked), a real subscription token, a fresh config folder:
before, "showed no prompt in 45s" and -p at 48s; with the first regexp
still 45s (the space case above); now "shows its first-run notes" and
the -p answer at 7.9s and 16.9s (two runs), streamed.
Not tried: WSL with a fresh folder (same helper code path); macOS/Linux
native with a fresh folder.
|
||
|
|
6a900e0d04 |
gui: a poll of the Agents page no longer drops every cached model list
/api/state keeps the state it built in agents-state.json, written only
when the bytes change. They changed on every poll: a stale copy's start
is now less how long it has run, two clock reads apart, so it moved by
microseconds each time (on a real config, only
/agents[1]/staleCopies[i]/since differed between two polls). The file
was written through edit.WriteAtomic, whose write calls
filememo.Forget(). That bumps provider.StampNow, so every 15s poll threw
away each agent's model list and picker (magpieModels, viaMagpie) and
every provider's kept catalog, and the next look built them anew.
- StaleCopies' since is truncated to the second (the check against
magpie's change still uses the exact time).
- keepState writes through steady.WriteFile (temp, flush, rename), which
leaves filememo alone: nothing a request reads is built from this file.
Not changed: on Linux and WSL the process list gives a run time in whole
seconds (ps etime), so a copy's since can still move by a second between
polls there; macOS reads the exact start from sysctl.
Run on mote at
|
||
|
|
7428f32294 |
provider: WorkBuddy's mover asks for opencode-workbuddy-auth 0.2.9, whose declared models take images (plugins #572)
kongbai01203 saw WorkBuddy AI's kimi-k3 as image: false. That came from the
models the plugin declares before an account's own list is read (an API
key, or a /v3/config that failed). Those declarations said no model took
images, while both builds' /v3/config mark every model supportsImages.
plugins 6727a1e (workbuddy 0.2.9) declares images for every model except
WorkBuddy AI's GLM models, which drop them. keepMovedCurrent now brings
every moved user up to it.
Run:
- go test -buildvcs=false -count=1 -timeout 45m ./... on mote at this
commit (rebased on origin/main
|
||
|
|
4182e68ab4 |
agent: whether the installed magpie wired an agent is looked up in the bytes read, not a copy
A magpie beside the installed one (a dev build on its own port) asks,
for each field's drift, whether the agent's config names the installed
magpie's gateway (theInstalled). It took edit.Read's copy of the file
and two strings of it: with a Codex config.toml of 1.5 MB (one table
per project trusted) that was 311 MB in 60 drift polls of a sandbox
built from
|
||
|
|
9fa11784db |
provider: a provider's proxy and off switch are read from providers.json as parsed once
A live magpie's heap profile (v0.1.2404, 53 minutes) allocated 3.6 GB of its 33 GB in provider.load, a parse of the whole providers.json, mostly for one field of one provider: storedPicks (its proxy, 1.73 GB) and leftAlone (switched off or hidden, 1.24 GB), asked for each request and each background look, then customIDs, keptAs, loginSwitching and accountRemoved. These six only read, so they now go through storedFile: filememo's parse of the file, kept until its time or size changes (and its bytes, written in the last two seconds), and dropped by every write magpie makes (writePrivate's Forget). A file missing or not decoding goes the way load goes, to its last good generation. What load's other callers get is unchanged, as some of them edit what they read before a save. TestStoredParsedOnceUntilTheFileChanges: 30 providers of 100 models. storedPicks and leftAlone with the file unchanged take under 40 allocations (a parse is 3381); a provider switched off since is left alone at once; another process's edit of the same size is seen; a zeroed file still finds its providers. Broken by hand: storedFile parsing each time, red (3386 allocations); a broken file read as none, red. Run at this tree on mote: gofmt clean; go vet ./internal/provider on darwin, linux and windows; go test -count=1 -timeout 45m ./internal/provider (ok 116.0s) ./internal/gateway (ok 613.2s). |
||
|
|
645eb92f3f |
gateway: a refusal after shown thinking goes to the next fallback
yhwangl on X: a request whose content trips a vendor's safety filter after the model streamed its thinking, before any answer, stopped there; the group's next member was never asked, as it is when credit runs out. When a model's reasoning is shown, a try passes on its first thinking event, so a refusal after it was the agent's. Now, for a streamed Anthropic, Chat or Responses request with another member still to ask (handsOver), the try's events go out one by one (passOver) and a refusal or refusal error before any text or tool call hands the request on (handOver): Anthropic's open blocks are closed and the next member's stream is spliced into the same reply (spliceAfter): its message_start or response.created/in_progress/queued are dropped, block indexes or output_index go after those sent, sequence_number goes on. Chat chunks go as they come. Once text or a call has gone, a refusal stays the agent's as before. With no other member nothing changes. A refusal is about the request, so nobody is rested for it. Zhipu's finish_reason "sensitive" and error 1301 (敏感), DashScope's data_inspection_failed and Volcengine Ark's *SensitiveContentDetected are now read as refusals too. Not covered (#4604): Gemini clients; a Responses reasoning item handed over gets no output_item.done and the next completed lists only its own output; A's thinking signature stays in the reply; non-streamed requests. Run (mote, worktree at base |
||
|
|
8a410f35a2 |
claudetui: Claude Code's interactive mode streams its replies, through a preload that copies the main turn's stream
The owner: make a Claude subscription stream as it goes while Claude
Code runs in its interactive mode (TUI), on macOS, Windows and WSL.
Until now the helper read Claude Code's transcript, which has a message
only once it ends, so a reply came to the client whole.
Claude Code is a Bun program, and Bun loads a script named in
BUN_OPTIONS (--preload) before it. The helper writes tap.js to a folder
of its own and starts Claude Code with BUN_OPTIONS="--preload tap.js"
(after the user's own BUN_OPTIONS, but not a Windows one's for a Claude
Code in WSL, where both go through WSLENV). tap.js makes Bun.FetchSession
a subclass whose fetch is the real one's, so the request, its headers,
its connection and TLS are Claude Code's own. For a reply to a
request marked x-claude-code-request-class: main to /v1/messages that
is text/event-stream, it tees the body: Claude Code reads its copy as
before, and tap.js writes each event, as it comes, as a JSON line to
the file MAGPIE_CLAUDE_TAP names. It takes itself out of BUN_OPTIONS,
execArgv and the environment first, so nothing Claude Code runs
inherits it.
The helper reads that file and tells the events as -p's stream_event
lines, so the gateway reads them as it reads -p's. A transcript message
waits up to 1s for its stream to begin (then it's told whole, its late
stream left out); a turn's end waits for its streams to end; a stream
cut short ends with a message_stop and no message_delta, as -p ends
one. The bridge now keeps the streamed messages by id, since a whole
message can come during the next message's stream, and a client
tool_use shown from the stream isn't told again from the whole message.
On Windows, BUN_OPTIONS has no quoting, so a temp path with a space
takes its short name; one that still has whitespace gets no tap, and
replies come whole, as they do from a Claude Code that isn't Bun or
doesn't send through FetchSession (2.1.281 on Windows doesn't; 2.1.289
and 2.1.316 do).
Run:
- gofmt -l: clean. go vet on mote for darwin, GOOS=linux and
GOOS=windows: 0.
- go test ./internal/claudetui ./internal/gateway on mote
(-timeout 45m): ok, ok (gateway 654s).
- go test ./internal/claudetui with win-run (Windows 11) and wsl-run
(magpie-desktop): ok, ok.
- macOS, real account (Claude Code 2.1.316, sandbox HOME, keychain
token): a reply came as message_start, text deltas,
content_block_stop, message_delta, message_stop, then the whole
message, then the result; stderr clean, the tap's folder removed.
- Windows native, Claude Code 2.1.316 against a fake that sends an SSE
event every 250ms (a user preload marking the request main, which
also checks the user's BUN_OPTIONS is kept): the deltas came 250ms
apart, before the whole message. The same with TEMP holding a space
(short name).
- WSL magpie-desktop, Claude Code 2.1.289 run through wsl.exe from the
Windows helper, the fake in WSL: the same.
- The scrub, on macOS and Windows: Claude Code's BUN_OPTIONS and
execArgv have no tap, MAGPIE_CLAUDE_TAP is gone, --smol is kept.
- Rebased on origin/main
|
||
|
|
535371c8f3 |
providers: a Claude subscription says whether it runs as Claude Code's interactive mode or claude -p, and why
The owner: the Claude Code provider page should say whether its runs go through the TUI or the CLI, and what tells them apart and what each gains. Under a Claude subscription's accounts a row now says "Running as Claude Code's interactive mode (TUI)" (a green dot) or "Running as claude -p (CLI)" with why: turned off in Settings, failed to start lately, Claude Code in WSL whose home wasn't found, not installed, or a system with no interactive mode. Under the TUI it says which requests still run as -p (safeguards, a JSON schema, an image by URL, a first message over 400KB). "TUI or -p?" opens what each is: entrypoint cli, the plan counting a request at about half; entrypoint sdk-cli, about twice. "Change in Settings" opens Settings › Models at the interactive mode's row. Only switch, which serves nothing, shows no row. The mode comes from GET /api/claude/mode (gateway.ClaudeModeNow), read as the editor opens and kept 30s, never in /api/providers' polls. Its machine-wide reasons are claudeMachineWhy, which claudePrintWhy now calls first, so the row and the gateway's own choice can't disagree. The row is drawn by claudemode.js, which app.js loads with that first read, so it weighs nothing on the core: after a rebase on origin/main |
||
|
|
02ff0e908f |
agent: the Codex app's route opens config.toml to see it can be read, not reads it whole
codexAppRoute runs every 3s for as long as magpie does (the Codex app's app-server watcher). It read the whole of Codex's config.toml with os.ReadFile only to learn the file could be read; the keys it uses come from filememo, which parses the file once per change. Codex keeps every project's trust level in that file, and the owner's is 1.5 MB, so this was 1.55 GB of the 33 GB a live magpie allocated in 53 minutes (heap profile: KeepCodexAppOnItsProvider → codexAppStep → os.ReadFile). It is now opened and closed: a file that can't be opened is still an unknown route, a missing one still a known one. Run on mote: - TestCodexAppRouteReadsNoWholeConfig (new): a 1.6 MB config, 10 looks allocate under 1 MB; a config with mode 0 gives no route. - Broken by hand: ReadFile put back, red (14.4 MB for 10 looks); the unreadable check dropped, red. - go test -run CodexAppRoute ./internal/agent: ok. - go test -count=1 -timeout 45m ./internal/agent ok (185.3s), at this tree rebased on 4a7d1c63a; gofmt -l clean; go vet ./internal/agent for darwin, linux and windows ok |
||
|
|
4a7d1c63ac |
provider: Resolve keeps the listed-by map and finds a group without copying the catalog
A live magpie's heap profile (v0.1.2404, 53 minutes) allocated 1.3 GB
in isMagpie -> provider.Resolve, from the window's drift poll asking
every 15s for each model value an agent's settings name:
- a bare model no entry has ("gpt-5.5") built listedBy, every
provider's whole model list, again on each request: heldOf only kept
it for one second inside a Hold (835 MB);
- a group ref copied the whole Catalog() to find one group (425 MB).
listedBy now goes through keptOf, the Stamp-keyed store the catalog
already uses, so it is built again only when providers.json, a group or
a setting changes. A group ref is looked up in the groups' own entries
first, and the full catalog stays the fallback.
TestResolveKeptAcrossRequests: three providers with 40 models each and
a group, each request in its own Hold. "group/g", "nope" and "m-b2"
take 44, 43 and 28 allocations once built (bar 60), they resolve right,
and a provider saved since is resolved by the next request. Broken by
hand: heldOf("listed", listedBy) put back, red; the Catalog() copy
first put back, red.
Run at this tree on mote: gofmt -l clean; go vet ./internal/provider
for darwin, linux and windows ok; go test -count=1 -timeout 45m
./internal/provider ok (126.0s), ./internal/agent ok (199.3s),
./internal/gateway ok (595.0s).
|
||
|
|
46ca9a6416 |
provider: a quota reading changes the history it wrote, not a new read of the file
Each new reading of a Codex or Claude account's windows (about one a minute per account while the window or a client asks) read the whole quota-history.json, parsed it, parsed it once more in KeepUnparsed to see it could be written over, and wrote it. On the owner's live magpie (a 512 KB history: 20 accounts, 39 lines, 5,031 points) that was 1.9 GB of the 33 GB allocated in 53 minutes: json.Marshal 751 MB, KeepUnparsed 590 MB, readQuotaHist 599 MB. The history this process wrote last is now kept with the file's stat, under quotaHistMu. While the file is still that one (same inode, size and modification time), noteQuotaHistory, MergeQuotaHistory and the account-move fold change it instead of reading the file, and writeQuotaHist skips KeepUnparsed: what it wrote parsed. Another process's write renames a new file in, so it is read again, and a file that doesn't parse is still kept aside. A failed write drops the copy. Run on mote: - TestQuotaHistoryWrittenNotReadAgain (new): six readings after the first read the file 0 times; a file another process renamed in is read and merged; an unparsed one is kept aside as .bad-*. - Broken by hand: never using the copy, red (6 reads); ignoring the stat, red (the unparsed file not kept aside). - go test -count=1 -timeout 45m ./internal/provider: ok (103.5s). - gofmt -l clean; go vet for darwin, linux and windows: ok. - A/B, 60 readings over a 20-account, 5,000-point history shaped like the live one: 238.3 MB and 1.30M mallocs before, 66.6 MB and 0.63M after. Not tried: a live magpie with real accounts over an hour; the numbers above are from the live profile's shape, not a new live profile. json.Marshal of the whole history on each change is still there. |
||
|
|
3baf3b6dfd |
agent: every agent's magpie options are built once per change, not per Drift poll
viaMagpie is the half of every agent's model picker that magpie serves. It built CatalogFor, the own and first accounts, and the fast and ultra picks on every call. The window's /api/drift poll asks each agent's fields for their options every 15s. In a live magpie's 53-minute heap profile (v0.1.2404), Claude Code's options alone (claudeViaMagpie) allocated 4.7 GB of 32.8 GB. viaMagpie now keeps its list per agent and prefix, the same way magpieModels does since v0.1.2422. It builds the list again when provider.StampNow moves, and after a minute for what the stamp can't see (an account another app signed in to). Each caller gets its own copy. The two now share stampedLists[T]. Run (mote, at this tree): - go test ./internal/agent: ok, 191.501s. - TestViaMagpieKeptWhileCatalogStays, TestMagpieModelsKept... and TestIsMagpieKept...: ok. - go vet ./internal/agent: darwin, linux and windows ok. Broken by hand, TestViaMagpieKeptWhileCatalogStays goes red each time: - never kept: FAIL; - the stamp not compared: FAIL; - the kept list handed out unshared: FAIL. Real A/B: magpie web --gateway under the same sandbox HOME as v0.1.2422's record, 200 GET /api/drift each. Before = v0.1.2422's tree. The drift JSON is byte-identical. - allocated under Drift: 2065 MB before, 1717 MB after. - under viaMagpie: 367 MB before, under pprof's cut after. - under CatalogFor: 538 MB before, 229 MB after. - CPU: 1.95s before, 1.80s after. Most of what is left under Drift in this sandbox is theInstalled's read of each agent's config. It runs only for a magpie beside the installed one (this sandbox's gateway port), not for the installed app. |
||
|
|
854fc81619 |
agent: magpie's model list is built once per change, not per field of every Drift poll
The window asks /api/drift every 15s. Each agent's Drift checks its
fields through magpieValue -> f.Options -> magpieModels, and
magpieModels built the whole catalog every time: CatalogFor, the
prices, Labels and Vision's ranking (provider.Described -> seersRanked).
A live magpie's heap profile (v0.1.2404, 53 minutes) allocated 32.8 GB.
Drift accounts for 14.5 GB of it, and magpieModels for 9.7 GB. The
footprint peak of 882 MB rides on that garbage.
magpieModels now keeps the list it built for each agent. It builds the
list again when provider.StampNow moves: a provider, account, plugin or
setting saved, catalog.Touched, or providers.json, settings.json or the
catalog cache rewritten by another process. It also builds it again
after a minute, for what the stamp can't see. Each caller gets its own
copy (slices.Clone). A model's own lists are clipped, so an append in a
caller's copy can't write into the kept list.
Run (mote, at this tree):
- go test ./internal/agent: ok, 188.985s.
- TestMagpieModelsKeptWhileCatalogStays: ok.
- go vet: darwin and windows ok, for internal/agent and internal/gui.
Linux vet of internal/gui fails in wails' cgo menu_linux.go
("undefined: pointer"); that is the cross-compile from darwin and not
this change.
- go test ./internal/gui: three reds, each filed already and none in
code this touches: TestSettingsSaveKeepsWhatItDoesNotSend (#4514),
TestMainWindowCorners/macOS_26_SDK (#3949), TestColdTurnsTaken
(#4510).
Broken by hand, the new test goes red each time:
- never kept: 422 vs 407 allocations;
- the stamp not compared: "a provider saved since is not listed";
- the kept list handed out unshared: FAIL.
Removing the Clip lines leaves the test green: its catalog's lists have
no spare capacity. The clip is a guard that wasn't shown to matter.
Real A/B: magpie web --gateway under a sandbox HOME with the owner's
providers, 200 GET /api/drift each. "old" is this tree with
magpieModelsFor = 0. The drift JSON is byte-identical.
- CPU: old 3.45s, new 1.99s.
- allocated under Drift: old 3098 MB, new 2063 MB.
- allocated under magpieModels: old 1049 MB, new 20 MB.
Not tried: the sandbox has no OAuth sign-ins, so subscription models
weren't in its catalog; the live catalog is larger.
viaMagpie (claudeViaMagpie, 4.7 GB live) still builds per call; that is
the next change.
|
||
|
|
f811bf2918 |
gateway: a request waiting for body room is not answered 408 (#4511 review)
The previous commit counted a body as still arriving whenever less of it
had been read than its Content-Length. Before the first read that holds
for a request waiting in bodyRoom.take, which is magpie's own wait. Its
client may have sent the whole body already, and a 408 there tells an
SDK to send it again at once, onto a room already full. bodyArriving
now holds only once the body's read has begun ("body" wait seen) and
while no body-room wait is under way. That is the gap between two reads
that #4511's full run raced into.
The patch's TestUnroutedBodyShortOfItsLengthAnswered408 asserted the
408 in the room wait. It is replaced by:
- TestUnroutedBodyRoomWaitNot408: same setup, not a 408.
- TestUnroutedBodyArrivingBetweenReads: not read yet / in the room wait /
between reads / read whole / no length.
Reproduced #4511 by injecting a gap. waitedBody.Read ended its wait and
slept 30ms after each read, and TestUnroutedTrickledBodyAnswered408
-count=5:
- with the narrowed check: ok 5 of 5;
- with giveUp back to "case u.inBody():": red, answered 504 "held this
request for 1s without routing", the CI red.
Broken by hand: bodyArriving back to the patch's (length only). Both
new tests fail, and the room wait gets the 408.
Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
on
|
||
|
|
94e46b5fea |
gateway: a body short of its own Content-Length is answered 408 even with no read under way
The unrouted hold's 408 (the client is still sending its body) was judged by whether the handler was inside a body read that instant. unroutedMost can run out between two reads of a trickled body, or before its first, and there the read's absence answered 504, as if magpie held the request of its own (#4511, red in a full run). The body is judged by its state now: less come than the request's own Content-Length says is still arriving, and the time is the client's. A body read whole, a length never said and an empty one are judged by the read alone, as before. Reviewed and applied from #4511 (ggbdpq, c59083f5f, SHA-256 matches). The next commit narrows it. As written, a request still waiting for magpie's own body room, before its first read, was answered 408 "its body was still arriving". That blames a client whose body may all be sent already. Run (on mote, through mote-run): - Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack on |
||
|
|
cd0875f5a0 |
provider: a Claude sign-in whose keychain write fails leaves logins.json alone (#4563)
addLogin wrote logins.json before the credential was stored, and a keychain write that failed (the login keychain out of reach over ssh) left the account kept all the same: importing the same file again reported it as already there. The credential is stored first now; the login is written only once it is in. Reviewed and applied from #4563 (ggbdpq, 7b42e98a1, SHA-256 matches). The test runs in signIn's sandbox HOME with a fake `security` first on PATH that exits 51. proc.Command looks PATH up at call time, so the real Keychain is never reached. Switching to a saved login still writes its On marks before the credential: #4592. Broken by hand: signin.go back at main with the test kept, and TestClaudeLoginKeychainWriteFailureKeepsLoginsFile fails. Run (on mote, through mote-run): - Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack on |
||
|
|
d1b62f4604 |
usage: price a local session's call at the provider its file names
What changed A call read from an agent's own session file (omp's model_usage, say) has no billing provider of ours — its row reads session-unknown — so Pricer priced it only through the maker lookups, which answer nothing for models no vendor catalog lists as its own, even when the models.dev catalog lists the model under the provider the file recorded (openrouter listing typesafe/jev-1.14 at $0.042/M in, #4278). When the effective price is unknown and the record is one of those, its session provider now prices the call — but only what the catalog itself affirms: the very model id, listed under that provider, with a price. A provider models.dev doesn't know, a model it lists that provider without, and an entry with no price stay unpriced, the CSV cost empty, rather than priced at another entry's guess; the pricer's memo is keyed by the session provider too, so two files naming different routes price apart. Run - go test -tags nogui -run 'TestUnknownProviderPricedBySessionProvider' ./internal/usage — red before (the named route stayed unpriced), green after - go test -tags nogui ./internal/usage/... — ok - gofmt -l internal/usage — clean Generated-by: GLM-5.3-FlashX (ZCode) Reviewed and applied from #4278 (ggbdpq, 645e80ab2). It differs from the patch hashed on the issue only in its git-version trailer. The reporter's own call stays unpriced for now. models.dev's default api.json, which magpie fetches, does not list openrouter typesafe/jev-1.14; only api.json?type=all does. #4278 stays open for that. The Sessions page prices a session-unknown call through its own priceOf, by model only: #4591. Broken by hand: ledger.go back at main with the test kept, and TestUnknownProviderPricedBySessionProvider fails. Run (on mote, through mote-run): - Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack on |
||
|
|
c8df9ecbbc |
gateway: a search round ended without its stop hands on its held text (#4562 review)
textCallRound holds text from where a written call may begin, and gives it back at KStop. A round whose channel closes without a KStop is one searchRounds takes as ended, and its held text was lost with it. The routes without a search give it back at their reply's end (gateway.go's held(), continuation.go's release), and the round now does the same after its loop. The previous commit's doc comment for textCallRound had also been put between searchReply's comment and its func. searchReply's comment is back on searchReply. TestTextCallRoundReleasesHeldAtEnd: a round that sends "Let me look." and the start of a DSML call, then closes. Broken by hand: the t.release() taken out. Red: it handed on only "Let me look.\n\n". Run (on mote, through mote-run): - Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack on |
||
|
|
90f8a10566 |
gateway: a search route's reply reads the calls written into its text (#4562)
searchReply's rounds answered a request that carried a hosted web search — Messages' web_search_20250305, Chat's web_search_options, Responses' web_search — for a model that can't search by itself, and never ran the text-call recognizer: a call the model wrote into its text (#823) reached the client as that text, while every route without a search made it a call (streamTranslated, forwardTranslated and the relayed Chat stream each wrap their reply in textCallSee or textCallTidy). The three routes the reporter lists all pass through searchReply, so its round is wrapped: textCallRound hands every round's events through a textCallSee over the client's tools plus magpie's own, and a call written out — the client's or the search tool itself — is read as the call it is. A reply that made a call of its own keeps the text as it came, as elsewhere. A round with no tools keeps the round it was: textCallNames is nil and the round passes unwrapped. Verification on the branch's base |
||
|
|
f2ae7bdecc |
gateway: plainSchema judges a self-reference by whole segments (#4561 review)
The previous commit's selfRef took a $ref as a self-reference when the
walk's path began with the ref's pointer as a string. So
"#/properties/a" inside /properties/ab, a sibling, was cut down to
{"type":"object"} instead of being resolved. A self-reference is now
the pointer itself or one of its containers: path == ref, or path
begins with ref + "/".
A "#/…" pointer that names nothing where it points also falls back to
its last segment as a $defs or definitions name again, as every ref did
before pointers were walked ("#/components/schemas/Mode" with Mode in
$defs).
TestPlainSchemaSelfRefBySegment covers both.
Broken by hand: selfRef and localRef back to the previous commit, test
kept. Red: "inner" and "mode" both go out as {"type":"object"}.
Not tried: a real Antigravity request with dsh's tool schema. The
fix is in the flattening, and the gateway tests send the result
through a fake upstream.
Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
on
|
||
|
|
abaf2c4e8f |
gateway: plainSchema resolves a $ref into properties (#4561)
A $ref that points inside the schema ("#/properties/func/properties/
triggers/items", as dsh's tool parameters carry one) is a local JSON
pointer like a "#/$defs/x" one, but plainSchema read a ref only by its
$defs or definitions name: the pointer's last segment named nothing
there, and the field it stood for went out as a bare {type: object} on
the Antigravity path, the tool losing that field's shape.
Any local pointer is resolved now, where it names; a self-reference —
a ref to the site or one of its containers — stops at the target's
type alone, as the plugin's googleSchema has it.
A test with the error's path fails on the old code.
Reviewed and applied from #4561 (ggbdpq, branch head ab39ddcbc; the
patch's SHA-256 matches the issue). A review fix follows in the next
commit: selfRef matched a pointer as a string prefix.
Broken by hand: plainSchema back at main with the test kept, and
TestPlainSchemaResolvesPointerIntoProperties fails ("again" goes out as a
bare {"type":"object"}).
Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
on
|
||
|
|
29d0ab39fb |
sessions: Antigravity CLI (agy) sessions can be deleted (ysm119 on Discord)
ysm119 (#help) could delete Codex sessions on the Sessions page but not agy's, and wanted to clear out empty ones. A delete now moves a conversation to magpie's trash the way agy's own /resume delete (F4) removes it: brain/<id>/, conversations/<id>.db with the -wal, -shm and -journal SQLite leaves beside it, and annotations/<id>.pbtxt. Restore puts them back. What agy keeps of a conversation, read from real agy 1.4.12 in a sandbox HOME against a fake Gemini endpoint (the live ~/.gemini was only read): the files above, presence/<id>.lock, a row in conversation_summaries.db, an entry in jetbox_summaries_proto.pb, and cache/last_conversations.json. agy's own delete removes the files, the row and the jetbox entry. It leaves the lock and last_conversations.json. magpie leaves the row and jetbox entry too, because agy keeps both files open and jetbox is an unknown protobuf. agy's /resume list leaves out a row whose files are gone, so it never lists a deleted conversation. A conversation agy has open is not deleted: agy flocks presence/<id>.lock for as long as it has it open, idle too, and a held lock (or one that can't be tried) is ErrActive. On Windows how agy locks it hasn't been seen, so the minute since a write decides there alone. Siblings: Hermes, Alma, OpenCode, ZCode, Cline, Grok Build, Kimi Code and Claude Desktop (Cowork) sessions still can't be deleted. Each keeps an index magpie would have to edit or leave stale; filed as #4595 with what each needs. Run at d018b9302 (on origin/main |
||
|
|
2cca111764 |
gateway: a 413 byte cap or an overflow tells Codex context_length_exceeded, so it compacts instead of reconnecting 5/5 (celestial_eagle_99230 on Discord)
A Codex user on a DeepSeek model kept getting "stream disconnected
before completion: 1017dp: 413 Request Entity Too Large: a web page,
not an API reply ... (request_too_large)" with "reconnecting 5/5".
The big body took the vendor past keepHeldAfter, so Codex's stream
had begun, and streamError sent response.failed with code
server_error. Codex (codex-api sse/responses_error.rs) reads any code
it doesn't know as Retryable, so it sent the same body five more
times. Each was refused the same way, and nothing compacted.
context_length_exceeded is the one code Codex stops on: it marks the
window full and compacts, and core compact.rs trims the oldest items
for as long as the compaction is refused too.
- streamError: a 413 on the Responses shape is code
context_length_exceeded, for every Responses client. The text still
says request_too_large for pi.
- failTo: Codex reads a 413 told by HTTP status as UnexpectedStatus,
and a 400 context_length_exceeded as InvalidRequest
(api_bridge.rs). Neither compacts. So when Codex (fromCodex, or
Claude Code's Codex plugin) asked for a stream, a byte cap or an
overflow goes to it in a stream even before one began
(keptAlive.compactsInStream). A vendor's own overflow, released
until now, goes this way too. Other clients keep the status they got
before.
- Nothing changes for resting: a 413 still rests nobody, and a group
still tries the next member first.
Tests: codex_byte_cap_test.go. It replays the reporter's nginx page
mid-stream and before the stream, plus a vendor overflow 400, and
checks a non-Codex client keeps its 413. Red on the old code:
TestCodexByteCapInStreamCompacts got "server_error" (the reporter's
exact text), and both TestCodexByteCapBeforeStreamCompacts cases got
a 413 or 400 JSON. TestStreamErrorByteCapInEveryShape now expects
context_length_exceeded for Responses.
Run on mote (mote-run, this tree): go test ./internal/gateway on the
byte-cap, stream-error, overflow, compact and Codex tests: ok. GOOS=linux
and GOOS=windows go vet ./internal/gateway: ok. gofmt -l: clean.
Full suite: mote-run go test -timeout 45m ./... at
|
||
|
|
c30d3b7b63 |
plugin pages: a page the reader left is told, and let go after 10 minutes unless it keeps itself
A plugin's page kept its frame, with its scripts, timers and
connections, for as long as the window was open once it had been
looked at: show() only hid its view, and a frame in a hidden view isn't
hidden to itself (its visibilityState doesn't change), so a page
couldn't even pause on its own. Asked by the owner: is that by design?
Only the lazy first load was.
- The kernel's leave hook now reaches the page part: the page is told
{event: "visibility", data: {visible}} as the reader leaves and comes
back. The bridge has magpie.visible and magpie.onVisibility(fn); hello
carries visible, for a page left before it said hello.
- A page left 10 minutes (IDLE_MS) has its frame removed and loads again
when next opened. Back sooner, it is the same frame. Its hello timer is
cleared, so nothing says it broke.
- magpie.page.keepAlive: true (plugin.PageSpec.KeepAlive, keepAlive in
/api/plugin-pages) keeps a page however long, for one that works while
no one looks at it. Anything but true is false, read as raw JSON so a
wrong type never drops the package's page.
- plugin-runtime.md's page row says so.
Run on mote. The Go suite and most GUI files ran at this change on
|
||
|
|
b75fa328ce |
gui: the ban warning is said once, not again beside accounts signed in
The owner, on Claude Code's editor with four Claude accounts in it and "Claude 账号可能被封禁" shown on Add another: "这里就不要显示可能被封禁了". A subscription that warns before a sign-in (Claude, Antigravity and the plugin-served ones with risk) now warns only while it has no account signed in, and never to sign one of its accounts in again. startSignIn asks hasLogins(agent), and its o.user, before the risk step. The import box keeps its note. What goes with it: Factory's warning offered "Use an API key instead…". Factory is retired and the Add sheet leaves it out with no account, so that warning was reachable only beside an account, and no longer is. Its accounts list's "Add an account by API key…" row still offers the key; factory-key.test.cjs now starts there. signin-close and signin-proxy no longer click "Sign in anyway" in editors with accounts. claude-risk.test.cjs: a new case opens a Claude editor with an account, clicks Add another, and wants the sign-in asked at once with no warning (chromium and webkit, en and zh). The first-account case is unchanged. Run, on the Linux box (magpie-desktop): - Broken by hand: the old app.js with the new test: red in both engines, nothing asked. - All 46 GUI files that reach a sign-in or the warning, plus i18n-keys: 739 ok, 2 red. login-import chromium en timed out waiting on its import box, then passed 4 of 4 alone. i18n-keys' "a plugin's words are its own" is red the same at origin/main |
||
|
|
fb29cd30f9 |
tray: the Mac's menu bar figures are regular weight, a lone one in the menu bar's own font (qingnianxiaozhe on X)
Beside Surge's speeds and another app's stacked "0 KB/s", magpie's
"93% / 98%" read visibly bolder, and a lone "98%" too small and too
heavy, so the reporter kept it out of the menu bar. mpRowFont drew two
stacked rows in 9.5pt semibold and one row in 11pt medium, both since
|
||
|
|
30cd39f19b |
provider: Devin's plugin is 0.1.29 at least, its Claude models keep the client's cache marks (plugins#566)
Devin 0.1.28 asks its Claude models on Anthropic's Messages API and sends each of the client's blocks as a prompt of its own, with Devin's cache mark (prompt_cache_options EPHEMERAL) where the client put cache_control. A grown Claude Code classifier history read 558 tokens from the cache and wrote ~7.3k again; on a real account it now reads 7,318 and writes the 560 it grew by (haiku-5-5 and opus-5-5). 0.1.29 says a failed tool result in its text, "Error: " first, as the chat path does. npm view @magpie-community/opencode-devin-auth version --prefer-online: 0.1.29 when this landed. Run: mote-run go test -timeout 45m ./internal/provider/... ok (102.8s). Not tried: a magpie gateway with Claude Code end to end on the new plugin. |
||
|
|
59ea5dc8f8 |
gateway: a failure with this computer off the network rests nobody (usrname1833)
usrname1833 on Discord: with the computer offline, a routing group's
members failed to connect one after another, each rested, and the first
stayed behind the others once the network was back.
A 502 whose error says no connection was made (dial, lookup, refused, no
route, TLS handshake timeout, and Bun's ConnectionRefused / ENOTFOUND
for a plugin's fetch) now asks whether this computer has a network,
unless any upstream answered in the last 15s: no interface up with a
global address means none; otherwise up to three hosts of the user's
other providers (not p's own, not proxied ones, not localhost / LAN) are
dialled at once (2s), and none taking the connection means offline. The
verdict is kept 5s and asked by one request at a time. Offline, the
member is passed over as a down proxy is (failProxy): no rest, no count,
the trace says Fail "offline". One provider that can't connect while
another's host takes a connection, or while replies came lately, still
rests as before.
Covered where every rest passes: restAfterMarked (so decide_group's and
count_tokens' rests too), the serve loop's next-member path, and the last
member's label. Routing page: "network down" tag and a story for the
next-member and last-member cases, in zh, zh-TW, ja and de.
Run (mote, at this tree):
- gofmt -l clean; go vet ./internal/gateway on darwin, GOOS=linux,
GOOS=windows: ok
- go test -run 'TestOfflineRestsNobody|TestProxyDownDoesNotRest' -v
./internal/gateway: ok; go test -timeout 45m ./internal/gateway:
ok (708s)
- GUI: routing-offline.test.cjs (new) 10/10 and routing-proxy 4/4,
Chromium + WebKit, en zh zh-TW ja de. Every routing-*.test.cjs at once
(load 30-44 on mote): 1997 pass, 29 fail. The untouched base
|
||
|
|
e0eb74987c |
plugins: a dist branch not read is unknown, not "not on npm", and its read isn't cut off by one ask
ferock on Discord (v0.1.2399): the Plugins page showed the Chat page plugin (@magpie-community/page-chat, on the community repo's dist branch only, never on npm) as Coming soon. Cause: Info asks each package under npmEach (6s). npm said 404, and npmAsk turned to distInfo -> distPkg, which read the ~1.6MB index.json (GitHub and the jsDelivr mirror) under that same 6s context, holding distMu. On a slow link the read was cut off, distPkg returned nil as if the branch had no such package, and npmInfo kept "not on npm" (ok=true, empty NPM) for an hour, saved to plugin-npm.json. distWait then held a new read back for a minute. Fix: - distPkg returns (*distPackage, error): nil, nil only when the branch was read and lacks the package (or it is out of scope); an error wrapping errDistUnread when the branch couldn't be read (last read failed or not finished) and the kept index doesn't have it. - The index is read in its own goroutine (readDist), apart from the asker's context, with its own distReadFor (2m). One read at a time (distReading); askers wait for it or their own ctx, distMu is not held across the network read. A read that ends after its asker stopped waiting is kept for the next ask. - npmAsk: npm's errNotFound with the dist branch unknown becomes the dist error, so every caller that keeps "missing" (Info/npmInfo, newestOf in store.go, the update checks in updates.go) treats it as unknown and asks again. Readme says the branch couldn't be read instead of npm's not found. installDist returns the unread error rather than "has no". - mendDist was checked: it reads only local files, no dist read. Old data: a "not on npm" already kept in plugin-npm.json by an older build is asked again once it is an hour old, as before. Tests: TestDistReadSlowerThanAnAskIsntMissing (index.json held past npmEach: not kept as missing, and the next Info after the read ends has 0.1.7) and TestDistReadFailedIsntMissing (index.json 503: unknown, asked again; a read branch without the package is still errNotFound). fakeDist's reset waits for a read under way (distSettled). Run (mote-run; vet at base |
||
|
|
8e9da4e832 |
provider: Zed's plugin is 0.1.12 at least: a string message content goes as a text block (Been on Discord)
npm view @magpie-community/opencode-zed-auth version --prefer-online: 0.1.12 at landing. The plugin's change: magpie-community/plugins 3e940bc, bun test 49 pass on mote, its new test red 2 of 2 with the change reverted. |
||
|
|
7dc8a18d0e |
provider: a plugin's Gemini model is tested on generateContent, as the gateway asks it
A plugin's @ai-sdk/google model is served by the gateway on Code Assist,
which it sends to the plugin's fetch as Gemini's generateContent. Test
models kept only chat, Responses, Anthropic and Gemini, so such a model was
sent the body of the plugin's first other API: Zed's cloud read a chat body
as a Google request and answered 400 "failed to parse Google AI request:
missing field contents" for every Gemini model (Been on Discord), while
agents were answered. Its test now goes through the gateway's translator
(testTranslated), with the plugin's longer wait.
Run (mote-run): go test ./internal/provider ./internal/gateway ok (120s,
710s) at e0bb3c30a; go vet ./internal/provider ./internal/gateway on
darwin, GOOS=linux and GOOS=windows ok; after rebasing on
|
||
|
|
484b45d825 |
provider: WorkBuddy's mover asks for plugin 0.2.8, which lifts deepseek-v4.1-flash's 100k cap on copilot.tencent.com (plugins #561)
@magpie-community/opencode-workbuddy-auth 0.2.8 (plugins 42a5055) takes
0.2.7's 100000-token cap on deepseek-v4.1-flash off the China build: three
users' China Free-plan accounts took 110k to 992k-token prompts on it, and
the vendor's own refusal names 1048576 as the maximum. The cap made agents
compact at 100k. A prompt WorkBuddy does find too long is its own 400
"prompt is too long", passed on as it came, which overflowed() reads as an
overflow (no rest, not retried). keepMovedCurrent brings every moved user
to it.
Run: go test -timeout 45m ./internal/provider/... on mote at
|
||
|
|
63cb1af3cb |
library: the MCP router's mark is the bird with its tail routed out to three ends
The owner asked for a mark that says MCP routing and picked, from three
generated drafts, magpie's bird whose tail fans out into lines ending in
dots. It is drawn as SVG on the bird itself, not a picture, so it stays
sharp at 17px and takes the theme's colour: the bird clipped short of its
tail (#bird-notail, beside #bird-tail in index.html), three strokes from
where the tail was and a dot at each end. Every place hubMark draws (the
Library's MCP router row, the Connect an app sheet) gets it.
Run on mote (macOS 27): library-mcp-hub now checks the clip, the three
routes and their ends (red on the old mark). library-*, i18n-keys and
old-webkit, both engines: 895 pass, 5 fail. The reds are i18n-keys
"a plugin's words are its own" (#4524) and library-row-remove's 3
subtests (#4304); both red the same at origin/main
|
||
|
|
557f51dbf0 |
library: a skill linked into an app version the update deleted follows it to the current one (tjhhhh on Discord)
tjhhhh: ego lite keeps its skills in its framework's Versions/<v>. After the app updated, the skill was in the new version's folder, the old folder was gone, and magpie still linked the old one. |
||
|
|
49b8c64559 |
dsh: deepseek-acp gets magpie's route in settings.yaml, and the key store is owner-only
liby233 on Discord: dsh in an editor over ACP (deepseek-acp, CodeG, the
desktop app) listed only DeepSeek's own models. Checked against the real
packages from npm (deepseek-acp 0.9.0, dsh 0.2.1-rc.5): deepseek-acp
mounts FileSettings on $DSH_HOME/settings.yaml alone, never profiles/,
and loads the pi-ai plugin only when that file mentions "llm-pi-ai". Its
credentials-local store throws when .credentials.yaml is readable beyond
its owner ("run chmod 600"), so a 0644 store stops it from starting.
- settings.yaml gets llm-pi-ai.providers.magpie, built by the same code
as the profiles' route (dshPutProviders), at 0600 when magpie creates
it. It gets no agent-default-model of magpie's. The user's routes,
other sections, comments, mode and the api they chose for magpie's
route are kept. Disconnect takes only magpie's route out, and the
section too when nothing else is left in it.
- dsh 0.2 renames settings.yaml to settings.yaml.imported (over the one
before) at each full start and imports it into the profile. The
serving round, Sync, Set and Unwire write it again. The user's own
import from before magpie's first write is copied once to
settings.yaml.imported.kept, so magpie's import never overwrites it.
- .credentials.yaml is made owner-only (go-rwx) on every write and every
Sync, whoever made it 0644. In a WSL distro, a file written through
\\wsl.localhost comes out 0644, so the chmod runs inside the distro:
wsl.exe -d <distro> -e chmod go-rwx <path>. A failure is logged and
doesn't fail the write.
Run:
- internal/agent on mote (ok) and its Dsh/WSL tests on Windows
(xiaomi-gpu, ok); gofmt; go vet on darwin, GOOS=linux -tags nogui
and GOOS=windows.
- The new tests (dsh_acp_test.go) were broken by hand, each turning red:
dshSettingsAgain disabled, ownerOnly disabled, dshKeepImported
disabled, and the round's call removed.
- Real runs on mote in a sandbox HOME (~/runs/realdsh-home), never a
live ~/.dsh. After magpie's Pick, real deepseek-acp's session/new
listed magpie::deepseek/pro and magpie::deepseek/flash; without
settings.yaml it listed only DeepSeek's. With a 0644 store its boot
failed with the credentials-local error, and it started once magpie
had made the store 0600. `dsh --profile web --dump-config` shows
agent-default-model magpie and the route. `dsh headless` ate
settings.yaml into the headless profile, and magpie's round
(dshWiredOnce) wrote it again, after which ACP listed magpie's models
again.
- On magpie-desktop: `wsl.exe -d magpie-desktop -e chmod go-rwx` takes
a file written through UNC from 644 to 600.
Not tried:
- magpie's own write into a real WSL distro end to end; only the
command form above, and fakeWSL in tests.
- A WSL distro has no serving round, so after dsh eats settings.yaml
there, it comes back only on magpie's next Sync or model pick.
- A dsh from before profiles (config.yaml only) is left as before.
Also: fakeWSL answers the chmod without recording it, since it is neither
a start nor a probe (TestWSLMoreAgentsStopped counts starts).
|
||
|
|
a51776f9c3 |
gateway: a socket's turn writes its conversation once, not through json.Marshal twice
Codex sends each turn on its Responses WebSocket with only what came after the reply before it, and the gateway put the conversation back together and wrote the body the HTTP route would have had: json.Marshal of the list, then json.Marshal of the body around it. encoding/json writes a json.RawMessage through its scanner a byte at a time into a buffer that doubles and is then copied out, so a 3.2 MB conversation allocated 9.6 MB on every turn. marshalRaw (#1532) had fixed this for the HTTP routes' rewrites; the socket's turn was left on json.Marshal. turnBody writes the same bytes, keys sorted, each value checked by jsonCheck and compacted with <, > and & and U+2028/2029 escaped, into one slice sized for them: its length plus the five bytes each <, > and & grows by, counted with bytes.Count, since code is full of them. A value encoding/json would refuse still goes to json.Marshal, which says why. Live heap on the owner's running app had 8.8 MB under this json.Marshal between collections. Run on mote (M5 Pro), at this tree: - TestTurnBodyIsJSONMarshal: byte for byte json.Marshal's for 0, 1 and 40 pretty-printed items with literal <, >, &, U+2028, U+2029, tabs and CJK; nil input is null; a broken item is refused. - TestTurnBodyWrittenOnce: a 3,225,123-byte turn allocates 3,252,336 bytes (1.01x); json.Marshal twice, 9,605,256. Broken by hand in the mote copy, each red: the escape count dropped (2.9x, the slice grew twice); values written without HTML escaping (bytes differ for all three sizes); json.Marshal back inside turnBody (3.0x). - TestResponsesSocket* and TestCodexSocket*: ok. - go vet ./internal/gateway/ for darwin, linux and windows; gofmt clean. - The whole internal/gateway package at the parent, v0.1.2406: ok (772s). Real use: this build (go build -tags nogui) in a sandbox HOME with the owner's DeepSeek key only, magpie serve on 127.0.0.1:3581, and Node 22's WebSocket on /v1/responses: a 30 KB first turn of 400 lines with <ZEBRA&n> and code, asked for the last one, answered <ZEBRA&399>; the second turn, previous_response_id and one new message, asked for the first, answered <ZEBRA&0>. The log: 2 turns, 1 continued, 88003 bytes sent on as whole requests. Not tried: a real Codex CLI session on the socket (the client here sends what Codex sends: response.create, previous_response_id, input). |
||
|
|
2cfb8351d0 |
install.sh: a Linux desktop without WebKitGTK 4.1 has it installed through sudo, then gets the desktop app (shuhai)
shuhai on Discord, on f68ddca37's hint: "为什么不能帮用户直接装好?" On a
desktop without WebKitGTK 4.1 the installer put in the terminal build and
told the user to `sudo apt install libwebkit2gtk-4.1-0` and run it again.
Now, on a desktop without the libraries (and with --gui), when someone is
at the terminal, the script installs WebKitGTK 4.1 (GTK 3 comes with it)
with the distribution's package manager, says first in one line what and
why, and installs the desktop app:
- apt-get install -y libwebkit2gtk-4.1-0 (Debian/Ubuntu family), and when
that fails, apt-get update and once more (lists missing or stale);
- dnf install -y webkit2gtk4.1 (Fedora/RHEL family);
- pacman -S --needed --noconfirm webkit2gtk-4.1 (Arch family; no -Sy, so
no partial upgrade);
- zypper --non-interactive install libwebkit2gtk-4_1-0 (openSUSE).
Through sudo, which asks for the password itself; as root, without it.
"At the terminal" is /dev/tty opening (in a subshell, since a failed
redirection would end the script): curl | sh gives the script the pipe
for stdin, so every package command reads /dev/tty too, never the script.
No terminal, no sudo, the package manager missing, Void/Gentoo/another
distribution, or the install failing: the terminal build and the command,
as before, with "didn't work (see above)" when it was tried. --tui and
MAGPIE_CLI=1 install no package; a headless computer neither.
MAGPIE_TTY points the check at another file for the tests.
Docs: reference.md Install, README en/zh, docs start (en/zh/ja).
Run:
- sh -n, dash -n; shellcheck -s sh: only SC2010 at the uninstall's
ls | grep, there before.
- site/install.test.mjs, 5 new tests (fake sudo, id and package managers;
every distro's command, root without sudo, no tty, no sudo on PATH,
Void, NixOS, a failing install, apt's update-and-retry, --gui, --tui,
MAGPIE_CLI, headless): red on origin/main's install.sh (the 5 new fail,
19 pass), green after. CI's site step (sh -n + node --test
site/*.test.mjs) at this head, rebased on origin/main: 63/63 on mote
(macOS sh) and 63/63 on magpie-desktop through wsl-run (/bin/sh = dash).
- Real installs in fresh containers (Docker on xiaomi-gpu, amd64), a user
u with sudo, DISPLAY=:0, `cat install.sh | sh` (stdin a pipe), the
terminal kept with setpriv (su -c starts a session without one),
v0.1.2399/2400 from the real feed; then ldd (nothing missing),
`magpie version`, and the package query:
- Debian 12, sudo with a password, typed by expect at sudo's prompt,
package lists deleted first: install failed "Unable to locate", apt-get
update, retry ok, desktop app, libwebkit2gtk-4.1-0 installed;
- Ubuntu 24.04 (NOPASSWD): libwebkit2gtk-4.1-0, desktop app;
- Fedora 44, password via expect: webkit2gtk4.1, desktop app;
- Arch (archlinux:latest): webkit2gtk-4.1 2.54.2, desktop app;
- openSUSE Tumbleweed and Leap 15.6: libwebkit2gtk-4_1-0, desktop app;
- Debian 12 as root: apt-get without sudo, desktop app;
- Ubuntu 24.04 --gui: installed, desktop app; --tui: terminal build,
nothing installed;
- Debian 12 without -t (no terminal): terminal build + the apt line, no
install tried; without sudo at a terminal: the same;
- Ubuntu 20.04 (no WebKitGTK 4.1 in focal): install, update, retry all
fail "Unable to locate", then the terminal build and the "didn't work
(see above)" hint.
Not tried: a real desktop VM (the containers fake one with DISPLAY=:0);
the installed app wasn't opened, only `magpie version`. Void and Gentoo
stay hint-only (Gentoo would build WebKit from source). Debian 11 failed
in the container's own setup (archives unreachable), so focal stood in
for a distribution without 4.1. A held dpkg lock (unattended-upgrades)
would fail the install and fall back; not reproduced. On focal the hint
still names libwebkit2gtk-4.1-0, which focal lacks, as before.
|
||
|
|
ccc791231f |
gateway: a long turn sent to a Chat upstream is copied once, not five times
A 3.2 MB Codex /v1/responses request served by a Chat provider allocated about 70 MB in the gateway, and that garbage, at GOGC 100 over the app's live heap, set the peak footprint. Four copies went: - unquoteJSON built an escaped string (any text with a newline) in a buffer and then copied it into a string; the buffer is the string now (unsafe.String, nothing writes to it again), with a copy only when \u escapes left more than a quarter of it unused. - turnIn joined every user text of the conversation (userSaid) only to see whether any was there; saysAnything stops at the first. - buildChat's user message grew a strings.Builder part by part across a merged turn; joinTexts sizes it once and takes a lone part as it is. - marshalItems ran json.Marshal, whose buffer doubles and is then copied out, over one message that holds the whole turn. marshalSized sizes the maps, lists, strings, bools and ints a body is made of first and writes them into one slice of that size, as encoding/json writes them (HTML escaped, � for bad UTF-8, U+2028/2029); any other value is json.Marshal's own. A []any item, reached by its address, is a *any, which went to json.Marshal twice (to size, then to write) until it was dereferenced; TestMarshalBodyAllocatesTwoBodies caught that at 154 MiB for a 47 MiB body, now 52. Run on mote (M5 Pro), at this tree: - TestLongTurnCopiedFewTimes, a 2.0 MB 300-turn Responses body with CJK and newlines: read 6.72 MB -> 4.76 MB (3.4x -> 2.4x), turnIn 1.93 MB -> 10 KB, buildChat 27.3 MB -> 6.06 MB (13.7x -> 3.0x). Broken by hand one at a time in the mote copy, each red on its own bound: unquote back to string(b) 3.4x; userSaid back in turnIn 1.9 MB; the Builder back 7.4x; json.Marshal back 6.2x. - TestMarshalSizedIsJSONMarshal: byte for byte against json.Marshal over all 256 bytes, bad UTF-8, a lone surrogate, U+2028/2029, HTML characters, keys needing escapes, nil maps and lists, floats, RawMessage, pointers, and a func json.Marshal refuses. - go test -count=1 -timeout 45m ./internal/gateway/: ok (582.9s). - go vet ./internal/gateway/ for darwin, linux and windows; gofmt clean. - Gateway bench (120 requests of a 3.2 MB Responses body, 4 at a time, through a fake Chat provider, 200 MB ballast held live), 3 runs each, old/new: TotalAlloc 8368-8403 MB -> 5889-5891 MB (-30%), GCs 26-27 -> 18-19, phys_footprint_peak 795/806/807 MB -> 763/762/749 MB, CPU 7.89-7.92 s -> 8.01-8.17 s (the size pass costs about what the copies saved). Real use: this build (go build -tags nogui) in a sandbox HOME with the owner's DeepSeek key only, magpie serve on 127.0.0.1:3581. A 180 KB /v1/responses request (a long CJK turn with <tag> & "quotes" \ tabs, a function_call and its output holding U+2028, then a question) to deepseek/deepseek-flash, served through buildChat: answered with both code words as sent (<ZEBRA&42>, MANGO), non-streamed and streamed. Not tried: an Anthropic-in, Chat-out request, and the live app's own peak (the bench stands in for it). |
||
|
|
7d11f7d428 |
gui: Rex opens sessions in a Rex session of magpie's own, with none, one or several open (#4565, StringKe)
StringKe tried |
||
|
|
f85a221c96 |
plugins: a plugin installed twice says "another copy" once, not its own name per provider (plugins#565)
ferock (plugins#565) installed the CodeArts / OfficeAce plugin from two
specs. Each copy serves codearts and officeace, so each card got one
clash line per provider, built from the other copy's shownName, which
is the card's own name. In zh it read "CodeArts / OfficeAce 也登录 CodeArts;
由这个插件提供" and then again for OfficeAce.
clashLine is now given groups (clashGroups): a row's clashes grouped by
side (served here or by the other plugin) and by which specs they clash
with, with the provider names joined. When every other spec's name is
this row's own name, the line says another copy of this plugin ({spec})
does it. Otherwise several names use new plural keys, and one name uses
the old key. All four new keys are in zh, zh-TW, ja and de. The
existing zh and zh-TW singular line now reads "{other} 也能登录 {name},
现由这个插件提供" in place of the clipped "也登录 …;由这个插件提供".
Run on mote, at this tree rebased on origin/main
|
||
|
|
73a12e8bf6 |
wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file when that file already exists` (linusxiong). In the distro ~/.codex is a link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't follow a link the distro has: a mkdir of it says it exists, and nothing below it can be made, written, read or listed. ggbdpq found and explained the link (thanks); their patch, which takes that EEXIST as "there", wasn't used: the writes below the link fail next (its test passed because a symlink here is followed). The fix, for every agent folder and every writer through \\wsl.localhost: - The WSL probe asks `readlink -f` in the distro where each agent folder, its skills folder and the folders beside them lead (wslLinkPaths -> distro.Links; a $HOME that is itself through a link is left alone), and which drive each Windows mount is (win:/mnt/c C: -> distro.Drives). - distro.open opens a path at or below a link where it leads: on a Windows drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the distro, through \\wsl.localhost again. native spells it back through the link, so the agent is told its own path. - A link readlink couldn't resolve is never guessed at: distro.open errors, and the agent is unreached (Agent.Unreached: its notice says why; every field Set and Sync returns it). - Writers: the agents' own files (place.join/place.open, every filepath.Join(at.home, ...) in internal/agent), the library's WSL targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir), the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs). - Not changed: magpie's image MCP server opens arbitrary paths an agent in WSL gives it the same way; filed as #4578. Links deeper than the probed paths (other than <agent dir>/skills) aren't resolved. A distro probed by an older magpie has no Links until probed again (each run). Run: - Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex, .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway Windows test running the real probe with that HOME: probe said link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi, win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\ magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file when that file already exists" (the report's error). distro.open wrote SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both read back with cat in the distro through the links; .pi said "~/.pi in WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target removed after. - New tests with a fake distro whose ~/.codex and ~/.claude are links to /mnt/c/... that don't exist here, so, as through \\wsl.localhost, nothing below them can be made: TestWSLFolderIsALinkToC, TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink, TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved (agent). - Broken by hand: the library tests on the base (with a no-op FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the report's error; with ggbdpq's patch applied they still fail (the skill mkdir, and RTK's hook not written). - mote: go build ./...; go vet of agent, library, sessions, provider for darwin, GOOS=windows (and linux for agent, library); gofmt -l clean; go test -timeout 45m ./internal/agent ./internal/library ./internal/sessions ./internal/provider: all ok. - Windows (win-run): the same four packages. The new tests pass (the RTK ones skip: the fake distro runs sh). 32 tests are red, all already red at the base |
||
|
|
3ecc02b78b |
agent: Claude Desktop is off magpie only when Desktop itself would be (dev_quj on X)
dev_quj on X: "magpie 一直提示Claude Desktop不经过magpie,我重启了依然还是
这个提示" — the Agents row said "已不经过 magpie:配置已变更" while
Desktop ran on magpie.
The check required deploymentMode "3p" in both Claude/ and
Claude-3p/claude_desktop_config.json. Desktop decides otherwise (m4 in
4.4212's and 2.7032's index.pre.js): with a 3p configuration applied it
starts in 3p when the profile has disableDeploymentModeChooser, whatever
deploymentMode says, and otherwise unless Claude-3p's file says "1p". The
Claude folder's deploymentMode is never read. And Desktop 4.4212 deletes
Claude-3p's deploymentMode itself: a stored "1p" with no claude.ai sign-in
is dropped at start (W5r -> "[custom-3p] deploymentMode written { mode:
undefined }") and Desktop relaunches in 3p on magpie. So a file left
without the key, by Desktop or another tool, was called off magpie, and
nothing magpie could do (Reconnect writes "3p" back) kept Desktop from
dropping it again.
desktop3p now asks Desktop's question with the applied profile (magpie's
or the user's for magpie's gateway). The appliedId, address and key
checks are as they were. appReads (the "restart Desktop" notice) reads
the same effective mode instead of the two files' words, so Desktop's own
write at start isn't a change to restart for.
Real Claude Desktop 4.4212.0 (macOS zip, on mote, sandbox
--user-data-dir, never the live config): three starts with magpie's
profile applied and Claude/ {} or "3p"; Claude-3p "1p" + chooser
disabled, "1p" + chooser not set, and {} — each ran in 3p with
apiHost=http://127.0.0.1:3425 in Claude-3p's main.log, and each left
Claude-3p's file without deploymentMode. The "1p", chooser-not-set case
started in 1p, logged "deploymentMode written { mode: undefined }" and
came back in 3p. An earlier start with both files "3p" kept them.
Run at the pushed head on mote (mote busy with other sessions' GUI and
gateway suites, so the touched package only, not the full suite):
go test -count=1 -timeout 45m ./internal/agent: ok
go vet, GOOS=linux go vet, GOOS=windows go vet ./internal/agent: ok
gofmt -l internal/agent: clean
Broken by hand: desktop3p put back to the old rule (both files "3p"):
TestClaudeDesktopModeAsDesktopReadsIt red on the dropped key, the Claude
folder's key gone, "1p" with the chooser disabled, and none with the
chooser on; TestClaudeDesktopChangedSince red too. Green with the fix.
TestClaudeDesktopMSIX and TestClaudeDesktopChangedSince's 1p cases now
turn the chooser on first, as Desktop needs for 1p to count.
Not tried: Windows' Desktop (MSIX or classic) and a real gateway request
from Desktop; a signed-in claude.ai cookie (Desktop keeps "1p" then,
which magpie says only with the chooser on); dev_quj's own files, so
this is the class the report is in, not their proven trigger. No other
desktop agent reads a mode the same way; Codex/WorkBuddy checks unchanged.
|
||
|
|
ba7c890223 |
sidebar: the gateway's address at its foot is lit as by a torch too
The owner asked for the gateway address row under Settings to get the torch light the page rows got in |
||
|
|
3d063e34fd |
providers: the editor names a routing group listed alone that keeps a model from agents (hayden4608)
hayden4608 on Discord: with a provider's "Only through routing groups" switched off, its models still weren't on the Agents page. Switching it off does bring them back to every list (tried in a sandbox HOME on mote: POST /api/provider/save unlisted:false, then /api/agent-models/codex, /api/state's Codex options and provider.Catalog all list them; nothing caches the old list). What still keeps them out, with the switch off, is a routing group whose Model lists is "The group alone" (Group.Unlists, #1783): its members leave every agent's list. The editor said nothing of it, so the switch looked broken. The provider's JSON now carries keptBy (provider.GroupKept: model -> the names of the groups listed alone that keep it out, a signed-in subscription's models excepted as Catalog excepts them), and the editor says under the models, and on each chip, which group keeps which model out and that its Model lists is changed on the Routing page. Words in zh, zh-TW, ja and de. unlistedByGroups returns the groups' names now instead of a bool; Catalog and Unlisted read it as before. Not confirmed for hayden's own setup: the other reasons a model is missing there are Codex's list in "Only models I pick" (the editor already names that agent) and GitHub sync bringing the other device's providers.json back (newer wins per part). The reply asks which. Run on mote at |
||
|
|
c63c2136b2 |
agent: with Claude Code's own models hidden, a tier's model keeps its /model row and the switch rewrites settings.json at once (#4548)
Two gaps in the previous commit's replaceBuiltInOptions: - writePicker leaves out the row of a model a tier is on at an effort (#1616), since Claude Code shows it as that tier's row. With replaceBuiltInOptions Claude Code drops the tier rows along with its built-in lineup (2.1.316: only the Default row and the picker's own stay), so such a model was in /model nowhere. While the switch hides Claude Code's own models, every model keeps its row. - SetOwnModelsHidden saved the setting without catalog.Touched, unlike SetHiddenModels, so flipping the switch in the GUI left Claude Code's settings.json as it was until some other change re-synced it. Tests: TestClaudePickerLeavesOutATiersModelAtItsEffort gains the replace case (Terra on Haiku at max is listed); TestOwnModelsSwitchTellsTheAgents counts catalog.Changed per flip. Reviewed and run by yetone at the batch head over |
||
|
|
509d8e7d14 |
agent: a portable VS Code reads its User folder in its data folder
YOUIMARK's Windows has Scoop's VS Code 1.143, a portable build: magpie showed the editor, but its Dir stayed %APPDATA%\Code\User, which doesn't exist — code.cmd on PATH was detection enough — so the provider, models and settings.json magpie wrote went where the build never reads. Before: vscodeUserDir always took the OS's place for the User folder, %APPDATA% on Windows; only detection ever looked at the editor itself, by its launcher alone, so any portable build was found and then read and written in a folder it doesn't use. Now: a build whose launcher has a data folder beside it is portable, as VS Code itself takes a build for portable by that folder alone — a zip's own data folder, or Scoop's, whose apps\vscode\current\data is the persisted one, current a junction into apps\vscode. Its User folder is data\user-data\User there: found, wired, connected and disconnected there. The launcher is found as detection finds it, and a Scoop shim stands for the launcher the .shim beside it names, which proc.Unwrap doesn't read. Zoo Code, which keeps its settings in VS Code's User folder, is laid out by the same function and follows it. An installed build's launcher has no data folder beside it, and keeps the OS's place; so does a portable build before its first run, whose launcher alone is still detection enough, its writes then making the folder where it reads. VSCodium portable is left as it was: its data folder is named by its product.json, which no report asks after. This is the other half of the branch the Copilot-launcher fix came from (taken along with |
||
|
|
6585315e32 |
gateway: a DeepSeek member's reasoning streams through once it has answered cleanly three times running (#4512)
|
||
|
|
2672ba429b |
agent: Claude Code's /model honors the own-models switch too (#4548)
The "show the agent's own models" switch filtered magpie's pickers alone (agent.Picks, #1642): Claude Code's own /model rows stayed put, because nothing magpie wrote for Claude Code looked at the switch — while /model is fed by magpie all the same (modelPicker's rows are writePicker's). raclen traced the whole chain (#4548). writePicker now sets modelPicker.replaceBuiltInOptions (Claude Code's own key: with it the /model picker shows only the listed rows) while the switch is off, and drops the flag again when it is on, so the whole picker is written either way. The Default row stays under both settings: Claude Code keeps it as its own fallback. Tests: TestClaudePickerOwnModelsSwitch writes a settings.json and checks modelPicker carries the rows plus the flag with the switch off, and the flag without it with the switch on. Verification on the base |
||
|
|
7804dfbb03 |
gateway: drop the locked sampling fields for Kimi on Volcengine Ark too
Volcengine Ark's plans lock the sampling parameters of the Kimi models they serve: any request carrying temperature != 1 is refused 400 "Volcengine Ark: `temperature` only 1 is allowed for this model" (#4495, kimi-k3.1-pro / kimi-k3 / kimi-k2.8-preview at ark.cn-beijing.volces.com/api/coding/v3), before any token is read — clients that send their own defaults (Claude Code, Copilot) fail every call, and a routing group spends its failover window on each try. kimiLockedSampling already drops temperature and top_p for the locked models on Moonshot's own endpoints (#1197), but its isKimi guard knows only Moonshot's hosts and presets, so the same models behind an Ark host went through with the fields. The refusal names the model ("for this model"), not the path, and the preset's Agent Plan and pay-as-you- go regions list the same kimi-kX.Y models, so the guard now also takes isArk — the ark.<region>.volces.com check the draw and video code already uses, which covers the preset's plans and a provider added by hand — and kimiLockedSamplingModel keeps deciding per model, as it already does for kimi-k2.5 and later, kimi-for-coding* and k3*. Ark's other models (doubao, glm, deepseek, minimax) are untouched, as is everyone not served by Moonshot or Ark. Run: TestKimiLockedSampling in internal/gateway grew four cases (the coding plan's chat and anthropic routes, an Ark model the server doesn't lock, a provider added by hand on an Ark host): the three drop cases fail on the unmodified code and pass with it, the keep case passes throughout. go test -tags nogui ./internal/gateway ok (499s); gofmt clean; go vet -tags nogui on darwin, linux and windows clean; go build -tags nogui ./... on darwin, linux and windows ok. Generated-by: GLM-5.3-Flash (ZCode) Reviewed and run by yetone at the batch head over |