b26fa0903787f1bfb0af0e32cb8e2318bc1a4e75
1326
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
dafe4af822 |
gateway: the ChatGPT backend's "auto"/"default" tier is recorded as unknown (jjt on Discord)
The ChatGPT Codex backend says service_tier "auto" in response.created and "default" in response.completed whether priority ran or not. jjt's measurements on gpt-6.1-sol with a Plus account: Fast decodes at about 200 tok/s, without it about 110, and the reply says "default" both times (real-priority.sse, speed-plus.txt). magpie copied that into tier_served, so the usage log, its CSV and /v1/magpie/route said served = default for requests that ran Fast. servedTierAt (tier_record.go) leaves those two words empty when the reply came from CodexBase's host. It is applied once per routed try, in attempt (gateway.go, a defer, so every return path and the route's tries see it), and on the relay of Codex's own sign-in (codexUpstreamOn). OpenAI's API, where service_tier means what it says, keeps it as given: a provider at api.openai.com and Codex with an sk- key relayed to it. "priority" or "ultrafast" said by the ChatGPT backend is still kept. Display: tier_served is shown by the CSV (an empty cell), the JSON log and /v1/magpie/route (omitempty). No GUI page or TUI shows a tier (grep of internal/gui/assets and internal/tui for tier_served, tier_asked, tierServed: none), so no strings changed. docs/reference.md and docs/subsystems/gateway-routing.md say it. Tests: - TestChatGPTBackendTierUnknown (new): the backend says auto, then default (jjt's events, cut to the fields read); a routed try asked priority and one asked nothing, and Codex's own sign-in relayed, all record "" in usage and the route. - TestOpenAIAPITierKept (new): api.openai.com's "priority" and "default" kept, routed and through the sk- relay. - TestTierRecordedPerTry: its "none asked" case on the ChatGPT backend now expects "" where it expected "default". Run on mote (mote-run; the wider run at base |
||
|
|
c37b8b6594 |
gateway: a remote magpie's out-of-quota refusal is asked again, not replayed here (zaidu259434 on X)
A routing group on another computer's magpie had one member, Open Design, out of its Coding Plan quota and wallet. This magpie rested that remote model (remoteModelRest) and, through quotaHeld, gave the 402 again on every request until the time it named, never asking the remote. The user moved the group to another vendor there, and Codex here still got "Remote magpie: Open Design: [code=insufficient_balance] ... (out of its allowance: not asked again before 06:19)". The remote magpie routes its own groups and holds its own rests, and what it serves under a name can change there at any moment. A rest from remoteModelRest is now marked (Rest.there), and quotaHeld passes it by: the remote is asked, and answers from its own hold at once, or from what it serves now. The rest still puts the model behind the others in a local group. verifyHeld is unchanged: its hold is a minute, and TestRemoteMagpieVerifyHeldOnTheModel asks for it. Run (on mote, at |
||
|
|
cc81ad4ea1 |
codex: a Windows Codex app that starts no app-server after a switch is reopened (蛋仔 on Discord)
After magpie switched Codex's account, the Windows Codex app answered every send with "Codex app-server process is not available" until it was quit and opened again. The report said the app doesn't reconnect after a clean exit. That is half right. The app (MSIX OpenAI.Codex 26.1021, an Electron ChatGPT.exe that spawns codex.exe app-server over stdio) does start another, but only once the old one's stdout reaches EOF and its exit has fired. On Windows a child of the app-server (an MCP server, a tool command) inherits that pipe handle. A child left running keeps the pipe open, so the app never sees the close, starts none, and its send() throws. Reproduced on the Windows box with the real codex.exe 0.164 app-server plus an MCP server: stdout ended only when the MCP server did, and at once when the tree was ended. magpie took "the old pid is gone" as done in each place it restarts the app-server. None of them checked that a new one came: - codexAppStep (the switch watcher) now records the pids it ended and waits codexAppBackWait (30s) for another app-server. If none comes and the app still runs (CodexAppOpen), it quits and opens the app as the Agents row's Restart does (CodexAppReopen: restartWin by the OpenAI.Codex_2p2nqsd0c76g0!App AUMID, Windows only). Where it can't, the row says to (CodexAppStuck). - RestartCodexApp (macOS Restart), RestartCodexAppWhenIdle (uninstall) and the switch notice's Restart (RestartSwitchedCodexApp, |
||
|
|
dca3e2d716 |
search: Doubao Search (Volcengine) as a search API (CyberCaius on Discord)
CyberCaius asked on Discord #help (10-30) for Volcengine's Doubao search under Settings › Models › Search APIs, or a custom API address. Volcengine's Doubao Search Custom (豆包搜索 Custom版, once 联网搜索 / 融合信息搜索, docs.volcengine.com/docs/networked-search/networked-search, the same page as volcengine.com/docs/87772/2272953) can now be added with its API key: - provider.SearchVendors: volcengine, "Doubao Search (Volcengine)", at https://open.feedcoopapi.com, keys at console.volcengine.com/search-infinity/api-key, after DeepSeek. The GUI takes its vendors from SearchVendors, so it shows in the Search API picker with its Get a key link and base URL field; no GUI file changes. - askSearchAPI: POST /search_api/web_search, Bearer key (the default, as the docs and volcengine/mcp-server's askecho_search_infinity send it), body {Query, SearchType: "web", Count: searchHits, Filter: {NeedUrl: true}}. The query is cut to the 100 characters the docs allow. NeedUrl leaves out its 火山如意 cards, which have no URL to cite. - readVolcSearch reads Result.WebResults: Summary as the page's text (the docs recommend it for models; Content is the whole page, Snippet ~200 chars "only for list display"), Snippet when there is no Summary, PublishTime as the page's age, a 1970-01-01 time (its image example's stand-in) as none, and a result with no Url left out. - volcSearchError: its errors are in ResponseMetadata.Error, a code the docs list, and the docs don't say the HTTP status, so the code decides: 10401/10403/10409 rest the key as turned away (403), 10406/10408/ 10410/10412 (free searches spent with none paid, no plan, plan spent) as out of credit (402), 700429 as rate limited (429). Any other code is a plain error, a 200 carrying one included. The key is masked in the error as for every vendor. - A custom address: every search API already takes a base URL (#1580, the field under the key in Settings, url= in the CLI), so an endpoint that answers as Tavily, SearXNG, Brave, Exa, Firecrawl, You.com, DeepSeek or now Doubao Search does can be set there. There is no common format across the vendors (each has its own path, body and reply), so no separate "custom" vendor was added. - Siblings: CLI usage (main.go, search_cli.go's api list and empty-state hint), README.md, README.zh-CN.md, gateway-routing.md's path list and refusal paragraph. The test's reply is the docs' own web-search response example, byte for byte (testdata/volcengine_web_search.json); its error replies are the docs' error example with its "// 该字段为错误码" note taken out (not JSON). Not tried against the real API: no Volcengine search key in this run. Run (worktree on origin/main |
||
|
|
7946256933 |
agents: omp, OpenCode and Crush get each model's price, and a group of mixed prices is priced at its first member (taotao7 on Discord)
taotao7 (#help, msg 1565576524193857678): omp on magpie's group/* models
counted every call at 0. omp's custom provider prices a call by the cost
in models.yml alone (omp 18.9.1: pi-catalog src/models.ts
calculateUsageCost, USD per 1M tokens; models-config-schema-bundle.ts
cost {input, output, cacheRead, cacheWrite}). magpie wrote no cost into
omp's models.yml for any model; an ordinary id still got one from omp's
bundled reference match, a group/* id matched none. And a group whose
members cost differently had no price in magpie's agent list at all
(EntryPricer prices only one-price groups), so Pi had none either.
- provider.AgentPricer: as EntryPricer, but a mixed-price group is priced
at the member it sends to first (a manual group's pick, else the first
not switched off); a fast or unpriced first member leaves it unpriced.
Chosen over "the member it routes to most" because that needs usage
history and would rewrite agents' files as traffic shifts; the first is
what an In order / Manual group sends to while it answers. Read at each
Sync, so it follows the members. The gateway's /v1/models keeps
EntryPricer.
- omp: models.yml model entries carry cost.
- Siblings: Pi, mothx, alma, penguin, plugged already wrote m.Price and
now get group prices too. OpenCode got no cost at all: now cost
{input, output, cache_read, cache_write} (OpenCode 2.0.25). Crush:
cost_per_1m_in/out/in_cached(write)/out_cached(read) (Crush 0.39.3).
- docs/subsystems/agent-wiring.md says so.
Run (mote): TestGroupModelsCarryTheirFirstMembersPrice ok; full
go test -timeout 45m ./... at load ~150-210 from other work: agent and
provider ok, 77 ok; reds TestTOMLBigFileParsesInLinearTime (#4109) and
the Antigravity turned-away tests + TestCodexSpentGrokFailingIsTold
(#4362), both filed against main. GOOS=linux/windows go vet of agent and
provider ok. Real omp 18.9.1 in a sandbox HOME: `omp models list --json`
reads group/mix with cost {1,2,0.1,1.25}, pricingStatus fixed.
Broken by hand: route.go back on EntryPricer -> red (group/mix cost
nil); omp's Cost line dropped -> red (a/cheap cost nil).
Not tried: a real omp turn through the gateway showing the cost; OpenCode
and Crush showing a session's cost in their UIs (keys read from their
binaries' strings only).
|
||
|
|
d31710c71d |
provider: the switch off a spent Claude account reads saved accounts it has no reading of (cn_Vincentzyx on X)
cn_Vincentzyx on X: Claude Code not connected to magpie, only its
sign-in switched ("Only switch Claude Code's sign-in"), the accounts in
the order Settings' Make first gave them. The account Claude Code was on
ran out and it was never moved.
|
||
|
|
3bebc38393 |
gui: a key combination opens the quick panel from any app (ben hanks)
ben hanks on Discord asked for a global shortcut that opens the menu bar or tray panel. Settings › General has a new row, Quick panel shortcut, with none set by default. Clicking its field records the next combination: a letter, a digit, Space or F1–F20 with Ctrl, Alt/Option or Cmd/Win, or an F key on its own. Esc or a click elsewhere stops recording, and the cross clears the shortcut. It is shown the system's way (⇧⌘K on a Mac, Ctrl+Alt+K elsewhere). POST /api/settings/panel-shortcut checks the combination, has the running app bind it through Wails' GlobalShortcut (Carbon hot keys on the Mac, RegisterHotKey on Windows, XGrabKey on X11), and saves it only once it is bound. One the system refuses is not saved, the old one stays bound, and the status line says why. A pressed shortcut toggles the panel as a tray click does. The shortcut belongs to each computer (KeepOwn), the Settings page's own save leaves it alone, and the old Mac process lets go of it as it hands over. On Wayland no app may grab keys, so the field is turned off and the row names the command (`magpie panel`) to bind in the desktop's own keyboard settings. Every string is in en, zh, zh-TW, ja and de. No size budget was raised: app.js is 1,315,252 of its 1,315,316 after older comments were cut. Run at this head (rebased on origin/main |
||
|
|
1534474c8e |
gateway: a ChatGPT account out of its credits rests until they are back, not 30 minutes
PaulT on Discord: ChatGPT plans now come with monthly API credits. An
account on credits only answers 402 once they run out, and magpie rested
it the flat creditRest (30 minutes, a guess) and asked it again, refused
the same, every half hour.
For a Codex account (UsageAgent "codex"; scoped to that vendor, every
other 402 rests as before) the credit rest now takes, in order: a reset
the refusal's body names (resetsAt), one its headers note (resetsNoted),
the time its full window renews from its usage reading (Allowance.Full),
a Retry-After longer than the default, else chatgptCreditRest (5 hours),
capped at longestMonthly and not marked guessed. renewed() also lifts a
Codex account's credit rest, so a reading that finds its window renewed,
or a reset spent, has it back at once.
Test: TestChatGPTOutOfCreditsRestsLong (internal/gateway/
chatgpt_credit_rest_test.go): unread -> 5h, lifted by renewed; window
read full, back in 3h -> rests 3h by "window", lifted by renewed; a key's
402 and a Claude account's 402 still rest creditRest, and renewed
("claude") doesn't lift theirs.
Broken by hand: the Codex branch off -> red ("rests 30m0s ... want
5h0m0s"); the renewed() change off -> red ("still resting after its
window renewed: 5h0m0s by credit").
Not tried: a real ChatGPT 402 from an account out of credits. No real
body is known (not in magpie's code or tests, the plugins repo, logs or
the codex binary's strings), so the test sends a bare 402 and the rest
keys on the account's vendor and status, not on body words. The 5-hour
default is a judgment: credits renew monthly, but the plan's own window
can serve again sooner, and a reading or reset lifts the rest early.
|
||
|
|
3f91b98eac |
gateway: a group's last member out of quota sends the request back to a relay that blipped, and rests
dbydd on Discord: an in-order group of sub2api relays with a Codex (or OpenCode Zen) subscription last. Once that last member's quota answers 429, requests still landed on it, the 429 reached the agent and broke its loop, and a new conversation stayed stuck there. Two causes, both in serve: - A relay that failed for a moment (503/502/429/500) went on to the last member; its quota 429 is not busy(), so the patience/replan block (#1418) never ran and the agent got the 429 while the relay could answer. Now a group's last member refused out of quota or credit (lastSpent: failQuota/failCredit, not passing, an earlier member busy this request) replans like a busy one: the earlier member is asked again, and the spent one rests with restAfterMarked. - The last one asked was never rested for quota when it was an account (#1772 rested keys only), so each later request asked it again. The #1772 block now rests the last account out of quota or credit too; quotaHeld still holds keys alone, and a Codex autoReset unrests the account whose reset it spends. Tests (internal/gateway/group_spent_last_test.go): - TestGroupRelayBlipDoesNotEndOnSpentLast: usage_limit_reached / rate_limit_exceeded / bare 429 on Codex, crossed with relay blips 503/502/429/500; every turn must be 200 from the relay, Codex asked at most once when spent. Red on the old code (turn 0 got the 429). - TestGroupSpentLastAccountRests: Patience off; Codex asked at most once. Red on the old code ("Codex asked 2 times"). - TestGroupLastMemberSpentGoesBackToEarlier: the reporter's stick case (on Codex, relay back, Codex spent); passed on the old code as well. Broken by hand: lastSpent forced false -> the blip test red; the #1772 block back to keys only -> TestGroupSpentLastAccountRests red. Not tried: a real OpenCode Zen or ChatGPT quota 429 body (the tests use Codex's usage_limit_reached shape, rate_limit_exceeded and a bare 429), and real sub2api relays. |
||
|
|
37527c7ad3 |
sessions: omp's subagents and advisor are their session's to the gateway, not counted again (Jumy on Discord)
omp's task subagent (Kid.jsonl) and advisor (__advisor.jsonl) each have a header id of their own, and omp sends that id, not the main session's, in x-session-affinity (seen in a real omp 18.9.1 run through a fake upstream: the main session's requests carried 01a18ae4-555c-…, the subagent's 01a18ae4-5671-…). magpie counts those files in the main session, but the gateway's native keys held only omp|<main id>, so the gateway's records of the subagent's and advisor's calls were added again as sessions of their own: in Usage › Sessions' totals (MergeExternalStats), in the Sessions list (MergeExternal) and in NativeIDs. Session.Subs (subIDs) now holds those ids, and GatewayKeys, MergeExternal and nativeIDsWith take them as the session's own. GatewayKeys takes Claude Code's Copies too, which the GUI list added by hand beside it; the stats' native map already had each copy's own group, so nothing counts differently there. This is at most a second count of the subagent's and advisor's share, not a ~1000x: it may not explain the whole ~900M Jumy saw. Not found in the reader: omp's usage is per call (assistant messages only; toolResult and compaction carry none), re-reads continue from the offset only when the head and sampled prefix hashes match. Tests: TestOmpSubagentsAreTheSessionsToTheGateway (sessions, the existing omp fixture, whose sub headers match omp 18.9.1's) and TestOmpSubagentCountedOnceWithTheGateway (gui, /api/sessions/overview and /api/sessions, from omp 18.9.1's own lines). Broken by hand (subIDs returning nil): both red, the overview showing the Kid id as a second gateway session with 5000 input beside the native one. Run on mote: go test ./internal/sessions -run 'TestOmp|TestRaft', ./internal/gui -run 'TestOmpSubagent|TestTopSessions'; gofmt -l; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on the two packages; go build for darwin, linux (nogui), windows. go test -timeout 45m ./internal/sessions ./internal/gui ./internal/usage: sessions and usage ok; gui red only in TestMainWindowCorners/macOS_26_SDK, #3949 (mote's macOS 27, titlebar code this change doesn't reach). The full ./... was not run before the push: mote had other sessions' full suites running at load ~180. Not tried: Jumy's own session files or ledger (not available), so the rest of the 900M is unexplained; Kimi Code's subagents (it sends no session header magpie knows, so its gateway rows aren't sessions); the GUI Playwright suite (no asset changed). |
||
|
|
d9459a5371 |
pii: pf-serve loads a model under a user folder named outside ASCII (Windows)
AIMetaPhD on X (Windows, Chinese user name): Settings → Privacy's Privacy Filter said "the local masking model didn't start: pf-serve-vulkan.exe: failed to read GGUF: C:\Users\<mojibake>\.cache\ magpie\privacy-filter\privacy-filter-q8-80efc1803eda.gguf", the same for pf-serve.exe. pf-serve's main takes a narrow argv, which on Windows is in the ANSI code page (936 on a Chinese system); ggml_fopen reads the name as UTF-8 and the GPU's weights are reopened through a narrow ifstream, so no device could open it, and its error came back in GBK, which magpie read as UTF-8. startOne now runs pf-serve in the model's folder and gives it the model's file name (modelName, ASCII), never the path. That works with the pf-v2 binaries users already have. A pf-serve error that names the file is shown with the whole path, in UTF-8. The stand-in pf-serve in the tests now refuses a model path with a byte outside ASCII and opens the file from where it runs, as the real one does. TestModelInFolder- NotASCIILoads and TestModelErrorNamesWholePath put the model under "用户 Ünïcode". The native side (wide argv, and ggml_fopen in weights-once.patch) is #4342. pf-serve is the only native helper magpie starts. AstrLink Guard's CoreML paths are darwin cgo, which is UTF-8. Run: - Real use on xiaomi-gpu (Windows 11, zh-CN, ACP 936): the real pf-v2 pf-serve zip and the real 1.6 GB model (both sha256 match the pins) under C:\Users\yeton\runs\pf-测试用户\.cache\magpie\privacy-filter. A temporary test (not committed) pointed dir there and called Find through win-run. Vulkan (AMD Radeon 8060S) loaded in 3.7s and found the person and the email. Forced onto the CPU, it loaded in 7.0s with the same finds. Broken by hand (the old full-path argv), it gave the reporter's exact error, the folder in mojibake, on both programs. - Broken by hand on mote: with the old argv, both new tests are red. - win-run go test ./internal/pii/...: ok (the real test included). wsl-run go test ./internal/pii/: ok. - mote: gofmt ok; GOOS=darwin/linux/windows go vet -tags nogui ./... ok; GOOS=windows go vet ./internal/pii/... ok. - mote: go test -count=1 -timeout 45m ./... at base |
||
|
|
d6284bf8a0 |
library: a skill's installed dependencies are no change of the user's
ggbr on Discord (#help): easyeda/easyeda-api-skill says to run
`npm install` in its own folder. Once that ran, the Library tagged the
skill Changed here (本地已改动). The check for updates still ran on it
(it compares commits, not the folder), but Update all left it out as
changed, and its own Update asked to replace "your changes" and threw
node_modules away with the old version, so the user had to install again.
Cause: editState compared the hash of the whole library folder (only
.DS_Store left out) with Hash, the hash of the files as fetched. The
install's node_modules and its rewrite of package-lock.json made them
differ.
Now what installing dependencies or running the skill writes is not a
change (fromInstall): node_modules, .venv, venv, __pycache__,
.pytest_cache, .mypy_cache, .ruff_cache, *.pyc/*.pyo, and the lock files
package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lock(b), uv.lock.
- New Skill.Own: the hash of the files as fetched without those, set on
install, update and when skill_from binds a skill to its repo.
onlyInstalled compares the folder with it first.
- An agent's copy (copy mode) counts as edited only when its ownHash
differs from the library's.
- An update carries those entries from the version replaced into the new
one wherever the new one has no entry of its own (carryInstalled). The
new version's own lock file wins.
A file the user really edited (run.py, SKILL.md, package.json, ...) still
marks the skill changed and is never overwritten without asking. An edit
to a lock file alone is no longer protected; an update takes upstream's.
Skills already marked changed: they clear on their own on the next page
read when only installed folders and bytecode differ, or the lock file the
skill came with was left byte-for-byte (compared with Hash, leaving
installed folders aside). A skill fetched before this commit whose lock
file the install did rewrite has no Own, so it stays marked until its
next update (Update on its row asks once, keeps the old folder in the
backups, carries node_modules over and records Own). From then on, a
rewritten lock file isn't counted.
Run (mote, worktree at
|
||
|
|
7632e1be1d |
redact: a text sent on a route goes on it as it went, the model's late finds too (vvrfxyz on X)
vvrfxyz on X: "脱敏功能是不是会降低缓存命中率 我开了脱敏后 dsh命中率暴跌".
Cause: the local model (AstrLink Guard, on by default) is waited for
2s a request (masking's defaultWait). A tool's output it hasn't read
by then goes with the rules' masking alone (pii.Partial). On the next
turn the model has read it, finds the names in it, and the same history
text now goes with {{PERSON_…}} in it. Everything from that message on
is a new prompt to the vendor, so its prefix cache misses.
|
||
|
|
e863f520c3 |
routing: an intent's effort survives the group's failover (#3664)
A routing group's intent rule picks a model and the reasoning it is
asked for (useEffort, #2633). When that model's provider turned the
request away and the group failed over to another member, the request
went out at the agent's own level (or none), not the intent's.
ruleEffort (internal/gateway/rules.go) gave a rule's useEffort only to
candidates of the member the rule names. Now the rule's effort is the
turn's: a member the group fails over to is asked it too, fitted to its
own model's levels (fitLevel), and Try.RuleEffort records it, so the
Routing page says "set by the rule". Unchanged: a rule that names the
candidate goes before one it only fails over from; a member the user
fixed at an effort keeps its own (#189; ruleEffort isn't asked when
c.effort is set); a model whose levels aren't known is asked as the
agent asked.
Ported from skygunner's fix (github.com/skygunner/magpie
fix/3664-intent-effort-failover, 2136cf044), with two changes after
review:
- A nested group's rule now decides for that group's members only.
skygunner's version gave an inner group's useEffort to every candidate,
so when the whole inner group failed, the outer group's member outside
it was asked the inner rule's level. ruleEffort takes the outer
group's members (ms) and skips a nested rule for a candidate not
reached through that group. New TestNestedRuleEffortStaysInItsGroup.
- TestIntentEffortSurvivesTheGroupsFailover now covers four cases for
the failover member, each in its own magpie: unknown levels (agent's
high, nothing traced), the same levels (low), levels medium/high
(fitted to medium) and fixed at high (high, Fixed traced, RuleEffort
empty). The stale "Then asks nothing" comment now says its member is
asked the first rule's.
docs/subsystems/gateway-routing.md says both.
Run (all on mote via mote-run, at this tree rebased on
|
||
|
|
4b4c4a8062 |
gui: tell a Chinese reader Claude Desktop's gateway window has no Chinese (GZXYMH on X)
GZXYMH on X, under the owner's tweet about Claude Code without the proxy:
"代理的话,就会变成网关形式的界面,就没有中文简体了(desktop版本)". The
"desktop version" is Claude Desktop. Connected to magpie it runs in its 3p
mode, whose window ("Gateway" inference) is Anthropic's bundled UI. That UI
has 11 catalogs and no Chinese, so the window comes up in English.
Cause, read from the real bundle: Desktop 4.4212.0 (darwin RELEASES.json
currentRelease, published 10-29) now packs that UI as
Resources/ion-dist.asar. Its header lists i18n/ en-US de-DE fr-FR ko-KR
ja-JP es-419 es-ES it-IT hi-IN pt-BR id-ID (and dynamic/ for the same 11),
with no zh. That matches 2.7032 (this Mac) and 3.6556.2 (
|
||
|
|
83e41a22c9 |
agent: Claude Desktop's key, sealed at rest by Desktop 4.4212, isn't said to be changed (Discord)
A Windows user on Discord: the Agents list keeps saying Claude Desktop's
inferenceGatewayApiKey (00000000-0000-4000-8000-6d6167706965.json) was
changed. Reconnect and a Desktop restart help only until the next start.
Cause: Claude Desktop 4.4212.0 (2026-10-29, Windows and macOS) seals
configLibrary secrets at rest. Its custom-3p:keys sweep runs at every start
and rewrites each clear-text secret field, inferenceGatewayApiKey among
them, in place as
"__sealed__:v1:" + base64(protect("anthropic.claude.crossProfileSecret.v1:"
+ {"configLibrary":{"key":k,"value":v}}))
Desktop opens the value again when it reads the profile, so it still sends
magpie's key and the gateway takes it. Only magpie's file check saw another
string. In 4.29.0 the writer was gated on !app.isPackaged; in 4.4212 the
gate is gone. Read from the 4.4212 nupkg and macOS zip's app.asar.
protect is the claude-native addon's userDpapiProtect on Windows (user
DPAPI, entropy "anthropic.claude.crossProfileSecret.v1") and Electron
safeStorage (Keychain) on macOS.
Fix: desktopOpen opens a sealed value before Check and Sync judge it. On
Windows it is opened with CryptUnprotectData and that entropy, the prefix
and the configLibrary key are checked, and the clear key is then compared
as before, so a sealed key that isn't magpie's is still "was changed". A
seal magpie can't open (macOS Keychain, another user, a bad blob) is
unknown, not changed: no notice, and Sync doesn't write over it. The
gateway's auth is unchanged; it still takes only the key magpie wrote,
which is what Desktop sends after opening the seal.
Run (mote, at this head on
|
||
|
|
ffa07395eb |
gateway: Codex talks Responses to magpie over a WebSocket, turns after the first as a delta (#4058)
Codex names previous_response_id and sends only the new input on its WebSocket path alone; magpie answered the upgrade 426 ( |
||
|
|
e887139e7a |
providers: Best in family serves the newest model of each family a provider lists
Steven on Discord #feedback asked for a provider to serve only the newest model of each family, so a newer one (Opus 5.6) takes the old one's place without re-picking. The provider editor's Models control gets a fourth option, beside Vendor's list / Picked only / Usage only: Best in family. It is also on the CLI as `magpie provider models <id> best`. With nothing picked, the provider serves only the newest model of each family in the vendor's list, up to 24. A family is the id with its version numbers taken out (catalog.FamilyOf/BestInFamily in internal/catalog/family.go). A dated snapshot counts as its alias, and sizes and suffixes (mini, flash, -fast, -thinking) stay part of the name. Provider.Exposed applies it, and so does Codex's native list (CodexNativePicked). A provider/model a request names explicitly is still served, since resolve doesn't go through Exposed. A pick, Select none or Usage only clears the flag (normalize), and a providers.json without bestInFamily reads as before, so every existing mode is unchanged. The editor draws the family's newest as dashed (m.best) before saving. Every language has the wording (zh, zh-TW, ja, de). The design reference is docs/subsystems/providers-accounts.md (Model picks). Tests: family_test.go is a table of real ids, including the models.dev Claude list in testdata (no network). There are also best_in_family_test.go (provider), TestProviderModelsBest (cli), provider_save_best_test.go (gui save keeps/clears), codex_best_in_family_test.go (gateway) and provider-best-in-family.test.cjs (5 languages x chromium/webkit x 1100/420). Broken by hand: with the BestInFamily filter in Exposed and in CodexNativePicked turned off, the 4 new Go tests went red. Budget: after the rebase app.js went over appScriptBudget. Comments were cut and the tooltip and hint merged into one string, so app.js is 1,311,399 of 1,311,735. Neither budget was raised. Run at this head, on origin/main |
||
|
|
55299ee304 |
agents: Switch accounts only, the account a Claude Code or Codex not connected is signed in to, a click from another
Users asked for an entry named 仅切换账号 (growaiskills), for the current
account to always show, for a clear sign that a switch took, and for the
switch away from the proxy settings that put them off (Rennix7t). The owner
said to build it.
On the Agents page, a Claude Code or Codex row that magpie doesn't connect now
shows the account the agent is signed in to as a button in its status line
(switchEntry). Clicking it opens the app menu, headed "Switch accounts only",
with:
- every sign-in;
- "Only switch {agent}'s sign-in", a ticked item (menuitemcheckbox). Claude
always gets it; Codex gets it only with more than one usable account;
- "Manage accounts…", which opens the provider editor.
Picking another account goes through /api/login/switch, or through
/api/provider/keeplogin when the provider keeps a login. The button then
shows "Switched" for 5s, and the status line says that new sessions use the
account and an open one keeps its account until it is restarted. A pure
switcher (Claude kept to its own accounts with nothing else in magpie, the
"empty" connect kind) used to show only "Add a key or a subscription
first", so it couldn't switch from the page. It now gets the entry, and
switch-only reads "Not connected · switching accounts only". The failover
line's "ChatGPT accounts" button is gone, since this entry replaces it. A
connected agent, the tray panel and the WSL twin get no entry. Strings are
in zh, zh-TW, ja and de. Docs: providers-accounts.md and reference.md.
The core budget is raised by this change's bytes only (app.js 1,315,316,
core 1,536,357), after cutting comments and dropping a key.
Run on mote at 9f299d54e (rebased on
|
||
|
|
deb0b8da72 |
codexcat: Codex shows a model's whole window and compacts at Long conversations' threshold (#3975, #3562; 01huadalang on Discord)
01huadalang on Discord: a Command Code model with a 1M window showed
258,400 in Codex. EasonSpirit (#3975) and greenfinchgreen-gif (#3562)
saw the same on OpenCode Go's 1M models.
The cause: magpie put Long conversations' threshold (272K by default, a
Compact at set on the model or provider, or a size typed in Settings)
into the Codex catalog entry's context_window, and the real window into
max_context_window. Codex shows context_window at 95% as the
conversation's context, so 272000 showed as 258400. The plugin was not
at fault: commandcode lists these models at 1M, from Command Code's
own list or its fallback table.
Now each catalog entry carries two values:
- context_window is the model's whole window.
- auto_compact_token_limit is the threshold, written only when it is
below the window. Full window writes none.
This applies to entries magpie writes itself (entriesAt) and to a
relay's own Codex-shape entry (listedEntry). Codex 0.165 compacts at
the lesser of the threshold and 90% of the window. A
model_auto_compact_token_limit the user put in config.toml still comes
first.
Two other changes:
- max_context_window is never written now. It stays a field of
codexcat's model, so Keep doesn't carry an old catalog's value
forward as if the user had added it.
- Tag carries a format mark (catalogFormat), so a Codex holding a list
in the old shape fetches it again.
Codex's own models (codex/) and Codex's base_instructions are
unchanged.
One behaviour moves. Codex used to compact at 90% of 272000 (244,800).
It now compacts at 272,000, the number the setting shows ("Compact at
272K").
Tests:
- TestCodexWindowShownCompactApart (new). Checks Command Code's
claude-opus-5-5 at 1M, a relay entry, and a relay entry with its own
Compact at, under the default, Compact at 400K, and Full window.
- TestCodexCatalogCompactAt, TestCodexCatalogToolSearch,
TestCodexCatalogCompactAtReachesDisk and
TestTypedWindowReachesCodexAndClaudeCode now expect the window in
context_window and the threshold in auto_compact_token_limit.
Broken by hand: I put the old codexcat.go back. TestCodexCatalogToolSearch,
TestCodexCatalogCompactAt and TestCodexWindowShownCompactApart went red
("commandcode/claude-opus-5-5 told window/compact [272000 <nil>]; want
[1e+06 272000]"). With this change restored, all three are green.
Real Codex 0.165.0 in a sandbox CODEX_HOME, against a local fake
Responses server, using the catalog codexcat.Catalog now writes for
commandcode/claude-opus-5-5 at 1M:
- The rollout records model_context_window 950000. The old-shape entry
(272000 with a max of 1000000) records 258400, the reporter's number.
- A turn reporting 260K tokens is not compacted. One reporting 280K is
(CONTEXT CHECKPOINT COMPACTION). The old shape compacted at 260K.
- model_auto_compact_token_limit = 500000 in config.toml keeps the
280K turn uncompacted.
Run (mote-run, at this change on origin/main 9b833205f; rebased onto
|
||
|
|
9b833205f7 |
groups: a found group's id and name come from models.dev's one spelling (XYenon)
XYenon on Discord (#feedback, 10-30): autoGroups() and spelledIn() picked a found group's name and its public id apart, so a group read glm-5-3-flash beside auto/glm-5.3-flash. The id also followed the order the providers were added in. Now: - spelledIn takes the spelling models.dev gives the model most (catalog.Spelling, the normal index normalFor already reads): every member spelling of GLM-5.3 Flash (glm-5-3-flash, Ark's glm-5-3-flash-260828, glm-5.3-flash) gives auto/glm-5.3-flash. A model models.dev doesn't know keeps the old pick (first listed member spelling, else the first member's). - autoGroups names the group from the same choice: catalog.NameOf of that spelling, else a vendor's own name, else the spelling itself. A found group the user changed keeps the name they saved. - Old ids keep working. group/auto-<slug> doesn't change, and any auto/<spelling> is still the group (CanonicalRef: gateway, key allow-lists, fallbacks, members). PublicRef now takes an old auto/<spelling> to the current one too, so hidden, picked and ordered models saved by it hold, and a pick of it written now (Agent.Apply) is written as listed. An agent field magpie set to an old spelling moves on the next SyncCatalog (renameFoundGroups), as group/auto- values already did, because OpenCode checks its model against the list magpie writes. A value the user set stays as it is and is still served. Tests (on mote, via mote-run): - TestFoundGroupIDAndNameAreOneSpelling (5 member orders/spellings, the user's name kept), TestFoundGroupUnknownToModelsDevNamedByItsID, TestFoundGroupMovedOffAnOldSpelling. The catalog fixtures use models.dev's real spellings and names (glm-5.3-flash "GLM-5.3-Flash", volcengine's glm-5-3-flash "GLM 5.3 Flash"). - Broken by hand, one file reverted at a time: group.go reverted, the test is red (named "GLM 5.3 Flash" beside auto/glm-5.3-flash); provider/autoref.go reverted, red (id auto/glm-5-3-flash with Ark first, PublicRef of the old spelling unchanged); agent/autoref.go reverted, TestFoundGroupMovedOffAnOldSpelling red (field stays magpie/auto/glm-5-3-flash). - go test -timeout 45m: internal/catalog, provider, agent, tui, cli, usageapi ok. internal/gui: everything ok except TestMainWindowCorners/ macOS_26_SDK, which is #3949 (AppKit on macOS 27, nothing to do with this change). internal/gateway, codexcat, sessions ok. - gofmt -l clean; go vet darwin, linux -tags nogui, windows clean. - No GUI file changed, so the GUI suite wasn't run. Names reach it through /api/groups. Not tried: a real models.dev sync with real providers in a sandbox app. Groups whose first provider spelled a model differently from models.dev (e.g. claude-opus-4.8 from a relay vs Anthropic's claude-opus-4-8) get the models.dev spelling once. Magpie-set agent fields move with it, and values the user set keep resolving. A key or fallback chip saved under the old spelling still shows it in the editor (it still works). |
||
|
|
4054251865 |
library: an MCP server can be kept to this computer, never synced
huhuy72219405 on X: "能不能把不同设备的mcp区分一下,有些mcp属于本地的, 同步之后其他设备不应该读取到". A server in Library > MCP now has a "This computer only" switch in its editor (Server.Local; CLI `magpie library mcp add ... --local` and `magpie library mcp local <name> on|off`; the TUI keeps it on edit and marks the row). - Collect leaves local servers out (carriedServers), so neither a sync nor a backup file takes one to another computer. Turning a shared server local takes it out of what is carried, so the other computers drop it at their next sync; the flag itself is never carried. - Put (sync, join, Restore, Undo, backup file) keeps every local server, with its agents, and clears Local on what comes in. - Another computer's server by a local server's name goes to Library.Away: given to no agent, not in the hub, carried on as it came, so a push from here never removes it from the computers that have it. settleAway (every change) promotes it once the name is gone here, and drops it once the name is shared here again. - The hub serves local servers like any other (it runs here); subagents aren't carried, so one naming a local server keeps it. Docs: docs/subsystems/library.md, docs/subsystems/sync-backup.md. Run at |
||
|
|
2a1ef15ba9 |
routing: a found group's card leaves out a provider switched off, and counts it (XYenon)
XYenon on Discord (#feedback, 10-30): "已经关闭的提供商还会显示在路由页的 自动成组里是不是不太对". A provider switched off stays a member of the groups magpie found (#2671, on purpose: agents on auto-<model> aren't moved while it is off), and the gateway already skips it (membersIn reads only providers that are on; TestFoundGroupWithAProviderOff covers chat, and a fallback group, affinity and a group's classifier (decide_group.go) go through the same FindGroup). So no request reached it. What was wrong was the page: the card still listed it as "B · model (switched off)" and its logo sat in the group's icon stack, where every other model list leaves a provider switched off out. - Routing page (plugins/routing/client.js): a found group's card, its remove-picker row and its logos (groupIcons, also used by the group pickers) leave out members whose provider is switched off; a tag "{n} switched off" says how many, its title why (offWords). When none would be left they are listed as before. The editor and a manual group's pick still show them, greyed with why. A group of the user's is unchanged: it lists what they put in. - i18n: "{n} switched off" in zh, zh-TW, ja, de. - TUI (sibling): the routing list's line for a found group does the same ("N models · ... · 1 switched off"), and a group's page marks such a member "· switched off: skipped until it is on again" (any group). - docs/subsystems/providers-accounts.md: the row says it. Tests: routing-provider-off.test.cjs gains a found group (card text, tag text and title, no logo of the provider off, editor still has it) and one whose only member is off (listed as before, no tag); every language, 1100 and 420 wide, Chromium and WebKit. TestFoundGroupLineLeavesASwitchedOffProviderOut (internal/tui). Run on mote (mote-run, this tree): node --test of 45 GUI files (group-*, panel-routing*, routing-group*, routing-groups*, routing-provider-off, i18n-keys, found-*, remove-found*): 488/488 pass. go test ./internal/tui ok; go test ./internal/gui: all ok except TestMainWindowCorners/macOS_26_SDK, red on macOS 27 and already filed (#3949), an AppKit window test this change doesn't reach. gofmt -l clean; go vet ./internal/tui for darwin, linux (-tags nogui), windows ok. Broken by hand: with client.js from HEAD the new GUI case is red (expected 'A Cloud · luna', actual 'A Cloud · luna → B Cloud · luna (switched off)'); with listedMembers returning every member the TUI test is red ("2 models · ... pa/luna → pb/luna"). Not tried: the real app with a real provider switched off; the full GUI suite (1002 files) and the full go test ./... were not run. |
||
|
|
d3898ca8d3 |
provider: ChatGPT account calls go with Codex's headers, and saved accounts are listed once a day
Two follow-ups of 6e55914b6's audit of what magpie sends OpenAI for
idle saved Codex accounts (owl, Discord #general: three ChatGPT accounts
deactivated). Product call made by the session the owner delegated
product calls to; mimicking the official client is allowed for every
vendor but Claude Code. Identity, base_instructions and prompts are not
touched.
- Headers. GET /backend-api/wham/usage, /wham/rate-limit-reset-credits,
POST .../consume and POST auth.openai.com/oauth/token (live and saved
sign-ins, and the sign-in's code exchange) went with Go's
"Go-http-client/1.1" and no originator. They now carry Codex's
originator and User-Agent through codexClientHeaders, the part of
codexSign that /codex/models and /responses already used. No version
header on them: codex-rs sends it with model requests only
(login/src/auth/default_client.rs default_headers is originator +
User-Agent; backend-client/src/client.rs adds auth headers).
- Refresh body. codex-rs (main f32b6cfd and rust-v0.165.0,
login/src/oauth/client.rs refresh, auth/manager.rs
request_chatgpt_token_refresh) sends JSON client_id, grant_type,
refresh_token and refresh_reason, and no scope. magpie sent
scope "openid profile email" and no reason. It now sends codex-rs's
fields: proactive_expiry near expiry, unauthorized_recovery after a
401 (stale token), scheduled from the 8-day keep-alive, forced for an
import or a revoked-sign-in check. The code exchange's form already
matched exchange_code; only its headers changed.
- Model lists. The active Codex account's /codex/models fetch (hourly
KeepAccountsListed, FetchNew, Refresh) also fetched every switched-on
saved account's list each time. codexFetchSaved now asks one with no
list at once, and the others once a day, one per call, oldest asked
first; a failed ask is remembered so a deactivated account doesn't go
first every hour. The active account's list is unchanged.
Docs: providers-accounts.md says both.
Tests (codex_quiet_test.go), each red on the old behaviour (broken by
hand: wham/refresh/exchange headers removed, scope back, the age check
and the one-a-look cap removed, the keep-alive's reason dropped, and
separately the failed-ask memory skipped):
- TestCodexAccountCallsGoAsCodex counts the requests to a fake (usage 1,
credits 1, consume 1, token 2) and checks User-Agent/originator on
each and the refresh body's keys. Old: Go-http-client/1.1, "" and
scope in the body.
- TestCodexRefreshSaysWhy: scheduled, forced, unauthorized_recovery.
Old: no reason.
- TestSavedCodexListsOnceADay: 2 asks on the first look, 0 an hour on,
1 then 1 a day on, 0 again, and 0 within the day while failing. Old:
2 on every look; without the memory, a failing one asked again.
Run (mote-run, at origin/main
|
||
|
|
fb2e11e288 |
agent: a Codex sign-in OpenAI refused to refresh for good counts as none (#4308)
jjt on Discord: Codex's ChatGPT sign-in was revoked, and magpie's
models were gone from Codex until they signed in again.
Cause: Codex keeps a revoked sign-in's auth.json as it was and remembers
the permanent refresh failure in memory alone (codex-rs
login/src/auth/manager.rs). magpie read auth.json alone
(codexChatGPTKnown), counted the sign-in and wired Codex beside it
(openai_base_url, requires_openai_auth). There, Codex's /models went to
the gateway, which passed OpenAI's 401 token_revoked through, so the
picker had no magpie model; and every turn, magpie's models too, failed
at Codex 0.162.1's workspace routing discovery
(/backend-api/wham/accounts/check, 401).
Change:
- provider: codexRefresh tells a refusal Codex takes as permanent
(request_chatgpt_token_refresh: refresh_token_expired, _reused or
_invalidated, a 400 invalid_grant, or a 401 - here only a 401 that
carries an error code, read as oauth/error.rs reads it). When magpie's
own refresh of Codex's sign-in (codexTokenRenewing, from the usage read
that KeepOnAnAccountWithRoom runs) is refused that way, and the store
still holds that refresh token, codex-signin-gone.json keeps the Codex
home -> sha256 of the refused refresh token (no token stored). A
successful refresh forgets it. Writes Touch the catalog so the agents
resync; the loop's noteCodexGoneNow notices a sign-in made again
elsewhere within minutes.
- agent: codexChatGPTKnown reads such a sign-in as none
(provider.CodexSignInGone), as v0.1.2087 did for forced_login_method =
"api": magpie is Codex's provider without requires_openai_auth, the
user's auth.json stays. A record that can't be read is unknown (as
magpie last wired it). Signing in again gives another refresh token,
which the record doesn't name: Sync writes requires_openai_auth back.
- gateway: codexModels doesn't pass a revoked /models answer
(provider.SignInRevoked) through: it lists Codex's cached models and
magpie's. The desk file does the same while the live list says revoked
(CodexListRevoked). Any other refusal (token_expired, 5xx) is as before.
- docs: agent-wiring and gateway-routing.
Run:
- real codex 0.162.1 (app-server over stdio, and exec) on mote, sandbox
HOME/CODEX_HOME, fake OpenAI (chatgpt_base_url,
CODEX_REFRESH_TOKEN_URL_OVERRIDE, provider.CodexBase) answering 401
token_revoked and refresh_token_invalidated; no real network.
- Old wiring beside the dead sign-in, old gateway: model/list had no
magpie model (jjt's case). With the gateway change: fake/m1 listed,
but exec -m fake/m1 fails at workspace routing discovery (401), and
account/read errors too - why the wiring change is needed.
- Uncommitted e2e in the agent package with magpie's own written
config: Set("fake/m1") wrote it beside the sign-in; magpie's
LoginUsage("codex") then heard the refresh refused, Sync rewrote it
to model_provider = "magpie", model_catalog_json, no
requires_openai_auth. account/read: {"account":null,
"requiresOpenaiAuth":false}; model/list: fake/m1 plus Codex's
models; exec -m fake/m1 answered "hi from magpie"; auth.json byte
for byte the same.
- Red on the old code (broken by hand): without the codexChatGPTKnown
check TestCodexGoneSignInIsNoChatGPT is red; without the
noteCodexSignInGone call TestCodexSignInGoneWhenRefusedForGood is red;
with codexRefreshGone true for every failure TestCodexRefreshGoneRule
is red; TestCodexModelListRevokedSignIn and
TestCodexDesktopCatalogRevokedSignIn are red on the old gateway.
Taking out the store re-check in noteCodexSignInGone leaves the tests
green: a token Codex rotated meanwhile is already held by the hash
comparison, and the re-check only saves a needless record, log line
and resync. Not guarded on its own.
- via mote-run, at this commit rebased on origin/main
|
||
|
|
05a6087e1f |
access: a key with accounts and no model may use only its accounts' providers' models
Linka on Discord (#feedback): in a gateway key's "Models this key can
use", ticking only an account and no model let the key list and use
every model of every provider.
Cause: Key.Models empty meant "every model", and Key.Accounts (#905)
held only the providers it names, so every other provider stayed open.
Change: access.HeldModels gives a key with accounts and no models the
models "<provider>/*" of each account's provider. Authenticate builds
the Identity with it, so every route's existing model gate narrows:
/v1/models, /v1beta/models, chat, responses, messages, Gemini,
count_tokens, embeddings, images, the Codex backend path, System One,
groups and fallbacks. A key that lists models is unchanged (#905: its
accounts still hold only the providers they name); a key with neither
is unchanged. The CLI's MODELS column and `gateway-key models` say so,
and the GUI editor's hint, the "not used" notes on providers no model
or account reaches, and the save status follow (en, zh, zh-TW, ja, de).
Tests:
- TestGatewayKeyAccountsOnlyHoldTheModels: each route above is 403 for
the accounts-only key and no upstream call reaches the other
provider, the decider or the image provider; its own provider, a
group of it and a key that also lists models work. Red on the old
code on every route (list showed spare/m2, chat/count_tokens/
embeddings/systemone 200).
- TestHeldModels (access).
- gateway-key-accounts.test.cjs: hint, notes and status; 4/4 red on
the old assets, green on the new.
- TestGatewayKeyAccountsListModels / SystemOne / OfANamedProvider and
TestHeldKeyToldItsOwnQuotas now encode the new rule (the held key is
told only its own provider's quotas).
Run on mote: gofmt -l clean; go vet darwin, linux -tags nogui, windows
on access, cli, gateway, gui ok; go test -timeout 45m ./internal/access
./internal/cli ./internal/gui ./internal/gateway: ok except gui's
TestMainWindowCorners/macOS_26_SDK (#3949, not this change) and
gateway's TestHeldKeyToldItsOwnQuotas, updated and rerun ok. After the
rebase on
|
||
|
|
1f03d75462 |
claude bridge: a caller on another computer naming no folder is told the tools run elsewhere
packinggoods on Discord: magpie on a Windows machine, the agent on a Mac.
Every shell command came wrapped in PowerShell. The model's prompt held
Claude Code's own environment section from the bridge's run: "Primary
working directory: C:\Users\...\Temp\magpie-claude-work, Platform: win32,
Shell: PowerShell". That describes the gateway, and no tool of the run
runs there: every tool is the caller's.
Claude Code has no option to leave that section out. With the real
claude 2.1.312 against a capture server (sandbox HOME, fake key), it is a
<system-reminder> in the run's first message, before magpie's text, with
the default prompt and with --system-prompt-file alike; the SDK's
excludeDynamicSections only moves it there. claude.exe on xiaomi-gpu gives
the same section with the Windows platform, temp folder and OS version.
|
||
|
|
9101bb8879 |
privacy: a request masking would change can go as written to a model you picked
jessyoungyu on X: when a masking rule hits, send the request to a self-hosted model instead, so a prompt like 「百度这家公司怎么样」 gets an answer about Baidu, not about a placeholder. Settings › Privacy › Instead of masking, send to (settings redactRouteTo). It is Off by default, and nothing changes for a user who leaves it Off. It is picked in the app menu, and only models whose every route is unmasked can be chosen: the provider is set to Send requests unmasked, it is on this computer or the network, it has no account, and any fallback or group member is unmasked too (gateway.MaskRoute, the same rule as provider.SkipsRedaction). The setting is saved on its own with POST /api/settings/redact-route, which checks it with MaskRoute. The general settings save keeps the value. Decisions: - When a value would actually be masked on an agent's turn (maskHits.n > 0), serve sends the request to the chosen model unmasked. Warn-only hits don't count, and Block still answers 400. - If that model fails, the request fails. It is never masked and re-sent to the model the agent asked for, and never goes to a cloud model with the unmasked text. Falling back to a masked cloud request would answer a different question in the background. The user picked this route because masking breaks the answer. - Streaming works the same as on any route. - The route is checked again on every request. A model that is gone or no longer unmasked, or that the caller's gateway key may not use, means the request is masked as before. - Covered: agents' Messages, Chat, Responses and Gemini turns (serve, marked by serveAgent), count_tokens, Codex magpie-model turns, and Codex own-sign-in /responses (codexMaskRoute). - Not covered: magpie's own asks (ownAsk clears the mark), embeddings, audio, images and video. These stay masked. GUI: redactRouteRow lives in plugins/redact/settings.js and wraps renderRedact, so app.js is byte-for-byte unchanged and the core budget is not raised. Strings are added in zh, zh-TW, ja and de. Docs: gateway-routing.md, gui-shell.md, and site/public/docs masking (en, zh, ja). Tests: internal/gateway/mask_route_test.go (TestMaskedRequestGoesToTheModelSet: unset, set, streamed, nothing to mask, local fails, falls back to a vendor, no longer unmasked, count_tokens; TestCodexSigninTurnGoesToTheModelSet; TestMaskRouteTakesOnlyUnmaskedRoutes; TestMaskRouteOnlyForTheAgentsTurn); internal/gui/redact_route_test.go; settings_keep_test.go; internal/gui/tests/redact-route.test.cjs (every language, chromium and webkit, 1100 and 640 wide). Broken by hand, each red: - serveAgent without the agent mark; - MaskRoute taking any route (TestMaskedRequestGoesToTheModelSet, TestMaskRouteTakesOnlyUnmaskedRoutes; at the pushed head); - the codex hook removed; - count_tokens without the mark; - ownAsk not clearing it; - no key check; - no reroute in serve; - the GUI: no keep in the general save, no MaskRoute check on save, and the picker listing every model; - the plugin script left out of index.html (redact-route.test.cjs 22 of 24 red; at the pushed head). Run on mote: - at 221ede767's tree, this change on |
||
|
|
f5806ed21e |
agent: Codex's forced_login_method = "api" counts as no ChatGPT sign-in (Tiger)
Tiger on Discord: after restarting Codex the Codex app showed a sign-in screen whose only option was "Sign in with an API key", and they couldn't get back in. Cause: a top-level forced_login_method = "api" in ~/.codex/config.toml. Other tools and guides write it; magpie never has (git log -S). With it, Codex won't use a ChatGPT sign-in: the TUI logs it out as it starts (codex-rs login/src/auth/manager.rs enforce_login_restrictions) and the app server reads no account (load_auth). The app takes its allowed methods from configRequirements/read, which then says ["api"]. magpie read auth.json alone (codexChatGPTKnown), counted the sign-in, and wired Codex beside it: the built-in provider, which requires OpenAI auth. The app asked for a sign-in that only an API key could give. Fix: codexChatGPTKnown reads forced_login_method = "api" as no ChatGPT sign-in. magpie is then Codex's provider without requires_openai_auth, and Codex needs no sign-in for magpie's models. The user's line stays (magpie's default never overrides the user's value). Taking it out brings the ChatGPT account back: Sync writes requires_openai_auth = true again. connectinfo's codexChatGPT gets the same answer. Run: - real codex app-server 0.162.1 on mote in sandbox CODEX_HOMEs (stdio JSON-RPC: account/read, getAuthStatus, config/read, configRequirements/read). Beside a ChatGPT sign-in with forced api: account null, requiresOpenaiAuth true, allowedLoginMethods ["api"] — Tiger's screen. magpie as the provider, no requires_openai_auth, same auth.json: requiresOpenaiAuth false, and auth.json kept. - TestCodexForcedAPILoginIsNoChatGPT is red on the old codex.go (it wrote openai_base_url and requires_openai_auth = true beside the sign-in) and green with the fix. - via mote-run: gofmt -l; go vet ./internal/agent for darwin, linux (-tags nogui) and windows; go test -timeout 45m ./internal/agent ok (150.6s); ./internal/provider ok earlier on the same codex.go change. Not tried: the real Codex app (ChatGPT.app) against a running magpie built with this; managed requirements.toml / MDM allowed_login_methods and forced_chatgpt_workspace_id, which this doesn't read; a revoked ChatGPT sign-in (jjt's report): magpie still counts its tokens as a sign-in and wires Codex beside it, and the /models 401 there comes from OpenAI, passed through. |
||
|
|
ec789445db |
gui: Settings' session rows are the sessions plugin's settings.js; app.js back under its budget
|
||
|
|
af8f3a9399 |
sessions: a new install reads no agent's session history until the user allows it (RustCats on X)
RustCats on X: a fresh magpie showed every agent's session history on
the Sessions page before anyone agreed to it, and asked for a per-agent
choice instead.
- sessions.Reads(agent) (internal/sessions/access.go) is the one gate,
from settings.SessionReads {Asked, All, Agents}. Every lister asks it,
the aggregators (allFiles, callFilesWith, callSourcesWith,
traceLineFiles, wslFiles, DesktopDataDirs) filter by it again, and
readers of an already-listed session (TranscriptOf, ContentOf,
SearchSession, SubagentTranscript, CarryOver, ReadCallSource) return
ErrNotRead, so a cache from before a switch was turned off goes no
further. The Sessions list, stats, /api/sessions/overview, the call and
trace indexes, Usage's agent-file calls and the Codex/Pi title readers
all pass it.
- SettleReads decides once and saves: an install with sessions.json or
a calls-v* cache read sessions before and keeps all on; a fresh one
reads none, not asked. A saved value is never replaced; save, sync and
restore keep it (KeepOwn); only SetSessionReads writes it. An
unwritable settings.json reads nothing this run.
- GUI: GET/POST /api/sessions/reads. While not asked, the Sessions page
shows a consent card: each agent found (by a stat of its folder only)
with a switch, Allow selected and Allow all. Settings > Privacy >
Agents' session history has "Agents found later" and a row per agent.
Strings in en, zh, zh-TW, ja, de.
- CLI: magpie sessions read [on|off all|<agent>...]; magpie sessions
says on stderr when nothing is allowed yet; the TUI's empty Sessions
page says how.
Read either way, because none of it lists or shows a session: the
gateway's own usage ledger, its projections and the conversations it
recorded (magpie's own records, so usage and cost keep working); the
agents' config and sign-in files; Claude Code's and Codex's
history.jsonl last-used time and a session file's mtime for a quota's
first use; Codex's newest rollout's last line before magpie restarts
Codex (codexTurnOpen).
Tests: TestFreshInstallReadsNoAgentUntilAllowed,
TestSettleReadsKeepsWhatWasThere, TestSessionReadsRoutes,
TestSessionsRead, TestSessionsNotAskedSaysHow, sessions-reads.test.cjs
(26 cases: consent and Settings in 5 languages, Chromium and WebKit,
390 to 900 wide).
Run on mote:
- full Go suite (gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui,
GOOS=windows go vet, go build, go test -timeout 45m ./...) at this
change on
|
||
|
|
c46829e0b4 |
routing: a group's card says its classifier's failure only when that group asked it
jjt on Discord: the Routing card of "claude难易" (group/claude-ny), which
no turn of theirs was sent to, said "分类器3分钟前失败:claude/claude-haiku-5-5:
Claude Code: You've hit your weekly limit", read as magpie asking its
classifier at every turn. The card read the failure by classifier model
(ClassifierFailure), so every group sharing a classifier showed the
failure of whichever group had last asked it.
What runs the classifier was not changed: ruleFor asks it only for a
request whose model is the group (group/<id>, its name, or a stand-in an
agent's config names it by: Claude Code's tiers, Codex's bare name), or
for a group in it its rules or order put first (nestedRules). A request
for another model or group asks nothing. Out of quota, the classifier's
account rests until the reset (restAfter), so later classifier calls get
magpie's held refusal back, at most once each classifyRest (30s), and
do not reach the vendor.
Now ruleFor notes the outcome per group (classifiedFor) and the card
reads GroupClassifierFailure(group, classifier): the classifier's own
words and time (resting or not) from that group's last ask, cleared when
it answers that group, and nothing once the group's classifier changed.
Run (mote, macOS 27, Go 1.26.8), at base
|
||
|
|
4586307de5 |
gateway: Codex's own model on a thread started on magpie goes on Codex's sign-in, not a 404
iuengei on Discord: after turning Codex's routing off and restarting,
Codex's official models answered "unexpected status 404 Not Found: magpie
knows no model \"gpt-6.1-sol\"", in ChatGPT and Always ChatGPT modes too.
A Codex thread keeps the provider it was started on (the
[model_providers.magpie] table stays for that reason). A thread started
while magpie was Codex's provider (magpie API, or the takeover of a
used-up account) goes on sending to /v1 after Disconnect or a switch back
to ChatGPT. An official model picked in it reaches serve as a bare
"gpt-6.1-sol"; with no ChatGPT account in magpie serving it (the Codex
sign-in removed from Providers, or subscription accounts off) it was
answered 404. /backend-api/codex relays such a model on Codex's own
sign-in; /v1 never did.
Now handle (Responses) puts such a request on the ChatGPT backend's route
(codexBackend) signed with Codex's own ChatGPT sign-in as Codex keeps it
(provider.CodexSignInAsKept, never renewed by magpie), magpie's key and
x-openai-actor-authorization left behind (codexOwnOffMagpie). Only for: a
bare model no provider, group or stand-in serves, not disabled or
switched off; one of Codex's own (its models cache, magpie's entries left
out) or OpenAI's in the catalog; from Codex on this computer (local); no
gateway key held to models or accounts. When the sign-in can't be had
(subscription accounts off, signed out, expired) the 404 says the thread
was started on magpie, why the sign-in can't be used, and to start a new
thread. Codex's identity and prompts are untouched.
Tests (internal/gateway/codex_own_v1_test.go): the reporter's case, a
sandbox HOME with Codex signed in, gpt-6.1-sol in its models cache, the
sign-in removed from magpie's Providers, Codex's request to /v1/responses
with magpie's key: was 404 "magpie knows no model \"gpt-6.1-sol\"", now
200 from a stand-in ChatGPT backend that got Codex's token and account
id, not magpie's key or header. Not sent: from another computer, a key
held to fake/*, a model that isn't OpenAI's (still 404). With accounts
off, a 404 that says why.
Run (on mote, at this commit's tree rebased on
|
||
|
|
92f02d677b |
agent: a VS Code fork's own code launcher no longer lists it as VS Code too (ggbr on Discord)
Qoder IDE was listed twice, as Qoder and as VS Code. Qoder IDE ships a launcher named code in Contents/Resources/app/bin beside qoder (checked in the 2026-10-29 Qoder-IDE-darwin-arm64.dmg: product.json applicationName "qoder", nameShort "Qoder", com.qoder.ide), and its Windows installers put that bin folder on PATH. VS Code's detection falls back to a code on PATH, and vscodeCodeBinary ruled out only a product.json naming Cursor (#931), so any other fork's code counted as VS Code. The class fix: a code, code-insiders or codium launcher counts as VS Code, Insiders or VSCodium only when the product.json beside it (app/product.json, or resources/app/product.json on Windows and Linux) names that build in applicationName. With no applicationName, nameShort must be one of VS Code's own (Code, Code - Insiders, Code - OSS, Visual Studio Code, VSCodium). A wrapper with no readable product.json keeps the PATH fallback as before. This covers Cursor, Qoder IDE, Windsurf, Trae, Kiro, CodeBuddy, Antigravity and any other fork, on the mac, Linux and Windows layouts. A VS Code User folder still detects VS Code by itself: a user who has both has both rows. Run: - TestVSCodeDetected gains rows for Qoder (mac with the real build's product.json, linux, windows, symlink), Windsurf, Trae, Kiro, CodeBuddy, Antigravity, an Insiders product behind code, and nameShort-only products; TestVSCodeBuildLauncher checks each build's own command. Broken by hand: with the old vscode.go, 11 of the new TestVSCodeDetected rows fail (mac/linux/windows qoder, qoder symlink, windsurf, trae, kiro, codebuddy, antigravity, insiders product, qoder name). - Real Qoder IDE: on mote, the dmg's bin folder alone on PATH, vscodeCodeBinary(".../Qoder IDE.app/.../bin/code") = false and VS Code not Detected. - gofmt -l clean; go vet ./internal/agent for darwin, linux (-tags nogui) and windows on mote. - go test ./internal/agent -timeout 45m on mote: ok (171.6s) at this change on base |
||
|
|
f11bf27c1f |
video: a plugin's model that gives video makes videos through its fetch on the account
XYenon asked for video for account-backed plugins: customVideomakers
left out every provider with an Account. A plugin's model that says it
gives video (capabilities.output.video / modalities.output) is now a
video maker (the Grok plugin keeps its own). Start, poll and content go
OpenAI-shaped to <base>/videos, /videos/{id} and /videos/{id}/content
through the plugin's fetch (videoBase now takes Provider.OpenAIBase,
the Chat base for any other provider). The video's id names the account
that started it (keyMark: "a" + signer), and markedKey asks after it on
that account of the plugin's (AlsoOn), as a key provider's videos are
asked on their key. Account and model holds (videoAsker,
videoModelHeld) and the start's usage row are the existing paths'.
Test: TestPluginMakesVideos (fake $FAKE_VIDEO, two accounts): started
by a key held to the second account, polled and fetched on it, a key
held to the first gets 403 on the poll, a key held to other models 403
on the start and the poll; the start is in the ledger. Broken by hand:
with the old video.go the video makers are empty (red); without the
account mark the poll goes to the first account and the content is
refused 403 (red).
Run on mote: gofmt -l clean; go vet ./internal/gateway ./internal/provider
./internal/plugin for darwin, linux (-tags nogui) and windows; go test
-count=1 -timeout 45m ./internal/gateway ./internal/plugin
./internal/provider ok at the tree of the video commit (
|
||
|
|
6cb73ec4f0 |
gateway: embeddings and speech reach a plugin through its fetch whatever API its chat is on
XYenon asked how /v1/embeddings and /v1/audio/speech reach a plugin whose models are all on Gemini's API. serveRetrieval sent them under the provider's Chat base, which a plugin has only with an @ai-sdk/openai-compatible model, so such a plugin was turned away 400 "has no OpenAI-style API". Provider.OpenAIBase is plugin://<id>/v1 for a plugin (the Chat base for any other provider), and serveRetrieval (embeddings, rerank, speech, transcriptions, translations) sends under it: the request reaches the plugin's fetch OpenAI-shaped at <base>/embeddings or /audio/speech, with the model's own id, for the plugin to put in its vendor's shape. magpie converts none of them to Gemini's embedContent or TTS; the plugin owns its vendor's protocol. Key holds, account holds, masking and usage are serveRetrieval's, as before. Test: TestGooglePluginTakesEmbeddingsAndSpeech (fake $FAKE_GOOGLE: every model on @ai-sdk/google, with $FAKE_KINDS' embedding and TTS): both reach the vendor through the fetch, both are in the usage ledger, a key held to other models gets 403 on each. Broken by hand: with the old Base(provider.Chat) it is red (400 "has no OpenAI-style API"). Run on mote: gofmt -l clean; go vet ./internal/gateway ./internal/provider ./internal/plugin for darwin, linux (-tags nogui) and windows; go test -count=1 -timeout 45m ./internal/gateway ./internal/plugin ./internal/provider ok at the tree of the video commit ( |
||
|
|
e2b7233499 |
draw: a plugin's Gemini image model draws on generateContent through its fetch
XYenon (magpie-google-ai-studio, Discord) asked how a plugin's image models reach /v1/images/generations and /v1/images/edits. A plugin's model on Gemini's API (@ai-sdk/google) that says it gives images (capabilities.output.image / modalities.output), or is named for them, is now a drawer: Drawers lists it, and draw sends it to drawCodeAssist (pluginDrawsGemini), as a Google sign-in's image models are drawn. That asks generateContent with responseModalities ["TEXT","IMAGE"] through the plugin's fetch, an edit's pictures as inlineData, and reads the pictures from the answer. Request.draws asks for the IMAGE modality of a model not named for images. Imagen (catalog.ImagesAPI, :predict) is left out. The OpenAI-compatible plugin path (SenseNova) is unchanged. Test: TestGeminiPluginDraws (fake plugin $FAKE_GEMINI_DRAWS: a model named for images, one that only says it gives them, an Imagen). Broken by hand: with the old draw.go the drawers are empty (red); with the old codeassist.go the declared-only model is sent no responseModalities (red). Run on mote: gofmt -l clean; go vet ./internal/gateway ./internal/provider ./internal/plugin for darwin, linux (-tags nogui) and windows; go test -count=1 -timeout 45m ./internal/gateway ./internal/plugin ./internal/provider ok at this commit on its first base |
||
|
|
172e65c80b |
agent: a Windows app closed to the tray is ended at once on Restart, not after 10s
CyberCaius on Discord (10-29): magpie's Restart of Claude Desktop on
Windows is slower than quitting and opening it by hand. The cause:
RestartApp asks the app's windows to close (taskkill without /F), then
waited up to appCloseWait (10s) for every claude.exe to end. Claude
Desktop on Windows hides its window to the tray in ~0.6s and keeps all
its processes, so every Restart sat out the whole 10s before ending the
tree.
waitClosed now also watches the windows (winShown, EnumWindows +
IsWindowVisible over the app's pids): once every window is hidden and
the app still runs appTrayGrace (1s) after the close, it is in the tray
and its tree is ended at once. An app still showing a window (a
question) keeps the full appCloseWait, and one that ends by itself in
the grace is never ended. When the windows can't be listed, it is
treated as shown (the old wait). The Windows part of RestartApp moved
into restartWin, unchanged otherwise.
Measured on the Windows box (xiaomi-gpu, Squirrel Claude Desktop
4.29.0, run in the interactive session through a scheduled task), the
real restartWin path through a test binary, 3 runs each:
before (tray grace off): returned 10.87-11.10s, window back 11.4-11.7s
after: returned 1.88-2.16s, window back 2.4-2.8s
A forced kill and relaunch by hand: ~1.6s. A PowerShell emulation of the
old path on 2.9939.2 earlier: WM_CLOSE hid the window at 0.6s, 9
processes stayed, all gone only after the 10s kill (12.3s total).
Run:
- TestRestartEndsAppInTrayAtOnce (new): tray / asking / quits-itself.
With the winShown check removed by hand, the tray case went red
(took 3.01s, want under 2s).
- mote: go test ./internal/agent -count=1 -timeout 45m: ok (174s).
- win-run: TestRestartEndsAppInTrayAtOnce, TestWorkBuddyRestartOnWindows,
TestRestartAppsOnWindows pass. The -run Restart|ChangedAt|WorkBuddyOwnSave
set has TestWorkBuddyOwnSaveAfterStartIsNoChange red on Windows, red
the same on untouched origin/main
|
||
|
|
fd5c631cbe |
image mcp: generate_image and generate_video take the model to use (XYenon)
XYenon on Discord asked whether an agent can pick the model magpie's image/video MCP draws with. Both tools now take an optional `model`, as provider/model: - The schema lists the models that may be asked (the Settings default first, then each on provider's OfferedDrawers or Videomakers), only those the calling gateway key may use. Up to 40 of them form an enum; past that, the description names three. - Left out, the Settings default is used, as before. - A bare id only one provider has, a ChatGPT account's other GPT Image name (ListedDrawer), or a newer family model (drawsFamily, grokVideoFamily) is accepted. Anything else is a tool error naming the models the key may use, and nothing is drawn. It never falls back. - The chosen model goes into the images/videos request's `model`, so the APIs' own key check (keyHolds, keyModelError, #882) refuses one the key may not use: the same check /v1/images makes. - The stdio Magpie Image server copies the gateway's `model` property from its tools/list, and asks the hidden JSON-RPC method magpie/media_model which model a call means. An older gateway (-32601) passes the model through as named. - `magpie tool generate_image --model ...` works through the schema; the usage text says so. Docs: gateway-routing.md (image MCP section), reference.md. Run (mote, via mote-run, at this tree): - gofmt -l: clean. - go vet ./... for darwin, GOOS=linux -tags nogui, GOOS=windows: ok. - go test -count=1 -timeout 45m ./internal/gateway/ ./internal/imagemcp/ ./internal/cli/: ok. Broken by hand: with `req["model"] = ref` dropped in imageMCPDraw and imageMCPFilm, TestImageMCPDrawsWithTheModelAsked, TestImageMCPModelHeldToTheKey and TestImageMCPVideoModelAsked go red (the default was drawn instead); restored, they pass. Not tried: a real vendor account. The fakes are easeled's art provider and the fake Grok. GUI files not run: no GUI file changed. |
||
|
|
ba3a7384fb |
gateway: a Responses request may name the response it follows (previous_response_id, kevinzhow on X)
kevinzhow on X: magpie didn't support previous_response_id on /v1/responses, so every turn carried the whole conversation, images included, and each turn was slow. Before: magpie kept no responses. previous_response_id went on as sent, so a provider that never made that id (or a route that translates to Chat or Messages) had nothing but the new input to give the model. After (prev_response.go, run in serveAgent before anything reads the body): - Each Responses reply passed with 200 (not failed/cancelled, not cut at 64 MB) is kept by its id with input + output, in memory, LRU to 256 MB of own bytes, 6h TTL. store:false keeps nothing. - Kept per caller (prevScope): gateway key, remote magpie, keyless remote address. Another caller naming the id is told it isn't there. - A kept id expands the request to the whole conversation, so routing, translation and masking see what they would have seen had the client sent it all. Masking runs on each request as it goes (deterministic placeholders), so a stored secret is masked the same on every turn; TestPreviousResponseMasked. - An unknown id gets OpenAI's 400 previous_response_not_found on a route that translates (and on Claude/Codex accounts), before anything is sent. A Responses relay is sent the id as it came. - Where the provider keeps responses itself (prevKeeps: API key, no plugin; api.openai.com, Azure, or Ark /api/v3 pay-as-you-go) and it answered the previous turn on the same key, with store not off, only the new input goes with the provider's own id (prevDelta). A provider that says it doesn't know the id (prevRefused) is sent the whole conversation at once. Codex: its HTTP ResponsesApiRequest has no previous_response_id; only the websocket's ResponseCreateWsRequest has it (openai/codex 9def09a, codex-rs/codex-api/src/common.rs:341, client.rs:2284). Over HTTP it sends store:false with the whole input, so nothing it sends or keeps changes. No prompt is touched. Ark checked with a real pay-as-you-go key (10-29): store:true then previous_response_id returned the stored word; an unknown id answers 400 InvalidParameter.PreviousResponseNotFound (param previous_response_id), which prevRefused matches. Tests (prev_response_test.go): GivenWholeToChat (3 turns), NotFound (unknown, other key, no key, store:false; upstream not called), UnknownPreviousResponseRelayedAsSent, KeptUpstreamSentNewInputOnly (200 KB image; delta < 2000 bytes; refusal retried whole), Masked, PrevStoreBounded. Broken by hand, each red, then restored: - previousResponse a no-op: GivenWholeToChat, NotFound, KeptUpstream, Masked red. - prevDelta off: KeptUpstream red (200355 bytes sent, no prev id). - prevRefused always false: KeptUpstream red at the retry turn (400 relayed). Timings on mote (BenchmarkImageRequest / BenchmarkPreviousResponseTurn, 8 images, 20.18 MB conversation): - whole Responses -> Responses: 277 ms, 145.6 MB/op before; 263 ms, 145.6 MB/op after (a first version that json.Unmarshal'd the input cost 364 ms and +20 MB; it now reads items over the body's bytes). - whole Responses -> Chat: 273 ms before, 224 ms after. - previous_response_id to a provider that keeps responses: client sends 82 B, upstream gets 122 B (was 20.18 MB each way), 309 ms locally. - previous_response_id to Chat: client sends 83 B, upstream gets the whole 20.18 MB, 295 ms. Run at this head on mote: gofmt -l clean; go vet ./internal/gateway for darwin, linux, windows ok; go test -count=1 -timeout 45m ./internal/gateway ./internal/redact: gateway ok (464.4s), redact ok (1.8s). Not tried: a real OpenAI or Azure key (Ark's real key only); Ark's Coding Plan Responses path (not in prevKeeps). The store is in memory, so ids are lost on restart (a translated route then answers 400, a relay passes the id on). A kept-id request is still read and masked whole on this computer before the delta is cut (~300 ms local for 20 MB). Doc: docs/subsystems/gateway-routing.md, "A Responses request that names the response it follows". |
||
|
|
8e5567161e |
settings: an older settings.json with no Dock choice keeps Hide
v0.1.2060 ( |
||
|
|
66b5e4a844 |
provider: every request to a Remote magpie carries the provider's Headers; its key always goes as x-api-key (Yirasumi)
Yirasumi on Discord: with a Remote magpie behind something that wants
its own header, chat worked but the Usage page's read of the remote went
without the provider's Headers. remoteJSON (the remote's cards, a card's
refresh, its quota history) and askRemoteKeyLimit (each gateway key's
limit) set only Authorization: Bearer <key>.
- signRemote puts the provider's Headers on those four, as Sign and
listHeaders already did for API requests and the model list. They are
no turn of a conversation: ${sessionId}/${threadId} are an id of their
own (SentHeaders with no conversation, v0.1.2058's path).
- Auth, decided: the key always reaches a remote magpie as x-api-key
(remoteKey), which a magpie gateway reads beside Authorization. A
user's Authorization (a proxy's own scheme) goes in place of magpie's
Bearer copy, as it already did on API requests and the list, without
taking the key away; a user's x-api-key is never sent to a remote
magpie. Sign now adds x-api-key for a remote magpie on every API (it
had it on Messages only), and listHeaders drops a user's x-api-key, so
a user's Authorization no longer leaves chat or the list without the
key, and each key's limit is read with that key.
- docs/subsystems/providers-accounts.md: a "remote magpie's headers" row.
Other requests to a remote magpie (every API, count_tokens, System One,
images, videos, embeddings, searches) already go through Sign; the model
list through listHeaders. No other request to one was found
(grep of p.Anthropic+, /v1/magpie/ and IsRemoteMagpie callers).
Run on mote at this head (rebased on
|
||
|
|
1407c9a3bb |
gui: the Mac's window is in the Dock and Command-Tab while it is open, by default (ShouguangCao on X)
ShouguangCao on X: on the Mac, with the window (Settings) open, magpie wasn't in Command-Tab, so going back to it to paste an API key copied in another app took the menu bar. Cause: Settings > Show in Dock already had "With window" (#101: Regular activation policy while the main window is up, Accessory once it closes, in openMain/hideMain through inDock and setDock), but the default was Hide, so out of the box magpie stayed Accessory with its window open. The main window is magpie's only window besides the tray panel, so no other window kind needed it. Change: With window is now the default. inDock is `s.Dock || !s.DockNever && shown || fullscreen`; Hide is a choice of its own, settings.DockNever (KeepOwn, like Dock and DockWindow), and the page reads the choice through dockChoice (With window unless Show or Hide was chosen) and saves dockNever with it. DockWindow is still written when chosen, so an older magpie reading the file keeps With window. The tray panel never calls dock(), so it is unchanged; Windows and Linux have no Dock (setDock is a no-op there) and are unchanged. For existing users: Hide was the default and was stored as nothing, so a user who picked Hide before can't be told from one who never chose; both now get With window, and choosing Hide again sticks (dockNever). Run on mote at origin/main |
||
|
|
810a4144fe |
catalog: a model's Same as gives it that model's window, levels and images; a channel's tag in brackets is read past (pinmmis on X)
pinmmis on X (tweet 2115776439341506603): the same model from several
relays, each renamed to be told apart ("ds.4.1(WB)" for
deepseek-v4.1-flash), had none of models.dev's specs, and setting each
spec by hand per model was the only way.
The ids are the relay's own (magpie looks up the model's id, not a
display name), so this is not a display-name bug. The editor's
per-model "Same as" (settings' ModelSameAs) already merged routing
groups and priced the model; now it also gives the model that model's
window, reply limit, reasoning levels, thinking and images:
- catalog.UserSame, set by the settings package (sameas.go,
sameAsBare: ModelSameAs indexed by bare model id, memoised per
shared map), is asked by contextIn/lookupIn after the id as given
and before magpie's own guesses (renamed, normalFor). An id
models.dev lists stays its own; the user's own window, output,
levels and images settings still win (callers read them first).
The model named is looked up once, never sent back to UserSame (no
loops). KnowsAsWritten (usage telemetry) never hears it.
- Zero-config part: those lookups also read past a channel's tag in
brackets at an id's start or end (untagged: "deepseek-v4.1-flash
(WB)", "[WB] ...", fullwidth and CJK brackets). A "[...]" written
onto the id with no space is not a tag ("deepseek-v4.1-flash[fast]"
may be a variant, TestRenameNeverTakesAModelForAnother). Prices are
never borrowed this way (TestOtherSpellingIsNotPriced's rule); a
Same as's price is still SamePriceIn.
- "ds.4.1(WB)" itself is not guessed: ds/4.1 could be flash or pro.
- GUI: the Same as box's tooltip says what it now covers, in every
language; provider-same-as.test.cjs checks every language, not zh
only. No layout or API change.
- docs/subsystems/providers-accounts.md says it.
Run on mote via mote-run:
- at the same change on
|
||
|
|
2d11cde056 |
provider: ${sessionId} and ${threadId} in a provider's Headers are the conversation's ids
Axel Burks on Discord (#feedback): his gateway in front of several Azure
accounts routes one conversation to one account by a session header, so
its reasoning can be read back. ${sessionId} was expanded only in Extra
body; in Headers it went out literally.
Now Sign expands ${sessionId} and ${threadId} in header values
(Provider.SentHeaders, conversation.go), with the id Extra body gets:
the agent's session header, else the id derived from the first user
message. The gateway carries it to Sign in the request's context
(WithConversation), on every API and count_tokens.
- ${threadId} is Codex's thread_id (turn metadata or thread-id header,
threadOf), which a subagent has of its own while sharing its lead's
session_id. No other agent names a thread; there it is the session's id.
Supported in Extra body too. Read only when a header or Extra body
names it (AsksThread).
- A request that is no conversation turn (model list, balance, embedding,
image, Azure/Kilo lists, a remote magpie's list) gets an id of its own,
"magpie-" and 12 random letters; Test and Detect use their
magpie-test-… id in headers and body alike. A literal placeholder is
never sent.
- Control characters (CR, LF, tab, NUL, DEL) are stripped from ids in a
header (headerSafe); with a CRLF id Go used to fail the request 502.
- GUI: Headers and Extra body hints name both placeholders, in en, zh,
zh-TW, ja, de. docs/subsystems/providers-accounts.md has a Headers row.
Run on mote at this head (rebased on
|
||
|
|
2c89794acb |
gateway: a provider's fallback gives the conversation back once the provider is ready (01huadalang)
01huadalang on Discord (#feedback): once a provider's main model works again, a conversation that went to its Fallback while it was down stayed on the fallback, with no switch to stop it. affine treated the fallback as any answerer: Auto kept it while its cache was worth reading (each turn read it again, so it never went cold), Session for the session, and a rotating provider's new turn went to the one after the fallback. A provider's fallback is now its emergency path. When the last answerer is a Fallback row and the provider's own model stands first in the plan, ready (restLast put it ahead, so its rest is over), the next turn goes to the provider (backToMain, Affinity.Why "main"), in every mode but Strict, which the user set never to move a conversation. Within a turn the conversation stays on the fallback until the user speaks again: the turn's tool loop runs on reasoning the fallback sealed, which the provider can't read, and the provider is sent the whole prompt afresh at the next turn either way. A routing group's members are never Fallback rows, so a group's own affinity is unchanged. No switch was added. "Ready" is unchanged: a rest ends when restAfter set it to (a minute and backing off for a plain failure; the vendor's reset or Retry-After for a quota or rate limit; quotaRest 15 minutes when nothing names a time), or earlier when renewed or a background probe lifts it. docs/subsystems/gateway-routing.md says this beside Strict. Run (mote, at this commit's tree on origin/main |
||
|
|
13b4a29ab9 |
gateway: Claude Code's tier calls in a Desktop chat on a non-Claude model go to that model (CyberCaius)
CyberCaius on Discord: Claude Desktop's Code tab was on Leee's DeepSeek V4.1 Flash, no tier picked in magpie, and Claude Code's own sonnet call (claude-sonnet-5-5: its auto mode's classifier or a subagent on the sonnet tier, which Desktop leaves at Claude Code's default while no model is tagged for it) went to Leee's claude-sonnet-5-5, which Leee's key may not use: 403, and the error reached Desktop. servedBeside kept such a call on the chat's provider and gave it that provider's Claude model of the tier (its model of the very name first). That fits a chat on that provider's Claude model (#2187: the classifier's sonnet beside an opus chat), but a chat on another vendor's model says nothing of the provider's Claude models, so the user never picked one. Now a call Claude Code makes on its own gets the provider's Claude model only when the chat's model is a Claude model there; otherwise it goes to the chat's model. Desktop's own client is unchanged (its tool-less non-title request is the user's chat turn). A tier the user picked now also takes Claude Code's own id of it where a provider lists a model by that name (before, desktopTierTurn took only an id no provider serves). Claude Desktop's tiers are its own (claude-desktop.tiers.json), apart from Claude Code's agent card; Claude Code CLI is untouched. The Agents page's "Not set" note for Desktop's tiers says the new rule, in en, zh, zh-TW, ja and de. Run (mote, via mote-run): go vet ./internal/gateway ./internal/agent for darwin, linux (-tags nogui) and windows: ok. go test -timeout 45m ./internal/gateway ./internal/agent: ok (519s, 176s). node --test desktop-tiers.test.cjs i18n-keys.test.cjs (chromium and webkit, en and zh): 17/17 pass. gofmt -l clean. Broken by hand: TestClaudeDesktopNonClaudeChatKeepsTierCalls against the old desktop.go is red on all 6 cases (sonnet, haiku and opus[1m] sent to leee/claude-*). Not tried: a real Claude Desktop; the reporter's Leee key. |
||
|
|
3ce2a9819f |
library: RTK for agents in WSL, with the distro's own rtk (lex on Discord)
lex: Claude Code and other agents in WSL couldn't use the RTK of magpie
on Windows. rtkAgents looked an agent up in rtkSpecs by its whole id, so
claude@wsl:Ubuntu never matched and WSL agents weren't on the RTK page at
all. Even matched, the specs read this machine's home, and Windows' rtk.exe
is no command inside the distro, where the hook runs.
Now an agent is looked up by its kind (rtkKind). One in WSL:
- has its files read and written under the distro's home as magpie opens
it (rtkClaudeDir, rtkCodexDir, rtkHome), with blocked/version checks
against the distro's rtk and OpenCode;
- uses the distro's own rtk: rtkDistroOf asks the distro (wsl.exe -d <d>
-e sh -lc) where rtk is on its shells' PATH, else in ~/.local/bin or
~/.cargo/bin (offPath), kept 15s; ReadRTK lists one RTKDistro per distro;
- switching on runs that rtk there (rtk init -g ..., its folder on PATH);
- Install RTK in WSL <distro> (POST /api/library/rtk/install {distro},
magpie library rtk install <distro>) runs RTK's own Linux installer in
the distro (curl, or wget).
A distro that isn't running is never started (#3896): its agents are
listed asleep with the switch off, and switching or installing says to
start it. The page has a card per distro (install, off-PATH, asleep) and
uses the distro's rtk for each WSL row's tags and switch; strings in zh,
zh-TW, ja and de. The install route now refuses a body it can't read
instead of installing on this computer.
Run:
- mote (macOS 27), at origin/main
|
||
|
|
2768f04f9b |
gateway: a thread switched off a used-up Codex model compacts locally (hiwise_aigc)
hiwise_aigc on X (2115741641017565304): with Codex's allowance used up,
an existing thread switched to a magpie model failed every turn and
"还会走gpt模型", restarts or not; a new thread worked.
Cause, from codex-rs: before a turn on a model with a smaller window
(or a changed comp_hash), core/src/session/turn.rs
maybe_run_previous_model_inline_compact compacts the thread on the
PREVIOUS model (gpt-5.5) through the current provider, turn metadata
compaction.reason "model_downshift" / "comp_hash_changed", phase
pre_turn. compact_model_fallback.rs retries with the turn's model only
when the provider is_openai() (name "OpenAI"). Under the takeover
provider "magpie" there is no fallback: /v1/responses resolved bare
gpt-5.5 to the used-up codex account, codexCompact returned its 429,
and that was the turn's error, every turn. A new thread has no previous
model, so no compaction.
Fix: codexCompact, off CodexPath only, reads the compaction reason from
x-codex-turn-metadata (header, else client_metadata in the body). For
model_downshift / comp_hash_changed, a failed, errored or empty
compaction on the old model is answered with localSummary (magpie's own
magpie1 summary, no model), so the thread goes on on the model it was
switched to. The held-account check doesn't short-circuit it either.
context_limit (the thread's own model out of room) still says the
refusal, and CodexPath is left alone: Codex's "OpenAI" provider falls
back to the turn's model itself and gets a better summary there.
Prompts and base_instructions are not touched.
Run:
- TestCodexLeavingModelCompactsLocally: red on the old code (429 at
codex_leaving_model_test.go:84), green now.
- Broken by hand: without the body client_metadata fallback the
header-less case goes red; without the CodexPath scope the CodexPath
case goes red (got 200).
- Sandbox repro (sandbox HOME + CODEX_HOME, fake upstream, live ~/.codex
untouched): codex 0.162.1, takeover-like config with
remote_compaction v2 and a model catalog (gpt-5.5 400k, magpie-x
128k), a gpt-5.5 thread relabelled to provider magpie, resumed on
magpie-x: POST /v1/responses model gpt-5.5 + compaction_trigger,
reason model_downshift; a 429 failed the turn ("Error running remote
compact task: You've hit your usage limit"); answered with a
compaction item, as the gateway now does, the turn went on to
magpie-x and completed. ChatGPT.app's bundled codex has the same
model_downshift / comp_hash_changed path (strings).
- gofmt -l clean; go vet ./internal/gateway on darwin, GOOS=linux
-tags nogui and GOOS=windows (mote).
- go test -timeout 45m -count=1 ./internal/gateway ./internal/codexsummary
on mote at this tree (parent
|
||
|
|
f6263439af |
gateway: serve OpenAI's text to speech, POST /v1/audio/speech
liuyuexue2020 on X (tweet 2115742181734445238) wanted audio models
(Mistral among them) behind magpie, and the gateway had no
/v1/audio/speech.
POST /v1/audio/speech (and the bare /audio/speech) takes OpenAI's JSON
body and goes through serveRetrieval, as transcriptions (#2053) and
embeddings do: routed (a group's members, a provider's keys and
accounts, pause rules, key limits), metered against MaxRPM, recorded
(usage operation "speech", Routing, recent calls). Only "model" is
rewritten to the provider's own id; every other field goes as sent, so
Mistral's voice_id and ref_audio pass too.
The answer is never held whole: a speech request's 2xx answer is left
unread by the new retrieveOpen (retrieveAs now wraps it) and copied to
the client as it comes, flushed per read, in the vendor's own
Content-Type: audio (mp3/opus/aac/flac/wav/pcm), SSE for
stream_format=sse, or a vendor's JSON (Mistral answers
{"audio_data": base64}). No Accept: application/json is sent for it.
The usage in SSE's speech.audio.done event is counted from the last
16KB. A vendor's error is read and passed on as before, and a failing
member still falls over to the next.
Masking: "input" and "instructions" are masked as the settings say,
as text (maskTextHits), each where it sits; nothing else in the body
is (voice, formats, a voice-cloning clip are no text of the user's).
Nothing is put back: the answer is audio, so a masked value is read
aloud as its placeholder (docs/reference.md says so).
Mistral: its API has POST https://api.mistral.ai/v1/audio/speech
(voxtral-mini-tts-3-0), at the OpenAI path but not OpenAI's shape:
voice_id instead of voice, and JSON {"audio_data": base64} back, not
raw audio. Both pass through as sent; a client must speak Mistral's
shape to it. OpenAI, Groq and other OpenAI-style TTS vendors (vLLM-Omni
included) are served as they are.
Also: the 404 message's list, /v1's "apis", remote_magpie's suffix
list, cors_test and lan_test route lists, docs/reference.md,
gateway-routing.md, plugin-runtime.md, site remote.html (en/zh/ja).
Run (mote-run, at this commit):
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go build ./...: ok; gofmt -l clean
- go test -timeout 45m -count=1 ./internal/gateway ./internal/provider at 7bc52d44e^{tree} (= this tree, origin/main
|