6b3ee5a03bd32bdf584e793de79c8dabfea463dc
785
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d9e87eb328 |
gateway: clients opt into Claude subscription cache marks and TTLs (#1717)
Problem: Messages clients need control of cache boundaries and TTLs when a Claude subscription answers. Ordinary clients must retain their run identity, prompt and environment. A routing group's API-key member keeps its marks and must not report the subscription bridge's drops. Change: Select client-owned marks only with X-Magpie-Cache-Marks: client. Map system and fresh-history boundaries and the request tail, default missing TTLs to 5m, validate slot and TTL order, and separate opted-in run identities. Retain prefix constraints across live and saved runs. Report unmappable marks only for the Claude subscription try. Bound its selection hold to two seconds and clear the report and hold for a non-Claude fallback. Check ordinary identity bytes without a version-specific hash golden. What was run: Sandbox HOME, nogui: go vet ./... on darwin; gateway vet with GOOS=linux and GOOS=windows; full gateway tests; focused cache and usage tests with -race. gofmt and git diff --check passed. The group probe failed before the fix with tools:1 on the API-key reply in both routing orders and both stream modes. Hand-broken candidate scoping, stale report clearing, keepalive holds and ordinary identity bytes each failed behavior tests. Live, Claude Code on a Claude subscription and an Anthropic API key, through a recording proxy: in a group whose API-key member answers, in either order and both stream modes, the reply has no dropped-mark header and upstream receives the tool mark; a Claude answer reports tools:1; a failed Claude try followed by an API-key answer leaves no report. With a delayed API-key reply, the group's first keepalive came 0.85 s after a direct request's. Without the header, the outgoing request equals one from a gateway built at the same base. No GUI or real Linux/Windows execution. |
||
|
|
a15e576564 |
agent: OpenPencil uses magpie's models (@JC_be_better on X)
OpenPencil (ZSeven-W/openpencil, the openpencil-desktop app) keeps the builtin agents its chat runs on in settings.json under Rust's dirs::config_dir()/openpencil (read from its settings_io.rs and settings_payload.rs). magpie adds one builtin_agents entry, id "magpie", kind openai-compat at the gateway's /v1 with the magpie-openpencil key, preset custom, the picked models as OpenPencil writes a list: the first as `model`, `models` only for two or more, at most 64. The user's other entries and settings stay, and so do the display_name and enabled they give magpie's entry; a sync with nothing to change doesn't write. A file magpie makes gets "version": 1 (OpenPencil sets a file without it aside as corrupt); a file with another version, or none, is left alone. Disconnect takes the entry out, and the file when nothing else is left. OpenPencil reads the file once at start and writes it all back when it quits, so a change is refused while openpencil-desktop runs (Windows can't be asked, so the notice says to quit it first). Notice translated in zh-CN, zh-TW, ja and de. README (en, zh-CN), docs/reference.md and docs/subsystems/agent-wiring.md list it. open-pencil/open-pencil, the other app of the name, keeps its providers in its webview's localStorage, so it gets no row. Run, under a scratchpad HOME with GOCACHE/GOMODCACHE pinned: - go test -p 2 -tags nogui -count=1 -timeout 45m ./...: ok, 66 packages ok, 18 with no test files - gofmt -l: clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean - go test ./internal/agent -run '^TestOpenPencil': ok - node --test agent-notice-lang, i18n-keys, header-relang (Chromium and WebKit, every language, wide and narrow): 37/37 pass Broken by hand, each went red: the running check, the 64 cap, the version check, keeping the user's display_name, the no-op sync, and writing the version into a new file. Real use: OpenPencil v0.8.4 (latest release, arm64, sha256 checked against its SHA256SUMS) under a sandbox HOME, started on a settings.json magpie wrote with the user's own Anthropic entry beside it. It started and ran 15s with the file intact and no .corrupt copy. v0.8.4 has no `models` field, so it lists only the first magpie model; main lists them all. Not tried: a chat request through OpenPencil's UI; its exit save (it didn't quit on an AppleEvent and was stopped with TERM, so the write-back wasn't seen); Linux and Windows; a build of OpenPencil's main. |
||
|
|
7597c13237 |
gui: a curl example pasted into a provider's editor fills it in (@mark_li21 on X)
@mark_li21 asked: 能支持通过curl例子直接导入provider不? A curl example
from a vendor's docs, pasted into a custom provider's Base URL or API key,
now fills in the editor instead of being pasted as text.
curlOf (app.js) is one pure function. It reads the paste the way a shell
would: lines joined by \, cmd's ^ or PowerShell's backtick; curl.exe;
quotes and escapes. From that it takes:
- the API that the URL's endpoint names: /chat/completions is Chat,
/messages is Anthropic and /responses is Responses;
- the base URL before that endpoint, spelled by respellURL the way the
editor already wants it;
- the key from Authorization: Bearer, x-api-key or api-key;
- the model in the JSON body.
A key that is only a placeholder ($X, ${X}, %X%, <token>, YOUR_API_KEY)
is not taken. The key box is left empty and focused instead. A new
provider adds the model to its models. A saved provider's picks are left
alone, because adding to an empty list would narrow what it serves. A
preset's editor only takes the key.
A note in the editor says what was filled in. It also points out a
placeholder left in the URL, such as {WorkspaceId}, and a URL with no
known endpoint. Its four strings are translated into zh, zh-TW, ja and
de. Text that isn't curl pastes as before, including several keys at
once.
Found along the way: url.onpaste = fromCurl cancelled every plain paste
into the Base URL, because an on-handler that returns false cancels the
event. The handler is now wrapped. The test fails on the unwrapped one.
Fixtures, in internal/gui/tests/fixtures/curl, are the docs' own bytes:
- OpenAI chat (API reference) and Responses (quickstart);
- Anthropic Messages;
- DeepSeek, Zhipu, Moonshot and OpenRouter quick starts;
- Alibaba Bailian's Windows cmd example (^ and \"-escaped JSON);
- SAP AI Core's PowerShell one-liner (curl.exe, <Deployment_url>);
- Unsloth Studio's PowerShell example, with backtick continuations, as
its usage panel renders the template. This one is not copied from a
static doc page.
The doc row is "A pasted curl command" in
docs/subsystems/providers-accounts.md.
Run at
|
||
|
|
674b6ca288 |
gui: a provider's per-key proxy lines fold past eight keys (@NetRozee on X)
@NetRozee on X: a custom endpoint given a thousand keys froze magpie.
Cause. The editor's Advanced > Proxy drew a line for every key, each
with a Provider's proxy | Direct | Custom control. Each control, once in
the page, looked up its place among every .segs in the editor and slid
its thumb (segsPlace, slide): quadratic, with a layout read each. The
Accounts list above it already folded (keyFold); this list didn't.
Fix. proxyLines folds a provider's keys as keyFold does: past KEYS_FOLD,
the first KEYS_FIRST and those with a proxy of their own, then All N
keys; opened, a filter (keyMatches, as the Accounts list's) over
KEYS_PAGE lines and how many more, and Show fewer. Typing draws the
lines again under the filter, which stays in the page (#1055). A key not
drawn keeps its proxy: Save posts every key's own, drawn or not.
Subscription accounts' lines are unchanged. No new strings.
Measured (Playwright, the editor opened on a provider of N keys):
1000 keys 5000 keys
Chromium 1067ms -> 100ms 55.6s -> 93ms
WebKit 4809ms -> 68ms 203s -> 81ms
DOM 9388 -> 434 nodes 45388 -> 434 nodes
Tests: provider-many-keys-proxy.test.cjs (new, en and zh, Chromium and
WebKit): fails in all four on the old app.js (no All 300 keys). With
account-proxy, provider-many-keys, filter-ime, usage-keys-fold,
i18n-keys, click-scroll, provider-proxy, proxy-own-wording,
routing-proxy, plugin-proxy-page, signin-proxy and proxy-test: 221 of
221 pass in both engines.
Run: gofmt -l (clean); GOOS=linux and GOOS=windows go vet -tags nogui
./... (clean); go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME (GOCACHE, GOMODCACHE pinned) on
|
||
|
|
af601541ef |
routing: a request opens to its request and response (Fate on Discord)
Fate asked on Discord to see what a single request on the Routing page sent
and got back, such as a Codex prediction. The bodies were captured already,
in the Gateway page's 40 recent calls and the opt-in request archive, but
nothing led there from a Routing request.
- gateway: a Call carries the Routing request it was (Call.Route = the
trace's Route.ID), set where serve, the Codex backend and a refused title
record it. Server.RouteCall finds it in the ring. A route id is not a
call id. A route names its archive copy (Route.Archive =
call.archiveName()), set only when the archive was on, so it reaches the
saved history too.
- gui: GET /api/gateway/call takes ?route= besides ?id=. It is the same
handler, the same no-store, the same key guard and the same 404 once the
ring has let the call go.
- Routing page: the story's head has "Request and response". It fetches
only when pressed, and shows the masked bodies through callBodyPanel (an
SSE reply reads as its events). A request the ring no longer has shows
the archive's copy through archivePanel when the route names one.
Otherwise it says the last 40 are kept until magpie quits and how to turn
the archive on. Nothing more is captured or kept than before.
- The head now wraps. At narrow widths its buttons ran past the story
("Back to live" was cut off at 440px).
- The two button words live in i18n.js: i18n-keys' "a plugin's words are
its own" found them inside core strings.
- docs/subsystems/gui-shell.md says how a route reaches its bodies.
Tests:
- TestRoutingRequestOpensItsBodies (new): each of two routes gets its own
bodies; route 0 and an unknown route get 404. Red without
`call.Route = tr.ID` ("route …: 404").
- TestArchiveWholeBodies now checks that the route names the archive. Red
without the t.Archive line (`route names archive ""`).
- routing-bodies.test.cjs (new), chromium and webkit at 440px, en, zh,
zh-TW, ja and de, 10/10. It covers the ring's copy read only when asked,
hiding, another request closing it, the archive's copy, the
how-to-keep note, nothing past the story and no left border.
- Red with the client asking ?id= and with the head's wrap removed.
- routing-request-metrics.test.cjs: with the head wrapped, its 480px
picker clicks in WebKit landed on the footer. Playwright's WebKit places
elements in the scrolled view hundreds of px lower than
getBoundingClientRect, which elementFromPoint agrees with. The test now
clicks where the page shows them. 5 runs of both engines, 20/20.
Run in a sandbox HOME at
|
||
|
|
ba17c4f90d |
provider: a Command Code plan key's card shows the month's credits as a meter (#2451)
tianxia3111 runs Command Code on the keyed preset with a plan's key. Its
card showed the 5-hour and weekly windows as meters, but the month's
credits only as dollars left ($5.27), with no share of the month. The
cause: billing/credits leaves out the planId, so the key's card couldn't
know the plan's monthly pool. The signed-in subscription's card gets
that pool from billing/subscriptions.
The key's card (planKeyWindows -> cmdKeyWindows) now asks
billing/subscriptions with the same key for the plan. It then makes the
month a "Credits" window beside the other two, through the same
cmdQuotaOf the subscription's card uses ("$4.78 / $10.00" on a Go plan).
- The plan id is kept per key for ten minutes, since
billing/subscriptions takes 15-20 s at times.
- The id read before still counts while the plan can't be read.
- A key whose plan was never read keeps its two windows alone.
- A pay-as-you-go key, with no windows, still gets no card.
planWindows' request and status handling move into planBody, so that
cmdKeyWindows can decode the reply itself; other vendors are unchanged.
Run:
- New TestCommandCodeKeyCardHasCredits uses the reporter's own
billing/credits reply. Its billing/subscriptions reply has the shape
the other Command Code tests use (individual-go-monthly), because the
reporter's plan id isn't known.
- With the new branch disabled by hand, the test went red: two windows,
no plan. With it, green.
- TestKeyQuotasKeepLast now answers billing/subscriptions with 503 and
still sees its two windows.
- gofmt; go vet -tags nogui for darwin, linux and windows.
- Not tried against Command Code's real API: there is no plan key here.
- Full suite (go test -timeout 45m ./..., at
|
||
|
|
97f264c7fb |
gateway: a 413 on the OpenAI routes says request_too_large, so pi compacts (@wilsonxuuuu on X)
@wilsonxuuuu's pi, on gpt-6.1 through magpie, stopped on
"magpie API error (413): {...,"type":"api_error"}" at 114k of a 1M
window and never auto-compacted. The vendor's 413 was a body byte cap.
pi's overflow table (pi-ai utils/overflow.ts) knows a byte cap only as
request_too_large, Anthropic's type, which magpie already gave on the
Anthropic route but not on chat/responses. writeErrorSaid now types
every 413 request_too_large (Gemini keeps its own status shape). The
status stays 413 and the byte-limit hint stays; it is not turned into
context_length_exceeded, so Codex and Claude Code read it as before
(Codex reads code, not type). pi compacts once and retries once
(_overflowRecoveryAttempted), so a body that is still too big after
compacting stops instead of looping.
Run:
- pi 1.1.0's own isContextOverflow on the reporter's body: api_error
false, request_too_large true.
- TestPayloadTooLargeSaysRequestTooLargeToPi (an nginx 413 page from a
chat upstream) and the new Chat/Responses rows of
TestBodyRejectionErrorShapes fail with the gateway.go change reverted
by hand, pass with it.
- go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME:
every package ok. gofmt clean; GOOS=linux and windows go vet of
internal/gateway clean.
Not tried: a real pi session hitting a real vendor 413.
|
||
|
|
6641e1b0ac |
provider: a plugin sign-in drops what a request holds at once (#2449)
TestPluginLoginInstallsItsCLIFirst went red on macOS CI (run
38798393584) with "not signed in after the install: []". cli's run()
sets catalog.Changed = agent.SyncCatalog, and a sync left going from an
earlier step holds the catalog (provider.Hold), plugins and their
sign-ins among it, for up to a second. The host's "auth" event dropped
that only through catalog.Touched, told in the background, so on a busy
runner provider.Logins right after the sign-in read the snapshot taken
before it.
plugin.OnChangeNow registers hooks run before changed() or listed()
returns, i.e. before the host's reply after the event is read; provider
registers dropHeld there. Changed() is filememo.Forget + dropHeld.
Reproduced by injecting a pause where SyncCatalog holds (patch kept
outside the tree): without the fix red 3/3 with the CI message; with it
ok -count=5. TestHeldGoesWithAPluginChange: red without the fix ("held
from before the change: built 1 times, want 2"), green with it, also
-race -count=20.
Run: -count=20 -run TestPluginLoginInstallsItsCLIFirst ./internal/cli
ok; internal/cli, internal/plugin, internal/provider whole ok; gofmt -l
clean; go vet -tags nogui for darwin, linux, windows on the three ok.
Full suite: go test -tags nogui -timeout 45m ./... at
|
||
|
|
bbf901570e |
provider: a WorkBuddy account's spent credits leave its free models counted out, as the plugin does (plugins#138)
hheei (magpie-community/plugins#138): an account at 560 / 560 credits
was ranked spent for deepseek-v4.1-flash too, which WorkBuddy serves at
x0.00 and which draws no credits. The plugin was fixed in 0.1.23
(notModels) and the mover min is 0.1.24 already; the built-in, which
users who haven't moved still run, had the same fault. wbQuota's
personal Credits window and the enterprise window now pass through
wbSpareFree, which scopes them (QuotaWindow.matches) to the models not
marked Free in the provider's last fetched list (catalog.Live). With no
list read, every model counts, as before. The 14018 "Credits exhausted"
rest already rests only the paid model (PaidBesideFree).
Run:
- TestWorkBuddyCreditsSpareFreeModels (new): with no live list the free
model reads 100%; with one, deepseek-v4.1-flash (either case) reads 0
while -sg (x0.03) and gpt-5.5 read 100. Broken by hand (wbSpareFree
returning early): red, "deepseek-v4.1-flash: 100% used, want 0".
- gofmt -l clean; go vet -tags nogui ./... for darwin, linux, windows: 0.
- Full suite: go test -timeout 45m ./... in a sandbox HOME, twice: every
package ok except internal/gui's TestPanelJoinsFullScreenSpaces ("the
panel shown doesn't take the keyboard"), which is red the same way
alone on a fresh origin/main
|
||
|
|
a80bc30092 |
agents: the Cursor editor's ~/.cursor is no Cursor CLI
The editor makes ~/.cursor on its own, so the folder alone says nothing
of cursor-agent (dirShared): cli-config.json or the command finds Cursor
CLI. The Library still writes the MCP servers and skills the editor reads
there when only the editor is here (SharedHere).
Run at this head before the rebase onto
|
||
|
|
486ea82378 |
agents: cursor-agent's row is Cursor CLI (@G_Z_Y on X)
@G_Z_Y looked for Cursor CLI on the Agents page and took the "Cursor" row
for the editor. The row is cursor-agent, so it is named Cursor CLI. What
it keeps in ~/.cursor is the Cursor editor's too (MCP servers, skills,
chats), so the Library and Sessions name it Cursor there (SharedName).
Run at this head before the rebase onto
|
||
|
|
7fefbc614e |
gateway: a relay's cap on one request's input fails over in a group (#2445)
B.ai answered a 380K request, under the model's 1M window, with 400
"Input token exceed the limit (request id: …)". No pattern in tooLongRe
matched it, and quotaWords wants "exceeded", so retryable() was false and
group/top's other three members were never asked (worksyang).
tooLongRe now also matches "input token(s) (count) exceed(s|ed) (the)
(max|maximum) limit". The refusal is taken as an overflow, so the chat
loop's existing #700 path asks the next member that may hold the request
(withRoom, failOverflow). Nobody rests, another account of the same model
isn't asked, and with no member left the agent is told it overflowed, to
compact. paceWords still keeps rate limits worded with input tokens out,
and a plain bad request still isn't asked of anyone else. System One's
decision groups (decide_group.go, which the report cites) are unchanged:
their requests are short decision text.
Test: TestRelayInputCapGoesToTheNextMember uses the reporter's message
verbatim. The JSON around it is not the reporter's; the issue shows only
the message. Docs: gateway-routing.md failure paragraph + verification.
Run:
- Broken by hand, the new test went red each time:
- pattern removed: group answered 400, member 2 never asked;
- paceWords check removed: two rate phrasings taken as overflow;
- retryable true for every 400: the plain bad request reached member 2.
- TestRelayInputCap, TestEveryVendorsOverflow, TestOverflow*,
TestContextOverflow*, TestOutOfBudget*: ok.
- gofmt -l: clean. go vet -tags nogui ./... on darwin, linux, windows: ok.
Full suite: go test -tags nogui -timeout 45m ./... at
|
||
|
|
7e4336e719 |
gateway: an event magpie appends to a cut stream begins after a blank line (#2446)
A passthrough stream cut mid-line got its error event written onto the half-written line, so the client read "event: error" as more of that line's data and never saw the error as an event. ggbdpq's patch (#2446) tracks whether the last write ended a line (passthrough's write, and holdWriter.atLine for cutLoop) and puts a blank line, two newlines when mid-line, before the appended event. The same join could happen to the other event passthrough appends: the finish_reason filled in for a Gemini OpenAI-compatible reply that ended done ( |
||
|
|
056cfe3323 |
provider: Codex's keychain read waits for the user, tells a refusal from no answer, and is kept while the item is unchanged (#2367)
Dony2050 (#2367) runs Codex with cli_auth_credentials_store = "auto" and no auth.json, so magpie reads "Codex Auth" through /usr/bin/security. Four faults: - One 10s timeout covered both of macOS's prompts and the user typing their password. A read they approved after 11-16s still failed. - A timeout and a refusal gave the same error. - A read was kept for 10s only. With "Allow" (once), background polls prompted again about every 30s. - Only a restart cleared the 10-minute failure cache. What changed: - Reading the secret is one ask per item at a time (askCodexKeychain). It runs in its own goroutine for up to 2 minutes (keychainAsk), outside codexKeychainMu, so no `security` run happens under a lock a reader needs. A reader waits at most 5s from when the ask started (keychainHold), then gets errKeychainWaiting. A request or a page never waits out the prompt. The ask's answer is kept when it lands, unless magpie kept a newer one after it started. - Each failure says what happened: - exit 44: no item. - exit 51 (errSecAuthFailed) or 128 (errSecUserCanceled): denied or cancelled (errKeychainRefused). Checked against SecBase.h. Exit 44 was also checked on a throwaway keychain in the scratchpad. - the 2 minutes ran out: no answer (errKeychainNoAnswer). - anything else: errKeychainUnread. None of them counts as signed out. - A successful read is kept while the item is unchanged. After 10s a reader runs Stat (find-generic-password without -w), which shows no prompt and returns only the item's mdat. The secret is read again only when the mdat changed. - Every write of the credential re-derives the cache: - codexStore.write keeps the date of what it wrote (keepCodexKeychain). - Switch, sign-out (deleteCodexLogin) and refresh forget a read (forgetCodexKeychain), so the next read checks the date. - forget keeps a refusal for its 10 minutes (#2408). - resetCodexKeychain clears everything. Only tests use it. - The saved accounts' line in the GUI has a "Try again" link beside Remove when a read was refused, got no answer or is waiting (Exclusion.Retry). It posts /api/provider/keychain-retry, and RetryCodexKeychain reads once past the refusal. - The reason now says "Always Allow" lets /usr/bin/security read the item, so macOS stops asking each time Codex changes it. - Two new strings in zh, zh-TW, ja and de. - docs/subsystems/providers-accounts.md: the "Codex's credential store" row describes the above. Tests: - TestCodexKeychainAskedSeldom (rewritten) covers: - an unchanged item over aged and forgotten rounds asks once; - a changed item asks again; - a gone item is not found without asking; - a refusal is kept through forget. - TestCodexKeychainPromptWaitedFor: a held prompt gives "waiting" to the first and to 8 concurrent readers without blocking. Once answered, the read succeeds with one ask. - TestCodexKeychainRetry: Retry and Why for refused, no answer and no item, and RetryCodexKeychain. - TestSecurityKeychainExits (codex_keychain_ask_unix_test.go): a fake `security` built with testenv.Program covers: - a 2s answer with keychainWait = 1s succeeds; - Stat parses the mdat; - exits 44, 51, 128 and 1 map as above; - a hang gives no answer. - signedout_test: Retry is set only for an unread item. - GUI keychain-retry.test.cjs runs in chromium and webkit, in en and zh: - order Try again, Remove; - the POST body; - the line leaves after a click; - no link without retry. Broken by hand (each restored after): - Find bounded by keychainWait again: TestSecurityKeychainExits red ("a read the user answered late ... no answer in time"). - exit 51 not classed as refused: TestSecurityKeychainExits red ("Find, denied"). - Readers wait on the ask (no hold): TestCodexKeychainPromptWaitedFor hangs; the package timed out. - forget clears every read: TestCodexKeychainAskedSeldom red (4 asks). - mdat match ignored: AskedSeldom red (7 asks). - Cache never re-checked: AskedSeldom red (the changed item wasn't seen). - RetryCodexKeychain also deleting the failure cache: still green, because a fresh read asks past a refusal. That loop was removed as redundant. Not tried: - A real macOS prompt, or an item Codex itself wrote. Every test uses a fake `security`; the real keychain and ~/.codex were not touched. - Put and Remove are still bounded at 10s. Run at this head, rebased on origin/main |
||
|
|
a6f908ba58 |
gateway: a Gemini OpenAI-compatible stream that lost its finish_reason is ended by usage, or cut
Linka (Discord #feedback): Gemini's OpenAI-compatible API sends a whole
function call (its thought signature, the usage) in one chunk and the
finish_reason in the next. When the upstream hung up between the two,
magpie relayed a stream that ended with neither, and Pi threw the
complete call away ("Stream ended without finish_reason") and asked the
whole 160k turn again. On a Chat upstream only a failed read was a cut,
so a clean EOF there went on as a stream with no end.
That API counts the usage only on the generation's last chunk(s): the
Vertex fixture (testdata/vertex_openai_thoughts.sse) has it only beside
finish_reason, Linka's frames have it on the call chunk and the finish
chunk, and Google's forum and third-party docs say the same; no Google
doc states it. So for a Chat upstream that is Gemini's (geminiCompat,
saysItsEnd) and ended without a finish_reason:
- its last chunk carried usage: the generation was done and only the
finish_reason was lost. It is filled in (chatTail), "tool_calls" after
a call and "stop" otherwise: relayed, as one chunk before [DONE]
(written only if [DONE] hadn't gone); translated, as the reply's normal
end (tool_use for Claude Code), streamed and unstreamed. Recorded ok.
- no usage at its end: the reply was cut, and the client gets "the reply
ended before it was complete" (errEndedShort), as a Gemini stream's
finishReason is told (#1643, #1644): the relay's error chunk, the
translated stream's error, an unstreamed 502.
A failed read keeps its own "connection lost mid-reply". Other vendors'
Chat streams are unchanged.
Tests (gemini_compat_cut_test.go, Linka's frames): relayed, the call
with usage ends with finish_reason tool_calls then [DONE], text with
usage with stop, the call without usage with the error and no
finish_reason; a whole reply with or without [DONE] goes as it came
with one finish_reason; kimi-k3 with and without usage unchanged.
Translated: with usage one message_stop with stop_reason tool_use and
no error, streamed, and a 200 tool_use unstreamed; without usage one
error and no message_stop, and a 502 unstreamed.
Broken by hand, each red: the relay fill off (relay test: no
finish_reason), the streamed fill off (0 stops, 1 error), the
unstreamed fill off (502), usage ignored in chatTail.finish (every
no-usage case ended as whole, unstreamed 200).
Run: gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./...
ok; go test -run 'TestGeminiCompat|EndedShort|TestStreamCut|
TestWellFormed|Sniff' ./internal/gateway ok.
Docs: gateway-routing.md says when the finish_reason is filled in.
Full suite: go test -tags nogui -timeout 45m ./... at base
|
||
|
|
db8b791797 |
plugin: tools-, page- and agent- packages take their short name without the prefix
@magpie-community/tools-calc served its tools as tools-calc_eval and its
page under "tools-calc" because ShortName only dropped middleware- and
opencode-. It now drops tools-, page- and agent- too, so the calc example
serves calc_eval/calc_convert/calc_date as its README and the docs say.
`magpie plugin options` / SetOptions find a plugin by its short name or by
its bare package name (plugin.Called), so "agent-aider" keeps working
beside "aider".
Run at
|
||
|
|
a0a4d55ef7 |
gateway: a passed-through reply whose reasoning loops before it says anything is asked again once, and its tries counted (#2436)
lqisgod's five looped replies (pi → WorkBuddy, Chat in and out) each
ended at once with empty tries and status 200. The once-only re-ask of a
reasoning loop (loopReasks) lived only in streamTranslated's onLoop, so a
same-protocol passthrough had holdWriter.reask nil and cutLoop ran on the
first trip. A re-ask that did happen in place wasn't counted in the usage
record's tries either (tries came from route.Tries alone).
Now holdWriter lets such a try go (mayReloop/letGoLoop) when its
reasoning looped, nothing has spoken (loopGuard.spoke: no text or call),
the request has its re-ask left and its context is alive, and either
nothing of the try reached the agent (held bytes dropped, any protocol)
or the agent speaks Chat (bytes written up to the end of the tripping
event, the next try's chunks follow). The fallback loop records the try
as failLoop with reloopedError and asks the same provider again after
retryPause. In-place re-asks add to tries too. An Anthropic or Responses
stream whose reasoning already reached the agent still ends with the
loop error: a second message_start/response.created can't follow. The
plugin host's fetch goes through the same holdWriter
(TestLoopEndsWorkBuddysReply's plugin subtests).
Tests: loop_guard_test.go's chat case now expects 2 asks and an answer;
every passed-through `data:` line is valid JSON; the usage record has
Tries == asks and no error. docs/subsystems/gateway-routing.md updated.
Broken by hand, each red:
- hw.reloop = false (old behaviour): TestLoopEndsTheReplyOnEveryProtocol,
TestLoopEndsWorkBuddysReply, TestReasoningLoopIsAskedAgain fail.
- reasked not added to tries: the same three fail with "usage record's
tries 0, the vendor asked 2 times".
- spoke never set: TestLoopAfterTextIsNotAskedAgain fails.
Run: gofmt -l clean; go vet -tags nogui ./internal/gateway ./internal/usage
with GOOS=darwin, linux, windows ok; go test -run Loop ./internal/gateway ok.
Not tried: a real WorkBuddy account looping (the loop can't be forced).
Full suite: go test -tags nogui -count=1 -timeout 45m ./... on base
|
||
|
|
b6533893a7 |
plugins: Discover lists tools and page plugins, and the intro links to the plugin docs
Every kind of plugin magpie runs now has its place on the Plugins page, so
someone looking to extend magpie finds what exists and how to write one:
- Discover has "Tools for agents" (market kind "tools") and "Pages" (kind
"page") sections beside Subscriptions, Gateway middleware and Agents,
each card with its own chip (a new Tools chip, the Page chip). Before,
both kinds fell under Subscriptions as Providers.
- A GitHub repository tagged magpie-plugin whose package.json has
magpie.page.file is a Page, and that file must be committed, as a
provider's entry must (TaggedRepos).
- An installed plugin that only gives tools wears the Tools chip.
- The intro says what a plugin can be (provider, gateway middleware,
routing strategy, tools, an agent, a page) and its "Write a plugin" link
opens usemagpie.ai/docs/plugins in the window's language (zh and zh-TW
to zh/, ja to ja/), outside the window.
- The docs' Publishing section lists the "tools", "page" and "agent"
registry kinds and the community package names for each, in en, zh, ja.
Run at the reviewed head (on origin/main
|
||
|
|
abc9006819 |
gateway: a rule naming a group in the group keeps the group's own routing's order (#2407)
What changed
ruleFirst ranked the candidates of a rule's member by the group's flattened
member order, so a rule that names a group in the group erased whatever that
group's own routing had planned: a rotate group's turn advanced underneath,
but every request the rule put first was served by its first member again.
The rule's own member that is a group in the group is one member now — its
models rank as the group's block, in the order the group's routing planned
them; the members the rules after it name keep their own ranks, so a model
the rule names that the group has too still leads over them (#625,
TestRuleNamesAModelAGroupInItHasToo). TestRuleNamingARotateGroupKeepsItsTurns.
Run
HOME=$(mktemp -d) GOTOOLCHAIN=auto go test -tags nogui -count=1 -p 2 -run 'Rule|Rotate|Nested' ./internal/gateway/ — ok
HOME=$(mktemp -d) GOTOOLCHAIN=auto go test -tags nogui -count=1 -p 2 -timeout 45m ./internal/gateway/ — ok 304s
TestRuleNamingARotateGroupKeepsItsTurns on rules.go at
|
||
|
|
a786c51cb0 |
agent: a magpie-models.json that doesn't parse is kept aside, not written over or removed whole
What changed: #2263 gave magpie's state files whose reader takes an unparseable file as empty the lastgood.KeepUnparsed copy-aside, and its sweep named the files it covered. Codex's magpie-models.json was in neither its covered list nor its cache exemption, and its reader has the exact missed shape: codexcat.Keep (#1450) returns the new list for a file it can't parse, and the next sync, model switch or stepping back in wrote that over the file, ending the keys the user added by hand (supports_reasoning_summaries and friends) with no copy. Stepping out was worse: dropList took an unparseable file for one holding nothing of the user's and removed it outright. Now the three writers of the list go through writeOwnList, which keeps an unparsed file aside (magpie-models.json.bad-<time>) before the write and stops when the copy can't be made, and dropList keeps one aside before it removes the file. Run: - gofmt -l internal/agent: clean. - go test -tags nogui -p 2 -count=1 -timeout 25m ./internal/agent: ok (183s). - TestUnparsedCodexCatalogKeptAside fails on the code before this ("the unparsed list was written over with no copy kept"); the ablation replays it against this commit's parent. - go vet -tags nogui ./... for darwin, linux and windows ok; go build for the three ok (reviewer, at the batch head). Full suite: go test -tags nogui -count=1 -timeout 45m ./... ok, every package (reviewer, at the batch head before #2424 was added). Generated-by: GLM-5.3-Flash (ZCode) |
||
|
|
d830d460f0 |
provider: a refused keychain read is not asked again for ten minutes (#2408)
What changed: copilotCLISecret backs a denied keychain read off (10 minutes, "don't ask again at once"), but the two other readers of the same family took every failure as an absent item and asked again after their ordinary 10s TTL. On macOS a denied item prompts again on every read, so a user who answers Deny once was asked again every 10 seconds while Cursor's status or Claude's credentials were polled, and every 10 minutes only for Copilot (#2408's report is the Copilot face of this). Now cursorKeychainToken and readClaudeKeychainItem (through claudeCredential's cache) treat any `security` failure but 44 — the item not being there, which asks nobody — as a read that may have shown the user a dialog, and don't repeat it inside keychainDeniedTTL (10 minutes, copilot's own pause). A sign-in or out in magpie reads afresh (forgetCursorStatus, forgetClaudeCredential clear the pause), and a fresh read in CursorToken is unchanged. Run: - gofmt -l internal/provider: clean. - go test -tags nogui -p 2 -count=1 ./internal/provider: ok (72s). - TestDeniedCursorKeychainReadIsNotAskedAgain and TestDeniedClaudeKeychainReadIsNotAskedAgain fail on the code before this (a refused read asked again 11s later). Not tried: a real macOS keychain dialog answered no (a fake `security` stands in for it); Copilot's own reader is unchanged. - go vet -tags nogui ./... for darwin, linux and windows ok; go build for the three ok (reviewer, at the batch head). Full suite: go test -tags nogui -count=1 -timeout 45m ./... ok, every package (reviewer, at the batch head before #2424 was added). Generated-by: GLM-5.3-Flash (ZCode) |
||
|
|
682e4253bf |
gateway: a Gemini call's thought signature is kept on disk and its id carries a 16-character key, not the signature — ids were 3KB+ and broke a client's PostgreSQL index (#2411, liangxyz)
Since #687 a tool call Gemini signed went to the client with the signature
inside its id (<id>__ts<n>__<base64url>), so the client's next request
brought it back. A Gemini 3 signature is often 2–6KB, so ids were too: LobeHub
stores tool_call_id in a btree index, whose rows are capped near 2.7KB, and
the write failed.
The signature is now written to <settings>/gemini-signatures/<key>, the key
being 12 bytes of its SHA-256 in base64url, and the id carries
__tsk16__<key> (≈36 characters). Coming back, the file is read and its hash
checked against the key; a file gone or changed is no signature, and the
call goes to Gemini with skip_thought_signature_validator, as an id a client
shortened already did. A file is touched when it is read or written again
and pruned 90 days after its last use (at most once an hour, on a write);
temp files from a write cut short go after an hour. When the folder can't
be written, the signature still rides in the id as before. Ids made before
this (__ts<n>__, __tsr<n>__, __ts__) are still read.
Real use: a sandbox HOME magpie serve with the owner's Antigravity account
copied in, antigravity/gemini-3.8-flash-high, a two-turn tool call over Chat
and over /v1/messages: ids came back as call_659137__tsk16__cOTtfB5LubcVSNaX
(36 characters), turn 2 answered from the tool result, and the store file
(584 bytes) was born on turn 1 and touched on turn 2's read.
gemini/gemini-3-flash-preview answered 502 (Gemini CLI no longer
supported), unrelated. Not tried in LobeHub itself; asked on the issue.
Tests: TestFortyCharacterIDThroughGateway now keeps the real signature
through a 40-character id; TestLongSignatureGivesShortID (6.4KB signature,
id ≤ 64, round trip); TestKeptSignatureGoneOrChanged; TestUnkeptSignature-
RidesInTheID; TestOldSignaturesPruned. Broken by hand: keepSignature
disabled fails FortyCharacter and LongSignature; the hash check removed
fails KeptSignatureGoneOrChanged.
Ran: gofmt; go vet -tags nogui ./internal/gateway/ for darwin, linux,
windows; targeted tests -count=3.
Full suite: go test -tags nogui -count=1 ./internal/gateway/ ok (466.9s);
the rest of the suite ran green on the batch this is rebased onto
(
|
||
|
|
a7a0122027 |
gui, gateway: the search grip's place is a class, not :has(), and Go no longer says the Routing plugin's words (batch GUI reds)
The full GUI run on this batch had two reds that are real, both from commits in it: - old-webkit "the styles hold up in Safari 15.0": 4b69460d1 (#2286) placed a search API's grip with `.search-unit:has(> .search-keys)`, which Safari before 15.4 can't parse. The unit now gets a with-keys class where its keys' row is added, as other rows in app.css do. - i18n-keys "a plugin's words are its own": 7ff5f595e's test name TestArkDrawsUnmarkedOncePerImage and f9ccca71e's comments in active.go and left_in_flight_test.go said "Unmarked" and "answering…", which are plugins/routing's words. The test is TestArkDrawsWithoutWatermarkOncePerImage (the subsystem page renamed with it) and the comments say it in other words. Run: node --test i18n-keys (3/3), search-order (16/16), old-webkit and mobile-web alone; gofmt; go vet -tags nogui ./internal/gateway. Not checked by a test: the grip's top under a unit with keys; the rule is the same, only its selector changed. Full suite: SUITE_LINE |
||
|
|
d6b045a7e7 |
usage: the Overview's lists fold under their headings and stay folded, the token totals can count the cache, and the Requests Tokens card wraps its cache count instead of cutting it (#2378)
The reporter asked for three things on the Usage page: fold Agents,
Models and Accounts from their titles and remember it (日常看账号维度
较多,都要拉到最底下); an option to count the cache in the token totals;
and the Requests tab's Tokens card cut its cache count off on a wide
window ("缓存 879…").
- Folds: each Overview list's heading (Agents, Models, Accounts, and
Gateway keys beside them) is a .fold button with its chevron, the
Gateway page's pattern. A click keeps the page still (backToReader).
What is folded is kept per viewer in localStorage magpie.usageFolded
(mountUsageFolds at the plugin's mount, showUsageFolds per render).
- Cache: the tokens tile's label is a pop-up (usageTokensPick, the app
menu, no <select>) of Without cache / With cache, kept in
localStorage magpie.usageWithCache. With cache, the tile, the chart,
and every row's count and share add cache read and written
(usageTokens), and the tile says the cache's count. Default unchanged.
- Cut count: a token line in parts (the Requests strip's Tokens card,
the Overview's tokens tile) wraps between its counts and keeps each
whole (usageParts, .parts); only a count wider than its card on its
own is cut. The part spans undo .kpi span's label capitals.
- Strings in zh, zh-TW, ja, de. docs/subsystems/gui-shell.md bullet.
- mobile-web.test.cjs: until BASE_REF has mountUsageFolds, the
desktop Usage comparison puts the new fold buttons and the pop-up
back to their plain labels and compares the rest as before. That
comparison caught the tile's line in the label's capitals and 5px
taller; both fixed, and usage-overview-fold now checks them.
Run at this head (base
|
||
|
|
b6fae8efd8 |
gateway: an advisor magpie leaves out takes its instructions and tool_addition with it, so the model no longer calls a tool it hasn't got (JackChou on Discord)
JackChou: "claude code 使用 advisor 返回找不到对应工具". Claude Code 2.1.300
(its request read from a fake ANTHROPIC_BASE_URL in a sandbox HOME, with
--advisor and a fake key) declares the advisor as the server tool
{"type":"advisor_20260301","name":"advisor","model":…,"defer_loading":true}
and also puts it in the conversation: a {role:"system"} message whose text
ends in "# Advisor Tool … call advisor BEFORE substantive work", and a
{"type":"tool_addition","tool":{"type":"tool_reference","name":"advisor"}}
block.
|
||
|
|
d98e17808b |
gateway: a refusal that comes as an error ends the try at once, is read across writes after content, and the high-risk message alone is one (#2400, Jichao)
Three gaps Jichao reported, each reproduced on origin/main
|
||
|
|
6e17d58ebf |
usage: a top session only the gateway saw says "Gateway session", not "(no prompt)" with no folder (#2285)
The reporter's Usage › Sessions card listed seven Pi sessions on
deepseek-v4-pro as "(no prompt)" with no folder, and their routing group
has no DeepSeek. Those rows were gateway projections: Pi asked magpie for
deepseek/deepseek-v4-pro (every served model is in Pi's models.json), most
likely through a pi-subagents child, whose session file is in a temp folder
magpie never reads. The card gave no sign of that, so it read as Pi's own
sessions with an empty prompt, and our first reply took it that way.
The overview's summaries from MergeExternalStats now carry gateway: true,
as MergeExternal's list rows already did. The card shows "Gateway session"
where the folder would be, "(prompt not recorded)" as the title when no
text was kept, and a tooltip pointing to Record gateway conversations.
Strings in zh, zh-TW, ja and de. gateway-sessions.md says it.
Run in this worktree (
|
||
|
|
3f4186fd8e |
providers: a provider you added can skip its own host's certificate check, nowhere else (#2383, fangzhengjin)
A vLLM on the LAN, an Ollama behind a self-signed certificate or a company CA can't be reached over https today. A custom provider now has "Don't check its certificate" (Certificate, in its editor, shown while an address is https), with a short risk note, in en/zh/zh-TW/ja/de. Scope, enforced in Go, not only in the GUI: - Only a provider the user added with their own base URL takes it (TakesInsecureTLS: no preset, no account, no Vertex, no subscription id). Save refuses it on anything else, and Via ignores a hand-set flag. - It reaches the hosts of the provider's own base URLs alone (netproxy.WithUncheckedTLS): a redirect elsewhere, a models/balance/ image URL on another host, and a nested request for another provider (With drops it) are still checked. - Every route: it is set in Provider.Via, which the gateway's attempt and forwardOnce (count_tokens too), List, Test, Detect, balance, draw, embeddings and video all go through. - The unchecked host gets its own cloned transport (the route key holds the flag), so the leave never reaches another request. An https:// proxy is refused for it, because its TLS would be dialled with the same config and go unchecked too; http:// and socks5:// proxies work. - The editor shows the saved value, Test/Detect/Fetch carry it before a save, and a save that omits it keeps it. Backup, export and WebDAV sync carry it (backup.Collect). Rewritten from fangzhengjin's fork 749e82a25 rather than applied: it had no Go-side limit to custom providers, set InsecureSkipVerify for every host the provider's requests reached (redirects, other hosts, nested requests) and for an https:// proxy's own certificate, never showed the flag back to the editor (the next save cleared it), and didn't carry it into Test/Detect/Fetch. Its transport cache key holding the flag is kept. Run in this worktree (-tags nogui -p 1, sandbox HOME): - go test -run 'TestUnchecked|TestWith|TestDispatch' ./internal/netproxy ok - go test -run 'TestInsecureTLS|TestVia|Proxy' ./internal/provider ok - go test -run TestInsecureTLS ./internal/gateway ok (chat, responses, anthropic, count_tokens, gemini against a self-signed server) - go test -run 'TestProviderSaveInsecureTLS|TestProviderSaveKeeps|Typed' ./internal/gui ok - go test ./internal/backup ok - GUI provider-insecure-tls.test.cjs: chromium 30/30, webkit 30/30 (en, zh, zh-TW, ja, de at 1100 and 420) - gofmt -l clean; go vet -tags nogui for darwin, linux, windows on netproxy, provider, gui, gateway, backup clean Broken by hand, each went red, then restored: - With not clearing the leave -> TestUncheckedTLSOnlyItsHost - the https:// proxy guard off -> TestUncheckedTLSStillChecksItsProxy - TakesInsecureTLS always true -> TestInsecureTLSNotForPresetsOrSubscriptions - Via not setting it -> TestInsecureTLSOwnProviderOnly and all 5 routes of TestInsecureTLSEveryRoute - backup field tagged json:"-" -> TestRoundTrip - save not keeping an omitted flag, providerInfo not showing it -> TestProviderSaveInsecureTLS - draftOf/asTyped not carrying it -> 2 of 3 GUI tests (en 1100 chromium) Not tried: a real vLLM or Ollama behind a self-signed certificate; the image, video, balance, embeddings and draw routes are covered through Via, not each by its own test. The full suite was not run. Co-authored-by: fangzhengjin <12680972+fangzhengjin@users.noreply.github.com> Full suite: SUITE_LINE |
||
|
|
dc8dcc85d1 |
provider: a custom Balance URL can be asked with POST, for an endpoint that answers only a POST (#2368, yaofeng)
A custom provider's Balance URL was always asked with GET, so a balance
endpoint that takes only a POST answered 405 and the card never showed.
- Provider.BalanceMethod ("" or GET, or POST with no body). It applies to
the user's own Balance URL only; a vendor magpie knows is asked as
before. balanceMethodOf refuses any other value before anything is sent.
- CLI: `magpie provider set <id> balance.method=POST` (GET clears it; any
other value is refused and the saved one kept); `magpie provider <id>`
shows "from POST <url>".
- GUI: a GET/POST segmented control (segs, not a <select>) beside the
Balance URL in More endpoints, aria-labelled and titled in en, zh, zh-TW,
ja and de. Check balance and Save carry it; a preset's save keeps it.
- No vendor preset or name is added. A string amount ("0.94306040") was
already read by number(), so `$usd_balance` reads as any field does.
- docs/subsystems/providers-accounts.md says it.
Run:
- go test -run TestBalance ./internal/provider/: ok. New TestBalanceMethod:
a POST-only httptest server, POST (any case) reads $0.94 from a string
usd_balance, "" and GET are still GET (405 is an error), PUT, DELETE and
a CRLF value are refused with nothing sent.
- go test -run TestProviderSetBalanceMethod ./internal/cli/: ok.
- Broken by hand: the request always GET turns TestBalanceMethod red
("asked GET, want POST"); balanceMethodOf passing any method turns it red
(PUT and DELETE sent); the CLI taking any value turns
TestProviderSetBalanceMethod red; the Check balance body without
balanceMethod turns 20 of 21 balance-method.test.cjs cases red, and
origin/main's app.js all of them.
- GUI: balance-method.test.cjs 42/42 (Chromium and WebKit, 1100 and 420,
en, zh, zh-TW, ja, de, saved GET and POST: opens on the saved method,
named and titled in the language, fits beside the URL with no page
scroll, the other pick goes in the check and save bodies). Siblings:
balance-parts, balance-field-default, balance-fix, catalog-hint,
duplicate-pause, key-balance-card, local-address, provider-base-api,
provider-auth-header, provider-gemini, provider-search,
provider-url-each-api, gui-de, gui-ja, gui-zh-tw, i18n-keys: 250/250.
- Real use: the built binary in a sandbox HOME, a custom provider at a
local server that answers GET 405 and POST {"usd_balance":"0.94306040"}.
Default: "unavailable 405 Method Not Allowed"; balance.method=post:
"$0.94 from POST …/api/check-balance $usd_balance", the server saw one
POST with Content-Length 0 and the Bearer key; balance.method=PATCH
refused. NanoGPT itself was not asked (no key here).
- gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
go vet -tags nogui ./..., GOOS=windows go vet ./...: ok.
Suite run here: HOME=<sandbox> go test -tags nogui -timeout 45m ./...: 62
ok, internal/gui FAIL only on TestSetAnswersWhileDevinAndProvidersHang
(a state took 11.97s, load ~180), open as #1375; it passes -count=2 alone.
Full suite: SUITE_LINE
|
||
|
|
afb0ff7720 |
gateway: a tool Pi adds in a message of its own joins the request's tools on every route, once by name (#2322, deephbz)
Pi 1.2.0 with supportsMidConvoToolAdditions sends a tool it adds
mid-conversation as {"role":"system","tools":[...]} with no content and
keeps top-level tools as they were. parseChat read only top-level tools
and the Chat relay sent the message on as it came, so the tool could be
called on no route, and the tools-only message became an empty part of
the system text ("</cwd>\n\n\n\nUpdated ...").
liftMessageTools (message_tools.go) moves message tools into the
request's tools. handle does it for every Chat body, before serveAgent,
so the Chat relay, schema fixers, redaction, the prompt shown and
routing all see them; parseChat does it too for a body that never came
through handle. Each tool joins once by name and the first definition
wins (top-level, then the earliest message's), as liftAdditionalTools
and a tool_addition in withoutDeferredTools do. A system or developer
message that carried only tools is left out; one with content keeps
its place without tools. Message order is unchanged: the in-place
system message / inline-tools beta part of #2322 is not in this commit.
6312af989 (#2338, inline-only tool_addition joins tools) is not on
origin/main
|
||
|
|
cc09c5bd97 |
stepfun: a Step Plan sign-in is the provider's own, not its site's: two accounts on one site show their own windows (#2384)
stepfun-auth.json kept one platform session per site ("ai", "com"), so
every StepFun provider on a site shared it: bringing a sign-in to one
signed in all of them, two accounts showed the same windows, and signing
one out signed out all (fangzhengjin, #2384). Sessions are now kept by
provider id; the site, which platform is asked, is still the provider's
(StepFunSite). StepFunSignedIn, SaveStepFunSession, SaveStepFunPaste,
SignOutStepFun, stepfunNow and stepfunAsk take the id, and
stepPlanQuotas gives one card per signed-in provider, not one per site.
Nobody signs in again for the upgrade: a file still keyed by site is
given, on read, to the StepFun providers on that site (stepfunBySite) and
written back through the temp-and-rename write. One provider: it's
theirs. Several: each gets it, so nobody loses their windows, and the
user brings the other account's sign-in to the ones that are someone
else's. Those copies are one sign-in, so stepfunNow renews every entry
holding the same refresh token together; renewed apart, the platform
could end the token the first renewal replaced and sign the others out.
With no StepFun provider on the site yet (or providers.json unreadable)
the old entry waits as it is. A file that doesn't parse, or that holds an
entry of another shape, is read as no session and nothing but a new
sign-in writes over it, after lastgood.KeepUnparsed has kept it aside.
Every other place keyed by the provider follows: Delete drops its
session (a provider added later under the same id doesn't inherit it),
Rename moves it, and the GUI posts /api/stepfun/{id}/session and
/api/stepfun/{id}/signout, 404 for an id that isn't a StepFun
provider's (a site's name among them). Backup and sync never carried
stepfun-auth.json, so nothing changes there.
Built on fangzhengjin's stepfun-per-provider branch (996cf969e), which
rekeyed the session by id. Not taken from it: it made every existing user
sign in again, left Delete and Rename on the old keys (a renamed provider
lost its sign-in, a removed one's was inherited by a new provider of the
same id), let signout take any id, and its two-provider test checked
only the stored Account, never each provider's windows.
Run at this head (on origin/main
|
||
|
|
6ea3b78d4e |
agent: OpenCode gets <level>-fast variants of a Codex account's GPT models, sent as Codex's /fast; the user's own variants stay (#2379)
OpenCode has no /fast (jiz4oh). A ChatGPT account's own gpt-* model (not a routing group; catalog.Model.CodexFast, set in magpieModels from provider.CanFast) is written into opencode.json with each level again as low-fast … xhigh-fast, or fast alone with no levels. Each asks service_tier "priority" twice: as an option, which OpenCode 1's @ai-sdk/openai-compatible sends as it is (read in v1.18.34's transform.ts and the SDK's getArgs), and in extraBody, which OpenCode 2 sends while it drops an option it doesn't know. The gateway already sends a Chat request's priority tier to chatgpt.com on Responses and drops OpenCode 1's stray extraBody field. Other vendors' models, an OpenAI key's GPT model and groups get no fast variants. The models block was written whole, so a variant the user added to one of magpie's models was wiped on every sync. openCodeKept (OpenCode, DevEco, Air, OpenChamber) keeps a user's variant and one written over under a name of magpie's; a variant exactly as magpie writes it is magpie's, so one the model no longer has goes. agent-wiring.md says so. Run: - go test -tags nogui -p 1 -count=1 -run 'OpenCode|OpenChamber|Air|DevEco|Deveco|Variant|Theirs|Kept|CodexTier|MagpieModels|Fast' ./internal/agent/: ok - go test -tags nogui -p 1 -count=1 ./internal/catalog/: ok - go test -tags nogui -p 1 -count=1 -run 'Fast|Tier|Codex|OpenCode' ./internal/gateway/: ok - New: TestOpenCodeCodexFastVariants (written config, user variants kept, stale one dropped, second sync byte-identical, relay/gpt-5.5 and codex/codex-auto-review without fast), TestOpenCodeVariants fast cases, TestOpenCodeFastVariantReachesCodex (Chat as OpenCode 1 and 2 send it, streamed and whole, against a fake ChatGPT backend: service_tier priority, effort kept, no extraBody; none without the variant). - Broken by hand, each red: CodexFast never set; theirsKept back in place of openCodeKept; user variants not read; stale variants kept; extraBody not written; gateway's Chat parse not reading priority. - Real use: the exact opencode.json the test writes, base URL pointed at a fake server, in a sandbox HOME, with opencode v2.0.25: -m "magpie/codex/gpt-5.5#xhigh-fast" sent reasoning_effort xhigh and service_tier priority; #medium sent no tier. - gofmt -l clean; go vet -tags nogui for GOOS=darwin, linux, windows on internal/agent, internal/catalog, internal/gateway: clean. Not tried: an OpenCode 1.x binary (read from source only), a real ChatGPT account's priority tier. Full suite: SUITE_LINE |
||
|
|
39b9703e3f |
agent: a remote magpie's model an agent isn't shown, or isn't on the remote's list yet, is refused, not written as the agent's own and taken out of magpie (#2376, moonshardx)
Reproduced with two magpies under sandbox HOMEs: B on 127.0.0.1:3592 with
a relay and routing groups, and A on 3593 with B added as Remote magpie
(renamed to "home"), plus a second remote with the id "remote". Codex
(codex-cli 0.162.1) and Pi (1.1.0) were wired through A, and both ran real
turns on remote ids (group/, provider/ and multi-slash ones).
The cause: Spell left a value the field's picker didn't offer as the
agent's own. A remote's model is missing from the picker when magpie
visible keeps it from the agent, or when the remote added it after A last
fetched the remote's list (a key provider's list is fetched on Refresh or
RefreshEvery). For Pi, `magpie pi remote/group/smart` then wrote
defaultProvider "remote", defaultModel "group/smart", said "disconnected
from magpie: … is Pi's own", and Pi went to its own endpoint ("Your account
is not active"). Codex got model = "remote/group/…" with no catalog entry.
The rename itself was fine: `magpie provider set remote-magpie id=home`
moved Codex's and Pi's values, and the old id still routes through Was.
Spell now refuses (notOffered) a value that names one of magpie's models
the agent isn't shown, a model of one of magpie's providers not on its
list, or a group/… magpie has no group for, and says how to fix it
(magpie models <agent>, magpie visible <agent> all, magpie provider
refresh <id>). Every agent's model field goes through Spell (CLI set,
GUI /api agent set, aside, profiles). A model shown to the agent that a
field offers fewer of (Claude Desktop's tiers) is still taken, and so is a
value whose provider part one of the agent's own models uses.
Run:
- TestSpellRefusesMagpieModelNotOffered (Pi and Codex, visibility on the
relay: hidden, unlisted and unknown-group values refused; shown and own
values spelled as before). It fails with notOffered disabled by hand:
all 8 refusals were spelled as given.
- go test -tags nogui -p 1 ./internal/cli/ (whole package; it caught
Claude Desktop's tiers, so the hidden check is on the agent's shown
catalog, not the field's options), ./internal/profile/ (whole package),
internal/agent -run 'Spell|Pick|Connect|Visible|Rename|Pi|Codex|Set|Apply|Own'
plus every test in the files that call Spell or Pick, and internal/gui's
agent_connect, agent_models*, agent_model_order, agent_disconnect,
agent_nomodels, aside_native, aside_offline and codex_agents_v1 tests:
all pass.
- gofmt -l; go vet -tags nogui ./internal/agent for darwin, linux and windows.
- The built binary in the sandbox: Pi and Codex narrowed to "home" refuse
remote/group/smart with the message and keep their config; an unlisted
remote/group/newpool is refused; shown every model again, both take it;
Pi's own anthropic/… still disconnects as before.
Not tried: the GUI picker (it only offers shown models; the GUI's set
endpoint now gets the error text). No GUI file changed.
Full suite: SUITE_LINE
|
||
|
|
4c07442d29 |
provider: a model no catalog prices is at the price its plugin lists, or $0 when the plugin says it is free; devin's mover needs 0.1.18 (太陽と向日葵 on Discord)
太陽と向日葵 on Discord: Usage no longer showed what calls through Devin cost. Devin's own models (SWE-2, SWE-1.7 Lightning) are in no catalog, and ListPrice read only catalogs. In the owner's ledger on origin/main, devin claude-opus-5-5 and deepseek-v4-1-flash rows are priced and the swe-1.7-lightning row is blank. Devin lists its own price for each paid model in GetCliModelConfigs, and devin 0.1.18 (plugins 43d93b0) now gives it as the model's cost. 0.1.18 also makes swe-2 free again: Devin's new -lightning variants under SWE-2 had taken that away on 0.1.17. After every catalog, ListPrice now takes the plugin's price (pluginListPrice, an input or output above 0, read with plugin.Cost, which now carries cache read and write). If there is none, a model the plugin marks free (plugin.Model.Free) costs $0 (pluginFree). A catalog's price is still kept over the plugin's, and a plugin model with neither stays unpriced. The devin mover's min is raised to 0.1.18 (npm view --prefer-online on registry.npmjs.org: 0.1.18). A row is added to providers-accounts.md. Run: TestPluginFreeModelCostsNothing (new) and TestPluginCatalogPriceAndImages, -p 1: ok. Broke it by hand: pluginListPrice off turns swe-1.7-lightning red; pluginFree off turns swe-2 red. gofmt -l clean. go vet -tags nogui ./... for darwin, linux and windows: ok. Real use: a sandbox HOME with only the owner's Devin key, plugin 0.1.18 and this build. - `magpie plugin list --json` on Devin's live answer: swe-2 free; swe-1.7-lightning 2.5/12.5 (cache 1); swe-2-high-lightning 1/5; claude-opus-5-5 4/20. - `magpie usage --csv`: the 10-03 swe-1.7-lightning row is $0.000819, where origin/main gave none. Not done: Cursor auto, Qoder's and WorkBuddy's own models have no USD price from their plugins (they list credit multipliers), so they stay unpriced unless marked free. Full suite: SUITE_LINE |
||
|
|
dbf331211f |
agents: an agent plugin with no model key is connect only, a switch with no model picker (#2374, rocona)
A Raycast plugin wants magpie to write the gateway, the agent's key and
the model list, and leave the model to Raycast's own picker. agent.model
was required ("agent.model names no key"), and the row always had a
model picker whose pick Raycast never read.
An agent export without model is now connect only:
- its one field is provider, magpie or nothing, as an app whose one
setting is magpie as its provider (ZCode); ListsModels is set, so the
row has the model list button and no model picker; no new UI control
and no new strings
- connect is called without model and only its keys are written; the
stash, the restore on Disconnect, the agent's own key and Check work
as before; Sync calls connect again on a catalog change
- such a module must export connect (else it doesn't load, saying why),
and connect must return keys (else the connect errs and nothing is
written), so the row never says connected with nothing written
An export with model behaves as before. Docs: the plugins page (en, zh,
ja) and docs/subsystems/agent-wiring.md.
Tests (internal/agent/plugged_connect_only_test.go):
- TestPluggedConnectOnly: one provider field, menu, connect without a
model, no model key written, the user's key and theme kept, list
follows a catalog change, Check sees a base moved by hand, off puts
everything back.
- TestPluggedConnectOnlyWritesSomething: no connect is a load error;
connect returning {} errs and writes nothing.
Broken by hand (only forced false and model passed): both FAIL.
The /api/state row for such an agent was dumped through gui.state() in
a temporary test: key provider, one magpie option, menu true, the same
shape as ZCode's. zcode-models, plugin-agent and agent-connect GUI tests
pass in Chromium and WebKit (46/46; every language, 1100/980 and 420).
Run at origin/main
|
||
|
|
3d63fc9cb5 |
gateway: an error in a stream already begun says its status and that it may be retried, so Pi asks again (#2372, zminds)
Once a group has sent the agent the stream's headers (the keepalive
while a member is slow), a later failure reaches the agent as an error
event in a 200 stream, with the member's words only: "no first token in
30s", "Upstream service temporarily unavailable", "521 status code (no
body)". Pi decides whether to retry from that text alone, and none of
these match its list, so the turn ended after one try where Claude Code
and Codex retried.
streamError, the one place every in-stream error passes, now runs the
text through saysPassing: for 408, 429 or 5xx whose text names none of
the words such agents retry on, it appends "(<status>: you can retry
your request)". A text that already says so, and a request's own fault
(400, 401, 404 ...), are left as they were. A response not yet begun
already carries its real status; unchanged.
Not done: an X-Magpie-Retryable header (can't be sent once the stream
has begun), and widening retryable()/passing() for relay wordings and
521-527 (overlaps the #2313 work on relay 400s).
Tests (internal/gateway/stream_error_passing_test.go, with Pi 1.2.0's
own allow and deny regexes as the reporter quoted them):
- TestStreamErrorSaysItPasses: the reporter's literal texts.
- TestGroupLastFailureInStreamSaysItPasses: a slow first member, a
keepalive, then a last member's relay 503; the stream's error is one
Pi retries. Broken by hand (Text: msg back): FAIL.
Run at origin/main
|
||
|
|
49639cd162 |
agents: a plugin signed in to, out of, or listing new models updates the agents' model files (#2373, 18565882223-beep)
After signing in to Trae CN (a plugin's subscription), Pi's models.json
kept the list it had before the sign-in, so Pi's picker had no trae-cn/*
model while settings.json named one. A plugin's sign-in change
(plugin.OnChange) only dropped what the gateway held; catalog.Changed
(SyncCatalog), which a provider saved runs, never ran for a plugin. Now
plugin.OnChange and a new plugin.OnListed (told when the host lists
providers/models other than the list kept, also across a restart) call
catalog.Touched, so every connected agent's own model list follows, Pi's
models.json among them, and a sign-out takes the models out again.
Not reproduced: the report's GUI pick leaving models.json's mtime
unchanged. GUI and CLI picks go through the same Agent.Pick, which writes
models.json in-process here. With this change the file is rewritten when
the plugin lists its models, not only on a pick. PiCode's providers.json
isn't wired by magpie at all; unchanged.
Tests:
- TestPluginSignInReachesPiModels (internal/agent): pick a model, sign
Trae CN in, models.json lists trae-cn/kimi-k3-max; sign out, gone.
Broken by hand (hold.go back to plugin.OnChange(Changed)): FAIL
"models.json hasn't Trae CN's models after its sign-in".
- TestNewListIsTold (internal/plugin): a new list is told once, the same
list or the one kept on disk is not. Broken by hand (listed() not
called): FAIL "the first list: told 0 times, want 1".
Run at origin/main
|
||
|
|
deffaed85e |
draw: Volcengine Ark's Seedream is asked as its images API takes it: watermark false, reference images as JSON, one request per image, a ratio as its 2K size or an error (JL on Discord)
JL (#help): magpie_image through a Volcengine Ark provider came back
watermarked, edits went as a multipart form, and n and a ratio size
were sent as for OpenAI. Checked against Ark's own doc, 图片生成 API
(https://www.volcengine.com/docs/82379/1541523, read 2026-10-15):
- watermark is a boolean, default true ("AI 生成" in the corner);
- image is a string or string[], a URL or data:image/<fmt>;base64,...;
there is no edits endpoint, it goes to /images/generations;
- there is no n field (one image, or a group the model sizes itself
under sequential_image_generation, which 5.0 pro/flash refuse);
- size is a tier (1K/1.5K/2K/3K/4K by model) or WIDTHxHEIGHT; a ratio
is to be described in the prompt. The doc lists each ratio's 2K WxH;
4.0/4.5/5.0 lite's 2K table is inside every model's pixel range (5.0
pro's max 2048x2048x1.1025 too), so it is the one used;
- no quality, no mask; output_format png/jpeg and background
transparent exist (5.0 models) and are passed when asked.
drawArk (draw_volcengine.go), reached from drawImages for any
ark.*.volces.com base (the preset's plans or a pay-as-you-go provider
added by hand): JSON body with watermark false and b64_json, images in
image, one request per image through eachDrawing, a listed ratio sent
as its 2K size and any other ratio a 400 saying to put it in the
prompt or give WxH, before Ark is asked. A mask is a 400.
Not tried against the real Ark API (no Ark key here); the fake server
follows the doc's request and answer shapes.
Run (worktree at origin/main
|
||
|
|
7dc5cd8f08 |
provider: Codex keeping its sign-in in the macOS keychain is read and written there (#2367, Dony2050)
Codex 0.162 with cli_auth_credentials_store = "keyring" or "auto" saves
its ChatGPT sign-in to the keychain and deletes auth.json. magpie read
only auth.json, so it hid the Codex provider and every saved account.
Adapted from Dony2050's fcebfc322 (fix/codex-macos-keychain). The changes
from that branch are below.
What Codex does (codex-rs at rust-v0.162.1: login/src/auth/storage.rs,
config/src/types.rs, features/src/lib.rs). The item is service "Codex
Auth", account "cli|" plus the first 16 hex digits of the SHA-256 of the
canonicalised CODEX_HOME. Its value is auth.json's JSON on one line.
keyring reads only the item. auto reads the item, and falls back to
auth.json when there is no item or the item can't be loaded. Saves follow
the same order. With [features] secret_auth_storage on (the default on
Windows), keyring and auto use Codex's encrypted storage instead.
internal/provider/codex_store.go is now the one reader and writer:
- A keychain interface. The real one runs `security` the way Claude Code's
item is read (keychainText, proc.CommandContext, 10s bound; errors carry
no argv or output). Tests get a fake (isolate, CodexKeychainForTest).
- readCodexLogin follows Codex's rules on macOS. keyring with no item is
signed out. keyring with a refused read is unknown (codexStoreError),
never signed out. With the encrypted storage, on Linux and on Windows,
keyring and ephemeral are unknown and auto is auth.json. A config.toml
that doesn't parse reads auth.json as before.
- Reads are kept 10s, a refusal 10 minutes, and only one `security` ask
runs at a time. Each read can be a Keychain prompt, and codexToken runs
on every request.
- A refresh writes the rotated tokens back where they came from, with
unknown fields kept, after re-reading the item.
- saveCodexLogin (switch, first sign-in) re-reads the store first. It
refuses when the store couldn't be read, when config.toml doesn't parse,
for ephemeral, and for a store magpie doesn't read. It never deletes
auth.json; Codex cleans that up itself.
- deleteCodexLogin (signing the last account out) removes the item, then
auth.json, as `codex logout` does.
- Routed through it: codexAccount, codexToken (it now takes the home dir),
liveLogin, CodexAPIKeySignedIn, codexLoginAuth, the usage card's
codexUntil, session identities, switchSavedLogin, addLogin, forgetLogin,
and agent's codexChatGPT/Source (provider.CodexSignIn).
- savedButSignedOut now says what was found (codexSignedOutWhy): nothing
in the item, an item macOS wouldn't give (allow it, or use file), or a
store magpie doesn't read here (use file). This replaces ed6e27f5f's
codexCredentialsStore and its single "magpie doesn't read the keychain"
text.
Changed from fcebfc322: secret_auth_storage is honoured (the branch would
read and write the wrong item); there is no second keychain package; reads
are cached and a denial backs off (the branch spawned `security` on every
read); auth.json is not deleted after every keychain write; auto falls back
to the file only when there is no item; the tests use an interface fake on
every OS instead of a darwin-only PATH fake; codexChatGPT keeps its
meaning; a malformed config.toml doesn't hide a file sign-in.
Run (in the wt-2367 worktree, sandbox HOMEs only, no real keychain or
`security` run, nothing under ~/.codex):
- gofmt -l: clean. go vet -tags nogui ./... for darwin, linux and windows:
clean.
- go test -p 1 -tags nogui ./internal/provider: ok (293s).
./internal/agent: ok (1291s). An earlier agent run hit the disk filling
up (ENOSPC from other sessions' builds); it was rerun with room.
./internal/gateway -run 'Codex|Login|Account': ok (261s).
- Broken by hand. The keychain never read (keychainItem false):
TestCodexSignedInInKeychain, TestCodexKeychainRefreshWritesItem,
TestCodexKeychainSwitch, TestCodexKeychainAskedSeldom,
TestCodexKeychainSignOut and TestSavedButSignedOut go red. saveCodexLogin
ignoring a refused read: TestCodexKeychainSwitch red ("switched over a
sign-in the keychain wouldn't give"). No cache:
TestCodexKeychainAskedSeldom red (20 asks for 20 reads). agent's
codexChatGPT reading auth.json only: TestCodexSignInInKeychain red.
- Not tried: an item Codex itself wrote. Codex writes it through
keyring-rs, and its ACL may trust only codex, so macOS may prompt the
first time magpie reads it, and Codex may prompt after magpie rewrites
it (`add-generic-password -U`). An unanswered prompt is killed at 10s
and reads as unknown. The reporter is asked to confirm on #2367, which
stays open.
Landing: this goes on top of ed6e27f5f (in this worktree as its
cherry-pick 66cdde294) and replaces that commit's message.
Co-authored-by: Dony2050 <88673296+Dony2050@users.noreply.github.com>
Full suite: SUITE_LINE
|
||
|
|
ad312dfee9 |
zhipu: a 1308 or 1310's reset time, written with no zone, is read as Beijing's, and a held refusal says its time with the offset (Player on Discord)
Player reached a Remote magpie with a GLM Coding Plan key: "Z.ai:
[1308][Usage limit reached for 5 hour. Your limit will reset at 2026-10-15
20:12 (out of its allowance: not asked again before 17:12)". Z.ai's 1308
and 1310 ("Usage limit reached for N hour. Your limit will reset at
YYYY-MM-DD HH:MM:SS", bigmodel.cn "您的限额将在 … 重置") write the time
with no zone. It is UTC+8: code-yeongyu/senpi#3348 has a 1308 received at
2026-09-21T17:17:32Z saying 01:18:11, 39s later as UTC+8 and 8h later as
UTC; kodustech/kodus-ai#2104 and openclaw/openclaw#97764 show the same
zone-less form for 1310. resetsWhen reads only a time with its offset, so
nothing read it: the key rested quotaRest (15 min), the held refusal said
"not asked again before" a quarter-hour on (17:12, this magpie's local
time with no zone), and after it Z.ai was asked and refused again until
20:12 Beijing time.
- routing.go: zhipuResets/resetsZhipu read Zhipu's own words ("Your limit
will reset at", "您的限额将在") then a whole date and a time to the
minute at least, in UTC+8; not when a digit, colon or zone follows
(cut in its seconds, or a zone of its own, which resetsWritten reads).
resetsAt tries it after resetsWritten, so restAfter and keepRetry both
see it, for the built-in key, a relay passing it on, and a Remote
magpie's held refusal.
- heldClock: a held time is given as "20:12 UTC+8" (today) or
"Oct 16 09:00 UTC+8", since its reader may be a Remote magpie's user on
another clock. Siblings: the quota-held 429 (gateway.go), the capped
window error (fallback.go), the spent searcher (search.go) and describer
(vision.go), all of which wrote Local() with no zone.
- docs/subsystems/gateway-routing.md says both.
The "manual weekly reset" was Z.ai's weekly reset card, spent on Z.ai's
site (magpie only counts them,
|
||
|
|
5c0049a38c |
agent: MothX is an Agents-page row, wired into ~/.mothx/settings.json, and Disconnect puts it back (#2353, zhenruyan)
MothX (oschina/mothx, formerly vibecoding; npm mothx-installer) reads its providers and start-up model from one settings.json: $MOTHX_DIR, else %APPDATA%\mothx on Windows, else ~/.mothx. This follows zhenruyan's fork (#2353) and the jcode/Prime Agent pattern. What changed - internal/agent/mothx.go: the agent. Connect writes provider "magpie" (openai-chat at the gateway's /v1, key magpie-mothx, one entry per magpie model with reasoning, input, contextWindow, maxTokens, cost) beside the user's own providers, and sets defaultProvider/defaultModel; "thinking" is defaultThinkingLevel, narrowed to the levels magpie knows for the model (none → off). thinkingFormat "openai" makes MothX send reasoning_effort for every model; without it MothX guesses Qwen's enable_thinking/thinking_budget or DeepSeek's thinking from the model id. A thinkingFormat or headers the user put in magpie's block are kept. Model options: the user's own providers' models, the current built-in pick (deepseek-openai/…), then magpie's. - Disconnect: settings.json is copied aside before magpie's first write (beforeMagpie) and put back byte for byte when nothing else changed; a file that wasn't there goes again. When MothX rewrote it meanwhile (/model, /statusline … global: SaveGlobalSettings marshals the whole struct), only magpie's provider, the pick and a providers object left empty go; the user's changes stay. - Detection, the restart notice (mothx or vibecoding running; translated in zh-CN, zh-TW, ja, de), WSL distros (~/.mothx), MOTHX_DIR in agentenv and the WSL dir moves, CLI updates through npm mothx-installer. - usage names its requests: the User-Agent is "Vibecoding Client/<ver>", matched by the alias vibecoding (usage.AgentOf takes the first word). - GUI: the icon (upstream docs/assets/mothx-small.png, MIT). - Docs: README en/zh lists, docs/reference.md (table row, provider-scoped list, notes), docs/subsystems/agent-wiring.md. - Not in this commit: MothX as a Library skills target (its own goal). Run - go test -p 1 -tags nogui: TestMothX* (real first-run settings.json as the fixture; user keys, headers and thinkingFormat kept; no-op Sync and same-value Set leave bytes and mtime alone; Disconnect byte-identical; no-file round trip x2; changes while connected kept; MOTHX_DIR/Windows/ WSL dirs; thinking levels), TestAgentOf, TestEveryNoticeIsTranslated, TestEveryAgentNamedByItsKey, TestWSLMore*; then ./internal/agent (1120s at load ~100; an earlier run hit the default 10m timeout inside TestReasonixConcurrentEditsAndSync at load ~50, not a failure), ./internal/agentenv, ./internal/usage: ok. - Broken by hand, each red then restored: no take() (TestMothX and RoundTripNoFile red), user thinkingFormat not kept, thinkingFormat "openai" dropped, the vibecoding alias dropped (TestAgentOf: got "Vibecoding"), the empty-providers cleanup (KeepsWhatChanged red). - gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./... clean. - GUI (playwright 1.62.0, chromium and webkit): agent-notice-lang, models-add-and-icons, pi-default-note 30/30; a scratch check of the MothX row (icon loads, connect, notice in the window's language, fits) in en/zh/zh-TW/ja/de at 1100 and 420: 22/22. - Real binary, MothX 1.3.104 (npm mothx-installer) in a sandbox HOME against a sandbox `magpie serve` and a fake OpenAI upstream: - `magpie mothx magpie/fake/echo-1` wrote the block; `mothx doctor` showed provider magpie, model fake/echo-1. - `mothx -P "Say PONG"` answered from the fake; usage.jsonl recorded agent mothx, provider fake. - Adding qwen3.7-plus to the provider live-synced the block (context, maxTokens, cost, reasoning). With thinking high, MothX sent reasoning_effort "high"; with thinkingFormat removed by hand it sent enable_thinking/thinking_budget instead, and `magpie provider refresh` put "openai" back. - The interactive TUI (tmux) started on "magpie | Qwen3.7 Plus · fake" and got the fake's reply; `magpie mothx effort medium` while it ran printed the restart notice. - `/statusline refresh 5 global` in the TUI rewrote the whole file (dropped reasoning:false, added responses:{…} to magpie's block); `magpie mothx` still read connected. `magpie mothx default` then left the original plus the user's refreshInterval, and (after the cleanup above) no empty providers. - Not tried: Windows and WSL with the real binary; a real vendor key. Full suite: SUITE_LINE |
||
|
|
0f398c4895 |
gateway: a group member whose window can't hold the request isn't asked it (dgqyushen on Discord)
dgqyushen on Discord: OpenCode Zen's free DeepSeek V4.1 Flash (200K) first in a group and a 1M DeepSeek subscription second, so that the first 200K go free and past that go to the subscription. The gateway fell over only on a refusal it reads as too long (#700, withRoom/failOverflow, tooLongUnsaid past 1.2x the window). A vendor that refuses a request just past its window without saying why (between 1.0x and 1.2x) reached the agent as that error while the next member had room, and every doomed request spent one against the free tier's limits. roomy (fallback.go), in serve after rules, affinity, the image filter and pinTo and before probeOne, estimates the request as the overflow path does (estimate) and leaves out the candidates whose known window (windowOf: Contexts, the catalog, ContextOf) is no larger, and their order rows with them. It is a check before sending, not a retry. Kept: a window not known, a body that doesn't parse, a single model, and a request no candidate holds (the first is asked, its overflow told to the agent to compact). A conversation stuck to the small member by affinity moves once it outgrows it. count_tokens (a count on the first member) and System One's decision models don't go through serve's candidate path and are left alone; every generation route (middleware, classify, search, vision, codex titles/backend, auto groups) goes through serve. No UI change: a member left out is absent from the route's order. TestPayloadTooLargeOverWindowTriesMemberWithRoom now expects the members too small not to be asked at all (c only, one try). Run: - go test -tags nogui -p 1 ./internal/gateway -run 'TestMemberTooSmallIsNotAsked|TestConversationOutgrowingItsMemberMoves| TestRoomyLeavesWhatItCantJudge|TestPayloadTooLarge': ok - the overflow tests (TestPayloadTooLarge, TestOverflow, TestContextOverflow, TestEveryVendorsOverflow, TestCodexOverflowInGroup, TestStreamOverflow, TestRateLimitNotContextOverflow) with the new ones: ok - gofmt -l clean; go vet ./internal/gateway (darwin); GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean; go build darwin, linux, windows: ok. Broken by hand: the roomy call in serve commented out: TestMemberTooSmallIsNotAsked red (400 "FREE: Invalid request parameters"), TestConversationOutgrowingItsMemberMoves red (free 2, paid 0), TestPayloadTooLargeOverWindowTriesMemberWithRoom red (a 1, c 1, 2 tries); restored, all green. Not run: the whole internal/gateway package (the run failed to build, "no space left on device", the disk at 0 GB free) and the full suite (left to the batch's run). Not tried against the real OpenCode Zen. Known: the estimate is bytes/4, so mostly-CJK text counts high and a member may be passed over a little early. Full suite: SUITE_LINE |
||
|
|
0dbb1a8490 |
library: subagents are written once and given to every agent in its own format, with what each agent can't bind shown (#2283, chuanchinatest)
The Library has a Subagents tab beside Hooks. A subagent is a name, a
description, a prompt, and the library's skills and MCP servers it uses.
magpie writes it to each ticked agent's user-level folder in that agent's
format, rewrites it on every change, and takes back only files it wrote.
Where each one goes (syncSubagents, subagentSpecOf):
- Claude Code: ~/.claude/agents/<n>.md, with skills and mcpServers
- Codex: $CODEX_HOME/agents/<n>.toml (name, description, developer_instructions)
- OpenCode: ~/.config/opencode/agents/<n>.md (mode: subagent)
- Gemini CLI ~/.gemini/agents, Qwen Code ~/.qwen/agents, Grok ~/.grok/agents,
Cursor ~/.cursor/agents, Copilot CLI ~/.copilot/agents/<n>.agent.md
- Factory Droid: ~/.factory/droids/<n>.md, with mcpServers
Skills and servers are named only where the agent's file can name them.
The page says, per agent, which of the two it won't bind, and that only
the Cursor app reads ~/.cursor/agents (cursor-agent reads a project's only).
Agents in WSL and agents with no user-level folder are greyed out.
The user's own files: every file is recorded by the hash of what magpie
wrote (Applied.Subagents). A same-name file of the user's is never written
over (the agent gets a problem). A file the user edited is theirs from then
on: it is neither rewritten nor removed. A carried library doesn't carry
subagents yet (as with hooks).
The Library's tabs now wrap onto a second line rather than scroll a narrow
window sideways (eight tabs in German at 560px). library-servers-bulk's
window goes from 1000 to 1100px tall to keep its stated premise that the
whole list fits.
Run:
- gofmt -l, and go vet -tags nogui for darwin, windows and linux: clean.
- go test of internal/library, internal/gui and the packages that import
internal/library, at this head: green.
Full suite: SUITE_LINE
- New tests: TestSubagentsEachAgentsFile, TestSubagentsLeaveTheUsersFiles
(covers the user editing magpie's file and then a sync), TestSubagentCheck.
- GUI: library-subagents (new) passes in Chromium and WebKit, at 1100 and
420, in en, zh, zh-TW, ja and de. Also all library-*, gui-ja, gui-de,
gui-zh-tw, i18n-keys, images-library-way, skill-* and mcp-* tests pass.
Greying out the WSL agent was broken by hand, and library-subagents
went red.
- Real binaries in a sandbox HOME against a fake upstream: each one sees
the subagent magpie wrote.
- Claude Code 2.1.300: it is listed in the system prompt.
- OpenCode 2.0.25: debug agents.
- Grok 1.0.50: grok inspect.
- Codex 0.162.1: spawn_agent's roles, with --enable multi_agent_v2. v1
showed no spawn_agent with a custom provider.
- Gemini CLI 0.63.0: <subagent> in the request.
- Qwen Code 0.21.9: its agent types.
Not tried: Factory Droid and Copilot CLI (both need a sign-in; Copilot
stops on auth before it reads agents), and the Cursor app.
|
||
|
|
c14842fbb7 |
routing: a try the gateway went on from says it went on, not that the agent got it (#2281, xishuchkui-code)
xishuchkui-code's Antigravity account answered 502 with an empty reply,
which doesn't rest it; the gateway went on to the next account and that
one answered. The Routing page's story said "answered 502 — an error
another account wouldn't fix, so Claude Code gets it" (换账号也无法解决,
Claude Code 收到此错误), and the account's row said "502 · failed ·
passed to Claude Code". Both guessed the outcome from where the try stood
in the order (not last, no rest, no retry), not from what the gateway did.
What came of a try is now read from the record. The gateway appends a try
to Route.Tries only as it asks it, so a later try is the request going
on; with none, the error ended the request, the agent's once the route
is done. No marker was needed for that. The one case the record can't
show is the `other` hand-back: the last try left, out of its allowance
after an earlier failure that wasn't one, while the agent is told the
earlier error (Discord, waroy). That try is now marked Try.Earlier.
Siblings in trySaid that guessed the same way:
- a try that went on with no rest: "answered {status}, and the request
goes on to {next} … doesn't rest for it" (was "wouldn't fix … gets it");
- a resting try with nobody after it (the last key, #1772) said the
request goes on to "the next"; it now says nobody is left and the
agent gets the error;
- slow to begin with nobody left said it went on to the next; same;
- the Earlier try says the agent got the earlier try's error;
- a failed try with no next on a route still running says only what it
answered.
The account row: "passed to {agent}" only for the route's last try once
it is done; a try the gateway went on from says "{status} · {fail} ·
went on to the next". Usage's request detail only shows the gateway's
"answered on a retry" counts and the CLI/TUI don't tell tries, so neither
changes. 6 new strings, in en, zh, zh-TW, ja and de.
Run at this head (rebased on origin/main
|
||
|
|
0fe7892320 |
library: shared instructions can be given to Alma, after the profile in its ~/.config/alma/USER.md (#2315, Jie211)
Alma had no instructions target: the library said it "has no user-wide
place for instructions". Alma 0.4.164's own main process
(out/main/index.js in its app.asar) does read one. Its main chat puts
~/.config/alma/USER.md into the system prompt as "USER PROFILE (your
owner/primary user...)", or a workspace's USER.md in its place. Alma's
prompt calls the file "your owner/primary user's profile (name,
preferences, habits - editable)". Its leading front matter (name,
telegram_id, discord_id, matched with ^---\n...\n---) is who its bots
answer to.
So Alma's target gets Instructions = ~/.config/alma/USER.md and a new
Profile flag:
- magpie's part goes after the user's, so the front matter stays first
and Alma still finds its owner. Turning Alma off leaves the file as it
was. A USER.md magpie made holding only its part is taken away again.
- ImportInstructions refuses a Profile target. Moving the user's lines
out would take the front matter out of USER.md and put the owner's
telegram/discord ids into every agent's file. The page hides "Move its
own into the shared text" for it (AgentInstructions.Profile), and adds
an aside in en/zh/zh-TW/ja/de. The aside says the file is Alma's
profile of the user, and a workspace USER.md is read instead.
Not tried with the real Alma app. Its live ~/.config/alma was not touched.
What Alma reads was taken from its bundled source. Sub-agents are not
confirmed to read USER.md.
Tests (sandbox HOME, Jie211's own line as the shared text, a USER.md in
the shape Alma's setup writes):
- TestTakesAlma
- TestAlmaInstructionsKeepTheProfile: the front matter is still matched
by Alma's own regexp after the sync; turned off, the file is the same
bytes.
- TestAlmaInstructionsWithoutUserMD
- TestAlmaProfileIsNotImported
Broken by hand:
- the Profile check in ImportInstructions taken out:
TestAlmaProfileIsNotImported goes red;
- Alma's Instructions path taken out: TestTakesAlma and
TestAlmaInstructionsKeepTheProfile go red.
Ran (at the reviewed head, on origin/main
|
||
|
|
357ffac7be |
usage: a model's Same as prices its calls when no list does (#2344, liuweifeng)
A model a provider serves under its own id (a WorkBuddy kimi-k3-1, a relay's renamed gpt) had no price unless the user typed one, even when the user had already told magpie in the editor's "Same as" box which model it is. Its calls showed no API-price cost in Usage, window holds had no price to weigh, and `magpie model price` said unpriced. Now, when neither the user's prices, the provider's list nor models.dev's maker price covers a model, provider.SamePriceIn takes the maker's list price of the model it is the same as (settings.ModelSameAs), and the provider's price rate still applies. A price the user set, or a list that prices the model, always wins; nothing is inferred without a Same as. The same fallback is used by priceOf (Usage costs, re-priced when the ledger is read, so past calls pick it up), usage's apiPricer (window holds), the model editor's greyed list price, and `magpie model price`, which names where the price came from. The "Same as" tooltip says so in en, zh, zh-TW, ja and de. Run: - go test -p 1 -tags nogui ./internal/provider ./internal/usage ./internal/cli ./internal/gui (focused: TestSameAsPricesAnUnlistedModel, TestHoldsPriceTheModelItIsTheSameAs, TestModelEditorShowsTheSameAsPrice, TestModelPriceCmdSaysWhereThePriceCameFrom, plus the packages): ok - GUI (chromium + webkit): provider-same-as, i18n-keys, model-price-edit, 11/11 pass - gofmt -l clean; go vet -tags nogui for darwin, linux, windows: clean Broken by hand, each went red: - SamePriceIn dropped from priceOf: "kimi-k3-1 ... false; want $0.3" - usage's apiPricer fallback removed: "wasn't its API price: <nil>" - the GUI editor branch removed: "list <nil>" - the CLI source line disabled: TestModelPriceCmd... FAIL - the zh tooltip left untranslated: provider-same-as.test.cjs 0/2 A prefix-stripping branch passed when removed (MakerPrice already resolves vendor-prefixed ids like moonshotai/kimi-k3), so it was dropped. Not tried: a real WorkBuddy account's usage after the change. Full suite: SUITE_LINE |
||
|
|
0c0665126b |
quota: magpie quota --json and /v1/magpie/quotas tell each window's whole (holds / holdsWhy) as the Usage page does (#2333, zhenghaowen0967)
usage.WithWindowHolds reckoned a subscription window's whole (tokens, and cost at API list prices) from magpie's own calls, or why it can't, but only GET /api/usage/quotas and its refresh called it. magpie quota --json, GET /v1/magpie/quotas and its ?kept=1 list showed name, used, remaining and resetsAt only, so a script comparing plans had to rebuild the estimate from the log without its guards. Package provider can't import usage, so usage sets provider.ReckonHolds in an init (like the other provider hooks). quotaReport, which QuotaReport, KeptQuotaReport and RefreshReport share, runs it once over every card and QuotaSpan carries Holds and HoldsWhy. The log is read through usage's cached snapshot, so ?kept=1 (magpie statusline, every message) adds no full read after the first. A key held to a budget, models or accounts and told cards (#2216) is not told holds: they are reckoned from every call routed through the account, other keys' too, so quotaScope.quotas drops them; this machine and unheld keys get them. The Balance guard in holdsBounds (a Codex account holding credits gets no whole and no reason) is unchanged; it is answered on the issue. Docs: reference.md's /v1/magpie/quotas section names holds/holdsWhy and each reason; providers-accounts.md's Allowance row names the hook. Run (sandbox HOME, -tags nogui, -p 1): - New TestQuotaReportTellsWindowHolds (provider), TestQuotaReportsReckonByTheLog (usage, against a real usage.jsonl in the sandbox) and TestHeldKeyToldNoWindowHolds (gateway) pass. - Broken by hand: the ReckonHolds call in quotaReport skipped → provider test FAIL "reckoned 0 times over 0 cards"; Holds/HoldsWhy not copied into QuotaSpan → FAIL "5 hours told no whole"; usage's init removed → usage test FAIL "provider.ReckonHolds isn't set"; quotaScope not clearing them → gateway test FAIL "a held key was told 5 hours's whole". - go test ./internal/provider ./internal/usage ./internal/cli ./internal/gateway: ok. - gofmt -l clean; go vet -tags nogui darwin, GOOS=linux, GOOS=windows on provider, usage, gateway: ok. - Not run: the GUI suite (no GUI file changed), and against the owner's real accounts. Full suite: SUITE_LINE |
||
|
|
d8d52c6e97 |
agent: Raycast is an agent magpie connects: a magpie entry in its Custom Providers' providers.yaml, magpie's models in Raycast AI's picker (lx_78654 on Discord)
lx_78654 asked on Discord: "agents能否加一个raycast". Raycast AI takes models of the user's own as Custom Providers (Raycast Pro, "Available on: Mac, Windows"), from ~/.config/raycast/ai/ providers.yaml in the user's folder on both systems (https://manual.raycast.com/ai/custom-providers). Raycast watches the file, so no restart notice. What changed: - internal/agent/raycast.go: a new agent, "raycast". One field, provider: connecting adds an entry, id magpie, to the providers list: the gateway's /v1 (OpenAI compatible, no /chat/completions), an api_keys alias holding magpie-raycast (Raycast's User-Agent isn't known, so its key tells it apart), and one model per magpie model with name, context and all five abilities said (Raycast assumes tools and vision off when left out): tools and system_message on, vision for a model taking images, temperature off for one that refuses it, reasoning_effort for one with effort levels. ListsModels: the model is picked in Raycast. - The list is edited as a yaml node, so the user's other providers, the top-level tools block (anchors too) and comments stay. - A key the user adds to magpie's entry or to one of its models (include_user_email, a description) is kept on a sync; a model gone from the catalog leaves the list. A sync with nothing to change doesn't write. - Disconnect takes the entry out, the list when it was the only one, and a file left with nothing in it (Raycast's providers.template.yaml is never touched). A providers key that isn't a list is refused and the file left as it is. - Detected by Raycast.app (com.raycast.macos) or the ~/.config/raycast folder. - agents.go: registers it. - icons/raycast.svg: Raycast's mark from Simple Icons (CC0), currentColor. - docs/reference.md, docs/subsystems/agent-wiring.md, README.md, README.zh-CN.md: Raycast's row and its place in the agent list. What was run: - go test -p 1 -tags nogui ./internal/agent -run '^TestRaycast' in a sandbox HOME: ok. The fixture is the manual's LM Studio and tools examples, with comments and an anchor; the result is decoded strictly (KnownFields) into the manual's schema. Red by hand when I: - turned off the no-op check ("a sync with nothing to change wrote"); - replaced the merge with magpie's entry alone (the user's include_user_email and a model's description gone). - go test -p 1 -tags nogui ./internal/agentenv: ok. - The whole ./internal/agent package didn't finish here: the first run hit the 10m default timeout at TestInstalledVersion with the machine at load ~110 (other sessions' suites), the second (-timeout 40m) ran 20 minutes with no FAIL and then stopped on "no space left on device" when the disk filled (0 GB free, not this run's files). It needs a run on CI. - gofmt -l; GOOS={darwin,linux,windows} go vet -tags nogui ./internal/agent: ok. Not tried with a real Raycast. On Windows it is found by the ~/.config/raycast folder only (its install path isn't verified). WSL isn't covered. Full suite: SUITE_LINE |
||
|
|
ecaa7e7dd7 |
gateway: a decision provider of several keys asks the next when one is out of quota, at /v1/systemone and as a classifier, in its routing's order (fflake33 on Discord)
A TypeSafe Jev provider with several keys never left its first key when that one's quota ran out. serveSystemOne and the classifier (askClassifier → askJev) always sent to p.Key, with no rest and no rotation. Only a decision group failed over (serveDecisionGroup, askDecisionGroup). Now the single provider goes the same way as a group: - decideKeys plans its keys and accounts with s.plan, so Smart or In order, rests and barred keys apply. probeOne keeps only the resting one back soonest. - serveDecideTries and askDecideTries (the group's loops, pulled out) ask each in turn. A retryable failure that isn't the request's own rests it and the next is asked. - serveSystemOne keeps #905's limits. A gateway key held to some accounts is asked only on those (allowedCandidates), and gets 403 keyAccountsError when none serves the model. - A provider whose every key is set not to serve the model is refused 403 (barredError) instead of being sent on its first key. - decideSeat is gone; the trace lists every key tried. - docs/subsystems/gateway-routing.md says so. Run: go test -p 1 -tags nogui -run 'SystemOne|Decid|Decide|Jev|Classif| KeyAccount|KeyModel|Disabled|RemoteMagpie|Caller|Usage|Plugin.*Decide| Barred|Rest|Probe' ./internal/gateway (ok, 124s). TestDecisionProviderKeysFailOver (Smart and In order) refuses the first key 429 and checks: - /v1/systemone answers 200 from the second, the trace has two tries and the first rests, and one usage row goes to the provider; - the next request asks only the second; - the same holds through askClassifier. Broken by hand: with the old decide.go, decide_group.go and classify.go it fails "systemone: 429 no capacity for k1" in both. The first version of the reordering ran the barred check before the held-key one, and TestGatewayKeyAccountsSystemOne caught the changed 403 message. The held check now runs first. gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./internal/gateway ok. Not tried against the real TypeSafe API. Full suite: SUITE_LINE |
||
|
|
e894443932 |
trae: a check-in Trae CN refused 9074 says Trae refused it and to check in in the Trae CN app, not that Trae pays only its own app (#1920)
#1920 showed Buddy Switch checking in third-party Trae CN accounts, so
"Trae CN only gives check-in credits to its own app" wasn't true. What is
known is that Trae CN answered the claim 9074 (当前参与用户太多). The
own-app outcome stays as it was (the day's answer, no Check in now), but a
Trae account (By "trae") now has its own text in every place it shows:
- GUI card and Settings line: two new keys in en, zh, zh-TW, ja and de
("Trae CN refused this check-in (9074: too many taking part); check in
in the Trae CN app" / "Trae CN 拒绝了这次签到(9074 当前参与用户太多),
请在 Trae CN App 里签到"). WorkBuddy keeps the shared own-app key.
- TUI line and cell, CLI: provider.TraeRefusedWords; the cell says
"签到 refused by Trae CN (9074) · check in in its app".
- trae_checkin.go, workbuddy_checkin.go and provider-plugins.md comments
and the claim's fallback message say the same. They also note the
plugin side: since @magpie-community/opencode-trae-auth 0.2.14 the
account the machine's own Trae CN client is signed in as checks in with
the client's device id, read only. No id is made up or rotated (#1705).
Ran (worktree at origin/main
|