85e4c693ee3ec96fc230bdd181eebe490888b366
882
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
489d816213 |
agent: dsh's wiring round does nothing when nothing it reads changed
A user's live heap profile showed 35.7 GB allocated in 48 minutes with
~157 MB live. 12.1 GB of that was one path: KeepDshWired -> keepDshWired
-> dshWiredOnce. It runs every 30 s, and each time it rebuilt the whole
catalog and every route, only to write nothing. Within it:
magpieModels("dsh") 9.5 GB, dshRouteAgain 4.8 GB, dshPutRoute 3.8 GB, and
Exposed/Catalog/heldOf/entriesOf ~7.7 GB under them. heldOf caches only
during a Hold.
What changed:
- provider.StampNow (hold.go) records what the catalog is built from,
without building it:
- held.gen, which Changed and a plugin's change move
- filememo.Gen
- the environment
- the stat stamps of providers.json, settings.json and the catalog's
cache file, which another process's writes move
- keepDshWired keeps a dshRounds between rounds.
- It builds magpieModels again only when the stamp moved, or when its
models are dshModelsFor (5 min) old. The 5-minute rebuild covers what
no stamp sees: another app's account file, or a model retired by date.
- It skips the round when these are all the same as at the last round,
and that round wrote nothing and left the files as it found them:
- the bytes of dsh's files: every profile's cordis.patch.yml, the
home layer, settings.yaml, .env, .credentials.yaml, config.yaml
- the gateway URL
- the hash of the models
- A read error other than "missing" hashes as unknown, so the round
runs.
- dshWiredOnce (Sync, Connect, tests) still always does a full round.
- No singleflight and no new lock: the round already runs under dshWrites.
- docs/subsystems/agent-wiring.md says so.
Not done: caching Exposed/Catalog/entriesOf outside a Hold. Their output
depends on time (retiredNow, disabledNow) and on files other apps write,
and nothing signals a change in either, so nothing would bound how stale
the cache gets.
Measured with a throwaway test in a sandbox HOME, on top of 4f044c24c:
12 providers from a real models.json, 270 models, 3 dsh profiles.
- Before, per round: 132.61 MB, 900,624 allocations (~265 MB/min).
- After, nothing changed: 0.26 MB, 119 allocations.
- After, models older than dshModelsFor: 30.77 MB, 88,336 allocations.
The dsh parse and write are skipped because the models' hash is the
same.
- Averaged over time: ~6.7 MB/min, against ~265 MB/min before.
New tests:
- TestDshRoundWithNothingChangedBuildsNothing: AllocsPerRun must be at
most 300; it is 77 now.
- TestDshRoundAfterAChangeWritesAgain covers each change:
- a provider saved
- a setting saved
- the patch list written over
- providers.json written by another magpie
- a change no stamp sees, picked up after dshModelsFor
Broken by hand, each went red:
- skip always off: the allocation test, at 2099 allocations
- stamp check removed: the provider, setting and another-magpie cases
- roots left out of the stamp: the another-magpie case
- aging removed: the unseen-change case
- file bytes left out of the sum: the patch-list case and
TestKeepDshWiredWritesTheRouteAgain
Run at this tree. It is built on origin/main
|
||
|
|
42e6aee534 |
sessions: the stats and id lookups don't build every session's subagents
Why: in a 48-minute heap profile of the user's magpie,
gui.combinedSessionStats → statsFor → StatsAndNative → statsIn
allocated 3.9 GB, and gui.warmSessions → Warm 5.7 GB. Their scans went
through assemble → subagentsOf → ccTask: the stats built every
session's subagents (each one's task read from its file), only to
count tokens and tell which sessions are listed. Every statsFor call
in the profile came from the warm-up's steps.
What changed:
- assemble is split. assembleListed holds the part that decides
whether a session is listed and gives its agent, id, title, models
and usage. assemble adds resume, carry, transcript and subagents on
top.
- These callers now use assembleListed: the stats' native-key and
summary loops (stats.go), Titles, the Codex provider lookup
(codex_provider.go) and manage's id lookup.
- List, One and manage's listing still use assemble.
- The docs/subsystems/gateway-sessions.md subagent section says
which callers build subagents.
Tests:
- TestStatsReadNoSubagentFile writes a subagent with no meta and no
task in its first lines, then simulates a restart (Saved, Reset,
memos cleared). It then runs StatsAndNative(0), StatsAndNative(30)
and StatsFor(7) three times and expects 0 scans of that file. List
still shows the subagent.
- Broken by hand: the stats back on assemble make it go red with
"the stats read an unchanged subagent's file 1 times". Green again
once restored.
Measured on a read-only APFS clone of the user's ~/.claude/projects
and ~/.codex/sessions/2026/10, in a sandbox HOME, at load ~500 from
other sessions. The whole series against origin/main dee5c9d75; this
commit is the change to the stats rows.
| Pass | origin/main | This series |
| --- | --- | --- |
| warm StatsAndNative(0) | 596.7 MB, 157,195 allocs, 6.2–9.0 s | 28.9 MB, 73,976 allocs, 0.08–1.1 s |
| warm StatsAndNative(30) | 594.9 MB, 6.8 s | 28.7 MB, 0.8 s |
| restart StatsAndNative(0) | 3,106.7 MB, 509,239 allocs, 30.0 s | 48.2 MB, 241,721 allocs, 1.9 s |
| restart StatsAndNative(30) | 594.9 MB, 9.6 s | 28.7 MB, 0.5 s |
Run at the final tree of this series:
- gofmt -l internal: nothing.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
- go test -count=1 -timeout 45m ./internal/sessions/ ./internal/gui/:
- sessions: ok, 366.7s.
- gui: only TestMainWindowCorners failed, "measuring the windows:
signal: killed". It also fails alone on an untouched origin/main
export, at load ~500. Filed as #1936 and #2645. Every other gui
test passed.
- go test -race -count=3 on the new tests: ok.
|
||
|
|
a23fbaeadf |
sessions: a subagent's file is read for its task only when its meta names none, once per change
Why: a 48-minute heap profile of the user's magpie allocated 6.3 GB
in sessions.scanAt, 3.5 GB of it from ccTask. The user has 3,174
Claude Code subagent files, 1,798 of them over 1 MB. Two things
caused it:
- subagentsOf titled each one `cmp.Or(m.Description,
ccTask(f.path))`. Go evaluates both arguments, so every subagent's
file was read for a first user line that was then thrown away
whenever the meta file had a description, which is nearly always.
- ccTask kept only a found task. A file whose first 16 lines name
none was read again on every ask.
What changed:
- Claude Code and Kimi subagent titles read the file only when the
meta (or the spawn record) gives no description.
- ccTask keeps what it read, a task or none, with the file's size and
mtime from before the read. An unchanged file isn't read again. A
grown, rewritten (even at the same size), or touched file is read
again from its first lines.
- A read that fails keeps the last good result, and a deleted file
gives "".
- A line appended while the file is being read changes the size, so
the next ask reads it.
- The docs/subsystems/gateway-sessions.md subagent section says so.
Tests:
- TestSubagentTaskReadOnlyWhenTheFileChanges counts scans through
scanHook for these cases:
- first ask: 1 scan;
- unchanged: 0;
- grown with a task: 1, then 0 once found;
- grown after the task: 1;
- rewritten shorter: 1;
- rewritten with no task: 1;
- same size with a new mtime: 1;
- a task appended past line 16: 1 scan, still "";
- appended during the read: found on the next ask;
- deleted: "", 0 scans.
- TestSubagentWithMetaTaskIsNotReadForIt lists a session after a
simulated restart (Saved, Reset, memos cleared) and expects 0 scans
of a subagent whose meta names its task.
- Broken by hand:
- ccTask back to keeping only a found task (`t.task != ""`) makes
the first test go red: "unchanged, no task yet: 1 scans, want 0".
- The title back to cmp.Or makes the second go red: "the list read
a subagent's file 1 times for a task its meta names".
- Both green again once restored.
Measured on a read-only APFS clone of the user's ~/.claude/projects
and ~/.codex/sessions/2026/10, in a sandbox HOME, at load ~500 from
other sessions. Times are noisy; allocations are not. Restart, then
List(All):
| Code | Allocated | Allocations |
| --- | --- | --- |
| ccTask keep, title still cmp.Or | 153.9 MB | 270,838 |
| this commit too | 25.8 MB | 109,854 |
| origin/main
|
||
|
|
20c0688316 |
gateway: Claude Code processes are held to what the machine's memory holds; a full room is a 503 the next provider takes (#2956)
Cause: nothing bounded how many Claude Code processes magpie runs for
Claude subscriptions. Busy runs had no limit, idle ones were capped at 6
and parked ones at 16 per bridge, and one-off tests, warm-ups and /usage
reads were counted nowhere. The reporter's 512 MiB systemd service had 2
busy runs and 14 starting at once when the memory cgroup's OOM killer
ended them.
Measured (Docker arm64, real Claude Code 2.1.303):
- one idle run holds about 205 MiB RSS, 86-112 MiB of it anonymous;
- six runs under a 512 MiB memcg gave oom_kill 2 and a peak of 512 MiB.
Fix: claudeRoom (claude_room.go). Every Claude Code takes a place before
it starts and frees it when its process exits. That covers startRun and
runClaudeTree (tests, warm-up, /usage).
How many may run:
- the user's claudeRunsMost (`magpie claude-code runs N|auto`). It is
machine-local (KeepOwn), and the Settings page's save keeps it.
- otherwise, on Linux, (limit - 256 MiB) / 128 MiB, at least 1. The limit
is the least of MemTotal, cgroup v2 memory.max and memory.high up the
tree, and cgroup v1 memory.limit_in_bytes. The reporter's 512 MiB
cgroup gives 2, and 1 GiB gives 6.
- otherwise no bound: macOS, Windows, or limits that can't be read.
A full room first lets go of the oldest idle run. Its session is
shelved, so the next turn resumes it. Next it lets go of a run parked
past parkLongest. Busy runs are never let go. Otherwise it waits up to
2 minutes, then answers 503 with the reason and the command.
Routing treats that 503 as protected. No Claude account is rested or
asked next, since each would wait for the same room, and another
provider in the group answers.
Tests (each run red by hand on the broken code):
- TestClaudeRunsHeldToTheRoom: 6 conversations at room 2. With take
forced to always admit: "6 Claude Code processes were alive at once,
2 may be". Fixed: at most 2, and all 6 answer 200.
- TestClaudeRoomLetsAnIdleRunGoAndItResumes, TestClaudeRoomFullIs503 and
TestClaudeOneOffsTakeRoom went red with take forced open.
- TestClaudeNoRoomPassesOnAndRestsNobody went red with the routing
exemption off: both Claude accounts were tried and rested.
- TestClaudeMemRunsFromTheCgroup uses the reporter's literal meminfo,
cgroup path and memory.max.
- TestClaudeCodeRunsSetsTheUsersOwn went red with validation loosened.
- TestClaudeRunsMostIsMachineLocal went red without the KeepOwn line.
- TestSettingsSaveKeepsWhatItDoesNotSend (internal/gui guard) caught a
Settings page save clearing the value. It is kept now.
Run at this tree (macOS, go1.26.8):
- go test -timeout 45m -count=1 ./... with pipefail, under a load
average of 650-800 from other sessions: 61 packages ok. Three were not:
- internal/agent and internal/gateway hit the 45m timeout mid-test.
The stacks show no hang. Re-run at -timeout 120m: agent ok (2779s).
- In gateway, TestClaudeAccountsSpentFallBackToCodex hit its 30s wall
bound. No room wait was logged before it, and it passed 5 of 5
alone.
- In the same run TestClaudeRoomLetsAnIdleRunGoAndItResumes was red
because of its own check: a random request id in the fake's log
spelled "a1". It now reads only the fake's "told" lines. Flipped to
"a2", it goes red.
- internal/gui: TestPanelJoinsFullScreenSpaces (a macOS window test)
passes alone. TestSetAnswersWhileDevinAndProvidersHang has a 10s
bound, and at the base commit under the same load it failed 2 of 3.
- The touched packages again, -count=1: settings, cli and gui ok.
gateway: the room tests and TestClaudeAccountsSpentFallBackToCodex
ok at -count=5.
- gofmt -l: clean.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
Not tried:
- the Docker 512 MiB reproduction re-run with this build against real
Claude Code. The fix is shown with fake runs only.
- a real cgroup v1 host.
- the site's docker docs (en/zh/ja) don't mention `claude-code runs` yet.
|
||
|
|
75e769a9f9 |
routing: Free first spends the models that cost nothing before the ones that spend (#3054)
A provider or group can be routed `free`. Seats whose model the vendor serves at no cost to the allowance or credits go first, in listed order. The rest follow, also in listed order. Free means the vendor's own catalog.Model.Free word, or else a $0 list price on every count (provider.FreeModel). A pool with no free model behaves as In order. routes.Seat gains Free and Strategy gains ByFree. weighRouted works Free out only for a strategy that weighs by it, so other routings never read a model list for it. It is wired through every list a routing appears in: - both save whitelists; - plugins/rotation's Builtin; - app.js's ROUTINGS (appScriptBudget 1,269,000 → 1,271,000 for the description) and the Routing page's options, hints and trace text; - zh-TW, ja and de strings; - the TUI's routings; - the CLI's aliases (free, free-first). Written by keeuu (issue #3054, three commits), squashed onto |
||
|
|
d9c6a60d8a | Merge commit '791604559' into pf/serve | ||
|
|
3806014ac8 |
redact: Chinese personal names are masked, where the model misses or overreaches them (#1977)
OpenAI's Privacy Filter gives common Chinese names (张伟, 李娜, 陈建国,
黄晓明) almost no PERSON weight. Lowering the O label's emission by 2 or
4 in a patched pf-serve didn't bring them back. It also returns spans
that run past the name (「王芳,她下周一」, 「张伟先生」).
zhname.go adds a rule layer behind the model, only when personal data
is covered:
- a surname (single, compound, or 小/老 + surname) with a 1–2
character given name is masked when something around it says it is
a person:
- a role before it (客户, 联系人:, 我叫, 作者:, @);
- a verb before it (给, 告诉, 抄送) or after it (说, 反馈, 先生);
- a title or 总 (孙经理, 邓总);
- a name joined by 和/与/跟/及/、 to a name already found counts too;
- words that start with a surname (张量, 高度, 王国, 周五, 总是) are
never taken;
- the model's PERSON spans with Han in them are cut at punctuation or a
title, and only when at least two characters remain.
Run:
- Real model, end to end through MaskJSON (pf-serve q8, Metal):
- masked 张伟, 王芳 (cut), 李娜, 刘洋, 陈建国, 赵丽颖, 欧阳娜娜, 司马光,
黄晓明, 周杰伦, 小王, 老李, 马云, 王老板, 邓总, 孙经理, 刘总监,
吴敏, 郑浩, 何静, 唐宁, 许文强, 罗志祥, 林老师 and 郭靖;
- Japanese, Korean and English names are unchanged.
- Missed, with nothing around them that says person: 「模块是谢磊写的」
and 「和黄蓉团队」.
- False positives: none over 2237 lines of the repo's Chinese docs and
i18n, or 61 developer sentences.
- Cost: ~19ms CPU over 880KB.
- Broken by hand:
- with the layer off, TestChineseNames has 8 names unmasked;
- with the two-character guard off before a title, 感谢李老师 goes red.
- Checks:
- gofmt -l is clean;
- go vet is clean on darwin, GOOS=linux -tags nogui and GOOS=windows.
- go test ./... -timeout 45m at load ~750: 63 packages ok, redact
among them. internal/agent (TestReconnectKeepsTheLastPick) and
internal/gateway (TestLargeRequestEndpoints) hit the 45m timeout with
no failed assertion, and are being rerun alone.
|
||
|
|
7916045591 |
library: RTK's tag for Grok Build and Grok App gives their own reason and rtk-ai/rtk#2136, not DeepSeek Harness's (新v学员 on Discord)
Every agent RTK has no hook for got dsh's tooltip on the RTK tab: "{agent}'s
hooks can only allow or deny a command, not change it" with
rtk-ai/rtk#3847 ("FR: Support DSH"). For Grok Build that is wrong twice:
the issue is dsh's, and Grok's PreToolUse hooks can rewrite a command
(updatedInput, shown on rtk-ai/rtk#1890). What holds is that rtk init has
no Grok agent (src/hooks/init in rtk v1.0.1 has none), and
rtk-ai/rtk#2136 is the open request for Grok Build (#4513 was closed as
its duplicate). Each link was checked with gh issue view; the others in
rtk.go (#3847, #3934, #4311, #3898, #4187, #3404) are right.
rtkNoHookWhy in plugins/library/client.js gives each agent its own reason:
dsh keeps its text and #3847, Grok Build and Grok App cite #2136 (Grok App
runs Grok Build), and an agent with no entry gets a reason with no link.
New strings in zh, zh-TW, ja and de. rtk.go's grok and grok-app reasons,
which the CLI shows, cite #2136 too.
TestRTKNoHookIssuesAreEachAgents fails when an rtkNoHook agent has no page
reason (or the reverse), when the page and rtk.go cite different issues,
when two agents cite the same issues without a reason in sharedRTKIssues,
or when the fallback carries a link. library-rtk-nohook.test.cjs checks
Grok Build's tag says #2136 and never #3847, DeepSeek or "hook".
Run in a worktree rebased on origin/main
|
||
|
|
822f2b3042 |
agent: dsh lists a vendor's reply limit at most a quarter of the window, so it has room to compact (#2823, LoKi on Discord)
dsh takes a model entry's maxTokens as the output of every request. Before deciding when to compact, it reserves that output plus 65536 of headroom out of contextWindow (dsh-compaction-basic resolveCompactSpec). When a vendor's reply limit is close to its window, dsh compacts at a sliver of the window, or can't compact at all. magpie now lists a vendor's figure held to a quarter of the window (dshMaxTokens). It does this on every pi-ai route and in the legacy llm-deepseek entry, the same rule VS Code and Copilot in JetBrains already use. A Max output the user set stays as they set it (outputOr). LoKi's patch capped only an output >= the window. That misses #2823's own case (a group at 500000 / 393216) and outputs above window - 65536, such as 131072 / 65536. The quarter rule covers all of them, and a cap can only lower the reservation. Run: real dsh 0.2.0-rc.2 headless, sandbox HOME/DSH_HOME, a fake OpenAI SSE server with a tool-call step so pre-step compaction runs, and an observe-only loader hook on resolveCompactSpec. origin/main |
||
|
|
5f73537f5b |
gateway: Codex's own turn on one ChatGPT account is asked again on an overload, then its fallbacks (夜松云 on Discord)
Codex signed in to ChatGPT with magpie as openai_base_url, one account, no usage cap: Codex's own gpt-* turns go through codexUpstreamOn with no account, relayed as Codex sent them. That path was pass-through since |
||
|
|
5e30d5b5ae |
autostart, gui: Open at login says when the Mac's own switch for it is off (#2120)
Anoninz on #2120: Settings said Open at login was On while System Settings › General › Login Items › Allow in the Background had magpie switched off, so magpie never opened at login. autostart.Enabled now returns a State: off, on, or needs allowing. - macOS 13+: with the plist present, Enabled asks Background Task Management through SMAppService statusForLegacyURL: (cgo, ServiceManagement weak-linked, minos stays 12.0). RequiresApproval reads as needs allowing. Any other answer, a failed ask (-1), macOS 12 or a build without cgo (the darwin CLI release) leaves the plist alone deciding, as before: a failed read is never "off". launchctl print-disabled did not follow the switch on macOS 26.2, so it isn't used. - BTM matches the item by the plist's Label, not its path: the tests ask about a label of their own, and TestMain stubs the ask so no test reads the user's real item. - GUI: Settings › General keeps On and adds one line, "Switched off in System Settings’ Login Items…", with an "Open Login Items" button that opens x-apple.systempreferences:com.apple.LoginItems-Settings.extension through /api/open (that one URL is allowed; other x-apple URLs aren't). The window's focus reload clears it once switched back on. The row is hidden in magpie web, as before. Strings in zh, zh-TW, ja, de. - CLI `magpie autostart` says where to switch it on. The daemon counts a held-back record as on (it is the user's choice, held by the system). Part B (SMAppService.mainApp) is not in this commit: it can't be verified here without registering in the user's real login items and logging out to see a login launch stay tray-only. Run: - go test ./internal/autostart (cgo and CGO_ENABLED=0), cli, daemon, gui after rebasing on origin/main |
||
|
|
40d1661852 |
Merge remote-tracking branch 'origin/main' into pf/serve
# Conflicts: # internal/gui/core_budget_test.go |
||
|
|
9588501c02 |
provider: Ollama's and Ollama Cloud's decision models classify routing groups through System One (Nanka on Discord)
Ollama 0.35.0+ (0.40.5+ for cloud models) serves System One at
POST /v1/systemone, locally and at ollama.com with a key. Its body and
answers are System One's, so magpie's request is sent unchanged (a real
answer adds prompt_eval_cached_count, which is ignored). Its /v1/models
lists the decision models (Tev, Nimble, Clef) among the chat models with
nothing to tell them apart, so clef:27b showed up as a chat model on
Ollama Cloud. /api/tags, asked with the same key, gives each model
capabilities: "decision" (and "vision" for Clef).
- Both presets get Decide = their chat base, and a saved Ollama or
Ollama Cloud provider is backfilled with its chat base, as oMLX and
MLX-Serve are.
- ollama_decide.go: the decision list is /api/tags filtered by the
"decision" capability (ollamaDecides, listedOllamaDecide), kept under
<id>.decisions. Images come from "vision". The window is the list's
context_length, else the cloud's 65,536 from Ollama's docs. An Ollama
older than System One lists no capabilities, so none, and no Jev is
made up.
- decide.go: oMLX's, MLX-Serve's and Ollama's mixed-provider checks now
share serverMarksDecisions.
- internal/gui/local_address_test.go: an Ollama added at another address
moves its decision URL with it, as oMLX's does.
- docs/subsystems/providers-accounts.md says so.
Run, at origin/main
|
||
|
|
e4ac5e8712 |
zcode: models magpie writes have native web search on, and a model the user unticked stays off (Gearclickist on Discord)
Gearclickist (#help, 10-19): every model magpie writes into ZCode came
without web search, and each had to be ticked by hand in its settings.
ZCode 3.14 keeps the switch ("原生联网搜索") as
config.properties.supportsNativeWebSearch on a model rule in
provider_config.json (read from ZCode.app's own bundle). It only works
with an anthropic-messages provider, where ZCode sends a
web_search_20260209 tool, which the gateway already serves; on other
formats ZCode's WebSearch throws. Unticking writes nothing: ZCode drops
the key from magpie's rule because false is its default.
zcodeRules now:
- turns it on for each model magpie lists, on Anthropic Messages only,
including rules an older magpie wrote without the key;
- remembers which models it turned on in the stash (zcode.web_search),
so a model whose key went missing was unticked by the user and stays
off on every later sync;
- keeps any value already in the rule, true or false;
- leaves manualProviderModelRules alone and drops those ids from the list;
- on another format takes back only its own true;
- turns nothing on when stash.json can't be read or parsed (unknown);
- forgets the list on disconnect.
config.json (pre-3.14 shape) has no such field and is unchanged.
Known gap, not fixed here: other edits a user makes in ZCode to a model
magpie lists (JSON output, mid-conversation system, context window) land
in the same rule and are still rewritten on sync.
Run at this head:
- TestZCodeWebSearch (new) fails on the old zcode.go ("first sync: pro is
<nil>, want true"). Broken by hand, it goes red at each guard: the
untick check removed ("unticked: flash is true"), the take-back on
another format removed ("chat completions: pro is true"), and an
unreadable stash read as empty ("unreadable stash: flash is true").
- go test -run TestZCode ./internal/agent/: ok.
- gofmt -l .: clean. go vet ./... on darwin, GOOS=linux -tags nogui,
GOOS=windows: clean.
- set -o pipefail; go test -timeout 45m ./... (sandbox HOME, at
|
||
|
|
e5b57794e2 |
routing: a rule's agent picker lists agents heard from and takes a typed User-Agent name (raikyou on Discord)
A rule can match a client magpie doesn't know, such as SillyTavern or someone's own app with its own User-Agent. The gateway already names such a client by its User-Agent's product name (usage.AgentOf), and a rule compares agents in lower case (cleanRules, MatchesBesidesIntent, Pauses). Until now the editor's agent picker listed only the agents magpie knows. The picker now lists the agents magpie knows, then the agents /api/usage?period=30d heard from that it doesn't know, leaving out "other" and magpie. The note on those reads "heard from in the last 30 days". The usage call is made once per editor and reads the cached SummarizeTop. A name typed in the filter is read the way the gateway reads a User-Agent: the text before the first "/", space or comma, in lower case. "MyApp/2.0 (Linux)" is myapp. A typed name that is already an agent's id is that agent. The picked name shows in the chip as the others do and is saved in agents:[…]. app.js's openPicker gains field.placeholder and field.typed for this; other pickers are unchanged. zh label: 筛选,或输入 Agent 名称… (notes: User-Agent 开头的名称, 近 30 天有请求). Strings are added in en, zh, zh-TW, ja and de. No backend change. The TUI takes rules as text (agents=…), so it already accepts any name. A typed alias of a known agent (claude-cli) isn't mapped to its id in the picker. Only an exact id is. Run at |
||
|
|
d155ab1619 |
gateway: a relayed Responses item keeps the id it was added with, so Codex on Copilot shows a message once (echo_ts on Discord)
echo_ts (v0.1.1293, Codex desktop, a GPT model on GitHub Copilot): each commentary paragraph was shown twice; fine around v0.1.1280. Cause: since |
||
|
|
81a24cf8fe |
groups: a found group is listed as auto/<model id as the vendor spells it>
ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.
What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
public one). Every old form is still accepted as input forever:
provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
gateway (validateModel), keys, stats, affinity and usage, so both ids
route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
(allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
exists, found groups are listed by their old id (AutoRefsOn) and
auto/<x> means that provider's model. Documented in
docs/subsystems/gateway-routing.md.
Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).
Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.
Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
gateway, whose failures were the tests' expected ids (updated here)
and two regressions now fixed (bare ids; desktop models hiding groups
by prefix). Every failing test passes on rerun. Load average was
~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
10.19s), and it fails the same in a git-archive export of
|
||
|
|
ef655acb40 |
gateway, gui: a console shows the routing of the magpie that serves the gateway (#2606, fatcutegg)
fatcutegg's patch (fatcutegg/magpie 40ceb22df). The routing trace is held
by the process that serves the gateway. A second magpie on this computer
(`magpie web`, or the app while a launchd `magpie serve` holds the port)
showed none of it. Now its console reads the serving magpie's
GET /v1/magpie/trace (and /v1/magpie/concurrency for the lanes) over
loopback, and plays that trace as its own. The heading names which magpie
is routing ("serve (pid N) is routing").
Reviewed as a community change. A trace names accounts and emails, session
ids, a folder's last two parts and error text. It holds no prompt text and
no key. The endpoint answers local(r) alone: a request from another address
gets 403, and so does a loopback request carrying a proxy or Tailscale
header, or a LAN request while the gateway is shared, whatever key it holds.
lanGuard and corsGuard stop rebinding Hosts, Origin: null and *.localhost
first, as on every route.
Changed on top of the patch:
- A gateway key held to a budget, models or accounts is refused with
KeyHeldCode (refuseHeld), as concurrency and quotas refuse it.
- The console reads loopback alone (ownerURL). A non-loopback MAGPIE_ADDR is
never asked, and 0.0.0.0, :port, [::] and localhost are read at
127.0.0.1.
- OwnerTrace lets a hung magpie go at wait+5s (was +20s). OwnerLanes waits
700ms like ServedBy (was 2s) and is asked only when a magpie answers.
- `/` tells pid and serves to a loopback request alone. A plain `magpie`
that opens the TUI reports itself as "tui".
- Takeover: in the real two-instance run, after B took the gateway over the
hub still read "serve (pid A) is routing", from the providers state. Now
the trace carries `by` (pid, serves), and the page names the router from
it. When `by` changes, the page drops its routes and reads the new
magpie's whole trace, so route ids from two magpies never mix. The
label's full text is in its title, because the node cuts it with an
ellipsis.
- Trace's doc comment, which the patch had orphaned, is back on it. Docs
(gateway-routing.md, gui-shell.md) say all of the above. Issue
references are #2606 (were #110).
- Tests: a proxy-header subtest, TestOwnerReadOnLoopbackAlone, the trace
added to TestHeldKeyToldNoAccounts, and `by` / pid / serves asserted in
both packages' peer tests.
Run:
- Each guarantee broken by hand, and its test went red: refuseHeld removed,
ownerURL returning MAGPIE_ADDR, local(r) replaced by a RemoteAddr check,
pid/serves dropped from the answer, `by` dropped in OwnerTrace, and the
console's OwnerTrace fallback turned off.
- A real sandbox (own HOME, ports 3591-3593, fake upstream on 3564):
- A `magpie serve`, B `magpie web`. B's Routing page played A's routes
live (the long poll counted 3 requests through A).
- Probes of A's /v1/magpie/trace. 200 from plain loopback. 403 for
evil Origin, Origin: null, evil.localhost, a rebound Host with and
without Origin, x.localhost Host, X-Forwarded-For and
Tailscale-User-Login.
- A LAN-shared instance answered 403 from 10.0.0.111 even with a valid
key, and gave no pid on `/`.
- Killed A: B took over in ~11s. The hub dropped the "is routing" label,
and the next request through B showed as a fresh trace (1 request).
- Chromium and WebKit screenshots at 1280 and 390 wide, in en, zh and ja.
No horizontal scroll.
- gofmt -l clean. go vet darwin, GOOS=linux -tags nogui and GOOS=windows
pass, and all three builds pass.
- go test -timeout 45m ./... at this tree (sandbox HOME, load 250-400):
every package ok except four.
- agent, gateway and library hit 45m in TestClaudeTierPickedAsTheMainModelStays,
TestQueuedStreamKeptAliveOnceSentToItsVendor and TestWellKnownKitGrouped.
- plugin failed TestGatewayHookMixedPiPackage (#2865).
- Rerun alone with -p 1: plugin ok (464s). gateway finished in 45m with
one red, TestRequestBuildsProvidersOnce, a 900ms/1s timing window under
load. It is 8/8 green alone here and on origin/main
|
||
|
|
b9d1cd36f5 |
agent: Hermes's api_key as "${VAR}" with the key in its .env reaches magpie (PaulT on Discord)
PaulT (magpie 0.1.1291) keeps Hermes's key the way Hermes keeps keys:
providers.magpie.api_key: "${MAGPIE_API_KEY}" in config.yaml, the key in
~/.hermes/.env. Hermes expands ${VAR} and ${env:VAR} as it loads the
config (hermes_cli/config.py _ENV_REF_RE, _env_expand_match), from the
.env beside it, which load_hermes_dotenv loads over the environment.
magpie compared the literal "${MAGPIE_API_KEY}" with its key, so Check
marked Hermes as needing attention, and a sync (mergeKept) wrote the
literal key over the reference.
Now hermesKey expands the reference the way Hermes does: the .env
beside the config (main or a profile's), then this machine's
environment. Check reads that key through keyHolds, so magpie's key or a
Gateway key is not drift. A variable magpie can't see (only a shell
profile sets it) or another secret source (${vault:...}) is unknown:
not drift, and kept. A sync or pick keeps the reference
(hermesKeptKey). When it names a key the gateway doesn't take, magpie
keeps the reference and writes its key into that .env under the
variable (made 0600 when there was none). A value with more than the
one reference in it is replaced by magpie's key, as before.
Siblings not covered here: other agents whose configs take env
references in the key (Droid's "${VAR}", OpenCode's {env:VAR}) still
compare literally.
Test: TestHermesWithAKeyInItsEnvFile uses the reporter's provider block
as written: a Gateway key and magpie's own (quoted, export) in .env,
${env:VAR} from the environment, an unseen variable, a wrong key (.env
rewritten in place, other lines kept), and a composite value.
Broken by hand: with hermes.go at origin/main it fails "a gateway key in
.env is drift: Hermes's api_key (config.yaml) was changed"; with only
the sync half removed it fails "the user's reference was written over".
Run (worktree, sandbox HOME, GOCACHE pinned, macOS, load ~300):
- gofmt -l internal/agent: nothing. go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./...: ok (at
|
||
|
|
94df239265 |
gateway: answers as an Ollama server, so Copilot in Visual Studio and VS Code lists magpie's models when given the gateway as its Ollama URL (wani on Discord)
Visual Studio 2026's Copilot (Agent preview, bring your own model) takes a
custom endpoint only for OpenAI and Ollama. wani's OpenAI attempt failed
with "Session was not created with authentication info or custom
provider". That error comes from the Copilot runtime in VS: the session was
created without a GitHub token or a BYOK provider config, and nothing
reaches magpie, so magpie can't fix it.
What an Ollama client needs, read from vscode-copilot-chat's
src/extension/byok/vscode-node/ollamaProvider.ts (5863f5a):
- GET /api/version, which must be at least 0.6.4, or no model is listed;
- GET /api/tags, from which it takes each model's "model";
- POST /api/show of each. A model without "capabilities" is skipped. The
window is model_info["<general.architecture>.context_length"] ?? 32768,
and the name is general.basename;
- chat on <url>/v1/chat/completions, streamed, with an empty
"Authorization: Bearer ". magpie already serves that.
It never calls /api/chat. The Copilot SDK under Visual Studio's agent
treats Ollama as an OpenAI API at <url>/v1 too.
ollama.go serves these three routes on Handler's mux, so every guard
/v1/* has covers them too:
- lanGuard: LAN sharing, a gateway key, rebound Host, forwarded loopback;
- corsGuard: a foreign Origin, Origin null and *.localhost;
- a key held to some models: catalogFor/keyAllowed.
/api/show tells:
- capabilities: completion and tools, plus vision from Images and thinking
from Thinks;
- the window, or 32768 when magpie doesn't know it, since VS Code would
take a 0;
- general.parameter_count and magpie.embedding_length, because the ollama
CLI 0.6.8's "ollama show" read them unchecked and panicked without them.
The real CLI found this.
/api/chat and /api/generate are not served, so "ollama run" doesn't work.
Tests (internal/gateway/ollama_test.go; lan_test.go lists the routes):
- TestOllamaModelRoutes, TestOllamaRoutesHoldAKey, TestOllamaRoutesGuarded
and TestOllamaClientChats each fail with 404 without the routes.
- Broken by hand, each went red:
- tags from provider.Catalog() instead of catalogFor: HoldAKey;
- vision dropped: ModelRoutes;
- corsGuard skipping /api/: Guarded (200 for a foreign page, Origin
null and a localhost subdomain);
- an unknown window told as 0: ModelRoutes;
- parameter_count and embedding_length left out: ModelRoutes.
Real use, in a sandbox HOME with MAGPIE_NO_ACCOUNTS=1:
- a nogui build on 127.0.0.1:3561, with a custom provider on a fake
OpenAI upstream (python, 127.0.0.1:3562);
- the real ollama 0.6.8 CLI with OLLAMA_HOST at it: "ollama --version"
(server 0.12.6), "ollama list" (both models) and "ollama show" all
worked. Before the model_info fix, show panicked;
- curl replaying VS Code's sequence (version, tags, show, then a streamed
/v1/chat/completions with an empty Bearer and VS Code's body) streamed
the upstream's reply, and the upstream got its own key;
- on the same server, a foreign Origin, Origin null and a rebound Host all
got 403.
Not tried:
- Visual Studio 2026 itself (no Windows VS here);
- VS Code's Copilot itself (VS Code isn't installed);
- JetBrains' Ollama client, which likely needs /api/chat.
Run at this head (macOS):
- gofmt -l .: nothing;
- go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet
./...: clean;
- go test -timeout 45m ./... at e89d6a4f9, load ~300 to 400: 59 packages
ok. These failed:
- internal/agent, internal/gateway and internal/library ran past 45m
(#2544, #2870, #2853);
- TestClaudeAccountsSpentFallBackToCodex in gateway (#2858);
- TestSetAnswersWhileDevinAndProvidersHang in gui, at 16s against its
bound (#1375);
- TestGatewayHookMixedPiPackage in plugin, starting plugins after 742s
(#2865).
Rerun alone:
- gui's and plugin's tests: ok (gui 35s, plugin 499s);
- internal/agent ok (2580s), internal/library ok (1112s);
- internal/gateway in two halves by test name, each ok (1406s and
1030s). Whole, it timed out again at 45m while starting
TestRouteKeepsItsFolderShort, not stuck.
No GUI file changed.
|
||
|
|
c863904338 |
gateway: Command Code's Zero Data Retention refusal rests nothing and goes to another member (plugins #246)
Command Code plugin 0.1.14 sends x-cmd-zdr: 1 when its Zero Data
Retention switch is on. A model with no ZDR upstream is refused with
the Provider API's 422 (code "cmd_zdr_no_providers") or, on Go, a 400
the plugin makes with type "cmd_zdr_no_providers". The refusal is about
that request's setting, not the model or the account.
Before, on the plugin path (moved commandcode-plan):
- Go's 400 was rewritten with type invalid_request_error, read as the
model unserved (unservedWords), rested commandcode-plan@<acct>/<model>
for a minute, and the account's second key was asked the same thing.
- The 422 went to the agent as api_error, and in a group the next
member was never asked.
- Raw bodies (restAfter, a decision group's decideFailed) read as
modelRefused too.
Now:
- zdrRefused (fallback.go) matches only that code as the error's type
or code, on 400/422. modelRefused and tooLongUnsaid leave it out.
- keepRetry notes it from the vendor's raw body (X-Magpie-ZDR-Refused)
since the Anthropic error shape keeps no code; pass/keepAlive strip
the note.
- The candidate loop skips the provider's mates at the same model
(notMates, they'd be sent the same header), tries the next member,
rests nobody, and returns the refusal alone.
- restAfterMarked and decideFailed rest nothing for it.
- docs/subsystems/gateway-routing.md says so.
Tests (internal/gateway/plugin_zdr_test.go), with the literal bodies
from plugins' zdr.test.mjs:
- TestCommandCodeZDRRefusalRestsNothing (422 and 400, plugin path,
two accounts): alone the agent gets Command Code's words and one
account is asked; group G answers from b over chat and over
/v1/messages; nothing rests; switch off, Command Code answers first.
- TestZDRRefusalIsCommandCodesCodeOnly: the same words without the
code, OpenAI model_not_found, unsupported_api_for_model and the code
named in a message still read as model refusals.
- TestZDRRefusalNeverRests: restAfter with the raw 422/400 and the
noted Anthropic body rests nothing; without the note it rests.
Broken by hand:
- old sources (zdrRefused stubbed false): e2e red in both subtests
("group: 422 ... (commandcode 1, b 0)", "alone: 400 ... (asked 2)"),
classifier table red.
- restAfter guard removed: TestZDRRefusalNeverRests red ("422 ...
rests: {Why:other Status:422 ...").
- loop branch removed: e2e red. keepRetry note removed: e2e red.
Run at this head: gofmt -l (clean); go vet ./...,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... (clean);
go test -timeout 45m ./... (go1.26.8, load avg ~300 from other
sessions): every package ok except
- internal/agent, internal/gateway, internal/library: past -timeout
45m (TestClaudeTiers, TestMessageReasoningRefused,
TestProjectServersQoderCodeBuddyDroid running), as #2869;
- internal/gui TestSetAnswersWhileDevinAndProvidersHang (13.8s), #1375;
- internal/plugin TestGatewayHookMixedPiPackage, #2865.
After rebasing on
|
||
|
|
d5bc9f0009 |
gateway: a plain 403 never rests an account until its window, and two accounts' alike 403 on one request rest neither (plugins#243)
zygs1083-dotcom on plugins#243: Factory answered 403 to a Claude Code 2.1.292 request (a changed instructions wrapper factory 0.1.33 didn't adapt), and the accounts went into cooldown. On |
||
|
|
f73378365f |
gui: a filter a click set on Usage's Requests goes when they are left (TJHHHH on Discord)
TJHHHH: after a jump to Codex's requests on the Usage page, every later
visit listed only Codex's. The Requests' filters are module state in
plugins/usage/page.js and nothing ever reset them, so a click on Codex in
the ranking split by agent stuck for the app's lifetime.
Now a filter a click lent the Requests (a ranking click on an agent,
provider, model or gateway key, a chart day, the address's ?agent= and
the like, a route from Routing) is remembered in ledLent and given back
by ledLeave when the reader leaves the Requests: for another Usage tab
(renderUsageTab), or another page through a new page hook, `leave`, that
show() calls on the page it leaves. A filter picked in its own menu or
typed in the search stays, as a menu choice does in a Mac app. A route's
saved filters keep their lent marks, and leaving with a route on gives
back the route too. Docs: plugin-runtime.md's Usage hooks.
Siblings judged and left: the tray panel's Usage tab ranking (its own
view, not the page's Requests), the Sessions reveal (per agent, no "all"), the KPI
failed/retried jumps (shown in the status segment, read as own picks).
Test: tests/usage-ledger-leave.test.cjs, chromium and webkit, en zh
zh-TW ja de: ranking click leaves for a page and for a tab, menu pick
stays, ?agent= goes, a route goes. On the old app.js/page.js/client.js
it is red, 20 of 25 in chromium ("back from another page: last asked
period=today&agent=codex"); only the menu-pick case passes there.
Green with the fix, in both engines.
Run at
|
||
|
|
197849ad4d |
gateway: image generation's timeout is a setting, 1 to 60 minutes
neighbads on X: a slow image endpoint needed more than the fixed 5 minutes. Settings > Images > Image generation timeout (imageTimeout in settings.json, 5 when unset, 1 to 60 accepted, anything else a 400) now gives every drawing that long, on each route it takes: - drawTimeout() reads the setting; drawWithin marks the context as a drawing and sets its deadline. Error texts say the time it was given (givenTo), ModelScope's task polling too. - A marked drawing goes through a vendor transport with no ResponseHeaderTimeout (drawsApart), since an images API sends its headers only once it has drawn; everything else keeps the 10-minute upstreamHeaderWait, so a 30-minute setting isn't cut at 10. - An image answered as a link is downloaded within the same time (imageLongest, never under ImageLongest). - Videos keep 5 minutes per call (videoTimeout): a video is made between its calls, so the setting isn't theirs. - magpie mcp image waits on a call up to callLongest (2h1m, past the 60-minute bound twice over), since it may not read the settings (WSL); ToolTimeout, which agent configs carry, is unchanged. - The plugin path: Bun 1.4.2's fetch has no 5-minute cap (tried against a server answering after 330s), so nothing changes there. - api.go keeps the saved value when a page doesn't send imageTimeout; prefsKeep carries it on every other Settings save. GUI: a segmented row under Image generation (5, 10, 15, 30, 60 min; a value set by hand gets its own segment), in en, zh, zh-TW, ja and de. Three GUI tests clicked controls the new row pushed under the window's foot or past the viewport; they now wheel to them with reader.cjs's reach (disabled-models, search-api, refusal-retries-setting). searcher-pick checks the help has no title before reach's pointer passes over it (the app's mouseover sets one on cut-short text). Run, at |
||
|
|
b10788745a |
agent: Claude Desktop on magpie keeps the language picked signed in with Anthropic (memory, Osal on Discord)
Desktop's 3p mode runs in a userData of its own, Claude-3p, whose
config.json (Desktop's settings, not claude_desktop_config.json) starts
with no "locale", so after magpie turned 3p on Desktop came up in the
system's language. magpie never wrote Claude-3p/config.json before this
commit: it writes only claude_desktop_config.json (deploymentMode, merged
key by key) and configLibrary's _meta.json and its own profile. So the
hand-set locale that reporters saw lost on restart was not written over by
magpie; Desktop 2.7032's own main process sets "locale" back to en-US when
its UI asks for one with no bundled catalog (pit in its index chunk), and
resets an unparsable config.json to {}. Which of those hit them is not
known.
Turning Desktop onto magpie now copies the one key "locale" from the
signed-in userData's config.json (Claude, %APPDATA%\Claude on Windows,
the first set's before the others for an MSIX install) into
Claude-3p/config.json, only when that file is missing or a JSON object
with no locale, and only a name Desktop takes for a catalog
(^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$, as Desktop's lit). A locale already in
Claude-3p is never written over, no other key there is written, and an
unreadable or non-object file is left alone without stopping the
takeover. Off removes the file only when magpie made it and it still
holds nothing but the carried language. The key name "locale" was read
from /Applications/Claude.app 2.7032's bundle (Fo.get("locale") on its
config.json store).
Tests: TestClaudeDesktopCarriesTheLanguage, TestClaudeDesktopKeepsThe3pLanguage,
TestClaudeDesktopUserEditsThenReapply, TestClaudeDesktopLanguageOddValues.
Broken by hand, each went red: no carry (Carries red), overwrite an
existing 3p locale (Keeps3p and UserEdits red), no removal on off
(Carries red), no name check (OddValues red). UserEdits passes on the
old code too: it guards that magpie never writes the user's file.
Run at
|
||
|
|
8febe3a50c |
provider: a pick a plugin's list leaves for a while comes back when it is listed again (多喝热水 on Discord)
多喝热水 picked models of the Our Free Model plugin
(mu-zi-lee/magpie-our-free-model) and had to pick them again after every
magpie update. A minute after magpie starts, and hourly, KeepPluginsListed
reads every plugin's models again and dropGonePicks deleted for good each
pick the list didn't have. OFM, started again with magpie, lists its free
pools at once and its account channels' models ("qoder/...", "kiro/...")
only once it has read them, so the first list was short and the channel
picks were lost. A relay's Fetch models or RefreshEvery list that left a
model out once did the same.
Now a pick the list leaves out moves to Delisted (providers.json
"delisted"): not served while it isn't listed, put back in Models when a
list has it again (relistPicks), for plugins and fetched lists alike.
After a list left picks out, the loop asks again in 5 minutes
(relistSoon), not an hour. A provider whose every pick is set aside serves
none of its models (waitsForPicks), not the whole list. Editor saves keep
Delisted (delistedWith, withPicks, the account whitelist); Select none or
the vendor's list picked clears it. While picks are set aside, new picks
saved keep the earlier PickedFrom too, so a model seen and left unpicked
isn't served as new when the list has it again; a list short of no pick is
taken as it is, as TestClaudePicksOfEveryModelTakeOnesListedSince wants.
New tests: TestPluginPicksComeBackWithTheirList (through the real
KeepPluginsListed loop), TestEveryPickDelistedServesNone,
TestRelayPicksComeBackWithTheirList (through Refetch on an httptest
/v1/models). Broken by hand, each red: relistPicks returning false (the
old behaviour: picks not restored), relistSoon as relistEvery ("wasn't
asked for again soon"), waitsForPicks removed (pool-a served with every
pick set aside), the PickedFrom union off (kiro/claude-z served).
The plugin side, for its author: OFM's managed runner answers `models`
before its channels and first model refresh are read; awaiting them (with
a timeout) or answering fallback(previous) with the magpie.fellBack marker
would keep magpie's last good list. OFM itself was not run here (its
install scripts weren't run, by instruction).
Run at base
|
||
|
|
9fd80b2128 |
library: skills install from any git repository, GitLab and a company's own among them (sunset on Discord)
ProbeSkills took only a GitHub source or a folder. It now also takes any
git repository's address: https/http on gitlab.com or a self-hosted
server (any depth of groups), a GitLab or Gitea page of a folder
(/-/tree/<ref>/<path>, /-/blob/..., /src/branch/...), ssh://,
git@host:group/repo.git, a bare host.name/group/repo, and file://.
Such a source is kind "git" (gitSource, skillgit.go).
It is fetched with the user's own git (proc.FindTool), so their
credential helpers and SSH keys reach an intranet host: git init, then
fetch --depth 1 --no-tags -- <url> <ref|HEAD>, checkout FETCH_HEAD into
a magpie-skill-* folder, .git removed; the same keepProbe/maxFetch path
GitHub's tarball takes.
What the user typed is data: an address starting with - and any
transport:: address (ext::, fd::, file::) are refused before git runs;
the address follows --; git runs with protocol.ext.allow=never and
core.symlinks=false, no shell, GIT_TERMINAL_PROMPT=0, and ssh -o
BatchMode=yes unless the user set their own SSH command (GIT_SSH,
GIT_SSH_COMMAND, core.sshCommand), so a sign-in it can't make fails
instead of waiting. An address with a password or token in it is
refused: library.json is shown and backed up. Git missing, a sign-in
refused, an unknown host key, a missing branch and an unreachable host
each say so plainly (gitError).
Updates: Commit keeps the repository head the skill was fetched at. A
check runs git ls-remote; another head is fetched (once per repository
and ref) and the skill's folder hashed, so a commit elsewhere in the
repository leaves it current and moves Commit on. UpdateSkill and the
edited-skill refusal work as for GitHub; EditedError and the page's
Changed here / Update / replace question name the repository instead of
GitHub. findNew, Group again, icons and the market stay GitHub's only
(documented).
Page, TUI and docs: the add box's placeholder in en/zh/zh-TW/ja/de
(zh: owner/repo、GitHub 或 GitLab 链接、任意 git 仓库地址,或本机上的文件夹),
a git skill's source shown as a link (https) or text (SSH), its own
Update and Check for updates; the TUI's prompt; library.md's Skills and
Skill updates rows. GIT_SSH/GIT_SSH_COMMAND are listed in agentenv's
notAnAgent (TestFolderVarsAreListed).
Tests (fail on the old code: gitSource/gitPath don't exist there, and
skill-git-source.test.cjs fails on the old assets' placeholder, checked
by stashing client.js/i18n.js): TestGitSourceReads,
TestInstallFromGitRepo (a local bare repo over file://: probe, install,
check finds an update, update, a commit elsewhere stays current, an
edit here is refused naming the repo), TestGitTreeURLInstallsFolder,
TestGitMissingSaysSo, TestGitSignInRefusedSaysSo (a local httptest 401,
GIT_CONFIG_NOSYSTEM so no Keychain), TestGitRefusesOptionsAndTransports,
TestGitErrorsSaid. No test reaches the network.
Run (worktree at origin/main
|
||
|
|
eb3f174289 |
agent: Claude Code's auto mode classifier model is set on its Agents row (Linka on Discord)
Claude Code 2.1.302 reads CLAUDE_CODE_AUTO_MODE_MODEL for the model its client-side auto mode classifier checks each action with. It doesn't change server-side auto mode, and a classifier model Anthropic sets for the account comes first. The installed 2.1.303 binary has the variable: unset, Claude Code picks the sonnet tier's model, else Sonnet. It refuses claude-sonnet-5-5, claude-opus-5-5 and claude-opus-5 with a warning and uses its own pick instead. - Claude Code gets an "auto mode" field (key auto_mode, Quiet, follows nothing). It can be set only while Claude Code is routed through magpie, only to one of magpie's models, and is written dashed like the other model keys. Its options leave out the three models Claude Code refuses, and Set refuses them too. - A value the user had before magpie routed Claude Code is stashed with their tiers (claudeOwnEnv). It is taken out while wired in and comes back on Disconnect or Claude Code's own model, unless they have set one again since. The restore loop now skips any claudeOwnEnv key the user wrote again. - magpie's own value goes when magpie steps out. A value the user sets while wired in is never touched. - GUI: an "Auto mode" line in the opened row's Tiers, after Subagents, using the app's model picker. Default is noted as Claude Code's own pick. Strings are translated for zh, zh-TW, ja and de. - Docs: agent-wiring.md and reference.md. Run, in a worktree at origin/main |
||
|
|
f76201a84a |
plugins: a sign-in page the plugin's CLI opened isn't opened again, Grok's opened twice on macOS (andyfmyth on X)
"magpie里的grok 登录验证 在mac下 似乎每次都会弹两次验证, 在浏览器窗口里". Grok's plugin signs in through `grok login --device-auth`, and Grok Build (1.0.50, the webbrowser crate) opens the device page itself, through NSWorkspace on macOS and ShellExecuteW on Windows. Neither reads $BROWSER; the macOS binary has no "BROWSER" string. magpie then opened the same URL from /api/plugin-signin (desktop), startPluginSignIn/followSignIn (a browser tab) or `magpie plugin login`. Reproduced in a sandbox HOME/GROK_HOME: grok's device-code tab appeared in Chrome with magpie not involved, with and without SSH_CONNECTION. Built-in grok is retired ( |
||
|
|
94919109cb |
gateway: a silent HTTP/2 connection to a vendor is pinged and dropped (#2843)
pinewhite (#2843, v0.1.1279, Linux): for ~30 minutes every request to
group/auto-deepseek-v4-1-flash hung with no first byte. The WorkBuddy
member was resting on a 429, so they all went to ClinePass, and usage
shows only 499s with in=0. A restart answered the same request in 1.6s.
Cause: the gateway's transport (upstreamTransport) speaks HTTP/2 to
any vendor that offers it, so every request to api.cline.bot shares one
connection. It had no HTTP/2 health check. A connection that goes silent
without closing (a local proxy whose own way out died, or a NAT that
forgot the flow) stays in the pool. Every new request is multiplexed
onto it and waits for the 10-minute ResponseHeaderTimeout while the
kernel takes the writes. The agent gives up first, so nothing fails over
and nothing rests the member. Restarting dropped the connection.
Fix: netproxy.HTTP2Health() (SendPingTimeout 20s, PingTimeout 10s) on
upstreamTransport. Go now pings a connection that has had no frame for
20s and closes it when no answer comes within 10s. The requests on it
fail as a 502 ("http2: client connection lost"), so a group moves on,
and the next request dials a new connection. A live vendor answers a
ping whatever its streams are doing, so a long wait for a first byte is
not cut. The same setting goes on http.DefaultTransport in
netproxy.Install, the sibling pool that usage cards, catalogs and
sign-ins use. Not covered: requests a plugin sends from Bun.
Tests (new):
- TestSilentHTTP2ConnectionIsDropped: an HTTP/2 TLS httptest vendor
behind a TCP relay that can go silent on its open connections (it
takes writes, passes nothing). After the relay goes silent, a request
must end well inside 10s, and the next one must succeed on a second
connection.
- TestGroupMovesOnFromSilentHTTP2Connection: the same through the real
Handler, with an ordered group a/m then b/m. Once a's connection is
silent, the request must get b's reply.
- TestInstallChecksHTTP2Connections (netproxy).
What was run (worktree on origin/main
|
||
|
|
38f6bee23e |
sessions: the manage page reads its agents' files once, and only the agents it shows (#2776)
GET /api/sessions/manage went over every agent's session files three
times: sessions.Agents() for the counts, sessions.List(All) only to build
the set that keeps a gateway session its agent keeps too from being
counted twice, and sessions.ListAgent for the list. List(All) also read
every agent's changed files again and put every session together, prices
and titles included, to take its id. So a page showing Claude Code's
sessions parsed Hermes's and Codex's writes too.
sessions.Manage now does it in one pass over the files, under one hold
of the locks: the counts, the ids of the sessions of the agents that have
gateway sessions (nativeIDs: the id from the file's key, or from its
parse for the agents that write it inside the file, idInFile, which are
the only ones read), then the picked agent's list. The handler's pick
runs as a callback so the counts can include the gateway sessions. A
change to an agent not shown and with no gateway sessions waits for a
page that shows it. assemble's id rule moved into sessionID, which both
use.
That set was also wrong in two ways. List leaves out a session nothing
was said in and stops at 5000 (All), while the list beside it keeps
every one, so a gateway session whose agent's file was empty (or among
the oldest of more than 5000) was counted twice and listed once. The
set is now every native session, the same as the list's, and
POST /api/sessions/delete, which tells a listed gateway session from a
native one, uses it too (sessions.NativeIDs).
docs/subsystems/gateway-sessions.md says so.
Tests:
- TestManageReadsOnlyTheAgentsItShows: Codex's files changed, Claude
Code's page parses none of them; asked for Codex's ids it reads them;
the native ids equal the list's, the empty session included. Red with
Manage reading every file as List(All) did ("read 2 of them").
- TestManageCountsAGatewaySessionTheAgentKeepsOnce: a gateway session
whose Claude Code file has nothing said in it is counted once. Red on
the old handler: "one session listed, counted [{claude 2}]".
Measured on the synthetic sandbox HOME (3000 Claude Code, 1500 Codex,
2000 Hermes sessions; no gateway sessions), CPU time of the request
(load average ~250 from other sessions, so wall times are noisy), the
parent bbee24810 against this change, the same run of each:
first manage?agent=claude after a restart 2164 -> 627 ms CPU
(15697 -> 10554 ms wall)
warm manage?agent=claude 173-222 ms -> 64-88 ms CPU
warm manage?agent=hermes 176-243 ms -> 56-70 ms CPU
warm manage?agent=codex 237-269 ms -> 155-162 ms CPU (after its
first, which reads Codex's model/effort)
Run: go test ./internal/sessions -count=1, go test ./internal/gui -count=1;
gofmt -l clean; go vet. Full suite and cross-OS vet are recorded on the
last commit of this series.
|
||
|
|
ec7f474323 |
gateway: Codex on Copilot is relayed with its web_search, and a translated call's arguments stream (echo_ts)
echo_ts (magpie 0.1.1279, macOS): Codex on a GitHub Copilot subscription
through magpie was about 10x slower than Copilot directly. Two causes,
both in the gateway:
- Codex offers web_search on every turn, and magpie counted Copilot as a
provider that can't search, so every Codex turn on Copilot was
translated for magpie's search instead of relayed.
- On that translated path responsesDecoder held a call's argument deltas
until the call was done, so Codex saw nothing while the model wrote a
command or a patch, then all of it at once. A custom tool (apply_patch)
got no custom_tool_call_input deltas at all.
Fixes:
- search.go: searchesItself counts a Copilot account on Responses. Real
check on 2026-10-17 with the owner's account: gpt-5.3-codex,
gpt-5.4-mini, gpt-6-luna, grok-4.7 and mai-code-1.1-flash each answered
a request offering web_search with web_search_call items and cited
pages. searchRank never picks Copilot to search for another provider's
models (its premium requests).
- gateway.go: a Copilot Responses request whose tools mark an argument
"encrypted" (MultiAgentV2's spawn_agent message) is still translated,
marks left out (asksSealing in responses.go). Checked on the real
account: relayed, Copilot seals the message ("UlQC...", no
encrypted_function_args), and the subagent's turn carrying it came back
"Encrypted function output content could not be decrypted or
decoded". This was already broken for a Copilot turn without
web_search; it is fixed for that too. An unsealed agent_message relayed
with web_search answers normally (checked).
- responses.go: responsesDecoder gives argument deltas as they come. It
holds only the deltas that make the arguments whole JSON, until the
done events, so #613's case (deltas that disagree with done) still
ends with the fuller arguments. The encoder sends a custom tool's input
as custom_tool_call_input.delta, read out of the {"input": ...}
arguments as they stream (customStream in custom_tool.go, which waits
for cut escapes, surrogate pairs and UTF-8), and closes it with
custom_tool_call_input.done.
- docs/subsystems/gateway-routing.md says the above.
Not changed: the HTTP/2 connection. Head-of-line blocking from large
uploads on the one connection to Copilot was measured on the real
account with a Go client: a 4MB request and a small one 300ms later,
5 rounds x 2, same connection vs a new one. The small request's first
byte took 0.93-1.68s on the shared connection, 1.26-4.77s on its own
(handshake included), 0.66-1.08s alone. No sign of blocking.
Small requests slower while a long session runs (echo_ts, 42.8s vs
17-29s first text, xhigh): nothing in magpie serializes Copilot requests
by default (lanes need MaxConcurrency, the RPM gate MaxRPM; Go's h2
windows are 1GB per connection, 4MB per stream). Measured: small
requests beside a 412s xhigh stream (16,617 output tokens) were as fast
as idle, via magpie 0.8-1.1s first text, direct 1.3-2.0s, sent_ms
1-10ms. One global lock found: copilotMu is held across the token
refresh's HTTP call, which stalls every Copilot request only around a
refresh, filed as #2762, not changed here. usage.jsonl's own_ms,
queued_ms and sent_ms against ttft_ms tell magpie's time from Copilot's.
Tests:
- TestCallArgsStreamWhenTranslated (function and custom), through the
real handler with an upstream that holds the rest of the call until
the client has the first delta.
- TestResponsesCallArgsStream, TestCustomInputStreams (pieces of 1, 2, 3,
5, 7 bytes and whole).
- TestCopilotRelayedUnlessAskedToSeal; TestCopilotUltraSubagentWithWebSearch
now expects the subagent relayed with the search.
Broken by hand at this tree, each went red:
- decoder holding every delta: TestCallArgsStreamWhenTranslated,
TestResponsesCallArgsStream;
- no custom input delta: TestCallArgsStreamWhenTranslated/custom;
- Copilot out of searchesItself: TestCopilotRelayedUnlessAskedToSeal,
TestCopilotUltraSubagentWithWebSearch;
- the asksSealing check off: the same two.
Real use: a built magpie serve in a sandbox HOME (port 3461) with the
owner's Copilot account, Codex-shaped requests offering exec_command,
apply_patch and web_search to copilot/gpt-5.3-codex:
- unmarked: relayed (Copilot's own response ids), apply_patch gave 93
custom_tool_call_input deltas from 3.55s to 11.69s;
- with a sealed spawn_agent: translated, apply_patch 117 deltas from
1.45s to 11.73s, exec_command 92 function_call_arguments deltas from
1.55s to 8.16s.
Not tried with the Codex binary itself.
Run at
|
||
|
|
ae7dc10ae2 |
docker: the image is Debian 12 slim, so the Cursor and Devin CLIs magpie installs at sign-in run in it (#2834, bborn2)
magpie installs a subscription's CLI at sign-in with its vendor's `curl … | bash` (internal/provider/install.go: Cursor, Devin, Grok Build). The distroless image had no curl and no /usr/bin/env (the installers' shebang), so that install couldn't run there, and only Grok Build had a native fallback. bborn2 reported that a Cursor CLI installed by hand failed with "cannot execute: required file not found". The image is now debian:12-slim with ca-certificates and curl. It keeps the nonroot user at uid/gid 65532, HOME and XDG under /config, the healthcheck, and magpie on PATH. Size: 157MB against 82MB for origin/main's image, both built here on arm64. Running a feature magpie offers is worth the 75MB. Changed in review: dropped the branch's GOPROXY build arg, a separate goal. The comments in install.go and install_test.go that said the image has no curl now say "had". docs/reference.md and the site's Docker page (en, zh, ja) say Debian with bash and curl instead of distroless with busybox. Run, with OrbStack's docker: - docker build of this tree and of d783df46c's Dockerfile: 157MB vs 82MB. - docker run of the new image: health "healthy", user nonroot (id 65532). `curl https://cursor.com/install -fsS | bash` exit 0, then `~/.local/bin/cursor-agent --version` printed 2026.10.16-e3cb207. Devin's install.sh installed devin v3000.11.92 (its trailing `devin setup` said "Login canceled" with no terminal, as on any host). `devin --version` printed 3000.11.92. bash and `magpie version` run. - Old image: `which curl` finds none, and /usr/bin/env doesn't exist. - A volume written by the old image (file owned 65532) was read and written by the new image. - gofmt -l clean; go vet darwin, linux (nogui) and windows clean. - Full `go test -tags nogui -timeout 45m ./...`: every package ok except internal/agent and internal/gateway, which timed out at 45m mid-test (TestConnectSaysHow, TestLargeRequestEndpoints) under a load average of about 200 from parallel suites. This commit changes no code those packages build, only comments in internal/provider, which passed (992s), so they weren't rerun. Not tried: a Grok Build install inside the image, and a full in-magpie Cursor/Devin sign-in with a real account in the container. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
07ecdda10f | gui: Settings > Privacy turns the local model on, and says where it runs (#1977) | ||
|
|
d783df46cb |
plugin: a plugin's page adds items to a provider's and an agent's row menu (P6)
package.json's magpie.actions: [{id, menu, title, titles}] puts items in
the row menus magpie draws, after its own: a provider row's (right-click)
and an agent row's (its handle, or right-click). Picking one opens the
plugin's page and posts it {event: "action", data: {id, provider|agent:
{id, name}}}, nothing else of the row; the bridge's magpie.onAction(fn)
gets it, and an action picked before fn was given waits for it.
- plugin.Window reads them (page.go): menu one of ActionMenus (provider,
agent; a session's menu is left out, its title is user content), id
^[a-z0-9][a-z0-9-]{0,39}$, an id given twice is the first's, 8 at most,
none for a plugin with no page.
- /api/plugin-pages carries them on the page; a missing title is the
page's, in each language (pluginpage.go).
- pluginpages.js: magpie.actions(menu, context) gives the row menu's
items; openRowMenu draws a plugin's name as written (literal), not
through t().
- The Plugins page says which menus a plugin adds to (actionsLine),
translated in zh, zh-TW, ja and de.
- Docs: plugin-runtime.md's P6 section and verification; the site's
plugin docs (en, zh, ja) gain "Items in magpie's menus".
- The core's budget (TestCoreScriptBudget) is not raised (#2710): with
P6 the core came to 1,447,648 bytes, 648 over. pluginpages.js's header
now says P5's and P6's part in one paragraph and points to
plugin-runtime.md, which says it in full, and plugins.js's panels and
actions lines share whereLine: 1,446,845, 155 under.
Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
built-ins-on commit since dropped for main's own
|
||
|
|
b9f790d37b |
plugins: panels in magpie's pages, a page that replaces a built-in one, titles in the window's language, and a look that matches
P5 of the plugin runtime (docs/subsystems/plugin-runtime.md):
- Panels (magpie.panels): a plugin draws a frame into a slot of a
built-in page (a provider's editor, Settings, Usage); magpie.context
says where it is, and the frame is as tall as what it draws.
- A page can replace a built-in one (magpie.page.replaces); show() opens
it in that page's place, and the sidebar row goes to it.
- page.titles and a panel's titles name it in the window's language
({"zh": …}); a malformed map is dropped, the title kept
(TestWindowTitles).
- main's #2501 already names wails:// in the policy of a page in the
desktop window (through ownWindow), which is why the usage page drew as
bare HTML from v0.1.1259. TestPluginPageLoadsItsFilesInTheWindow loads
a page through ownWindow in a real WKWebView, which Playwright on http
can't; the subsystem page says how.
- The bridge adds magpie's look for what a page leaves unstyled, every
rule in :where() so any rule of the page's wins, and the theme's
colours as --magpie-* variables.
One commit: the panels, the replacing pages and the titles share hunks
in page.go, pluginpage.go, pluginpages.js and the docs, and couldn't be
split cleanly.
Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
built-ins-on commit since dropped for main's own
|
||
|
|
5380114da1 |
LESSONS: 10-17: runs recorded at another tree, "under load" reds left unowned, a body scan on every passing reply
Folds the review of 10-17 04:00 to 10-18 04:00 (77 commits, v0.1.1277 to v0.1.1283) into LESSONS.md, and moves two lessons seen a third day into docs/code-standards.md: - magpie's default never overrides a value the user set (10-05, 10-10, 10-17: 5a2414acd's Essentials to All, #2749), a row under "What a change contains"; - a checkout, worktree or log belongs to the session that made it (10-09, 10-12, 10-17: 7660399a1's worktree checked out by another session, 17557132c's log deleted), under Commits. New lessons, each seen once: - a named sibling left alone gets an issue ( |
||
|
|
b14784c03f |
gateway: a fallback too small for the request is asked once every account with room is out of its allowance (Kai on Discord)
Kai on Discord (0.1.1278): Claude Code to claude/claude-opus-5-5, the
Claude provider's two subscription accounts (Max, Pro) both at their
limit ("resets 5:58am", "resets Oct 18 at 3pm"), its Fallback
codex/gpt-6.1-sol. Routing said the second account's 429 had nobody left
to try, and Claude Code had the 429. The fallback was never in the
route's order.
Cause: roomy (
|
||
|
|
e44b9aef33 |
middleware: onProvider changes what one provider a request is tried on is sent
A JS gateway middleware can export onProvider(body, ctx). The gateway
calls it on each try, just before the body goes to that provider, with
ctx.provider = {id, name, account, model}: account is the subscription's
kind (claude, antigravity, …), absent for a key. Every try starts again
from the body onRequest left, so a change for one provider never reaches
another in a routing group. null and ctx.reject turn nothing away there.
A hook that throws or runs past 250ms leaves the try's body as it was.
A plugin could act only before routing until now, by the model name the
agent asked for. Claude Desktop asks for opaque aliases, so a plugin
couldn't tell which vendor a request was going to. The first user is
@magpie-community/middleware-antigravity-cloak: it changes only what an
Antigravity account is sent, so that Antigravity stops refusing Claude
Code's system prompt (xzplzpl on X). magpie itself still sends every
prompt as the agent wrote it.
- gwmw.To and gwmw.Tried; middleware.Run.Tried runs the hooks.
- serveAgent puts the runs on the request's context, and serve's
candidate loop calls triedOn before the Antigravity foresight, so it
judges the body that will be sent.
- Docs: gateway-middleware.md, reference.md, integrating.md, and the
hooks table and community list in site docs plugins.html (en, zh, ja).
Run:
- go test ./... -timeout 45m in a sandbox HOME (macOS, at
|
||
|
|
de671719a0 |
provider: a retired built-in's failed move is tried again in 10 minutes, not 6 hours
A failed move waited moveRetry (6h) before KeepRetiringMoved tried it again. That was fine while the built-in carried on serving the accounts. A retired built-in serves nothing, so a move that failed for a moment (npm out of reach, or the plugin listed in plugins.json but not installed yet, which the real-account run on 85b8f6d4d hit with Command Code: the first Move failed, the second worked) left the user's subscription unserved for up to 6 hours unless they pressed Move. - retryWait(id) is retiredRetry (10 minutes) for a retired built-in, and moveRetry otherwise. MoveRetiring and HandOver both use it (retryDue). - KeepRetiringMoved's next run is brought forward to when a retired built-in's failed move is due (nextRetiringRun, at least a minute), instead of always an hour. - docs/subsystems/provider-plugins.md says so. TestMoveCutShort now also checks: - a failed move 11 minutes old waits while the built-in serves it, and the next run is an hour; - once retired, the next run is 10 minutes, it isn't tried at once, and it is moved after retiredRetry. Broken by hand, each red: - retryWait returning moveRetry for a retired built-in: "a retired built-in after retiredRetry: map[]" - nextRetiringRun always an hour: "the next run after a retired built-in's failed move: 1h0m0s, not 10m0s" Run: go test -tags nogui ./internal/provider -run TestMoveCutShort: ok. What was run for the stack, at load ~300 (it was rebased from |
||
|
|
bd30b068d3 |
docs: every deprecated built-in is retired; AGENTS.md and gateway-routing say so
AGENTS.md: the table's subscriptions are retired, not moving; the plugin does everything, the built-ins' code is gone but for what the movers read; the "fix the built-in too" step is gone; the parity tests hold each plugin to what its built-in did. gateway-routing.md: no bridges to a vendor's own API are left, so the structured-output, tool-image and billing-line lists lose Cursor, Kiro, Qoder, Devin and Command Code; Kiro's image ordering is its plugin's. Run: docs only; the full suite runs at the stack's head. |
||
|
|
be62bcf79e |
provider: Command Code's built-in is retired; its plugin serves it
commandcode-plan joins retiredBuiltins (migrate.go): PluginServes is true
for it moved or not, and @magpie-community/opencode-commandcode-auth does
its sign-in, models, requests and usage.
Removed
- Sign-in: the StartSignIn case (startCommandCodeSignIn, the Studio
callback, cmdOrigins, cmdWhoamiWait, commandCodeCallback/Keep) and the
pasted-key branch (commandCodeKey, cmdSignedIn).
- Accounts: commandCodeAccount, cmdProvider, cmdSide, cmdLoginList,
switch/on/forget (switchCommandCodeLogin, setCommandCodeLoginOn,
forgetCommandCodeLogin, commandCodeAlsoOn), the Logins case, and the
per-login usage (cmdLoginQuota, cmdQuota, the perLogin fetch). The
Logins("") list keeps {CommandCodePlanID, nil} so its order holds.
- The Go plan's path: CommandCodeGenerate, cmdGoModels/cmdGoFetch/
cmdGoRefused, cmdModels, cmdFree/cmdMarkFree, cmdPlansSeen's built-in
users (cmdRemember, cmdPlanKnown, cmdPlanNow), CommandCodeOutputOf, and
the account's generate field.
- asksOwnBackend's Command Code case.
- Gateway: the cmdGenerate/serveCommandCode dispatch and countOn's
cmdGoing clause; internal/gateway/commandcode.go (the /alpha/generate
translator) deleted.
- Built-in-only tests: gateway commandcode_test.go and
commandcode_place_test.go, TestBillingLineLeftOutOnCommandCode;
provider commandcode_go_test.go, commandcode_go_models_test.go,
commandcode_free_test.go, TestCommandCodePlan,
TestCommandCodeSignInWhoamiDown, TestCommandCodeSignInAgainToRemovedOwn,
TestCommandCodeSignInPastedKey.
- Docs: Command Code out of gateway-routing.md's bridge lists (the
2xx check, structured output, tool images, the billing line).
Kept, and why
- The mover and what it reads: cmdAuth, cmdOwn, cmdWho, cmdLogin,
cmdSaved, cmdLogins (migrate_side.go, plugin_accounts.go).
- cmdAPI/cmdStudio (plugin_usage.go's moved card), cmdKeysURL
(pluginsignin_paste.go), the plan and credit readers (cmdPlans,
cmdPlanOf, cmdPlanName, cmdWindows, cmdLeft, cmdQuotaOf, cmdTime,
cmdSubscription, cmdKeyWindows, cmdKeyPlanID): the keyed preset
"commandcode", planquota.go, balance.go and qoder_usage.go use them.
- CommandCodeMaxOutput (models.go caps the plugin's "commandcode-plan"
models with it), estimatedMoved, chat.go's plugin host cases, the
gateway parity tests, and the PLUGIN-SERVED notice in
commandcode_plan.go, now in the retired wording.
Tests whose meaning changed
- TestLoopbackSignInsTakePastedAddress no longer starts Command Code's
built-in sign-in; the plugin's (TestLoopbackPorts) says its key is
posted, never pasted as an address.
- The Go plan's free-model marks (TestCommandCodeFreeModels) were the
built-in's alone; the keyed preset never marked them.
Run (worktree magpie-wt-rt-a, on top of 9a64c4025)
- gofmt -l internal: clean
- go vet -tags nogui ./... (darwin, GOOS=linux, GOOS=windows): clean
- staticcheck U1000 on ./internal/...: no declaration unused that wasn't
unused at HEAD
- go test -tags nogui -count=1 ./internal/provider/ -run
'CommandCode|commandcode|Migrat|Move|Moved|Retir|SignIn|AsksOwnBackend|
SideLogin|Logins|Unmoved|Paste|Loopback|Account|PlanQuota|Balance|
FetchNew|FetchingNew|LeftAlone|Identit|Order': ok (100s)
- same, -run 'Usage|Card|Quota|Discovery|Exposed|Models|Output': ok
- ./internal/gateway/ -run 'CommandCode|commandcode|Plugin|Parity|Moved|
BillingLine|Search|ShapeFallback|GroupFails|CountTokens|Count|Format|
ToolImage|Cursor|Connect': ok (117s)
- ./internal/cli/ ./internal/gui/ -run 'CommandCode|commandcode|Plugin|
Retired|Moved|SignIn|Login': ok
- Not run: whole packages, the full suite, the GUI node suite (the
machine is loaded; the parent runs those).
|
||
|
|
07a445f42b |
provider: Devin's built-in is retired; its plugin serves it
"devin" joins retiredBuiltins, as Zed (c0605abc2) and Grok (60ecd598c)
did. @magpie-community/opencode-devin-auth serves it, moved or not.
Removed:
- Sign-in: the PKCE localhost listen and callback branch in signin.go,
devinExchange/devinExchangeURL. The exchange is Codex's alone again.
- Accounts: devinAccount and devinProvider in the account list, and the
Logins, switch, on and forget cases (devinSide, devinLoginList,
switchDevinLogin, setDevinLoginOn, forgetDevinLogin, removeDevinHome,
addDevinLogin, devinAlsoOn). "devin" keeps its place in Logins("") with
a nil list.
- Usage: devin_usage.go whole (perLogin fetch, usageLogins, loginQuota).
devinUsageVersion moved to devin_images.go, which still uses it.
- asksOwnBackend's "devin".
- Gateway: attempt()'s serveDevin dispatch and the Devin translator
(serveDevin, askDevin, buildDevin, decodeDevin, the Gemini schema and
tool-description rewriting, the call-id helpers). gateway/devin.go is
now connect_pb.go and keeps only the protobuf and Connect framing that
cursor.go uses.
- Tests of the built-in alone: gateway devin_test, devin_gemini_schema,
devin_sampling and devin_tool_ids; provider devin_usage_test,
devin_cli_signed_out_test, TestDevinSignIn, TestDevinSeveralAccounts,
TestSignInInstallsMissingCLI, TestDevinSignInUnseen, the Devin case of
the required-tools test, and TestDevinSplitParallelCallsKeepTheirResults.
Kept, because the plugin, the devin agent or the move uses them:
- The mover, devinLogins, devinIdentity/devinStatus, DevinAuthAt,
devinCredentialsAt, newDevinHome, devinCommand/devinProxy.
- DevinFamilies, DevinVariant and models.go's p.ID == "devin" shaping
(the plugin's provider id is "devin" too). internal/agent/devin.go
reads the families.
- The installer's "devin" case: the plugin's sign-in installs the CLI.
- The PLUGIN-SERVED notices in devin.go, devin_accounts.go and
devin_images.go, reworded as retired.
Also fixed:
- cliIdentities no longer lists devinStatus. No look at the accounts
asks it now, so it stayed unsettled, and FetchNewBehind told every page
that lists were on their way (TestFetchingNewOnceStarted went red).
- 60ecd598c (Grok) left TestFetchingNewForgottenWhileListed red: its
hook was GrokExecutable in the account listing. It and
TestFetchNewListsAgainForAnAnswerWhileListing now hook kiroCLIDB,
which is read after Cursor's account. Retiring Kiro will need another
hook.
Tests whose meaning changed:
- TestSignInInstallFails and TestSignInCanceledWhileInstalling go
through StartPluginSignIn("devin"), the plugin's install of the CLI.
- TestDevinCLIGoesThroughItsProxy seeds both accounts in logins.json
instead of signing one in. The sign-in's proxy is covered by
TestPluginSignInGoesThroughItsProxy.
- TestLeftAloneRunsNoCLI no longer expects `devin auth status` when the
subscription is switched on.
- TestFetchingNewOnceStarted's unanswered CLI is Cursor's.
- devinRawID moved to anthropic_call_ids_test.go. A Devin call id is
checked as safeCallID("dv_", ...).
Run:
- gofmt -l internal: clean.
- go vet -tags nogui ./... on darwin, GOOS=linux and GOOS=windows: clean.
- staticcheck U1000 on provider and gateway: no Devin leftovers.
- go test -tags nogui -count=1 -run '^(every test in provider, cli and
gateway that names Devin|TestFetchNew.*|TestFetchingNew.*|
TestLeftAlone.*|.*Identit.*)$' ./internal/provider ./internal/cli
./internal/gateway: ok.
- -run 'Migrat|Move|Moved|Retir|SignIn|AsksOwnBackend|SideLogin|Logins|
Unmoved|Install|Proxy|Account' ./internal/provider: ok.
- -run 'Devin|Required|Split|CallID|Cursor|Connect|Parity|ToolImage|
Format|BillingLine' ./internal/gateway: ok.
- -run 'Devin|Plugin|Retired|Moved' ./internal/gui ./internal/agent: ok.
- Not run: the whole packages, the full suite, the GUI node suite (the
machine is loaded).
|
||
|
|
2927a161ef |
provider: Grok's built-in is retired; its plugin serves it
Grok ("grok") joins Zed in retiredBuiltins. It is served by
@magpie-community/opencode-grok-auth, moved or not.
Removed, the built-in's own paths:
- the sign-in (startGrokSignIn) and the per-account homes it made;
- the Logins/switch/on/forget cases and the alsoOn branch;
- grokAccount and the account list entry;
- the usage fetch (grokSubscriptionUsage, grokLoginUsage, the windows);
- the model list (grokModels, grokContextModels, the window labels);
- the token refresh, the headers, the version probe, and routing's usage
clearing.
grok_usage_test.go is deleted, along with the six built-in-only tests in
grok_test.go and the four in grok_accounts_test.go.
Kept, because something still uses them:
- grokLogins and readGrokCredential, for the mover (migrate_side.go);
- grokBody, for the plugin's request bodies;
- GrokHome, the CLI install (pluginRunsCLI) and GrokBase;
- the gateway's grok draw, video, search and namespace code. It asks
PluginProvider()=="grok" too.
Each remaining grok file has a PLUGIN-SERVED notice.
Fixes the retirement needed:
- movedAgent asks Moved again, not PluginServes. A retired Grok that is
not moved yet still records the CLI's own sign-in, so the move takes it.
TestMoveGrok fails without this: only the second account moved.
- In Logins(""), a retired built-in keeps its place, with no list. Grok's
and Zed's accounts list where the built-ins' stood. Without this,
TestAllLoginsMovedKeepTheirPlace fails ("[zed grok]").
Tests whose meaning changed:
- The gateway's grokSignedIn now serves Grok through the fake plugin
moved onto "grok". It proxies to provider.GrokBase, read per request
and refused unless loopback, so no test reaches the network. It names
127.0.0.1 in fetchPrivate, because the vendor's own host is now the
fake's.
- TestVideoContentAtPrivateAddressNotFetched clears that setting. Without
the clear it fails with "200 secret-bytes".
- TestGrokAccountDraws checks the plugin's Authorization only. The real
plugin's headers are the plugin repo's to test.
- The Grok cases in TestVideosRedacted and TestMediaRedactedErrors reach
their echo through GrokBase (grokEcho).
- TestVideoModelByItsBareName's chat model is the fake's fake-1.
- TestGrokPluginSearchesItself expects "grok", not grok-plugin.
- TestGrokHideOwnSignIn is removed: hiding the CLI's own sign-in was the
built-in's ForgetLogin.
- grok_accounts_test.go keeps test-only newGrokHome and addGrokLogin
fixtures for the mover's tests.
Run in the worktree:
- gofmt -l internal: empty.
- go vet -tags nogui ./... on darwin, GOOS=linux and GOOS=windows: clean.
- go test -tags nogui -count=1 -run
'Private|Grok|grok|CallerUsageVideos|GatewayKeyModelsHoldTheImageAndVideoLists|RemoteMagpie|Video|Redact'
./internal/gateway: ok.
- go test -tags nogui -count=1 -run
'Grok|grok|Migrat|Move|Moved|Retired|Retir|SignIn|AsksOwnBackend|SideLogin|Hide|OwnRow|Logins|Unmoved'
./internal/provider ./internal/cli: ok, ok.
- go test -tags nogui -count=1 -run 'Grok|grok|Plugin|Retired|Moved'
./internal/gui: ok.
Not run: the full suite, the GUI node suite, and a real Grok account.
The machine is under heavy load.
|
||
|
|
1357236917 | docs: the retired built-ins leave the gateway and account pages | ||
|
|
21252f6a2c |
provider: Zed's built-in is retired; its plugin serves it
The first built-in taken out (the owner, 10-16: 陆续把内置Provider下线掉, 一定要下线完毕). @magpie-community/opencode-zed-auth serves Zed for everyone now; built-in accounts not moved yet are moved by the hourly loop, or from the Providers list's line (the commit before). Removed: the built-in's sign-in (zed_signin.go and its loopback paste branch), usage (zed_usage.go), its login list, switch, forget and account cases, its own-backend case in asksOwnBackend, the gateway's serveZed and zed.go, internal/zed, and the tests of only those. Kept, because the mover and the plugin path use them: zed.go's credential and login readers (migrate_zed.go's move), zed_body.go (plugins.go), and Zed in accountIDs, side_logins, cards_kept, plugin_usage's movedCards, the gateway's estimatedMoved and the CLI's account names, which name the plugin's accounts too. Zed the editor as an agent (internal/agent, the library's MCP target) is untouched. Tests changed: TestMovedBuiltinQuiet is TestRetiredBuiltinQuiet (no Zed card, its sign-in refused, the move still offered with the account); TestZedMoveCarriesItsModels compares the models without internal/zed; TestLoopbackSignInsTakePastedAddress and asksOwnBackend's set lose Zed. AGENTS.md and gateway-routing.md no longer name Zed's built-in client. Run on this tree over af08ecb27's parent tree: - go test -tags nogui ./... -count=1 -timeout 90m: 64 packages ok, internal/gui red only in TestCoreScriptBudget (the Move line; the budget is raised in af08ecb27). Rebased onto it: go test -tags nogui ./internal/gui -count=1: ok. - Earlier on wt6 before the three fixes: provider red in TestAsksOwnBackendAgreesWithTheGatewayDispatch and TestLoopbackSignInsTakePastedAddress (Zed still named), fixed here. - gofmt -l internal: nothing; GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean. - GUI: retired-move, plugin-move, deprecation-notice and deprecated-subscriptions, both engines, en and zh: 20 pass. |
||
|
|
0f1666b387 |
provider: a built-in can be retired, its plugin serving it moved or not, and its unmoved accounts get a Move line
The owner (10-16) wants every deprecated built-in taken out of magpie,
one at a time. This is the ground for that; it retires nothing yet.
- retiredBuiltins / BuiltinRetired(id) in migrate.go name a built-in
whose code is gone. Only an id with a mover can be retired.
- PluginServes(id) is Moved(id) or retired. Every gate that asked
Moved(id) asks it now: sign-in, Factory keys, usage, logins, cards,
forget, accounts, check-ins, plugin sign-in, the CLI's accounts and
providers, the GUI's account label.
- A retired row's move.state is plugin, and its id is in onPlugins
once the plugin is installed.
- /api/providers lists a retired subscription's built-in accounts that
haven't moved in `unmoved` (MoveCandidate, now with the failed move's
error and why). The GUI shows a quiet line over the Providers list
for each, with Move / Try again (unmovedLine), in en, zh, zh-TW, ja
and de.
- AGENTS.md and docs/subsystems/provider-plugins.md say what a retired
built-in is.
Run at 270aa1c9c with this change:
- go test -tags nogui ./... -count=1 -timeout 90m: 66 packages ok.
- gofmt -l internal: nothing. GOOS=linux and GOOS=windows
go vet -tags nogui ./...: clean.
- GUI, both engines, en and zh: retired-move (new, 4/4), plugin-move,
deprecation-notice, deprecated-subscriptions, plugin-move-unserved,
plugin-movable-review, i18n-keys: 39 pass.
- TestRetiredBuiltinIsThePlugins -count=20 (it picks a mover at random).
The Move line is the Providers list's own, not a page that could be a
plugin. It took the core's scripts to 1,427,218 bytes, which the budget
main raised in
|
||
|
|
45b8c725cf |
gateway: a legacy /responses/compact carrying another account's native compaction goes to that account, or is refused saying why (#2727, ggbdpq)
codexBackend's /responses/compact relayed to Codex's sign-in (or, with the sign-in paused, compactOn's account) before any seal check, so a compact whose input carries a compaction magpie recorded another account as the writer of reached an account that can't read it, and Codex got the backend's bare 400. Now sealedCompact judges it, as /responses already is (codexSealedFor -> serve, #2642): the writer on in magpie answers it, signed as the writer (codexUpstreamOn); a writer gone (signed out, lapsed, paused, switched off, kept from the model) is refused 400 with checkpointError's reason; the sign-in's own seal, a key's seal, a request naming its own chatgpt-account-id, and a sign-in state magpie can't read relay as before. Two Team seats of one email still read as one (the record holds the email). Review fix on top of ggbdpq's 781381f4: a gateway key held to some accounts (#905) was checked (compactSigninHeld) against the sign-in before the compact was handed to the writer, so a key held to me@ spent the writer biz@ (acct-2 asked, 200), and a key held to biz@ was refused 403 "goes through the account Codex is signed in to" though the compact would go to biz@. The hold is now asked of the account the compact goes to; a writer the key may not use gets 403 sealedCompactHeldError naming the writer, with nothing asked. The test's fake backend now records under a lock. Reviewed and run (reviewer, at this commit with the #2739 commit under it, on 89521b03d; rebased after onto origin/main, see the last line): - Each fix broken by hand, TestNativeCompactionCompactJudgesItsWriter: M0 codex_backend.go as on main: 3 subtests red (writer answers, gone refused, compactOn gone). M1 the key '#' skip dropped: "a seal a key wrote is not judged" red (400). M2 the chatgpt-account-id skip dropped: its subtest red (400). M3 the writer never relayed to: the healthy-writer subtest red (backend saw ""). M4 gone never refused: 2 red. M5 judged after compactOn's relay: the compactOn subtest red (backend saw acct-2). Each green with the code restored. - TestNativeCompactionCompactKeepsTheKeysAccounts (new) on ggbdpq's 781381f4: red both ways ("200, the backend saw acct-2" for a key held to me@; 403 "goes through the account Codex is signed in to" for a key held to biz@). Red again with the hold put back on the sign-in; green with this change. TestGatewayKeyAccountsHoldCodexCompact and TestGatewayKeyCompactOnCodexAPIKey still pass. - -race -count=3 on both tests: ok. - gofmt -l clean; go vet ./... and -tags nogui (darwin), GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean; go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok. - Full suite, set -o pipefail, go test -tags nogui -count=1 -timeout 45m ./... at 519bcc843 (both changes, on |
||
|
|
0eab029ea7 |
provider: a ChatGPT account's turn is zstd-compressed with at most Codex's own 2 MiB window, not 8 MiB (#2739, pc418)
codexZstd (internal/provider/codex_zstd.go) set no window, so klauspost's
encoder declared its default 8 MiB (and, single-segment, up to the body
size below that) on every turn magpie re-compresses for the ChatGPT
backend: the accounts loop (forwardOnce), the native relay
(codexUpstreamOn) and warm-up all go through CodexCompressed. Codex's own
client never sends that: openai/codex ce0323f2
codex-rs/http-client/src/request.rs compresses with
zstd::stream::encode_all(Cursor, 3); zstd 0.13.3 (Codex's Cargo.lock)
copy_encode streams through Encoder::new(dest, 3) with the size unknown,
which libzstd 1.5.7 gives level 3's windowLog 21 (2 MiB). pc418's
15,173,526-byte image-heavy turn got 400 in the 8 MiB frame and 200 at
2 MiB; a later replay of the 8 MiB bytes was taken, so this matches the
client's envelope rather than proving a backend limit. Level and checksum
are unchanged. Cost: a large turn is bigger on the wire at 2 MiB with
SpeedDefault (pc418's turn 7.59 MB -> 12.44 MB; libzstd -3 gives 9.78 MB).
Reviewed and run (reviewer, at this commit on
|
||
|
|
5a2414acdd |
plugins: every built-in plugin starts on, a new install's too
The owner (10-17): "所有的内置插件默认都应该是开启的", "尤其对新用户来说…… 不然新用户都不知道有哪些功能". Since |