ac4af582301a4e8a29245dbba767eba31334ddf9
7089
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
62045475b4 |
library: Codex on magpie reaches a command's MCP server through the gateway, run only while a thread uses it (#3885)
Codex starts every stdio server in its config once for each thread it has loaded and keeps them as long as the thread: YPYT1 counted 204 node processes, 21 GB, beside one Codex. While Codex is on magpie (Wired, not disconnected, this machine's gateway key, not WSL) the library now gives it a server run by a command as url = <gateway>/mcp/run/<name>, which magpie serves over streamable HTTP and runs the command for itself (internal/library/mcp_run.go): - a session (Mcp-Session-Id) starts its own child only when it sends something past initialize, the first page of tools/prompts/resources lists and ping; those are answered from what the first child said for the same command, args and env, and a list_changed from a child drops that list; - a (re)started child gets the session's own initialize replayed, so a server that keeps state per client still keeps it per thread; - a child idle for 15 minutes is stopped (a later call starts it again), DELETE stops it, and a server changed or removed from the library has its children stopped at the next sync; - server-initiated requests and notifications go to the session's newest open stream (GET, or a POST answered as SSE). The gateway route lets only this machine in: no Origin, a loopback Host, no forwarded or LAN address (TestRunMCPThisComputerOnly). A server with an env var magpie hasn't, a remote one, and Codex off magpie, in WSL or on another machine's key keep the command as before. agent.Rewired re-syncs the library when Codex is connected or disconnected, so it is handed the commands back when it leaves magpie. Tests (internal/library/mcp_run_test.go, a fake server): starts on a call and not on initialize/lists, idle end and DELETE, a server's own request round-trips, list_changed, a changed/removed spec, an unknown session, and the Codex entry in a sandbox (url when wired, the command back when not, a keyed env var kept as a command). Each was red with its part broken by hand: the init cache removed, the sweep off, runsFor forced false, forget a no-op, the Origin/Host guard dropped. Real runs: - mote, sandbox HOME, real codex 0.162.1 + @modelcontextprotocol/ server-memory: config.toml gets url = "http://127.0.0.1:3581/mcp/run/ mem"; codex app-server's mcpServerStatus/list lists its 9 tools through the bridge. - this Mac, sandbox HOME with only the DeepSeek provider copied, codex 0.162.1 on deepseek/deepseek-flash: a real turn called mem create_entities and read_graph through the bridge and answered with the stored observation. Three codex exec turns at once that used no tool started 0 memory-server node processes (before: one each). - Windows 11 (xiaomi-gpu), sandbox profile, codex 0.161.0: url entry written, app-server lists the 9 tools, 0 memory-server node.exe left after Codex closed. Run at the pushed head (mote): GOOS=linux/windows/darwin go vet -tags nogui ./internal/library/ ./internal/gateway/ ./internal/agent/: ok. go test -count=1 -timeout 45m ./internal/library/ ./internal/gateway/ ./internal/agent/ ./internal/gui/: library ok (167s), gateway ok (596s), agent ok (279s); gui FAIL only TestMainWindowCorners/macOS_26_SDK ("a toolbar doesn't change the corners ... yet the main window's was taken off"), #3949, red on mote's macOS 27 on main too; no gui or AppKit file is touched here. Windows (win-run): go test -run 'TestRun|TestFakeRunServer|TestMCPProxy' ./internal/library/ ./internal/gateway/: ok. Not tried: the Codex desktop app (the same config.toml), a server that asks the client for sampling or elicitation in a real agent. Codex picks up the new entries when it restarts. Reported-by: YPYT1 |
||
|
|
ddf31ca305 |
gateway: a large translated body is written into itself, its items not kept beside it (#4004)
marshalBody marshalled every item of a translated request's list (the messages, the input items) and kept the bytes, so it could size the body exactly before copying them in: at the body's peak the written items were a whole copy of the conversation beside the body. Past bodyKept (4 MiB) of kept items, an item is now only measured, encoded through a json.Encoder into a writer that only counts, and once the body is made it is encoded again straight into it, then let go when its list is spent. A body under 4 MiB is written as before, with no second encoding; a larger one pays its encoding once more (on mote the 47 MiB case of TestMarshalBodyAllocatesTwoBodies went 0.09 -> 0.11 s for both marshals together). The bytes are json.Marshal's either way. Measured on mote, scratch harness (not committed): a 45 MiB Codex conversation sent Responses -> Chat through the gateway, GOGC=10, HeapInuse sampled every 2 ms, 3 runs each, base heap 54 MiB: |
||
|
|
8eb7f5565b |
gateway: a translated body lets its built conversation go as it fills (#4004)
marshalBody wrote a translated request's list (Chat's and Anthropic's messages, Responses' input) an item at a time, but the list itself, the conversation the builder made, strings joined from the request's parts among it, stayed held in the body's map until the whole body was written: at the body's peak it sat beside the written items and the body. The builder names that list as spent, and each item is set to its zero value once written. Every caller's map is its own and dropped after the call (buildChat, buildAnthropic, buildResponses); buildGemini spends nothing. Keys are checked before anything is spent, so the json.Marshal fallback for an odd key still sees the whole map. Measured on mote, TestZZPeak4004-style scratch harness (not committed): a 45 MiB Codex conversation sent Responses -> Chat through the gateway, GOGC=10, HeapInuse sampled every 2 ms, 3 runs each: base |
||
|
|
f6e7214af7 |
minimax: api.minimax.cn is MiniMax China, for the usage card and the thinking sent back
MiniMax moved its China API host to api.minimax.cn (MiniMax-AI/cli
8746d48f, 2026-09-28: mmx agent setup now writes it into Claude Code,
Codex, OpenCode and pi). api.minimaxi.com still answers, but a provider
pointed at the new host got no usage card, because the plan-quota source
knew only api.minimaxi.com and api.minimax.io. Chat requests to it also
lost the <think> block MiniMax wants back on the turns after.
Every place in magpie that matches MiniMax by host is covered:
- planquota.go: api.minimax.cn reads /v1/token_plan/remains on its own
host. Probed without a key, api.minimax.cn answers this path with the
same base_resp 1004 as api.minimaxi.com.
- gateway/chat.go: inlineThink also matches minimax.cn.
Pricing and the catalog go by the provider's Catalog id ("minimax"),
not by host, so nothing changes there. The presets keep api.minimaxi.com.
Tests: a TestPlanQuotaSource case and a TestMiniMaxThinkingGoesBackInTags
case for api.minimax.cn. Both are red on the old code (code reverted by
hand, test kept; mote-run) and green with the fix.
Run on mote (mote-run):
- At 96bfdd57c (base
|
||
|
|
2fc2d53583 |
routing: the head's line keeps its height live, so a pick doesn't pull the list up
|
||
|
|
425a613224 |
library: a server run with npx -y reaches the agent as node running the package (#3885)
npx stays running as the server's parent for the server's whole life. On Windows that is cmd.exe + npx's node + a second cmd.exe beside the server: measured on xiaomi-gpu with @modelcontextprotocol/server-memory, 4 processes and 143 MB (cmd 8.1, npx node 76.2, cmd 8.2, server 50.8) for one instance. Codex starts an instance a thread; #3885 had 223 node processes under codex.exe. A library server `npx -y <registry package> args` (no other npx flag) is now installed with npm into ~/.config/magpie/mcp-npm/<hash> in the background, and the next sync writes it into each agent on this machine as `node <package bin> args`: node by name for npx by name, or the node beside an npx given by path. Until the install is done, or when npm fails (tried again after an hour), the agent keeps npx. An unpinned spec is installed again after a day, as npx would fetch the newer one; an install no library server runs any more is removed a day after its last. The library's own entry, a server's check, Copy config… and WSL agents keep npx. Taking a server off ends node's run of the program (launchedBy reads the node line), as before for npx. Run at this head (rebased on origin/main 1ff54f079; nothing it brought touches internal/library): - mote: go test -count=1 -timeout 45m ./internal/library ok (116s); GOOS=linux/windows/darwin go vet -tags nogui ./internal/library ok; ./internal/proc/... ./internal/testenv/... and the root package ok; TestNpx*/TestReadNpx under -race ok. - xiaomi-gpu (win-run): TestNpx*/TestReadNpx ok. - Real, on xiaomi-gpu, Node 22 + real npm registry, sandbox HOME: the library synced server-memory into a Codex config.toml; the install took 12.8s and the second sync wrote command = "node", args = [the install's …\server-memory\dist\index.js]. Started from that entry, the server answered initialize and tools/list, and its process tree was 1 process at 56.2 MB, against 4 processes and 143 MB through npx. - Broken by hand: without the npxDirect call in syncMCP, TestNpxServerRunsByNode is red ("the package was never installed"). Not tried: a real Codex or Claude Code session starting the node entry (the entry has the same command/args shape they already start), and macOS's process tree (npx's node and sh there too). Not done (#3885 stays open): Codex starting the same MCP once a thread. |
||
|
|
1ff54f079f |
grok: each model is asked on its native API (responses, messages), not Chat for all (uk.jent)
uk.jent on Discord: magpie wrote api_backend = "chat_completions" on every
[model."magpie/…"] table of Grok Build's config.toml, so a Responses-only
GPT or a Claude on an Anthropic endpoint was translated through Chat by
the gateway. Grok Build 1.0.67's own docs (the "Supported API Backends"
page bundled in its binary) take api_backend per [model.*] table:
"chat_completions" (default), "responses" and "messages" (Anthropic
Messages), sent to base_url + /chat/completions, /responses or /messages.
grokBackend now writes the model's native API from catalog.Model.APIs, as
Pi, droid and dsh pick theirs; Chat stays for a Chat-native or unknown
model and for a group whose members differ. All three go to the same /v1.
Grok App (grokapp.go) is unchanged: it has one channel, [model.magpie],
whose model the App's composer switches, so a backend written for the
picked model would be wrong for the next one picked there.
Run:
- TestGrokAsksEachModelNatively (new): red with the old "chat_completions"
put back by hand ("resp/gpt-6-sol: api_backend "chat_completions" ...
want "responses""; same for anth/claude-sonnet-5 / "messages"), green
with the change.
- At this head (rebased on origin/main
|
||
|
|
2cdbe92ded |
pii: a value the model found sure once in a text is sure wherever it found it there
wangwu25685333 on X (10-29): of one sentence with an address repeated
400 times, the address was left unmasked "a few times", thought to be
where the text was cut into chunks.
Reproduced with the real model (AstrLink Guard, pure Go, Linux box,
GOMAXPROCS=4) through masking's strict path and redact.MaskJSON, 400
copies of a sentence in one message:
"Please ship it to 1600 Amphitheatre Parkway, Mountain View, CA 94043
by Friday." joined by "\n": 346 of 400 left as written; by " " or
nothing: 0. Two Chinese addresses, any joiner: 0.
It isn't where the text is cut. Guard found the address on every line,
but less surely the more often it had read it in the text: 0.99 alone,
0.59-0.70 at 20 copies, and on 400 the whole address 325 times at 0.50
to 0.90 and split ("1600" at 0.85, the rest at 0.50-0.59) 65 times.
Masking takes 0.8 and over, so it masked only the sure ones, about one
a piece. Joined by "\n" the pieces are alike, so every piece got the
same few sure finds.
Now spread puts each value of 8 bytes or more the model found in a text
(minSpread, as redact's minKnown) wherever else it is in that text,
with its label and the score of its surest find there, then merges. A
value never found sure stays as unsure as it was, and a house number
alone isn't looked for. It runs on each text and piece the model reads
and on a long text's merged pieces, before they are cached. Spans from
the disk cache written before keep their scores until read again.
After, the same probe: 0 of 400 left for every sentence and joiner.
Test: TestValueFoundSureOnceIsSureThroughoutItsText has a stand-in model
that finds an address sure only first in its first read and unsure
after, on 3 and 400 lines, and fails when an address is left unsure,
another value never found sure is raised, or a short one is spread.
Broken by hand: without spread in find.go it fails ("1600 Amphitheatre
Parkway" at 110 scored 0.50).
docs/subsystems/gateway-routing.md says this, the pieces' ends
(landmark) and the turn's order (takeTurn, queue) of the two commits
before.
At
|
||
|
|
43a9d04400 |
pii: of the requests waiting for the local model, the one with the least left to read goes next
wangwu25685333 on X (10-29, v0.1.1840, Linux, i5-7500 4c/4t, AstrLink
Guard on): requests of 1.4K tokens waited 8.5s for the model behind a
fresh session's 31.5K, and their client gave up at 20s.
The model's turn was a buffered channel, and the requests blocked
sending on it took it in the order they came. A long request gives the
turn up between chunks (4 KB for Guard, about a second or more on 4
cores), but a short request that came after another long one waited
a chunk of each long request ahead of it.
Now each request waiting says how much it has left to read (the bytes
of its texts and pieces neither got nor the cache has; of a Bounded
request's backlog, no more than it will read), and only the one with
the least left (the first to come of those with as little) sends on the
turn; the others wait for the queue to change. The channel stays, so
Warm and guardIdle take the turn as they did. Privacy Filter's pf-serve
turn is the same backend and gets the same order.
Measured with the real model (AstrLink Guard, pure Go) on the Linux box
(wsl magpie-desktop) with GOMAXPROCS=4 taskset -c 0-3, a 5 KB request
sent 1.5s after long requests (a 110 KB system prompt each, cold):
alone: 2.47s before, 2.54s after
behind 1 long: 5.49s -> 4.91s
behind 2 long: 8.29s -> 4.50s
(after: the chunk on the model when it came, then its own two chunks;
before, 8.3s is the reporter's 8.5s.)
What this leaves as it was: masking's waits (2s for the model on by
default, then the rules alone; 15s for a model the user turned on) and
its log line when the rules mask alone (notePartial, once a minute) are
unchanged. Most of the reporter's case was fixed after v0.1.1840 (tool
definitions not read v0.1.1871, the 2s and 15s waits v0.1.1874 and
v0.1.1886, newest first and a 4 KB chunk v0.1.1891, windows in
parallel v0.1.1864).
Order is by bytes left, not by age: a long request waits while shorter
ones keep coming. With masking's waits bounding every request, a long
one waits until its wait ends and the rules mask the rest.
Test: TestShortRequestGoesBeforeLongOnes puts a long request (4 chunks)
on the model, another long one waiting, then a short one, and fails
unless the short one is read second. Broken by hand: with find.go of
the previous commit it fails, read in the order d, h, hi Alice, c, g...
(the second long request's chunk first). Run -race -count=20 with the
turn tests (TestStopped*, TestWaiter*, TestQueued*) on mote: ok.
Run (mote): go test ./internal/pii/... ./internal/masking ok; gateway
-run 'Mask|Redact|PII|Guard|Model' ok.
At
|
||
|
|
40593e898c |
pii: a long text's pieces end where its own text says, so an edited system prompt is read again around the edit only
wangwu25685333 on X (10-29, v0.1.1840, Linux, i5-7500 4c/4t): a fresh Hermes session of 31.5K tokens spent 98.8s in the local model (AstrLink Guard) and 2.3s upstream, and every new session (cron opens one each time) read the same ~30K of system prompt again. The cache by content was already there (#3682: sha256 of each text or piece -> spans, in memory and in found-<rev>.bin, no text), and tool definitions are no longer read ( |
||
|
|
67d0e4da61 |
gui: app.js is back under its budget; the lane comment says what it said before
TestCoreScriptBudget was red on main: |
||
|
|
ca221e115e |
routing: a pick lets the stage go live when the reader is back to newer requests
未寒 on Discord (#feedback, 10-28): the Routing page's stage stayed on a 16:36 Mozilla request to qwenwork/flash, "The agent canceled the request", headed "16:36 的请求是怎么路由的", while the requests list under it went on with auto/deepseek-v4-flash at 17:08 and 17:09. Cause: that head is a pick. A click on a list row, the errors stat, the context card, Usage's openRoute or the tray's ?req= pins the stage to one request. #1389 lets a pin go only when the request leaves the 60 the page keeps, so at a calm pace a pick holds for hours. A reader who left for another app or another page and came back finds the stage on a request they no longer remember picking, and reads it as stuck. Fix (plugins/routing/client.js): the reader leaving while a pick holds the stage (window blur, another page, the window hidden) marks the newest request then. Back in sight and focused, if a request newer than the mark has come, the pin is dropped and the stage follows live (followListed). This is checked in start() when the poll was running, and in the poll's catch-up pass when it had slept out of sight, so requests read only on return count too. Back to nothing new, the pick stays. A reader who never left keeps it as requests come, as before. A new pick clears the mark. Day mode and a replay are left alone. The tray panel has no pin, so there is no sibling there. Test: internal/gui/tests/routing-pin-away.test.cjs. The canceled request is picked from the list. It holds while requests come, and it holds after leaving and coming back to nothing new. The reader then leaves while 8 more come, still within the 60, and comes back: the head is "How the last request was routed", there is no Back to live, the first row is pressed and the stage shows the newest model. Three ways of leaving (another app, another page, the window hidden), en at 1100 and zh at 420, in Chromium and WebKit. Run on mote at this head (rebased on c5cdb043e; main to |
||
|
|
53913be7aa |
providers: a key or account with no limit on requests at once shows how many run (chentuoyan on Discord)
The account and key rows' lane pill said only "No limit at once" when no
concurrency limit was set, never how many requests were out. Now, with no
limit and requests out, it says "{n} running" (zh: "{n} 运行中") and is
shown without a hover, in the same pill style (no full-lane or queue
colour). Idle with no limit it says "No limit at once" again and goes back
to hover-only. Rows with a limit are unchanged.
Backend: /api/lanes (Server.Lanes, /v1/magpie/concurrency's data) only
listed lanes with a limit, because lanes.take took nothing for limit 0.
take now counts a request with no limit in its lane (Limit 0, never
waits; grant still lets any waiter go at once when a limit is lifted) and
gives it back through the same once-only releaser, so Lanes says Busy for
it. Cost: the same one mutex take every request already paid, plus one
small lane and closure; /api/lanes, read every 2s, copies a map of only
the lanes with requests out. A limit set while unlimited requests are out
now counts them (the vendor does see them). The only caller of take
(serve) always calls release (deferred after attempt, or on an RPM
failure). Strings in zh, zh-TW, ja and de. gateway-routing.md says it.
Tests:
- TestLanesCountWithNoLimit (new, internal/gateway): three held streams on
a provider with no MaxConcurrency read Lane{Busy:3}; all gone after.
Red on origin/main's concurrency.go: "lane = {Busy:0 Waiting:0 Limit:0},
want 3 out, none waiting, no limit".
- TestLanesLimitLifted now releases its limit-0 acquire (it was a no-op
before).
- lane-limit.test.cjs "with no limit, what runs is shown, and none running
says no limit again" (Chromium and WebKit, en and zh), red on
origin/main's app.js: expected '3 running', actual 'No limit at once'
(zh: '3 运行中' vs '并发不限'). lane-limit.test.cjs whole: 16/16 ok on mote.
Run on mote at the tree rebased on
|
||
|
|
72ca3d593b |
codex: magpie as Codex's provider keeps the Codex app's ChatGPT account while it has room, so its Work chats and projects stay
Qyburn3 on X: with magpie taking Codex over, the Codex app's "Work"
sessions don't load while the model still answers; turned off, they
come back.
Cause: [model_providers.magpie] had no requires_openai_auth, so Codex's
app-server answers account/read and getAuthStatus with no account and no
token whenever magpie is Codex's provider (magpie API, or the codex.out
takeover). ChatGPT.app 26.1021 then switches to an identity of no
account: onboarding again with no name, ChatGPT mode's projects and
chats ("Work") empty, no avatar, no Chrome control (#1824).
Now putProvider writes requires_openai_auth = true while Codex has a
ChatGPT sign-in with room (openaiAuth: codexChatGPTKnown and not
codexUsedUp), and takes it out otherwise:
- API key alone: left out. With it Codex drops image_gen (captured: 11
tools without, 10 with), and there is no account to keep.
- No sign-in: left out (the app would ask for a sign-in).
- A sign-in the Codex app holds (codex.out, or magpie API while used
up): left out, since the app's composer gate (authMethod chatgpt +
allowed false, #540) would grey Send for magpie's models again. The
takeover's note now names "its ChatGPT chats and projects" among what
is off till the reset, beside Keep on ChatGPT.
- An unknown sign-in read leaves the table as it is.
Sync rewrites the key on any table that disagrees (authStale), an older
magpie's included, and the key joins codexAppRoute, so the Codex app's
app-server is restarted onto its account with nothing for the user to
do. The magpie API note no longer says Chrome control needs ChatGPT (en,
zh, zh-TW, ja, de); agent-wiring.md says why.
Real app (mote, ChatGPT.app 26.1021 with its codex 0.164.0-alpha.11,
sandbox CODEX_HOME, copied real ChatGPT auth, auth.json unchanged after):
- native config: the account's projects and recent chats listed.
- magpie table without the key: onboarding, "ChatGPT Work" with no
projects, no chats. app-server: account null, authMethod null.
- magpie table with requires_openai_auth = true (the keys this commit
writes): every project and chat back; account/read chatgpt pro,
getAuthStatus authMethod chatgpt with a token.
- Model requests to a capturing server, with and without the key:
Bearer is magpie's experimental_bearer_token, no ChatGPT-Account-ID,
15 tools both ways with a ChatGPT sign-in (image_gen kept).
Tests: TestCodexMagpieProviderKeepsChatGPTAccount (ChatGPT + magpie API,
used up and back; taken over and the reset; an older magpie's table from
live config bytes; API key and no sign-in, fresh and after ChatGPT) and
TestCodexAppRouteFollowsOpenAIAuth. Broken by hand: on the old codex.go
5 of 7 subtests red; without the Sync re-derive 3 red; with the key kept
while used up 2 red; agents.go without the route key, the route test red.
Run (mote-run, at this tree on origin/main 157d575c3; the build and the
agent run again after the rebase onto
|
||
|
|
5a85a9836c |
redact: a value at the end of a tool call's arguments keeps its closing quote (xiaojiang091499 on X)
xiaojiang091499 on X (v0.1.1808): "隐私脱敏误把 Codex 工具参数结尾的引号和
花括号一起替换了,破坏了参数格式,导致会话一直报错重连". Still the case on
main before this commit.
Cause, outbound: a tool call's arguments are masked as JSON text
(MaskJSON, escaped). A span is kept out of escapes (#3022) but not inside
its JSON string, so a span that runs past the string's end took the
closing quote with it. The local model does this: Privacy Filter's
tokenizer merges a punctuation run, so in {"cmd":"export
DB_PASSWORD=Hunt3r!"} the real model's SECRET span is `Hunt3r!"`, and a
secret's edges are kept by design (#3591). Same with "the api key is
AbC…!?\"", "ship to 221B Baker Street, London.\"", "pwd=Qq123456@#\"".
A user rule like `tok-\S+` does the same. The vendor got
{"cmd":"export DB_PASSWORD={{SECRET_…}}}: arguments no longer JSON, so
Codex's turn failed and reconnected. The model is on by default since
v0.1.1858, so this hits every user from then.
Fix: inStrings (redact.go) moves each span in escaped text onto the JSON
string it starts in and ends it where that string ends. A span that is a
whole bare value (a number a rule finds, "acct": 12345678901) is kept and
its placeholder goes in quoted (span.bare); any other span outside a
string is dropped. Text that isn't valid JSON is left as before. This is the
path for Responses function_call and Chat tool_calls arguments (JSON
text); Anthropic tool_use input and Gemini functionCall args are
objects, masked string by string, so a span there never leaves its
string.
Sibling, inbound: Writer.event and restoreJSON read an event's "type" as
the walk reached it, so a Responses function_call_arguments.delta whose
"delta" key comes before "type" (as a Go map or any key-sorting proxy
writes it) had its value put back unescaped: a password with a quote in
it ended the arguments' string. typeOf now reads the type first, and the
Writer falls back to the SSE event name. Chat tool_calls and Anthropic
input_json_delta were already right (key "arguments"/"partial_json").
Tests (internal/redact/argstail_test.go):
- TestArgumentsValueAtEndKeepsQuote: the real model's four spans
(captured from Privacy Filter on mote) and a \S+ rule, in Responses and
Chat bodies; arguments stay JSON, the value is gone, Restore gives the
original back.
- TestArgumentsBareValueQuoted: a bare number is masked as a string.
- TestWriterStreamArgumentsValueAtEnd: a value with a quote and a
backslash, at the end of the arguments, split at every byte after its
placeholder starts, through Responses deltas (delta before type),
Chat tool_calls and Anthropic input_json_delta.
- TestRestoreJSONDeltaBeforeType: the whole-body path.
Broken by hand: without inStrings, the first two fail; with the type
read in the walk again in writer.go, the stream test fails at cuts 28-43
({"cmd":"export DB_PASSWORD=Hunt3r!"\x"}); the same in json.go fails
TestRestoreJSONDeltaBeforeType.
Real model: a probe (not committed) ran Privacy Filter on mote over 36
argument texts through MaskJSON as the gateway does; before, the
arguments were broken for each case above; after, all 36 are valid JSON
with the value masked.
Run on mote (mote-run): go test ./... -timeout 45m -count=1 at this
change on
|
||
|
|
e5e2aa58e5 |
routes: each provider's wallets go by what they have left in a group too (#4095)
mycf_711 (#4095, comment): SuperMagic's accounts asked directly went by their points (6,636, 282, 119), but in group/deepseek-v4.1-flash1017 they went 282, 119, 6,635, the provider's listed order. A Smart group weighs its members' accounts as one pool (planLevel → weigh over the heads), and the pool held WorkBuddy's credits beside SuperMagic's points: byLeft returned nil as soon as it saw two kinds of LeftIn, so no balance ordered anyone. Each 400 「积分已不足」 was then met on the small balances first. byLeft now orders each kind (provider + unit) in the places its own seats take: the told seats' places in the pool's order (Smart) or by what magpie sent each lately (Pace, Least used, as their tie-break after the balance), each kind's seats put into its places by what they have left, and seats of two kinds keep that order between them. A seat that told none still goes after those that did. It is one rank per seat, so the comparators stay a consistent order; comparing two kinds as a tie would not be. One kind alone orders exactly as before (TestWalletsGoByWhatTheyHaveLeft unchanged). Tests: TestWalletsOfSeveralProvidersEachGoByWhatTheyHaveLeft (routes: Smart, Pace, Least used, the reporter's three behind a WorkBuddy seat, two kinds interleaved, and Least used's token order between kinds) and TestGroupWalletsGoByWhatTheyHaveLeft (gateway: weigh over a group's pool with the reporter's balances, smart/pace/usage). docs/subsystems/provider-plugins.md and gateway-routing.md say it. Broken by hand: with the old strategies.go both tests are red (the group keeps 632, 710, 051 under every routing). Run on mote, at |
||
|
|
3627742104 |
gateway: an error read as out of credit moves on at any 4xx (#4095)
mycf_711 (#4095): SuperMagic answered an account with no points left 400 "非常抱歉,当前对话需要调用大模型 / 付费工具,您的可用积分已不足。 您可以点击右上角「用户头像」,通过「充值」通道补充积分…". failure() read it as failCredit (creditWords: 充值), but retryable()'s 400/422 branch asked quotaWords only, which has neither 积分, 不足 nor 充值. So hw.failed() was false: the 400 went to the agent while another account in the order had 6,467 points, and the empty account was never rested. retryable() now takes any 4xx failure() reads as failCredit, after the overflow check, so the two deciders agree on credit at every status (400, 422, and the 4xx outside the always-retried list, 409 say). Sibling: shapeRefused() kept out quotaWords but not creditWords, so a shape refusal saying 请充值 would rest nobody; it now keeps out both. Quota: usedUpWords (failQuota) is a subset of quotaWords, so 400/422 already agreed; a quota word at another 4xx (413's "exceeded the limit" is the request's size) is left alone on purpose. Tests (credit_400_test.go), with the reporter's literal body: TestCreditRefusalIsRetryableAtAnyStatus (400/409/422, raw and as magpie tells it on, plus shapeRefused) and TestCredit400MovesToTheNextAccount (two keys: the empty one 400s, the next answers 200, the empty one rests as credit 400, the next request goes straight past it). docs/subsystems/gateway-routing.md says it. Broken by hand: with the new case disabled and creditWords taken out of shapeRefused, both tests are red (every status not retryable, the shape case rests nobody, the request ends 400 after k-empty alone). Run on mote, at |
||
|
|
99299c7b1c |
edit: the big-TOML ratio test compares 1 MB with 8 MB under a bound of 24 (#2219)
|
||
|
|
36200091ad |
edit: the big-TOML shape test bounds the parse by two sizes' time ratio, not one second of wall clock (#2219)
edussss on 10-15, running `go test -tags nogui ./...` for #1928 at load
average ~190: TestTOMLBigFileParsesInLinearTime went red, a 3 MB file
took 1.272s against the 1s bound. Rerun alone it passes. The parse was
still linear; the bound was not.
The check now parses a 2 MB and an 8 MB file three times each, keeps
the fastest of each, and requires the 8 MB time to stay under 8 times
the 2 MB one. Load slows both parses together, so their ratio holds
where a wall-clock second does not. The code standards' "a timing test
leaves room on both sides" asked for exactly this: measured here, the
linear parse's ratio is 3.7 to 4.5, and the quadratic parse the test
guards against, which counts each key's line from the top of the file,
needs 16 times the time for the 4 times bigger file. 8 sits between
the two, far from both.
What was run:
- go test -tags nogui ./internal/edit/: ok
- the fixed test with -count=3: ok (6 runs)
- a local quadratic tomlShaper (per-key line scan, the behavior
|
||
|
|
157d575c39 |
usage: pairing Codex calls by response id allocates no pick an id (#2278)
codexChunkResponsePairs kept a *pick for every response id the gateway
had. The alloc profile of v0.1.1928 on mote (34k session files, 240k
gateway rows, two minutes of polls while an agent worked) had it at
1.05 GB, &pick{} alone 308 MB. The picks are now one slice the map
holds places in, so a poll makes a few slice growths, not an allocation
an id. What is paired is unchanged: every pick is still read once.
TestPairsAllocateNoPickAnID: 4000 Codex calls named once on both sides
are all paired, and a second pairing makes at most n/4 allocations. Red
on the old code (4161 allocations), green on the new.
Run on mote at the pushed head (origin/main
|
||
|
|
b7da6cf932 |
gateway: the fake ChatGPT socket counts a handshake before it reads the message
TestCodexSocketTooBigGoesOverHTTP was red on ubuntu CI at
|
||
|
|
655f8dbd1c |
usage: matching by request id keeps no slice an id (#2278)
matchedBlocks kept each request id's gateway calls in a map of slices, the local calls that named it in a second map of slices with the id cloned, and each match group behind a pointer. Over a year's calls the alloc profile of v0.1.1928 on mote (34k session files, 240k gateway rows, two minutes of polls while an agent worked) had matchedBlocks at 2.5 GB: groups 598 MB, byID 547 MB, byRequest 504 MB, matched/used 463 MB. Now: - an id is a place in one slice of calls, its first call held in place and only repeats in a slice; the map of ids is sized by a count pass; - the local calls that name an id are one slice, each linked to the one found before it, read back in the order they were found, so the order (and newestIDs' sort) is what it was; - the id is looked up, not cloned, and a call with no id is skipped before the lookup; - groups are a slice the map points into. TestMatchByIDAllocatesNoSliceAnID: 4000 gateway calls with ids, a third of the locals naming an earlier id again, match as matchedLocalLegacy does, and the second match makes at most n/10 allocations. Red on the old code (11,334 allocations), green on the new (168). Run on mote at the pushed head (rebased onto origin/main |
||
|
|
1319a44bbc |
docs: plugin guide says what four rules do when a plugin gets them wrong (plugins#468)
Guide (en, zh, ja) and provider-plugins.md: - usage: leave used out rather than send 0; with amount/limit it is their share, with no count the window is text and routing doesn't read it; aside keeps a window out of routing whatever its count. - sign-in: a model refused is 403/404, not 401; a 401 that says only that the model isn't served is read as kept. - free comes only from the vendor's word; rate 0 is none given, never free (magpie infers nothing from rate). - GitHub listing licence: from LICENSE as GitHub reads it, else package.json's license. Docs only. Checked each claim against the source at this tree (plugin_usage.go quotaOfPlugin, plugins.go modelOnly401, fallback.go modelRefused, plugin/providers.go Model.Rate, models.go FreeModel, github.go readTagged). Site deployed with wrangler and the pages read back with curl. |
||
|
|
5957d45ac1 |
plugin: a GitHub listing takes package.json's licence when GitHub names none (plugins#468)
GitHub's search gives NOASSERTION for a LICENSE file it can't match to a licence (MIT's text with a line of credit added) and nothing for none; magpie drops NOASSERTION, so such a card on Plugins > Discover had no licence, while the same package from npm shows package.json's. readTagged keeps package.json's license (a string) as PkgLicense, and License falls back to it, on a fresh read and across searches (fresh). Run (mote, at this tree): gofmt -l clean; vet on three OSes; go test -tags nogui -timeout 45m ./... (go test -tags nogui -timeout 45m ./... at base |
||
|
|
1390aa458f |
provider: a usage window's count is its share when used is left out (plugins#468)
A plugin window that sent amount and limit but no used was text alone (Text, Aside), and an account whose windows all did so was unknown to routing, weighed behind accounts it should beat. quotaOfPlugin now fills Used from amount/limit when both are above 0 and used is absent: 370 of 1000 is 37. An amount of 0 is what a left-out amount reads as, so a limit alone still says nothing (#3650 unchanged). aside still keeps a window out of routing whatever its count. amount is the amount used: the guide ("amount of limit used") and host.js's usageOf say so, and every community plugin that sends it (magpie-community/plugins 95fa761) sends the used count, never what is left: codearts (limit - remain), joycode (item.used), kiro, minimax (total - left), raccoon (granted - avail), cloudflare-workers-ai, cline (used, or total - remaining), zcode (used, total - remaining, or currentValue), gcp-ai (credits.used), copilot (limit - remaining), trae, workbuddy. None reaches the new path: each of these windows sends a finite used beside amount/limit. The one that can leave used out, cloudflare-workers-ai with no Analytics reading, sends amount null, which reads as 0, so its window stays text as before. The path is for plugins outside the community repo (GitHub-tagged or local) that send a count and no share. Run (mote, at this tree): gofmt -l clean; vet on three OSes; go test -tags nogui -timeout 45m ./... (go test -tags nogui -timeout 45m ./... at base |
||
|
|
3ec25523cb |
provider: a plugin's 401 about the model keeps the account's sign-in (plugins#468)
A plugin that answered "this model isn't available on your plan" with 401
marked the account as needing a new sign-in, and the gateway fails a 401
over to the provider's next account (retryable in fallback.go), so every
account of the provider was marked "sign-in has expired" for credentials
that were fine.
notePluginSignIn now reads a 401 that carries no X-Magpie-Sign-In as
"kept" when its body says the model isn't served (provider.ModelUnserved,
the gateway's unservedWords moved here, read decoded by catalog.Words)
and nothing of a token, key, credential, session or sign-in. Only the
first 64KB is read, and the body goes on whole.
Not changed: the gateway still rests the account under its failure
backoff for that answer; modelRefused still reads only 400/403/404/422 as
the model refused. The guide asks for 403/404 (docs commit).
The 401 bodies the community plugins hold for a sign-in that is gone
(magpie-community/plugins 95fa761, every package's tests), each in the
test's "marks" list and none read as kept (none names a model, which
ModelUnserved needs):
- devin: {"code":"unauthenticated","message":"invalid api key" / "bad key"}
- zed: "unauthorized", "", {"code":"upstream","message":"bad key",...}
- cline: {"error":{"message":"nope"}}, {"success":false,"error":
"unauthorized"}, {"message":"expired"}, "the sign-in lapsed — sign in
again"
- raccoon: "unauthorized", {"code":200003,"message":
"authorization_verify_error"}
- joycode: {"code":401,"msg":"登录票据已失效"}, "private-marker"
- zcode: "", {"code":1001,"msg":"Authorization Token非法"},
{"error":{"message":"token expired or incorrect"}}
- mimo: "", {"code":401}, {"error":{"message":"stale"}},
{"error":{"message":"Invalid API Key"}}
- cursor: "no", "Unauthorized — sign in to Cursor again in magpie",
Connect's ERROR_NOT_LOGGED_IN body
- search1api: {"message":"expired"}
No plugin source builds a 401 whose text names a model.
Run (mote, at this tree): gofmt -l clean; go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./...; go test -tags nogui
-timeout 45m ./...
(go test -tags nogui -timeout 45m ./... at base
|
||
|
|
3ec9babe7d |
sessions: the overview points to the sessions it sums up, not copies (#2278)
Stats.Overview copied every Summary (~400 bytes) into its working slice, then cloned that slice once per Top ranking. Over 34k sessions the Sessions page's poll allocated ~1.5 GB in two minutes this way while an agent worked (alloc profile of v0.1.1928 on mote: `in = append` 958 MB, slices.Clone 557 MB). It now ranks pointers into st.Sessions and copies only the k sessions each ranking keeps. shapes, toolUse and skillUse take the pointers. TestOverviewCopiesOnlyItsTop: a second Overview over 5000 sessions allocates at most half of their Summaries' size, and its count and rankings are what they were. Red on the old code (14,923,144 bytes over a 1,020,000 bar), green on the new. A/B on mote (34,040 session files, 240k-row usage.jsonl, the feed run of run2278c.sh: 230s, feed from 60s, Usage and Sessions pages polled), v0.1.1928 code vs this change. mote's load was 47 to 66 from other runs throughout, so the numbers are noisy: avg CPU after the feed starts 122.8% -> 69.4% heatmap poll mean 6.97s -> 4.84s all polls mean 3.11s -> 2.16s footprint peak 685.6M -> 626.1M footprint at the end 402.8M -> 337.5M Run on mote, at base |
||
|
|
7a79318337 |
redact: a package's name goes as written, an import's module first (dniray on Discord)
dniray (v0.1.1917): "脱敏会把包名给替换了", with the case
import { and, eq } from ' drizzle-orm ' going out as
from ' {{SECRET_…}} '. The SECRET came from the local model; the rules
left it. AstrLink Guard reproduces the class on mote with
require( ' jsonwebtoken ' ) -> {{SECRET_…}} and a requirements.txt
django-rest-passwordreset==1.4.0 -> {{SECRET_…}}==1.4.0; Privacy Filter
took a pnpm-lock integrity hash (sha512-…==}) for one, eating the }.
A probe of ~60 package shapes (npm scoped and pinned, Java/Android ids,
Go module paths, Python modules, purls, Debian, Cargo, Gradle, Maven,
CocoaPods, lock files) through Preview, rules alone and with both real
models, default kinds and all kinds, found these and fixed each class:
- model, any kind: the module a line of code loads is never PII
(moduleAt): a quoted specifier after from on an import/export line or
after } or *, import 'x', require('x'), import('x'), and unquoted
from x import / import x / use x:: / extern crate x at a line's start.
A from in prose ("the token from 'Zq8v…'", "copy it from Zq8v…") is
judged as before.
- model SECRET: a name a version is pinned after (==, >=, ~=, !=, <=,
===; pinnedAfter); @ is left out so s3cretPass@10.0.0.5 still masks.
- model SECRET: an SRI hash (sriRe in namesThing).
- secret-named field rule (fieldAt, keyAt, modelTakes): a version or a
range is no secret value: "js-tokens": "^4.0.0-beta.1",
jsonwebtoken = "9.2.0-beta1", secretVersion = '2.1.0-alpha03'
(versionValue).
- user@host (off by default): js-tokens@4.0.0: in pnpm-lock.yaml went
as a user and a host (notPackagePin); alice@10.0.0.5 still masks.
Left as is: SECRET_PACKAGE=@acme/secret-store-v2 and
PASSWORD_LIB=passlib-1.7.4 (a value under a secret's name, not told
apart from a password), and Privacy Filter's "Dagger Hilt" as a person.
Tests: package_names_test.go. TestPackageNamesGoAsWritten (rules,
default and all kinds), TestPackagePinIsNoLogin,
TestModelPackageNamesNotMasked (dniray's literal bytes first, through
fakeModel), TestPackageNameChecksKeepRealValues (emails, an ssh host,
password=, API_KEY=, a secret-named field with a real value, alice@ip,
a model secret in prose after from, before ==, before @ip).
Run, at
|
||
|
|
b692de9c89 |
provider: WorkBuddy's mover min is 0.1.45, so magpie's drawings through WorkBuddy work again
iwinux on Discord (10-28 ~22:30 UTC+8, magpie v0.1.1812): the Magpie Image
MCP through WorkBuddy AI answered
400 Bad Request: Unmarshal create image params failed with error:
invalid character '\x1f' looking for beginning of value (11101)
from the minute plugin 0.1.43 was published (14:30Z). 0.1.43 gzipped every
non-Messages body its fetch sent, and drawWorkBuddy's JSON to
/v2/images/generations and /v2/images/edits goes through that fetch; the
images API reads plain JSON only ('\x1f' is gzip's first byte). magpie
passes the JSON through unchanged. 0.1.45 (plugins 880cd93) gzips only a
chat completion, and gives only a chat the model's default effort.
npm view @magpie-community/opencode-workbuddy-auth version --prefer-online:
0.1.45.
Run at this head (parent
|
||
|
|
87a983423e |
codexcat: Codex's own GPT models stay in the Codex app's first 100 whatever the user's order (maiya on Discord)
maiya (Discord): after updating, the Codex app lists magpie's models and none of Codex's own GPT ones. Cause: the Codex app and its VS Code extension read the first 100 of the list by priority (codexcat.AppList). codexMerged ranks the list by the user's order from the Agents page (codexcat.Order, #855), where a model the order doesn't name goes after every one it does, and codexcat.Fit only brought the models Codex used back into the 100. The GUI saves the whole shown list as the order, so an order saved while Codex's list had no Codex section (the codex provider kept for routing groups before |
||
|
|
40f206dff1 |
vertex: partner models (DeepSeek V4.1 Flash, GLM, gpt-oss) go to Google's OpenAI-compatible chat completions
Dani Ariyanto (Discord) asked for Vertex AI's partner/open models, such as
DeepSeek V4.1 Flash, beside Gemini. Google serves them (Model as a Service)
on an OpenAI-compatible chat completions endpoint in the same project,
https://<host>/v1/projects/<p>/locations/<loc>/endpoints/openapi/chat/completions,
with the same OAuth token. The model goes in the body as publisher/model
(deepseek-ai/deepseek-v4.1-flash-maas). Source: Google's
maas/call-open-model-apis page.
An existing Vertex provider needs no change. A model id with a slash
(VertexPartner) is a partner model, as is every publisher/model id that
models.dev lists for google-vertex as @ai-sdk/openai-compatible. It is
asked on Base(Chat) = <project base>/endpoints/openapi (ListedAPIs, so
ModelAPI can't move it). Gemini ids have no slash and stay on
streamGenerateContent. Speaks is now [chat, gemini].
- vertexEffort (Gemini's levels) no longer applies to a partner model.
Before, a Codex xhigh was clamped to high.
- The provider's own test probes Gemini only. A partner model answers
only after the project enables it in Model Garden, so an unenabled
partner model would turn every Gemini user's test red. A partner model
is tested by its own model test.
- tinyBody's chat probe uses Base(Chat), so the probe goes to the openapi
address. That address is the only one Sign lets the token go to.
- A test as Codex is refused for Vertex, as it already is for Claude Code
("only of a relay").
The global list adds the three partner models that Google's docs list as
live at global on 2026-10-28:
- deepseek-ai/deepseek-v4.1-flash-maas (Preview, global only)
- zai-org/glm-5.2-maas
- openai/gpt-oss-120b-maas
Left out of the list: Gemma 4 (Experimental) and the models retired on
10-21 (v3.x, glm-4.7/5, qwen3, llama-3.3...). Gemma 4 still routes when
typed in by its full id. us/eu/regions are unchanged.
Docs: providers-accounts.md and gateway-routing.md Vertex rows;
reference.md (the global row, how a partner id routes, Model Garden
enablement, typing one in).
Run (on mote via mote-run):
- go test -tags nogui -run TestVertex ./internal/provider ./internal/gateway: ok.
- New: TestVertexPartnerModel (gateway). It covers Chat, Anthropic and
Responses clients, streamed and whole, against a fake openapi endpoint
answering in the shape of Google's docs. It checks the path, the Bearer
token, the body model and the client's text, that Gemini stays on
streamGenerateContent, and that xhigh is kept.
- New: TestVertexPartnerModels (provider). It covers Speaks/Base,
APIs per model, the global list, no partner model at us/us-central1,
that Test() probes Gemini alone, and TestModels on openapi with the
minted token.
- TestVertexProviderListed now pins Speaks [chat gemini].
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./..., go build ./...: all ok; gofmt -l clean.
- Full suite: go test -tags nogui -count=1 -timeout 45m ./... at
80f2bda50 (this change on
|
||
|
|
b5d2858f41 |
usage: matching gateway calls decodes only the session files they can match (#2278)
matchedBlocks paired the gateway's calls with the session files' by request id, then by session, tokens and time, and decoded every session file of the period for each pass: twice per poll, for the few sessions the gateway had calls of. In a 24s heap profile of a fed sandbox it was 0.77 GB of the 5.3 GB allocated, and 5.4s of a minute's 42s of CPU. Each local chunk's hints are now kept by its serial (match_chunks.go, as chunkIDs keeps Codex's response ids): a 32-bit hash of each request id it names, a hash of each session a call of it can be matched in (agy's as agyMatchSession, rows of no tokens and no failure left out, as the pass does), and its last call's time. A pass decodes a chunk only when one of its ids or sessions is the gateway's and its last call is in the period. A hash that matches only decodes the chunk, so the matches are exact. Hints live 8 matchings past their last use. Run at this head ( |
||
|
|
b119f87771 |
LESSONS: a change to when a value appears re-reads every wait on it (3dd59428e)
|
||
|
|
3dd59428e4 |
gateway: TestClaudeRunsNamesEachProcess waits for the hung run's pid, not only two runs
Red on ubuntu CI under -race at |
||
|
|
cb167fcbd8 |
usage: CodexModelEffort's allocation bar is a packed row a call, not a visit (#2278)
TestCodexModelEffortLetsUnrelatedCallsGo held a build of
CodexModelEffort to a visit of the log and a half. Since
|
||
|
|
dc6f6d9022 |
usage: a read of the gateway log decodes its blocks into one buffer (#2278)
logSnapshot.visit unpacked each block of usage.jsonl's snapshot into rows of its own. Every Sessions, Usage and Routing poll reads the log through it (buildGatewaySessions, topSummary, buildVias), so while calls came in it allocated ~800 MB of rows a minute: 1.3 GB of the 5.3 GB a 24s heap profile of a fed sandbox allocated was unpackReusing's rows, strings and text under visit. It now decodes every block into one chunkRows buffer, each over the one before, as the page's other readers do. A record's strings are the block's own text, not the buffer's, so fn may keep them. Run at this head ( |
||
|
|
8273325b05 |
site: Sidrune AI has a China and a Global site, picked by where the user is
Sidrune reported (10-29) that it runs two sites whose keys don't cross:
China at sidrune.ai and Global at global.sidrune.ai, and its website
sends a browser to one by language. magpie listed the China site only,
so a user abroad who signed up on Global and pasted that key got 401
Invalid API key. They asked for a Global / China choice that moves the
endpoints and the key link with it.
Sidrune's entry is now two regions instead of top-level endpoints:
China (cn: sidrune.ai/v1, sidrune.ai) and Global (global:
global.sidrune.ai/v1, global.sidrune.ai), each with its own key link
(register?promo=MAGPIE3 on its site) and website. With regions named
China and Global, the app's existing paths take over (
|
||
|
|
c5cdb043e6 |
routing: a request held before routing says so, not "0 on" and one account
Jason on Discord (v0.1.1818): the Routing card read "magpie · 0 on",
gave the one-account hint and "Nothing could take ." while his
ChatGPT Pro accounts were healthy. His client (AirbuildEnvironment)
sends Codex turns to /backend-api/codex/responses. A request held over
15s before routing (masking, Settings › Privacy) gets the unrouted
watch's placeholder route; codexBackend never called noteAsked, so the
placeholder had no model, and the card read its empty order as zero
accounts on and one account. The requests themselves were held, then
routed; only the page was wrong.
- codexBackend notes the asked model, as handle and gemini do.
- The card: an empty order says masking…/routing… (or nothing when
done) instead of "{n} on", hides the chip, and its line says why
(masking before routing, not routed yet, or the error it ended
with). The one-account hint needs exactly one account on.
- New keys in zh, zh-TW, ja, de.
Run (mote, at c12d2f130's tree before rebase onto
|
||
|
|
602ad84adc |
plugin: the host is told the gateway's address (MAGPIE_ADDR), so a page's own service reaches it on any port
yuesh1_ on X (reply to 2115451149633626237) opened the community chat page (Magiczerowxy/magpie-chat, @magpie-community/page-chat 0.1.16) and got "127.0.0.1 拒绝了连接". That is Chromium's frame error: the plugin's chat server on 127.0.0.1:3477 wasn't listening. Before v0.1.1905 ( |
||
|
|
298bfce59e |
provider: Cursor's plugin min is 0.2.30, an Enterprise account's overall allowance (plugins #391)
0.2.30 (lexleizou, #3288, plugins #391): an Enterprise account's GetCurrentPeriodUsage has no plan pools, so its card was empty; the plugin now reads the website's usage-summary and shows the overall allowance as an Enterprise window in USD, aside while team on-demand is unlimited or a measured budget has room. npm view @magpie-community/opencode-cursor-auth version --prefer-online: 0.2.30 when this landed. Run on mote at this tree: go test -timeout 45m ./internal/provider ok (139s); gofmt -l clean. Not tried: a real Enterprise account. |
||
|
|
b69f8e96af |
usage: a call through magpie adds up the heatmap only for the chunks it changed (#2278)
A call through magpie changes the gateway's log, so the heatmap's kept
page (heatFresh) is no use and the Requests tab's refresh read every
row of the year again: unpacked each session file's chunk and summed its
days. While an agent worked through magpie that was every refresh.
The heatmap now keeps each chunk's day sums (chunkPart.days, in
requestIndex.heatParts, apart from the pages' cells so neither pushes
the other's out), under the same pairing signature the cells use, and
adds up again only a chunk whose rows or pairing changed. A call is
still counted at once. pairedRows.visit had no other caller and is gone.
Measured on mote at #2278's scale (synthetic HOME: 15 GB of Codex
rollouts, 1.9 GB of Claude sessions, 240k-row usage.jsonl), the GUI's
polls every 5s and 4 gateway records appended a second, against
v0.1.1920:
- CPU of a 60s profile while appending: 57.9s -> 42.1s;
HeatmapOf 11.5s -> 6.7s, of it the visit 4.8s -> ~0
- /api/usage/heatmap mean 2.79s -> 1.69s; process CPU average
107% -> 83%
- peak footprint unchanged (579 MB, 607 MB this run: noise; what is
left is pairRows' pairing of the year, next)
Test: TestHeatmapAfterACallAddsUpOnlyWhatChanged (8 session files and
a gateway call: after one more call, at most 1 chunk is added up again,
the call is counted, and the sums equal a cold build). Broken by hand
(old sums never taken): red, "a call added up 9 chunks again".
Run at the pushed head (rebased on
|
||
|
|
fc6f1d5e8d |
site: CoreCode serves OpenAI chat and Responses too, with its ref links and new copy
CoreCode (Joe, 10-28 23:12) added an OpenAI-compatible API and asked for it in the Add sheet: chat and Responses at https://corecode.live/v1 beside the Anthropic endpoint, keysUrl https://corecode.live/keys?ref=magpie, website https://corecode.live/sign-in?ref=magpie, and the en and zh taglines they sent, word for word (sponsors' copy is used as written). zh-TW is made from the zh. Checked: without a key, /v1/models lists the Claude models with supported_endpoint_types anthropic and openai, and /v1/chat/completions and /v1/responses answer 401 "Invalid token". Both ref links answer 200. Run: node --test site/*.test.mjs on mote, 45 of 45 pass. Not tried: a request with a key. The test key CoreCode sent on 10-26 now gets "Invalid token"; a new one has been asked for. |
||
|
|
5bfd76cd83 |
provider: WorkBuddy's mover min is 0.1.44 (plugins #461)
0.1.44 (plugins 95fa761) hashes a huge chat's conversation and turn ids
from its pieces instead of joining the whole user message into new
strings, and reads the one parse for "Free models only" and for a model
that wants a reply after tools. On the issue's 45 MiB repro on mote (4
requests, Bun 1.4.2) the peak goes from 717-760 MiB (0.1.43) to 583 MiB,
one request 390 to 275 MiB; every byte sent is held to 0.1.43's by the
plugin's sent.test.mjs.
npm view @magpie-community/opencode-workbuddy-auth version
--prefer-online: 0.1.44.
Run at this head (parent
|
||
|
|
89f3865efa |
about: the Version row and the title bar hold still while the update's state comes in (#4057)
#4057 lists four jumps on Settings › About and the title bar. Each was reproduced in Chromium and WebKit (update-row-steady.test.cjs) before the fix: 1. Opened cold (no state read yet), the Version row drew with no line under its name, 48px, and grew to 60px when the read came in. The line is now kept, empty (a no-break space), until the answer. 2. Opened with a state read long ago, the row drew it first: "Up to date" and Check, then "0.1.x is downloaded" a moment later. A state is drawn early only when read in the last 30s (#3469's case, a row drawn again within Settings, still is); an older one may be old news, so the line waits empty for the answer. 3. The header's Update pill showing pushed the Settings search in the title bar beside the sidebar ~80px left in one frame, through the ResizeObserver that sets --tools-r. The pill now opens from nothing (max-width and padding from 0 in update-in), so the search slides over with it during the pill's .45s entrance instead. It still ends ~80px left: the pill needs the room, and holding it empty for a pill that is usually not there would take it from the title. 4. Not changed: a failed download's reason still wraps (sub.wraps). It is a new state, not a flicker, and the reason is shown in full on purpose: the network case says what to do (Click Check, or the release page), which a one-line cut would hide. A Check from there keeps the class until its answer, so the row doesn't shrink and grow on each try. No new strings. app.js grows 26 bytes over origin/main |
||
|
|
257eab646d |
update: a click that updates takes the newest the feed has, not the last check's
coeo91 on Discord: "更新行为不对,他会在点击更新按钮后下载上一次或最近一次 获取到的最新版本,而不是实际的最新版本". Clicking Restart to update asked the feed again, but four paths still acted on what an earlier check had found: - With Settings' "Download updates automatically" off, the click's check found the newer version and kept the staged older one (the hold), so the restart went into the older one. The click's check now counts as a click (fetch), so the newest is downloaded, then restarted into. - When the feed took longer than the 10s wait, the route restarted into the staged version anyway. It now answers "checking". The header pill reads again and restarts once the answer is in; About's Version row redraws, and a second click restarts into what the answer found. - The tray's Restart to update didn't ask the feed at all. It now goes through restartAsked: it checks first, or waits for the gateway as the page's click does (#577). - A magpie that can't replace itself opened the release page the last check found. When that check is over a minute old, it checks again first. A current version that is already downloaded is not downloaded again: the check finds the same version and keeps it. The wait on the feed is the one the click had already (at most 10s, usually one round trip). Not changed: usemagpie.ai/api/latest is cached at the edge for 5 minutes (site/worker.js), so a release less than 5 minutes old may still be unseen. magpie web's "Open the release page" opens the URL the page holds, since window.open must run in the click for the popup blocker. Tests (internal/gui/update_fresh_test.go, a fake feed, no network): TestRestartClickTakesTheNewest, TestRestartWaitsForTheFeed, TestTrayRestartTakesTheNewest, TestAvailableOpensTheNewestPage. Run on mote (macOS 27), at this tree: - gofmt -l internal/gui: nothing - go vet ./internal/gui; GOOS=linux go vet -tags nogui; GOOS=windows go vet: clean - go test -tags nogui -count=1 -run 'TakesTheNewest|WaitsForTheFeed| NewestPage|Update|Restart' ./internal/gui: ok - the same five with -race -count=10, with RestartWhenIdle and RestartToUpdate: ok Broken by hand, one at a time, each red in its own test only: - recheck's fetch = false: TestRestartClickTakesTheNewest, "went into the version the last check found: ... Latest:0.1.11" - the "checking" answer taken out: TestRestartWaitsForTheFeed, "restarted before the feed answered: {State:ready ... 0.1.11}" - restartAsked restarting at once: TestTrayRestartTakesTheNewest, "the tray restarted into 0.1.11 with 0.1.12 out" - the available recheck taken out: TestAvailableOpensTheNewestPage, opened [v0.1.11 v0.1.11] Not tried: a real update from a published release; the tray item on Windows and Linux (the code is shared, the menu callback runs in its own goroutine on Wails v3 beta.24). |
||
|
|
ff6fdffd60 |
usage: opening the page on Requests or Sessions asks no vendor for allowances (#4064)
Opening Usage called quotasOpened() whatever tab it opened on, so a switch to the page on its Requests or Sessions tab started an asked read of every vendor's allowance and the allowance history beside the tab's own read, and the frame the switch drew waited on all of it. Only the Overview shows the allowances; it now alone asks for them. Clicking the Overview subtab still asks (loadUsage(true)). allowance-open-read: leaving the page on Requests and coming back past the 30s gap asks no vendor and no history; clicking the Overview then asks once. Run on mote at this tree, rebased on origin/main |
||
|
|
96115018cf |
gateway: a key's Limit and Models keep their room unhovered (#4072)
|
||
|
|
11cbf4de1d |
usage: Sessions' agent filter is a menu, as the model and folder ones beside it
The owner (10-28, screenshot of Usage › Sessions with 13 agents in a strip across the page): "这应该是个 Combo Box". The agent filter was a segmented strip, one segment per agent in range, that scrolled sideways in itself once it ran past the window (#929). It is now the same sessPick button as 全部模型 and 全部文件夹, with the same searchable menu: "All agents", then every agent with sessions or usage in the range, the most used first, each with its tokens under the other two filters. One agent in range still leaves it hidden; the pick still resets to All when its agent leaves the range. The request ledger's agent filter was already this menu. #sessAgent left the CSS rules for scrolling strips; the strip's own test (sess-agent-strip, #929's sideways scroll) is gone with the strip, and usage-sessions-agents-fit now checks the menu: no sideways scroll at 860 and 560 wide, the three filters on one line inside the window, the menu's order, search, a pick shown on the button and kept when the page is drawn again, All clearing it, one agent hidden. sessions-empty-range and sessions-overview-once pick their agent from the menu. Run on mote (node 22, Playwright 1.62.0): - usage-sessions-agents-fit, sessions-empty-range, sessions-overview-once: 24 of 24, Chromium and WebKit, every language they cover. - usage-sessions-agents-fit against origin/main's page.js, client.js and app.css: red in all four (BUTTON.sess-pick expected, a div of segments). - go test -tags nogui -run Budget ./internal/gui: ok. - 122 other GUI files that touch Usage, sess-pick or i18n, concurrency 3, beside another session's full GUI suite (load 36-75): 1944 pass, 24 fail in gateway-caller-keys, gateway-key-cycle, i18n-keys, mcp-oauth-app, usage-ledger and web-page. Rerun alone at concurrency 1 on this tree and on origin/main ( |
||
|
|
6ecc65b6db |
agent: the CodeBuddy IDE is CodeBuddy too, found with no CLI
bjzhangwn on X: magpie supported CodeBuddy only as its CLI, not the IDE. The CodeBuddy IDE (4.12.2, codebuddy.ai's CodeBuddy.app, com.tencent.codebuddy, and codebuddy.cn's CodeBuddy CN.app, com.tencent.codebuddycn) reads the file magpie already writes for the CLI: its genie extension's CustomModelsProductProvider loads ~/.codebuddy/models.json's "models" (a string id and url each) and "availableModels", and lists them in its own picker. So one row, renamed CodeBuddy, stands for both. desktopApps gets a "codebuddy" entry, with a "more" list for the second build's bundle id. A `sign` lists the row with only the IDE installed. That row shows the IDE's version, is never "CLI not found", and the CLI isn't offered for install. Tests: TestCodeBuddyIDEIsCodeBuddy uses the real Info.plist bytes of both builds, cut to their first keys. TestCodeBuddyIDEReadsMagpieModels reads the written models.json the way the IDE's loader does. Run (mote, macOS 27): - gofmt -l: clean. - GOOS=linux and GOOS=windows go vet of ./internal/agent/... and ./internal/sessions/..., plus GOOS=windows -tags nogui ./internal/gui: ok. - go test -timeout 45m -count=1 ./... at |
||
|
|
2ff85f8a2b |
gui: a page's bar room comes out of its right padding, so both sides match
v0.1.1904 had every page keep its scrollbar's room, so nothing moves
when a page grows past the window. The owner asked whether the clear
bar now makes the sides uneven: it did, by the bar's width (8px on the
Mac, 10px on Windows and Linux), and the centred pages sat 4px to the
left.
layout.js measures the bar of a .view into --bar (again on resize, so
a text-size zoom is followed), and app.css takes it from each page's
right padding: the panel's 12px, the window's 16px, the centred pages'
max(16px, 50% - 600px) and the phone web's safe-area right. The heads
and strips that reach over the padding (Library's and Settings' sticky
heads, Providers' after-list fade, the masking record's bar) reach that
much less on the right, or they would run the page sideways. A plugin's
page, whose frame scrolls itself, shows a bar only when it needs one.
layout.js's measuring adds 254 bytes to the core's scripts; the budget is
raised by exactly that, with no room added.
page-width-steady.test.cjs now checks every page's left gap against its
right gap with the bar (chromium and webkit, the Mac's 8px bar and the
10px one, 1100 and 1600 wide) and that no page scrolls sideways; that
check found Providers' after-list fade running 4px past the page. With
v0.1.1904's CSS it is red ("agents: 16px on the left, 24px on the
right (bar 8px)", 26px with the 10px bar, 94/102 centred). page-width's
"centred" check compared paddings only, and now counts the bar too.
Run on mote at this head (f70cb6825's tree, on origin/main
|