ccb75030aaba3cf7359ea2dd784c00ecc7e80c19
1500
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9162277b91 |
routing: Until used up stays on the next account once the first is used up (dzxx0496)
dzxx0496 on Discord: with free accounts one after another, the first used
up, requests went to the second; when the first renewed they went back to
it ("如果第一个恢复了,它又优先用第一个了"). No routing did what they asked:
In order and Smart both put the first back first.
A new routing, Until used up (drain, 用完再换): requests stay on one seat
until its quota is used up, then go on to the next in the list and stay
there. A seat counts as used up when its known allowance is at 100% or
it was refused for quota or credit (failQuota / failCredit, routes.Drained
called where the rest is recorded, so a failover inside one request moves
the pool too). A rate limit or other failure only passes it over while
it rests, as In order does. Each pool (a provider, a group/<id>) keeps its
own place; routes.Forget clears it.
Offered wherever a routing is picked: the provider editor, a group's row
menu and editor (app menu, no native select), the TUI, `magpie group set
<id> routing=drain` and a provider's routing=drain. Nothing defaults to
it, so no saved setting changes. SpentShareOf is 100 for it, as for In
order. Words in en, zh, zh-TW, ja and de (i18n.js and the routing
plugin's own), docs/subsystems and the site's start page (en, zh, ja).
Tests:
- internal/routes/drain_test.go: stays on the next when the first renews,
through a rate limit, all used up, a seat gone, per pool, Forget,
Drained after a renewal.
- internal/gateway/drain_test.go: a real request path with a fake upstream;
k1 refused for quota, k2 takes over, k1 renews: drain stays on k2,
In order goes back to k1. Red without the Drained hook (request 3 went
to k1). A rate limit comes back to k1; drain is saved on a provider and
a group.
- routing-drain.test.cjs: the Routing page's why and mode line in 5
languages, 1100px and 420px, Chromium and WebKit; red on the old assets
(20 of 20).
- routing-group-strategy, routing-save, builtins: the menu has 11 routings.
Run on mote (macOS) at origin/main
|
||
|
|
699ddf1524 |
gateway: a Codex account can spend its credits only after every other account, key and fallback (gokoshiki on Discord)
gokoshiki wants a Codex subscription first, then an OpenAI API key, then the subscription's credits. Until now an account at 100% that holds credits either kept its place and spent them there (on) or was held (off). This adds a third way per account, "last": - settings: CodexCreditsLast []string, empty by default, so a setting saved before it keeps its order. provider.CodexCreditsLast, CodexCreditsMode and SetCodexCreditsMode(user, on|last|off); SetCodexCredits(on) still means "in its place" and clears last. - gateway: candidate.creditsLast is true for such an account once a window for the model is used up and it is going on its credits (a call ChatGPT counts in no window stays in its place). restLast orders ready, then resting, then those, and marks Weighed.CreditsLast. restLast runs over the asides too, so such an account goes behind a provider's reserves (Accounts at once, |
||
|
|
2c6b7c0632 |
gateway, provider, gui: Accounts at once keeps the first N accounts taking requests, the others in reserve
01huadalang on Discord (#feedback 1566170404542742740): three ZCode
accounts used at once from one address got the address refused with a
405; two were served. They asked for one account to be used until it
runs out, then the next. Even under "In order", ZCode's maxConcurrency 3
spilled a full lane onto the next account (laneMate) and rests spread
the load, so every account was in use at once.
A provider's MaxAccounts (the editor's Advanced → "Accounts at once",
beside Concurrency; `magpie provider at-once <id> [n|off|default]`) is
how many of its accounts or keys take requests at the same time.
provider.AtOnce() is the user's own value, else what its plugin
declares (maxAccounts on the auth hook or package.json magpie, read by
host.js atOnceOf), else no limit; the user's 0 is no limit over the
plugin's. perKeyBarred keeps the first N in the user's own order
(rank), preferring ones not resting, and keepAtOnce puts the rest after
everything as asides with candidate.reserve (Weighed.Reserve). So in any
routing mode a reserve is asked only once the kept ones failed or rest,
and a kept one that rests gives its seat to the first reserve next time.
Guards: laneMate never spills onto a reserve; a full queue (laneErr)
drops the provider's reserves (dropReserves) and turns the request away
with the 429; session affinity moves a conversation off a reserve once
the kept ones can take it (affine "reserve"; Strict still holds).
Routing says "in reserve · {n} at once" on the row and why in the
request's story. zcode 0.1.40 (plugins 26864ec, on npm) declares 2, and
its mover min is raised to 0.1.40 two commits on.
Known leak, in docs/subsystems/gateway-routing.md: a failure that rests
nobody (a 5xx on one try) still passes that one request to the reserve,
as it does to any next candidate.
Tests: TestAtOnceKeepsFirstInUserOrder (every routing mode, a dragged
order, a resting key handing over its seat), TestAtOnceFullLaneWaitsForTheKept,
TestAtOnceReserveTakesOverAndGivesBack, provider TestAtOnce, plugin
host maxAccounts (hook and package.json), gui TestAtOnceSave, cli
TestAtOnceCmd, provider-at-once.test.cjs (both engines, five languages,
900 and 360px).
Broken by hand, each red then restored: laneMate's reserve guard
removed (FullLane times out); affine's reserve case removed
(ReserveTakesOver answers on k3); keepAtOnce disabled (all three red);
dropReserves disabled (FullLane gets no reply); the Routing row's
reserve branch removed (provider-at-once's Routing test red in all 10
engine/language runs).
Core budget: the field adds ~530 bytes to app.js; the neighbouring
editor comments are cut to fit, so TestCoreScriptBudget passes with no
raise.
Run on mote, Go 1.26.8:
- full suite, -timeout 45m, at a7d4c662d (on origin/main
|
||
|
|
5032d3ade7 |
gateway: a reasoning item magpie hands Codex with its text in it becomes one of its own, a summary and nothing sealed (#2855)
What changed A Responses reasoning item that carries the model's reasoning as content parts (reasoning_text) — another vendor's shape; OpenAI's own items carry summaries — no longer reaches a client of magpie's as the upstream wrote it. It is made over into the item magpie makes of any other upstream's reasoning: its text (and its summaries) as one summary, an rs_ id, no content and no seal — in a reply translated for the client (magpieMadeReasoningRaw at the encoder's sealed item and the whole reply's renderer) and in one relayed as it came (reasoningTidy, a passthrough filter on Responses streams and whole replies, the item in output_item.added/done and in response.completed's output). The subsystems doc's rule is amended to say so. Why A Codex conversation that used OpenAI, went through magpie to DeepSeek, then had magpie disconnected again, was stuck: every later turn, the remote compact too, answered 400 "Invalid 'input[43].content': array too long. Expected an array with maximum length 0, but got an array with length 1 instead." The reporter's rollout forensics narrow it: the DeepSeek phase had left 25 reasoning items, each with its text in content parts and a 38-character encrypted_content of the vendor's own (not the gAAAA the thread's own GPT-phase items carry, which have no content), which Codex stores and replays to OpenAI. OpenAI takes a reasoning item sent back only with its content empty (#1411) and cannot open another vendor's seal, so such an item poisons the thread for OpenAI wherever it was planted — and once Codex holds it, no retry of magpie's can strip it: client keeps, and #2855 came with magpie out of the path entirely. A Chat-API upstream's turn has always translated to an item of magpie's own (an rs_ id and a summary, TestTranslatedChatReasoningCarriesNoContent pins it); the items the reporter held are a Responses wire's own, which both the translated and the relayed reply handed over as they came. What magpie hands a client must be re-sendable to a strict Responses upstream: the text is kept in the summary, so an upstream that wants its reasoning back still gets it (withReasoningText), and magpie's own OpenAI destinations keep the item out as they did (#1008, #1044, #1411). Run - TestForeignSealedReasoningGivenCodexCarriesNoContent (translated) and TestForeignSealedReasoningRelayedCarriesNoContent (relayed) fail on upstream/main with the issue's item handed over whole — content, empty summary and the vendor's seal in both output_item.done and response.completed — and pass with the change; TestTranslatedChatReasoningCarriesNoContent (a Chat upstream's reasoning, translated) is green without and with the change. - Restoring the three product files alone to upstream/main (tests kept) fails the two again; restoring them back passes. - Attaching content to the made item fails both again ("carries its text"), and dropping the made summary fails both ("carries no summary"). - go test -tags nogui -count=1 ./internal/gateway: ok 312.4s; -run 'TestTranslated|TestReasoning|TestSealed': ok 7.9s; go test -race -tags nogui -count=1 -run 'TestTranslated|TestReasoning': ok 9.4s. gofmt -l internal/gateway empty. go vet -tags nogui and go build -tags nogui -o /dev/null . on darwin, GOOS=linux and GOOS=windows: pass (a pre-existing cgo -Wenum-conversion warning in internal/gui/trayimage_darwin.go on darwin, untouched). Not tried against real OpenAI or DeepSeek accounts; the reporter's rollout reading is taken from the issue, not re-derived from a live thread. Reviewed and landed as one batch of 12 commits (gua's #4593, #3269, sibling, and four review follow-ups). Run for the batch, whose last commit's tree is 5d58a75f3: - Full suite before the rebase (base |
||
|
|
cbefb65987 |
gateway: a compaction summary answered 502 for ending short compacts locally too (#3526)
#3526's patch compacts locally when the summary ask ends short with an error. The same cut can come back as a recorded 502 whose error says it ended short (errEndedShort), with no error returned, and that still went to the client as a 5xx. The local fallback now runs before the status check, for both shapes (summaryEndedShort), and says why from the recorded error. A 502 that says anything else still goes to the client as it did. Edward4226 pointed at the 502 shape in the thread. TestCodexCompactCutShapesCompactLocally covers a stream error, a 502 saying it ended short (compacts locally) and a 502 saying more (stays 502). Landing record (yetone): Run at the pushed batch head (tree a6b084d0b, on origin/main |
||
|
|
45385f0eed |
redact: a secret's field name masks only in a tool's arguments and result, with secrets on (#2946)
#2946's patch masked any JSON value whose field name looks like a secret's (api_key, password, *_token) anywhere in a request body outside tool definitions. That is an exemption, and a mask, keyed on a field's name: it rewrote what the agent itself sends (mcp_servers' authorization_token, a top-level api_key, metadata.session_token) as well as the user's data. The name check now runs only where the user's data sits in the protocol: a tool call's arguments (Anthropic tool_use input, OpenAI arguments, Gemini functionCall args) and a tool's result (Gemini functionResponse.response is added to the places scan reads), and only with secrets masking on. The Authorization/Cookie rule masked the word after the header name in prose too ("Authorization: required for this route"). It now masks only a value with a credential's shape: one token, or a scheme word and a token, of 8 or more characters with a non-letter and not a ${VARIABLE}; or name=value cookie pairs. Tests: TestMaskJSONNamedSecrets puts its values in tool_use input, functionCall args and functionResponse response; TestMaskJSONSecretNamesOnlyInToolArgs holds the agent's own fields as written and nothing masked with secrets off; TestMaskAuthHeaders gains prose rows (no mask) and a Cookie row. docs/subsystems/gateway-routing.md says where the name check runs. Landing record (yetone): Run at the pushed batch head (tree a6b084d0b, on origin/main |
||
|
|
78632d4b84 |
gateway: a Codex compaction cut short with no candidate left compacts locally (#3526, Edward4226)
A summary wanted whole whose stream every candidate broke off reached codexCompact as an error none of its fallback conditions name: not a 404, not an unreadable item, not "Upstream request failed", not "response protection is unavailable". The relay ends such a stream with a response.failed event saying "the reply ended before it was complete" (#2274), and with nobody left to fail over to, that error fell out of the 404/protection family and went to Codex as a 502. Codex asked the same huge summary over, three times, each paying for the whole conversation, until compactFails answered 400 and held it: the conversation could neither compact nor go on. That is the no-candidate case #2274 left, after it made a cut summary fail over where there was someone to fail over to. The summary is magpie's own then, as when no model can be asked at all (#866, #1008, #1270 end so). The summary as text isn't tried either: the cut was in what the model wrote, not in what it was asked, and that would be another ask of the same huge prompt. The words before the cut are never taken: the local summary is built from the request's own items. A summary that failed halfway, or ended incomplete — the output limit's own event — is still told to Codex as it came and still counts the guard; only the bare break-off turns local. 401, 403, 429 and request-shape refusals are untouched. Run: TestCodexCompactCutAloneCompactsLocally (new) is red on the parent with the issue's 502 ("the reply ended before it was complete, so there is no summary") and green here — 200, one magpie compaction holding the local handoff, the cut stream's words in none of it, the last ask the fake saw still the original summary request (no plain-text retry). The #2274 tests keep their shape: TestCodexCompactCutSummaryFailsOver (a whole fallback summary still wins) green unchanged; TestCodexCompactCutSummaryIsNoSummary now covers the halfway and incomplete shapes alone (the cut one moved to the new test); TestCodexCompactKeepsFailingIsHeld holds on the incomplete shape, which still fails and rests nobody. Ablation: only codex_backend.go put back to the parent, tests kept — the new test is red again, restored, green. go test -tags nogui -p 2 -count=1 ./internal/gateway: ok (350.8s). Targeted TestCodexCompact with -race -count=2: ok. ./internal/usage: ok. gofmt -l clean; go vet -tags nogui on darwin, linux and windows clean; CGO_ENABLED=0 go build -tags nogui on all three ok. docs/subsystems/gateway-routing.md says the new terminal state. Refs #3526 Landing record (yetone): Run at the pushed batch head (tree a6b084d0b, on origin/main |
||
|
|
3f2faef620 |
gui: the Providers page has its own Hide accounts switch
Routing's Hide accounts (账号打码) also masked the Providers page, where nothing showed it was on or let you turn it off (Discord #feedback, 1566189346665799752). The Providers page now has its own switch beside its search box, placed and drawn like Routing's (.rt-mask moved from routing.css to app.css), and each page follows its own switch: Routing, Usage and the tray panel follow magpie.maskEmails, Providers follows magpie.maskProviders. The user's own choice is kept: when maskProviders was never stored, it is seeded from maskEmails and written at once, so someone who had masking on stays masked on both pages after the update, and someone who turned it off stays unmasked. A switch with a stored choice is not changed by Mask personal data's follow(); turning Mask personal data on still masks both (hideAccounts.set(true, true), in app.js and plugins/redact/page.js). show() asks hideAccounts.page() to re-mask when the page in sight follows the other switch. No new strings: the button reuses Routing's translated label and title. app.js 1,310,438, core under its budget, no raise. Run: - New internal/gui/tests/provider-mask.test.cjs, both engines, all 5 languages, at 1000 and 420 wide, plus the touched window-mask, account-eye, privacy-hides-accounts, mask-emails, plugin-name-unmasked, masking-demo-unblurred: 134/134 on mote. At the rebased head (origin/main |
||
|
|
a6de2a15ea |
gateway: an allowed_tools choice reaches the Grok plugin's fetch, end to end (#3153)
Follow-up to ggbdpq's grokShaped change: its test reads grokPluginBody alone. skygunner's TestAllowedToolsReachesGrokPlugin (852182f6 on their fork, from the #3153 thread) posts a /v1/responses request with an allowed_tools choice through the gateway to the fake Grok plugin and checks its fetch gets that object as sent, which is where the plugin decides on x_search. Taken as written; provider-plugins.md names it. Broken by hand: with internal/provider/grok.go at |
||
|
|
ca183561f7 |
gateway: an allowed_tools tool_choice reaches the Grok plugin (#3153)
grokShaped dropped a tool_choice object whose type isn't among grokTools on the plugin's path too, the same as for the built-in: a Responses request relayed to the Grok plugin in its own protocol reached the plugin's fetch with no tool_choice, so with the X search option on (grok 0.2.0) the plugin added x_search over a client's allowed_tools and a tool outside the allowed list went out. The plugin reads the choice and leaves an unsupported one out before Grok itself (every version since the TOOLS filter, the mover's min 0.1.18 among them), so grokPluginBody now keeps such an object, as it keeps the lone "none" (#3110); grokShaped's keepNone is forPlugin, since keeping is no longer only about "none". The built-in, which is Grok's last stop, still drops it. Run: - gofmt -l on the changed files: clean - go vet ./...: darwin and GOOS=windows clean; GOOS=linux vet needs -tags nogui (the GUI's wails doesn't vet without it), clean with it - go build: darwin, GOOS=linux -tags nogui and GOOS=windows: ok - go test -tags nogui ./internal/provider: ok 167.3s, no FAIL - go test ./internal/gateway -run 'TestToolsOffWithoutTools|TestGrok': ok - TestGrokPluginBodyKeepsUnsupportedToolChoice fails without the change ("plugin: tool_choice {Type: Mode: Tools:[]}"), passes with it; broken by hand, each way red then green on restore: deleting the choice whatever the path (plugin red), deleting only a supported type (built-in red) Landed (yetone): the next commit adds the end-to-end test through the gateway to the fake Grok plugin. Run at the pushed head on mote: go test ./... -timeout 45m on mote with this branch on |
||
|
|
c26d16018f |
gateway: a plugin model that refuses temperature is asked without it, relayed or translated (#2492)
What changed: the plugin host carries a model's temperature where it is said - the config model's temperature (Factory 0.1.31's configModels, plugins#154), models.dev's own, or a models hook's model field - into plugin.Model and pluginCatalog's catalog model, where RejectsTemperature reads it as it reads a built-in's. A Chat or Responses request relayed as it came to a model whose list refuses temperature and top_p now leaves them out (passthrough), as the translation of one (build) already did. A model nothing says so of keeps what the client sent. OpenCode's capabilities.temperature is not read: its false is what it reads a models.dev silence as, not a refusal said. Docs: the sampling row of gateway-routing, and provider-plugins' new "A plugin model's sampling". Run at |
||
|
|
1cf66e4b17 |
agent: a tool asked on Responses says strict: false, its optional parameters stay optional (#3055)
What changed: OpenAI's Responses API takes a function tool whose strict is left out as a strict-mode one and normalizes its schema, where every property is required, so a tool's optional parameters came back filled (#3055, ArakawaHenri). pi-ai (dsh's llm-pi-ai, Pi and its kin) says strict: false on an ordinary tool only when the model's compat says supportsStrictMode, which it takes as false where the compat is left out. magpie now says it: every model of a dsh route whose api stands as openai-responses carries compat.supportsStrictMode, by the api the route has now (the one the user picked in dsh's Models page kept), not by its name, beside the keys they set there (dshKeepCompat); and piModelJSON says it for a model best served on Responses, which Pi's and StepCode's models.json carry (Pencil's entries stay on Chat throughout). omp's models.yml is left alone: omp turns a models.yml away over a field its schema doesn't name (16.3.5 over a max), so the compat needs an omp version of its own pinned first. docs/subsystems/agent-wiring.md says so. Run: new TestDshTellsAResponsesToolsStrictIsOff and TestPiTellsAResponsesToolsStrictIsOff fail without the change (the first with "a model asked on Responses isn't told strict is off: Compat:<nil>", the second with "resp/gpt-5.5 is asked on Responses and isn't told strict is off") and pass with it; removing only the dsh case turns the first red and only it, removing only the piModelJSON compat line turns the second red and only it. go test ./internal/agent/ (TestMothX fails the same with both files back at the baseline here, so not from this change), gofmt -l on the changed files (nothing), go vet ./..., GOOS=linux GOARCH=amd64 go vet -tags nogui ./..., GOOS=windows GOARCH=amd64 go vet ./..., go build . (darwin arm64), GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui ., GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui ., GOOS=windows GOARCH=amd64 go build -o /dev/null . Landed (yetone). Broken by hand on mote: with the dsh case and piModelJSON's compat line taken out, both new tests are red ("a model asked on Responses isn't told strict is off: … Compat:<nil>", "resp/gpt-5.5 is asked on Responses and isn't told strict is off"). Run at the pushed head: go test ./... -timeout 45m on mote with this branch on |
||
|
|
5bfa9f0762 |
gateway: a group's backup gives the conversation back once the member listed ahead of it is ready again (01huadalang on Discord)
01huadalang on Discord, after |
||
|
|
5a56bc7d73 |
gateway: a CI job trades its OIDC token for a short-lived key (#4531)
xazaj on X asked for GitHub OIDC: a GitHub Actions job should get a
gateway key without a long-lived magpie key in the repository's secrets.
A rule (magpie gateway-key oidc add --key <id> --repo owner/name
[--ref …] [--environment …] [--claim k=v] [--ttl 1h] [--issuer URL]
[--audience a]; oidc list, oidc remove) names an issuer (GitHub Actions'
by default, any https issuer), an audience (magpie-<rule id> by default,
so a token asked for one rule opens no other, and the workflow needn't
know the gateway's address), claims (exact or path.Match globs) and the
gateway key the keys are issued under, which must be let issue. A GitHub
rule names the repository or its owner with no wildcard, or every
repository on GitHub could get in. No rule, no exchange.
POST /v1/magpie/keys/oidc with Authorization: Bearer <token> and an
optional {"ttl","models"} verifies the token (RS256 only, keys from the
issuer's discovery document's https jwks_uri, exp required, nbf/iat with
a minute's leeway, the rule's aud and claims, a jti traded once) and
issues a key through access.IssueKey under the rule's key, named
repo@ref (run N), living no longer than the rule. Everything issued keys
guarantee holds: bounded by the issuer's models and accounts, its spend
counted against the issuer, stopped when the issuer is turned off.
- A token is judged only against rules naming its iss, so it can't make
magpie fetch from a URL of its choosing.
- Keys are cached an hour per issuer, read by one request at a time with
no lock held across the fetch, asked again for an unknown kid at most
every 10s, and kept while the issuer is down; with none ever read,
nothing is let in.
- The route is lanGuard's one exemption from remoteKeyed (that exact
path, POST, no gateway key): only while shared, past the allow list,
and a refused token counts against tooManyAuthFails (429 past the
burst). A read-only key is refused it.
The issue's open questions, decided: rules are generic from the start
(the GitHub repository rule applies to GitHub's issuer); rules are CLI
and file only for now (oidc-rules.json), no GUI.
Docs: docs/subsystems/gateway-routing.md (Trading an OIDC token for a
key, routes table) and site/public/docs remote in en, zh and ja, with
the workflow snippet.
Tests: TestOIDCTokenTradedForKey (no rule, a traded key that works on
chat with its TTL capped and its name, a model past the issuer, another
branch, no token, 51 bad tokens -> 429, issuer turned off, a token on a
model route, loopback, not shared -> 403); TestMatchEachCheck (14 bad
tokens, list aud, replay, the refusal naming the claims);
TestKeysCachedAndKept (8 concurrent tokens one fetch, rotation, a made-up
kid inside and past the gap, the issuer down 2h later, an unnamed issuer
never fetched); TestUnreadKeysLetNothingIn; TestAddRefuses;
TestGatewayKeyOIDCCLI; TestReadOnlyKeyEveryRoute with the new route.
A JWKS from an httptest TLS server, never the network.
Broken by hand, each red then restored: the signature check, the claims
match, the jti check, the exp check, the refetch gap, the GitHub scope
rule, the lanGuard exemption, the throttle and the TTL cap.
Run at this head (rebased on
|
||
|
|
93879515a0 |
agent: QwenPaw, each of its agents' active_model one of magpie's (pkh1585 on Discord)
pkh1585 asked for QwenPaw (AgentScope, github.com/agentscope-ai/QwenPaw)
on Discord. Read in its source, 2.2.2.post1, as data:
- Its folder is QWENPAW_WORKING_DIR, else ~/.copaw when that exists (the
old name), else ~/.qwenpaw; WORKING_DIR/.env is loaded without
overriding the environment. config.json's agents.profiles lists the
agents, each with a workspace_dir whose agent.json holds active_model
{provider_id, model}, read again on each message.
- Providers are no plain config: SECRET_DIR (QWENPAW_SECRET_DIR, else
"<WORKING_DIR>.secret") holds providers/{builtin,custom}/<id>.json,
read once at start. A plain api_key there is encrypted to "ENC:" at
start, so that is the place QwenPaw itself keeps keys.
What magpie does now:
- `magpie qwenpaw <model>` and the GUI: a row per QwenPaw agent
(qwenpaw#<id>, the default one as plain qwenpaw), skipping agents whose
backend is ACP (another CLI runs those) and agents turned off.
- Connecting writes providers/custom/magpie.json (mode 600, the gateway's
/v1 and the magpie-qwenpaw key, magpie's models as extra_models with
their window, output and tool use) and sets that agent's active_model
to {magpie, <provider>/<model>}. The old active_model is stashed as it
was and put back verbatim on disconnect, absent and null included.
The provider file is removed only when no QwenPaw agent still uses it.
- A sync after QwenPaw re-saved the provider (encrypted key, discovered
models, its own defaults) keeps what QwenPaw wrote and changes only
what magpie owns, so a second connect leaves the file as it is.
- The notice says QwenPaw reads providers at start-up: restart it once
after connecting and after magpie's models change. New text in every
locale.
- appdir: QWENPAW_WORKING_DIR and QWENPAW_SECRET_DIR take ~/ as QwenPaw's
expanduser does; agentenv clears them in tests.
- README (en, zh), docs/reference.md, agent-wiring.md, the site's agent
list and start pages (en, zh, ja), icon.
Run:
- internal/agent's QwenPaw tests (Connect, AgentsAreRows, SyncKeeps-
WhatQwenPawChanged, Check, NotStartedYet, Folders, OwnModelAfter-
Magpies, SyncAfterQwenPawSaved, NullModelRestored) on mote, and the
all-agent tests (applied, rewire, lan_kept, proxy_kept, spelled) with
a QwenPaw fixture.
- Broken by hand, each red: always rewriting the key
(SyncKeepsWhatQwenPawChanged), removing the provider while another
agent uses it (AgentsAreRows), no backend filter (AgentsAreRows lists
qwenpaw#coder), dropping the keep of QwenPaw's own fields
(SyncAfterQwenPawSaved), IsObject for Exists (NullModelRestored).
- Real QwenPaw 2.2.2.post1 (Python 3.12 via uv) in a sandbox HOME on
the Linux box (WSL magpie-desktop), magpie on 3741, a fake OpenAI
upstream on 3742: first start wrote config.json and agent.json;
`magpie provider add fake …`, `magpie serve`, `magpie qwenpaw
magpie/fake/echo-1`; after a restart QwenPaw encrypted the key (ENC:)
and `qwenpaw agents chat` answered "PAWPAW-OK from the fake upstream",
its log "built agent … model=magpie/fake/echo-1"; the upstream saw
/v1/chat/completions model echo-1 streamed, magpie's usage.jsonl
agent qwenpaw status 200. A second connect and `magpie models` left
the provider file unchanged. `magpie qwenpaw default` took
active_model back out (the only diff in agent.json) and removed the
provider; QwenPaw started clean after.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui.
- Full suite on mote (go test -tags nogui -count=1 -timeout 45m ./...)
at 9554883db on
|
||
|
|
9bb1efdde3 |
gateway: a reply names the model the agent asked for when it went out under another name (issennknight)
issennknight on Discord (#general): an agent asked for deepseek-v4.1-flash, which goes out as deepseek-v4.1-flash-1017 (settings' ModelIDs). The vendor's reply said -1017, magpie passed it back, and the agent warned that the model didn't match. Before, only MemberModel (#822) or X-Magpie-Response-Model: member rewrote a reply's model, and only to the group member's id. Now the default is nameAsked. When magpie sent the request under another name than the agent asked for (a model's own id, a routing group, a provider/model id), the reply names the asked model. That covers Chat and Anthropic `model`, Responses `response.model` (created, in_progress, completed), Anthropic `message.model` (message_start) and Gemini `modelVersion`, streamed and whole, translated paths and plugins included: it all goes through serve's one memberWriter. A vendor that sent back the wire name as asked keeps its own name, a dated -20261017 too. Usage rows, recent calls and the Routing page still record served = the vendor's name: the writer sits outside captureResponseWriter. Claude Code, Claude Desktop and Codex get the asked name (or the vendor's), never the member's id, as before. Streams are rewritten one complete line at a time (memberLines). A run with no "model" in it is written through as the same slice. Only a JSON reply that has a target at decide time is held whole, which is what MemberModel already did. A JSON body that doesn't parse (a reply cut short) goes on as it came. A request to a remote magpie now sends X-Magpie-Response-Model: vendor (passOnCaller). That magpie names the vendor's model, as before, so this one still records what served the call (TestRemoteMagpieGroupNotSwapped went red without it). Existing tests that held a native reply byte for byte now expect only its model renamed to the asked id (namedAs in member_test.go): passthrough_severed, stream_accounting, refusal, refusal_thinking, thinking_signature and vertex. The archive keeps the reply as the vendor sent it, under the vendor's name (archive_test). Also dropped: the openai-model header code. serve never relays that header, so the test for it could not pass. Run (mote, at this head rebased on origin/main |
||
|
|
606743831e |
appdir: on Windows an agent's folder variable follows the registry, and a gone folder it names isn't made again (bm_rabbit on Discord)
bm_rabbit (0.1.2405, Windows x64, Pi 1.4.0) moved Pi's AgentDir from
F:\piData\.pi\agent to F:\HarnessData\Pi\.pi\agent, deleted the old one and
set the User variable PI_CODING_AGENT_DIR to the new path. Changing Pi's
model in magpie then made the deleted folder again with only models.json
and settings.json in it.
Cause: Windows gives a process its variables once, from the registry, and
never passes a changed User variable to one already running. magpie runs
for days in the tray, so appdir.Getenv("PI_CODING_AGENT_DIR") (piDir) kept
the old path, and edit's write did MkdirAll on it. Every agent folder
variable (CODEX_HOME, CLAUDE_CONFIG_DIR, ...) had the same problem.
Fix, where every agent folder is read (appdir.LookupEnv, follow.go): on
Windows a variable in agentenv.Vars that came from the registry (its value
in magpie's environment at start matched the registry's, unset in both
counts too) is read from HKCU\Environment, else HKLM's Session Manager
Environment, with %...% expanded, at most once a second, and set in
magpie's environment so the programs magpie starts get it too. A value
the launcher set itself, or one set inside magpie since (a test sandbox),
stands. The direct os.Getenv reads of agent variables go through appdir
now: claudetui's CLAUDE_CONFIG_DIR, sessions' CODEX_SQLITE_HOME and
PI_DESKTOP_DATA_DIR, cliupdate's GROK_HOME, omp's OMP_PROFILE/PI_PROFILE.
And edit's writeFile no longer makes a missing tree of folders that an
agent's variable names: when the folder the variable names is missing
and so is the folder above it (bm_rabbit's whole F:\piData was gone),
appdir.Gone returns a GoneError naming the variable and the folder. The
named folder itself is still made when its parent is there, as mkdir
would (a CODEX_HOME or ANTE_HOME set before the agent first ran; 12
internal/agent tests rely on it), and an agent's default folder is made
as before. TestAnteHome's ANTE_HOME was <tmp>/elsewhere/ante with
elsewhere missing; it now makes elsewhere first. Writes that call
os.MkdirAll themselves don't ask yet: #4634.
Pi's install-layout.json isn't Pi's: Pi 1.4.0's getAgentDir
(@earendil-works/pi-coding-agent dist/config.js) reads PI_CODING_AGENT_DIR,
else ~/.pi/agent, and no file in the package names install-layout.
magpie doesn't read it.
Tests: TestAgentVarFollowsTheRegistry, TestAgentVarAddedLaterFollows,
TestAgentVarSetByHandStands, TestRegistryReadAtMostEachFollowFor,
TestGoneNamedFolderIsNotMade (internal/appdir, a fake registry), and
TestWriteNeverMakesANamedFolderAgain (internal/edit).
Broken by hand: LookupEnv back on os.LookupEnv, TestAgentVarFollowsTheRegistry
and TestAgentVarAddedLaterFollows FAIL ("after the user moved it,
PI_CODING_AGENT_DIR = .../old, want .../new"); Gone's refusal turned off,
TestGoneNamedFolderIsNotMade and TestWriteNeverMakesANamedFolderAgain FAIL
("= <nil>, want a GoneError", "the folder was made again"); Gone refusing
whenever the named folder is missing, TestGoneNamedFolderIsNotMade FAILs
("a named folder whose parent exists: ..."). All put back, green.
Real Windows run on xiaomi-gpu, sandbox USERPROFILE/APPDATA/LOCALAPPDATA,
at this head: a probe built from this tree started with
PI_CODING_AGENT_DIR=<sb>\piData\.pi\agent in its environment and the User
registry; then the User variable was set to <sb>\HarnessData\Pi\.pi\agent
and <sb>\piData deleted, and agent.Find("pi").Apply("model", ...) ran in
the same process. Pi's dir and os.Getenv are the new folder,
settings.json written there, piData not made. With HarnessData deleted
too: "PI_CODING_AGENT_DIR names <sb>\HarnessData\Pi\.pi\agent, which
doesn't exist and neither does the folder above it: ...", not made. An
earlier run of the old code (LookupEnv on os.LookupEnv, no Gone) wrote
into the old folder and made it again: bm_rabbit's case. The User
variable was removed after; the box had none.
Full run at this change on
|
||
|
|
544b91ca87 |
dsh: magpie's routes wait for a slow reply as long as the gateway does (tim on Discord)
tim's first "who are you" to gemini-3.8 through the third-party plugin
magpie-gemini-web 0.8.0 took minutes in dsh and ended in 499 ("the agent
canceled the request"). dsh hung up: llm-pi-ai gives a turn up after 5
minutes with no pi-ai event (DEFAULT_STREAM_IDLE_TIMEOUT_MS, every
dsh-llm-pi-ai from 0.1.5 to 0.2.2), and the gateway's ": keepalive"
comments (keepQueued, keepQuiet) are not events. The plugin serves one
request at a time (maxConcurrency 1), dsh's own session title goes to the
same route model in parallel, and the plugin's backend sends no byte
before its first token, so the turn's 5 minutes ran out in magpie's queue
and the backend while the gateway (10 minutes for headers) and the plugin
(240s per wait, then its own 504) were still waiting.
Every one of magpie's dsh routes (patch lists and deepseek-acp's
settings.yaml, all through dshPutProviders) now has streamIdleTimeoutMs:
600000 (dshIdleWait), the gateway's upstreamHeaderWait. A value already on
the route, set in dsh's Models page or by hand, stays. Codex's
comment-blind limit is still met in the gateway (agentQuietMost); dsh's is
a route setting. The plugin's own slowness is its maintainer's and is not
changed here.
Verified:
- New tests TestDshRoutesWaitAsLongAsTheGateway and
TestDshRouteKeepsTheUsersIdleWait (internal/agent/dsh_idle_test.go),
green on mote. Broken by hand: without the field the first fails
("route magpie waits 0ms for the next event, want 600000"); without the
keep the second fails ("sync 1: the user's 120000 became 600000").
- Real dsh 0.2.1-rc.2 (headless, sandbox HOME/DSH_HOME, the route as
magpie writes it, a fake Chat server on 127.0.0.1:3561 that answers
after 8s): streamIdleTimeoutMs 3000 -> "TIMEOUT: pi-ai stream idle
timeout after 3000ms"; 600000 -> "hello there", exit 0. With headers
sent at once and ": keepalive" every second it still timed out at 3000,
so comments don't feed the watchdog. dsh-llm-pi-ai 0.1.5-rc.3,
0.1.7-rc.2, 0.2.0-rc.2 and 0.2.1-rc.5 (npm pack, read) all take the
field per provider, max MAX_TIMER_DELAY_MS.
- gofmt -l clean. On mote: go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./..., go build, GOOS=linux go build -tags
nogui, GOOS=windows go build: all ok.
- Full suite, go test -tags nogui -count=1 -timeout 45m ./..., on the
Linux box (wsl-run, magpie-desktop; mote had two full suites running)
at
|
||
|
|
3182a66586 |
provider, gateway: OpenRouter's decision model picked with a variant (inception/mercury-decide:free) is a decision model, never sent to chat/completions
coeo91 on Discord (2026-10-31): inception/mercury-decide:free, picked by
hand into a group used as smart routing's decision model, failed with
"OpenRouter: inception/mercury-decide:free is a decisions model and
cannot be used with the chat/completions endpoint. Use the
/api/alpha/decisions endpoint instead."
Cause: magpie already reads OpenRouter's decision models from its own
list (/models?output_modalities=decisions: output_modalities
["decisions"], endpoints ["/api/alpha/decisions"]) and asks them at
/api/v1/systemone. That list names each model once, without variants,
so the hand-picked ":free" id was taken for a chat model. Its group was
a chat group and the classifier asked it in words on chat/completions.
Now a variant of a model OpenRouter's decisions list names (base id
before the last ":", OpenRouter providers only; Ollama's :tag stays a
name of its own) is a decision model (openRouterVariant):
- it is kept from agents' model lists, and its group is a decision
group, asked at /api/v1/systemone (classifier, RouteDecider);
- an agent's chat naming it gets magpie's 400 "only decides", with
OpenRouter not asked;
- count_tokens naming it, or its decision group, gets the same 400
(count_tokens had no decision guard and forwarded upstream);
- test-models sends it the System One yes-or-no, and the provider
editor marks it as a decision model (/api/providers deciders).
Not done: an /api/alpha/decisions client. OpenRouter's /api/v1/systemone
(what magpie uses) answered the same model the same way as the alpha
path in a real probe (200, identical System One shape), so the alpha
endpoint adds nothing but an alpha contract.
Real probe (owner's OpenRouter key, 2026-11-01): chat/completions with
inception/mercury-decide:free gives the reporter's 400 word for word;
/api/v1/systemone and /api/alpha/decisions give 200 for
inception/mercury-decide and 404 for :free ("This model is unavailable
for free... use this slug instead: inception/mercury-decide"). So
after this change the reporter's group is asked the right way, and
OpenRouter's own 404 says to pick the paid slug.
Tests (fixtures are OpenRouter's real list and answer bytes):
TestOpenRouterDecisionModelVariant (provider),
TestOpenRouterDecisionVariantNeverChats (gateway: classifier group asked
at /systemone, chat and count_tokens refused, OpenRouter asked once),
TestOpenRouterDecisionVariantPicker (gui). Each is red on the old code
(provider: "taken for a chat model"; gateway: the reporter's 400 as the
classifier's error; gui: deciders without the variant), checked at
|
||
|
|
e6b595e1ab |
claude: Interactive only, a setting under which a model request never runs as claude -p (_yuchanns_ on X)
_yuchanns_ on X, on the interactive mode falling back to -p: for people
who stayed off magpie's Claude subscriptions because of -p, a fallback
is a time bomb. Settings › Models › Replies › Claude Code's interactive
mode now has three choices: Off (always -p), On (the default, falling
back to -p as before) and Interactive only.
With Interactive only (settings.ClaudeTUIOnly; ClaudePrintMode set too
wins):
- a run claudeTUI would make -p is not started; the request fails with
the reason and the setting (claudeOnlyErr, claudeNotTUIWhy);
- the helper is handed MAGPIE_CLAUDE_TUI_ONLY=1 (claudetui.OnlyEnv,
claudeCLI.tuiEnv). Where it would exec -p (no start, sign-in, first-run
notes, untrusted folder, 45s timeout) it exits with the reason
(fallBack in Run), and it ignores the broken mark;
- a helper that never answers initialize ends the turn with an error,
not a -p retry, and `broken` isn't counted (claudeMachineWhy), so the
next run tries the interactive mode again;
- the model test's and warm-up's "hi" (askClaude) runs through the
helper (askClaudeTUI) in stream-json, its stdin closed at the first
result. The helper command and env are built in one place now
(tuiCommand, tuiEnv) for both.
Reading the plan's allowance (/usage) asks no model and stays -p; the
setting's text says so. Docs: claude-subscription-bridge.md.
Provider editor, on e8347401f's "Claude Code runs as" pill
(ClaudeMode.Only): with the interactive mode in use and no last
request, it says a request it can't take fails, and the card's foot says
nothing runs as -p. Where the interactive mode can't run, the pill names
Interactive only, never claude -p, the line says "Claude requests fail:
<why>", and Change in Settings goes to the row. A request refused this
way never ran, so it isn't noted as the last request (noteClaudeRun
comes after the refusal).
app.js: the Replies rows share one helper (segRow, which waitRow uses
too), so app.js is 530 bytes under main's with the third choice; no
budget raise.
Tests: TestClaudeTUIOnlyRefusesPrint, TestClaudeTUIOnlyHungHelperNoPrint,
TestClaudeTUIOnlyTellsHelper, TestAskClaudeTUIOnly (gateway);
TestShimOnlyNeverPrints (claudetui: fake fail/trust/login/notes each
exit with an error and no -p, a marked-broken run still interactive);
claude-tui-setting.test.cjs (three choices, Only saves claudeTUIOnly with
claudePrintMode false) and claude-mode.test.cjs (Only in use, and Only where it can't run).
Broken by hand, each red, then put back: the startRun gate off
(RefusesPrint 200); start()'s Only check off (HungHelper 502 without the
Only reason); tuiEnv's OnlyEnv off (TellsHelper); askClaude's branch off
(AskClaudeTUIOnly); the helper's fallBack ignoring only (4 subtests);
BrokenSince's `&& !only` gone ("marked broken"); the save without
claudeTUIOnly (16 of 16 setting tests) and claudemode.js's m.only
branches gone, rebuilt on e8347401f's file (10 of 10 Only tests,
Chromium).
Run on mote at
|
||
|
|
e1aec53895 |
routing: each session sending at once has its own context window, named by its title (tjhhhh on Discord)
tjhhhh runs several agent sessions at once. The Routing page's context
window card followed whichever request came last, so it jumped from one
session's prompt to another's. The card still tells of the request it
picked. Under it, while two or more sessions are live, a strip now
shows one small block per session (renderCtxSessions):
- keyed as the card's line of prompts is (sessionKey, else the
conversation);
- named by the agent's title for the session (sessionName), else its
folder's last level, never a bare id;
- holding that session's newest reading through context.js's stack bar,
exported as window.ctxStack.
A session is live while a request of it is under way, or while its
newest request is within 15 minutes of the newest overall. At most six
blocks show, newest session first. A block keeps its place while the
sessions take turns, because blocks are ordered by each session's first
request. The block the card tells of is lit (aria-pressed), and a click
on a block picks that session's newest request. The card's footer names
the session by its title too. New words are in every locale in
plugins/routing/i18n.js. The strip reuses the card's tokens: no select,
no coloured border, no gradient.
The strip sits under the card, not over it. Over it, the strip's first
appearance moved the card, and routing-ctx-still ("the cache kept its
place") went red in both engines. It is green at base
|
||
|
|
e40675cc19 |
middleware: onAccount can pass an account over for a request (bm_rabbit)
bm_rabbit (Discord) is building MOD_Probe, a middleware that tells
Codex accounts apart and needs to keep some requests off some of them.
onProvider could only change a try's body, never which account took
it.
A JS middleware may now export onAccount(account, ctx). The gateway
calls it before each try on a subscription account, at the top of the
candidate loop (accountSkipped). That is before anything of the try is
done: no Codex reset is spent, no body is built, nothing is sent.
account is {ref, provider, name, kind, model}. ref is 32 hex
characters: an HMAC-SHA256 of the middleware's name and the account's
agent, lower-cased user and plan. Its key is random, made once per
install in account-ref.key in magpie's config folder. It is written to
a temp file and linked into place, so it never writes over a key that
is there. The ref is the same on every request and after a restart,
and different for each middleware. The email can't be found from it
without the key. A key file that can't be read is never overwritten:
that process uses a key of its own and logs it.
{skip: true} passes the account over for this request. The next
candidate is asked, as past an account that can't be used. The call's
fallback gets a "passed over by middleware <name>" line, and the
account is not rested or held against. When the last candidate is
passed over, nothing is sent (no fail-open). The agent gets the
failure of a candidate asked before it, or, if there was none, the
usual 404 "none of <model>'s models is ready".
Anything else uses the account: undefined, {}, null, a throw, or going
past the 250ms limit. The last three count as failures. A key's try
asks no onAccount. ctx.account holds the same object for the hooks
after it on that try, and is taken away on a key's try. ownAsk clears
the Accounts runs with the Tried ones.
Note: the plan is part of the ref, so a plan change gives the account
a new ref.
Docs: docs/subsystems/gateway-middleware.md (runtime path step 4,
limits, fail open, verification), docs/reference.md,
docs/integrating.md, and site/public/docs/{,zh/,ja/}plugins.html (an
onAccount row in the hooks table). The Bun plugin host is unchanged:
middleware runs in moejs in the gateway, not in host.js.
Tests:
- internal/middleware TestOnAccount: the ref is stable across runs and
a key reload; it differs between two middlewares, users, plans and
kinds, and is the same when only case differs; no email or plan
reaches the hook. {skip:true} names the middleware; undefined,
{skip:false}, throw and null use the account (2 failures counted);
ctx.account reaches onProvider; a key's try clears it.
- internal/middleware TestAccountRefKey: the key file is made at 0600,
read back, never written over when unreadable, and no temp file is
left behind.
- internal/gateway TestOnAccountSkipMovesToNextAccount: two Codex
accounts, Ordered. The first is passed over, only acct-2 is sent
the request, acct-1 doesn't rest, and the same holds on a second
request.
- internal/gateway TestOnAccountSkipEveryAccount: every account passed
over gives a 404 "…models is ready", nothing is sent, nobody rests.
Broken by hand, each on mote, each red, then restored:
- skip ignored in accountSkipped: both gateway tests red (acct-1
reached; 200 instead of 404)
- fail open on the last candidate: SkipEveryAccount red (200)
- the skipped account rested: both gateway tests red (rests)
- a random key per ref: TestOnAccount (refs changed between requests)
and TestAccountRefKey red
- the middleware name left out of the hash: TestOnAccount red (two
middlewares told one ref)
- an unreadable key overwritten: TestAccountRefKey red
Run at this commit's tree (rebased on origin/main
|
||
|
|
20482d71ff |
library: a skill by a name the library has from elsewhere goes in beside it
mora1n on Discord: anthropics/skills' skill-creator and openai/skills'
are two skills by one name, and only the first could be added; the
second was skipped as "another skill called skill-creator, left as it
is". The library keyed being had by name in every place that asked.
Now being had is decided by source (hadSkill): the same source under any
name here, or a skill with no source (taken in from an agent's folder)
by that name with the very same files. Another skill from GitHub or a
git repository whose name is taken goes in beside it as
<name>-<owner> (skill-creator-openai), then owner-repo, repo, a number,
at most 64 bytes (freeSkillName in skill_beside.go). The library's copy
of its SKILL.md gets that name in the front matter's top-level name:
line (nameSkill), so no agent sees two skills by one name; Skill.Called
keeps the name it came with, and the carried bundle carries it. Its hash
is of the renamed copy, and checks (GitHub and git) and updates compare
what they fetch renamed the same way (fetchedHash), so it doesn't read
as edited and an update keeps the name.
The class: probe (Candidate.Have now means this skill; Candidate.As is
the name it has or would get), installFrom (listed and unlisted folder
by that name), the new-skills check (no longer drops a skill because
its name is taken), the market's had check (by name only for a skill
with no repository: none or a folder), carry, the TUI's probe list and
the GUI's probe list ("adds as {name}" with why in its title, "In the
library as {name}"; zh, zh-TW, ja, de; the tag is cut short in its row).
Old data: nothing is renamed. A skill already in the library keeps its
name, folder, SKILL.md and agent links; library.json without "called"
reads as before. Only a skill added from now on can get another name.
Not changed: a folder of the user's own is linked as it is and its
SKILL.md can't be named apart, so one by a taken name is still skipped,
now saying to rename it in its SKILL.md; and an agent's own skills
folder still holds one skill per name (an agent's own skill by the
library's name is settled by Use library / Keep agent's as before).
Run (mote, at c6fd4b37c on origin/main
|
||
|
|
76e4494dbd |
gateway: In turn passes over a provider's fallback while the provider is ready (01huadalang)
01huadalang on Discord (#feedback, 10-31): once the main provider has quota again, requests keep going to the fallback model, which is only meant for emergencies. Cause: a provider routed In turn treated its fallback rows as more of its own keys. A new turn went to the row after the last answerer (after), which past the provider's last key is the fallback, and a new conversation went to the row the fewest conversations held (leastHeld), which is the fallback nobody is on. Both happened while every key of the provider was ready. The session spread already skipped fallbacks (readyForNew); rotate's after and leastHeld(ready=false) did not. Fix: standsIn(order, i) marks a fallback row when the plan's first row is the provider's own. after, leastHeld and readyForNew all skip it, so a fallback takes a new turn or conversation only when nothing ahead of it can. Within one turn (tool results) a conversation still stays on whoever answered, because of sealed reasoning. Stays: Strict is the user's own choice and is not changed. A conversation it keeps on the fallback stays there. The trace now names the provider's ready first row (Affinity.Main), and the Routing page says why: the provider is ready again, Strict never moves a conversation, and new conversations go to the provider (en, zh, zh-TW, ja, de). Tests (internal/gateway/affinity_fallback_paths_test.go): - TestRotatingProviderKeepsItsFallbackForEmergencies (1 and 2 keys) - TestFallbackGivesBackAcrossRoutings: auto, in turn, in turn+session, least used+session, stays turn, and a group fallback with auto, in turn and session - TestStrictKeepsTheFallbackAndSaysTheMainIsReady On the old code, the rotate provider's new turn went to spare-key (Why new-turn), and in turn+session's new conversation went to the fallback (Why first). Broken by hand: with after's standsIn removed and Strict's Main dropped, the rotate test, the in-turn cases and the Strict test go red. session_spread_test's fallback case pinned the old In turn pick; it now expects k2. GUI: routing-affinity-order has a "strict" case. Run (via mote-run unless noted): - go test -tags nogui -count=1 -timeout 45m ./... at b08f35fcc (this change on |
||
|
|
88a0262bf2 |
claudetui: Claude Code's first-run notes send the run to -p at once, not after 45s
A config folder whose onboarding isn't done (one only -p was run in,
given CLAUDE_CODE_OAUTH_TOKEN) has the interactive mode show "Security
notes: … Press Enter to continue". The helper knew the sign-in screen
but not this one, so it waited out ReadyWait (45s) before running -p.
Now firstRun is matched like signIn: the run is -p at once and the
start is marked broken. Agreeing to the notes is left to the user.
The match is on the screen's words with any space between them one
(strings.Fields): the real 2.1.316 screen didn't match a plain regexp,
since Claude Code draws some spaces by moving the cursor.
Run:
- mote: go test ./internal/claudetui -count=1 ok; go vet for darwin,
windows, linux; gofmt clean.
- Broken by hand: with the case off, TestShimFallsBackToPrint/first-run
notes goes red ("wrote 0 lines of 1 in 30s").
- Real, on xiaomi-gpu (Windows 11), Claude Code 2.1.316 (official dist,
sha256 checked), a real subscription token, a fresh config folder:
before, "showed no prompt in 45s" and -p at 48s; with the first regexp
still 45s (the space case above); now "shows its first-run notes" and
the -p answer at 7.9s and 16.9s (two runs), streamed.
Not tried: WSL with a fresh folder (same helper code path); macOS/Linux
native with a fresh folder.
|
||
|
|
645eb92f3f |
gateway: a refusal after shown thinking goes to the next fallback
yhwangl on X: a request whose content trips a vendor's safety filter after the model streamed its thinking, before any answer, stopped there; the group's next member was never asked, as it is when credit runs out. When a model's reasoning is shown, a try passes on its first thinking event, so a refusal after it was the agent's. Now, for a streamed Anthropic, Chat or Responses request with another member still to ask (handsOver), the try's events go out one by one (passOver) and a refusal or refusal error before any text or tool call hands the request on (handOver): Anthropic's open blocks are closed and the next member's stream is spliced into the same reply (spliceAfter): its message_start or response.created/in_progress/queued are dropped, block indexes or output_index go after those sent, sequence_number goes on. Chat chunks go as they come. Once text or a call has gone, a refusal stays the agent's as before. With no other member nothing changes. A refusal is about the request, so nobody is rested for it. Zhipu's finish_reason "sensitive" and error 1301 (敏感), DashScope's data_inspection_failed and Volcengine Ark's *SensitiveContentDetected are now read as refusals too. Not covered (#4604): Gemini clients; a Responses reasoning item handed over gets no output_item.done and the next completed lists only its own output; A's thinking signature stays in the reply; non-streamed requests. Run (mote, worktree at base |
||
|
|
8a410f35a2 |
claudetui: Claude Code's interactive mode streams its replies, through a preload that copies the main turn's stream
The owner: make a Claude subscription stream as it goes while Claude
Code runs in its interactive mode (TUI), on macOS, Windows and WSL.
Until now the helper read Claude Code's transcript, which has a message
only once it ends, so a reply came to the client whole.
Claude Code is a Bun program, and Bun loads a script named in
BUN_OPTIONS (--preload) before it. The helper writes tap.js to a folder
of its own and starts Claude Code with BUN_OPTIONS="--preload tap.js"
(after the user's own BUN_OPTIONS, but not a Windows one's for a Claude
Code in WSL, where both go through WSLENV). tap.js makes Bun.FetchSession
a subclass whose fetch is the real one's, so the request, its headers,
its connection and TLS are Claude Code's own. For a reply to a
request marked x-claude-code-request-class: main to /v1/messages that
is text/event-stream, it tees the body: Claude Code reads its copy as
before, and tap.js writes each event, as it comes, as a JSON line to
the file MAGPIE_CLAUDE_TAP names. It takes itself out of BUN_OPTIONS,
execArgv and the environment first, so nothing Claude Code runs
inherits it.
The helper reads that file and tells the events as -p's stream_event
lines, so the gateway reads them as it reads -p's. A transcript message
waits up to 1s for its stream to begin (then it's told whole, its late
stream left out); a turn's end waits for its streams to end; a stream
cut short ends with a message_stop and no message_delta, as -p ends
one. The bridge now keeps the streamed messages by id, since a whole
message can come during the next message's stream, and a client
tool_use shown from the stream isn't told again from the whole message.
On Windows, BUN_OPTIONS has no quoting, so a temp path with a space
takes its short name; one that still has whitespace gets no tap, and
replies come whole, as they do from a Claude Code that isn't Bun or
doesn't send through FetchSession (2.1.281 on Windows doesn't; 2.1.289
and 2.1.316 do).
Run:
- gofmt -l: clean. go vet on mote for darwin, GOOS=linux and
GOOS=windows: 0.
- go test ./internal/claudetui ./internal/gateway on mote
(-timeout 45m): ok, ok (gateway 654s).
- go test ./internal/claudetui with win-run (Windows 11) and wsl-run
(magpie-desktop): ok, ok.
- macOS, real account (Claude Code 2.1.316, sandbox HOME, keychain
token): a reply came as message_start, text deltas,
content_block_stop, message_delta, message_stop, then the whole
message, then the result; stderr clean, the tap's folder removed.
- Windows native, Claude Code 2.1.316 against a fake that sends an SSE
event every 250ms (a user preload marking the request main, which
also checks the user's BUN_OPTIONS is kept): the deltas came 250ms
apart, before the whole message. The same with TEMP holding a space
(short name).
- WSL magpie-desktop, Claude Code 2.1.289 run through wsl.exe from the
Windows helper, the fake in WSL: the same.
- The scrub, on macOS and Windows: Claude Code's BUN_OPTIONS and
execArgv have no tap, MAGPIE_CLAUDE_TAP is gone, --smol is kept.
- Rebased on origin/main
|
||
|
|
535371c8f3 |
providers: a Claude subscription says whether it runs as Claude Code's interactive mode or claude -p, and why
The owner: the Claude Code provider page should say whether its runs go through the TUI or the CLI, and what tells them apart and what each gains. Under a Claude subscription's accounts a row now says "Running as Claude Code's interactive mode (TUI)" (a green dot) or "Running as claude -p (CLI)" with why: turned off in Settings, failed to start lately, Claude Code in WSL whose home wasn't found, not installed, or a system with no interactive mode. Under the TUI it says which requests still run as -p (safeguards, a JSON schema, an image by URL, a first message over 400KB). "TUI or -p?" opens what each is: entrypoint cli, the plan counting a request at about half; entrypoint sdk-cli, about twice. "Change in Settings" opens Settings › Models at the interactive mode's row. Only switch, which serves nothing, shows no row. The mode comes from GET /api/claude/mode (gateway.ClaudeModeNow), read as the editor opens and kept 30s, never in /api/providers' polls. Its machine-wide reasons are claudeMachineWhy, which claudePrintWhy now calls first, so the row and the gateway's own choice can't disagree. The row is drawn by claudemode.js, which app.js loads with that first read, so it weighs nothing on the core: after a rebase on origin/main |
||
|
|
2cca111764 |
gateway: a 413 byte cap or an overflow tells Codex context_length_exceeded, so it compacts instead of reconnecting 5/5 (celestial_eagle_99230 on Discord)
A Codex user on a DeepSeek model kept getting "stream disconnected
before completion: 1017dp: 413 Request Entity Too Large: a web page,
not an API reply ... (request_too_large)" with "reconnecting 5/5".
The big body took the vendor past keepHeldAfter, so Codex's stream
had begun, and streamError sent response.failed with code
server_error. Codex (codex-api sse/responses_error.rs) reads any code
it doesn't know as Retryable, so it sent the same body five more
times. Each was refused the same way, and nothing compacted.
context_length_exceeded is the one code Codex stops on: it marks the
window full and compacts, and core compact.rs trims the oldest items
for as long as the compaction is refused too.
- streamError: a 413 on the Responses shape is code
context_length_exceeded, for every Responses client. The text still
says request_too_large for pi.
- failTo: Codex reads a 413 told by HTTP status as UnexpectedStatus,
and a 400 context_length_exceeded as InvalidRequest
(api_bridge.rs). Neither compacts. So when Codex (fromCodex, or
Claude Code's Codex plugin) asked for a stream, a byte cap or an
overflow goes to it in a stream even before one began
(keptAlive.compactsInStream). A vendor's own overflow, released
until now, goes this way too. Other clients keep the status they got
before.
- Nothing changes for resting: a 413 still rests nobody, and a group
still tries the next member first.
Tests: codex_byte_cap_test.go. It replays the reporter's nginx page
mid-stream and before the stream, plus a vendor overflow 400, and
checks a non-Codex client keeps its 413. Red on the old code:
TestCodexByteCapInStreamCompacts got "server_error" (the reporter's
exact text), and both TestCodexByteCapBeforeStreamCompacts cases got
a 413 or 400 JSON. TestStreamErrorByteCapInEveryShape now expects
context_length_exceeded for Responses.
Run on mote (mote-run, this tree): go test ./internal/gateway on the
byte-cap, stream-error, overflow, compact and Codex tests: ok. GOOS=linux
and GOOS=windows go vet ./internal/gateway: ok. gofmt -l: clean.
Full suite: mote-run go test -timeout 45m ./... at
|
||
|
|
c30d3b7b63 |
plugin pages: a page the reader left is told, and let go after 10 minutes unless it keeps itself
A plugin's page kept its frame, with its scripts, timers and
connections, for as long as the window was open once it had been
looked at: show() only hid its view, and a frame in a hidden view isn't
hidden to itself (its visibilityState doesn't change), so a page
couldn't even pause on its own. Asked by the owner: is that by design?
Only the lazy first load was.
- The kernel's leave hook now reaches the page part: the page is told
{event: "visibility", data: {visible}} as the reader leaves and comes
back. The bridge has magpie.visible and magpie.onVisibility(fn); hello
carries visible, for a page left before it said hello.
- A page left 10 minutes (IDLE_MS) has its frame removed and loads again
when next opened. Back sooner, it is the same frame. Its hello timer is
cleared, so nothing says it broke.
- magpie.page.keepAlive: true (plugin.PageSpec.KeepAlive, keepAlive in
/api/plugin-pages) keeps a page however long, for one that works while
no one looks at it. Anything but true is false, read as raw JSON so a
wrong type never drops the package's page.
- plugin-runtime.md's page row says so.
Run on mote. The Go suite and most GUI files ran at this change on
|
||
|
|
fb29cd30f9 |
tray: the Mac's menu bar figures are regular weight, a lone one in the menu bar's own font (qingnianxiaozhe on X)
Beside Surge's speeds and another app's stacked "0 KB/s", magpie's
"93% / 98%" read visibly bolder, and a lone "98%" too small and too
heavy, so the reporter kept it out of the menu bar. mpRowFont drew two
stacked rows in 9.5pt semibold and one row in 11pt medium, both since
|
||
|
|
557f51dbf0 |
library: a skill linked into an app version the update deleted follows it to the current one (tjhhhh on Discord)
tjhhhh: ego lite keeps its skills in its framework's Versions/<v>. After the app updated, the skill was in the new version's folder, the old folder was gone, and magpie still linked the old one. |
||
|
|
2cfb8351d0 |
install.sh: a Linux desktop without WebKitGTK 4.1 has it installed through sudo, then gets the desktop app (shuhai)
shuhai on Discord, on f68ddca37's hint: "为什么不能帮用户直接装好?" On a
desktop without WebKitGTK 4.1 the installer put in the terminal build and
told the user to `sudo apt install libwebkit2gtk-4.1-0` and run it again.
Now, on a desktop without the libraries (and with --gui), when someone is
at the terminal, the script installs WebKitGTK 4.1 (GTK 3 comes with it)
with the distribution's package manager, says first in one line what and
why, and installs the desktop app:
- apt-get install -y libwebkit2gtk-4.1-0 (Debian/Ubuntu family), and when
that fails, apt-get update and once more (lists missing or stale);
- dnf install -y webkit2gtk4.1 (Fedora/RHEL family);
- pacman -S --needed --noconfirm webkit2gtk-4.1 (Arch family; no -Sy, so
no partial upgrade);
- zypper --non-interactive install libwebkit2gtk-4_1-0 (openSUSE).
Through sudo, which asks for the password itself; as root, without it.
"At the terminal" is /dev/tty opening (in a subshell, since a failed
redirection would end the script): curl | sh gives the script the pipe
for stdin, so every package command reads /dev/tty too, never the script.
No terminal, no sudo, the package manager missing, Void/Gentoo/another
distribution, or the install failing: the terminal build and the command,
as before, with "didn't work (see above)" when it was tried. --tui and
MAGPIE_CLI=1 install no package; a headless computer neither.
MAGPIE_TTY points the check at another file for the tests.
Docs: reference.md Install, README en/zh, docs start (en/zh/ja).
Run:
- sh -n, dash -n; shellcheck -s sh: only SC2010 at the uninstall's
ls | grep, there before.
- site/install.test.mjs, 5 new tests (fake sudo, id and package managers;
every distro's command, root without sudo, no tty, no sudo on PATH,
Void, NixOS, a failing install, apt's update-and-retry, --gui, --tui,
MAGPIE_CLI, headless): red on origin/main's install.sh (the 5 new fail,
19 pass), green after. CI's site step (sh -n + node --test
site/*.test.mjs) at this head, rebased on origin/main: 63/63 on mote
(macOS sh) and 63/63 on magpie-desktop through wsl-run (/bin/sh = dash).
- Real installs in fresh containers (Docker on xiaomi-gpu, amd64), a user
u with sudo, DISPLAY=:0, `cat install.sh | sh` (stdin a pipe), the
terminal kept with setpriv (su -c starts a session without one),
v0.1.2399/2400 from the real feed; then ldd (nothing missing),
`magpie version`, and the package query:
- Debian 12, sudo with a password, typed by expect at sudo's prompt,
package lists deleted first: install failed "Unable to locate", apt-get
update, retry ok, desktop app, libwebkit2gtk-4.1-0 installed;
- Ubuntu 24.04 (NOPASSWD): libwebkit2gtk-4.1-0, desktop app;
- Fedora 44, password via expect: webkit2gtk4.1, desktop app;
- Arch (archlinux:latest): webkit2gtk-4.1 2.54.2, desktop app;
- openSUSE Tumbleweed and Leap 15.6: libwebkit2gtk-4_1-0, desktop app;
- Debian 12 as root: apt-get without sudo, desktop app;
- Ubuntu 24.04 --gui: installed, desktop app; --tui: terminal build,
nothing installed;
- Debian 12 without -t (no terminal): terminal build + the apt line, no
install tried; without sudo at a terminal: the same;
- Ubuntu 20.04 (no WebKitGTK 4.1 in focal): install, update, retry all
fail "Unable to locate", then the terminal build and the "didn't work
(see above)" hint.
Not tried: a real desktop VM (the containers fake one with DISPLAY=:0);
the installed app wasn't opened, only `magpie version`. Void and Gentoo
stay hint-only (Gentoo would build WebKit from source). Debian 11 failed
in the container's own setup (archives unreachable), so focal stood in
for a distribution without 4.1. A held dpkg lock (unattended-upgrades)
would fail the install and fall back; not reproduced. On focal the hint
still names libwebkit2gtk-4.1-0, which focal lacks, as before.
|
||
|
|
7d11f7d428 |
gui: Rex opens sessions in a Rex session of magpie's own, with none, one or several open (#4565, StringKe)
StringKe tried |
||
|
|
73a12e8bf6 |
wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file when that file already exists` (linusxiong). In the distro ~/.codex is a link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't follow a link the distro has: a mkdir of it says it exists, and nothing below it can be made, written, read or listed. ggbdpq found and explained the link (thanks); their patch, which takes that EEXIST as "there", wasn't used: the writes below the link fail next (its test passed because a symlink here is followed). The fix, for every agent folder and every writer through \\wsl.localhost: - The WSL probe asks `readlink -f` in the distro where each agent folder, its skills folder and the folders beside them lead (wslLinkPaths -> distro.Links; a $HOME that is itself through a link is left alone), and which drive each Windows mount is (win:/mnt/c C: -> distro.Drives). - distro.open opens a path at or below a link where it leads: on a Windows drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the distro, through \\wsl.localhost again. native spells it back through the link, so the agent is told its own path. - A link readlink couldn't resolve is never guessed at: distro.open errors, and the agent is unreached (Agent.Unreached: its notice says why; every field Set and Sync returns it). - Writers: the agents' own files (place.join/place.open, every filepath.Join(at.home, ...) in internal/agent), the library's WSL targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir), the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs). - Not changed: magpie's image MCP server opens arbitrary paths an agent in WSL gives it the same way; filed as #4578. Links deeper than the probed paths (other than <agent dir>/skills) aren't resolved. A distro probed by an older magpie has no Links until probed again (each run). Run: - Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex, .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway Windows test running the real probe with that HOME: probe said link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi, win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\ magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file when that file already exists" (the report's error). distro.open wrote SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both read back with cat in the distro through the links; .pi said "~/.pi in WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target removed after. - New tests with a fake distro whose ~/.codex and ~/.claude are links to /mnt/c/... that don't exist here, so, as through \\wsl.localhost, nothing below them can be made: TestWSLFolderIsALinkToC, TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink, TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved (agent). - Broken by hand: the library tests on the base (with a no-op FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the report's error; with ggbdpq's patch applied they still fail (the skill mkdir, and RTK's hook not written). - mote: go build ./...; go vet of agent, library, sessions, provider for darwin, GOOS=windows (and linux for agent, library); gofmt -l clean; go test -timeout 45m ./internal/agent ./internal/library ./internal/sessions ./internal/provider: all ok. - Windows (win-run): the same four packages. The new tests pass (the RTK ones skip: the fake distro runs sh). 32 tests are red, all already red at the base |
||
|
|
3ecc02b78b |
agent: Claude Desktop is off magpie only when Desktop itself would be (dev_quj on X)
dev_quj on X: "magpie 一直提示Claude Desktop不经过magpie,我重启了依然还是
这个提示" — the Agents row said "已不经过 magpie:配置已变更" while
Desktop ran on magpie.
The check required deploymentMode "3p" in both Claude/ and
Claude-3p/claude_desktop_config.json. Desktop decides otherwise (m4 in
4.4212's and 2.7032's index.pre.js): with a 3p configuration applied it
starts in 3p when the profile has disableDeploymentModeChooser, whatever
deploymentMode says, and otherwise unless Claude-3p's file says "1p". The
Claude folder's deploymentMode is never read. And Desktop 4.4212 deletes
Claude-3p's deploymentMode itself: a stored "1p" with no claude.ai sign-in
is dropped at start (W5r -> "[custom-3p] deploymentMode written { mode:
undefined }") and Desktop relaunches in 3p on magpie. So a file left
without the key, by Desktop or another tool, was called off magpie, and
nothing magpie could do (Reconnect writes "3p" back) kept Desktop from
dropping it again.
desktop3p now asks Desktop's question with the applied profile (magpie's
or the user's for magpie's gateway). The appliedId, address and key
checks are as they were. appReads (the "restart Desktop" notice) reads
the same effective mode instead of the two files' words, so Desktop's own
write at start isn't a change to restart for.
Real Claude Desktop 4.4212.0 (macOS zip, on mote, sandbox
--user-data-dir, never the live config): three starts with magpie's
profile applied and Claude/ {} or "3p"; Claude-3p "1p" + chooser
disabled, "1p" + chooser not set, and {} — each ran in 3p with
apiHost=http://127.0.0.1:3425 in Claude-3p's main.log, and each left
Claude-3p's file without deploymentMode. The "1p", chooser-not-set case
started in 1p, logged "deploymentMode written { mode: undefined }" and
came back in 3p. An earlier start with both files "3p" kept them.
Run at the pushed head on mote (mote busy with other sessions' GUI and
gateway suites, so the touched package only, not the full suite):
go test -count=1 -timeout 45m ./internal/agent: ok
go vet, GOOS=linux go vet, GOOS=windows go vet ./internal/agent: ok
gofmt -l internal/agent: clean
Broken by hand: desktop3p put back to the old rule (both files "3p"):
TestClaudeDesktopModeAsDesktopReadsIt red on the dropped key, the Claude
folder's key gone, "1p" with the chooser disabled, and none with the
chooser on; TestClaudeDesktopChangedSince red too. Green with the fix.
TestClaudeDesktopMSIX and TestClaudeDesktopChangedSince's 1p cases now
turn the chooser on first, as Desktop needs for 1p to count.
Not tried: Windows' Desktop (MSIX or classic) and a real gateway request
from Desktop; a signed-in claude.ai cookie (Desktop keeps "1p" then,
which magpie says only with the chooser on); dev_quj's own files, so
this is the class the report is in, not their proven trigger. No other
desktop agent reads a mode the same way; Codex/WorkBuddy checks unchanged.
|
||
|
|
cac655c14f |
gateway: GET /v1/magpie/mcp lists magpie's own MCP servers that are on (ferock on Discord)
ferock on Discord: the community chat page's "use all of magpie's MCP
servers" gave a chat only the servers in library.json, never magpie's own
web search, image recognition or image generation. Nothing told an app
which of magpie's own servers are on, so the page couldn't add them.
GET /v1/magpie/mcp (OwnMCPPath, own_mcp.go) answers
{"servers":[{"name","title","path"}]} for the ones on now, each named
as its initialize names it: magpie-web-search while plugins/search serves
and something searches (canSearch), magpie-vision while a model sees
(seer: not Off), magpie-image while a model draws (drawer: not Off),
magpie-tools while plugins/tools serves and a plugin that is on gives a
tool (plugin.ToolsOn; a note that can't be read lists it). It holds no
secret, so a read-only gateway key may read it (readOnlyRoutes); it is
otherwise guarded as every /v1/magpie/* route is. It is in / "apis".
page-chat 0.1.7 (magpie-community/plugins) reads it in every route the
page takes its MCP list from (readMcp: the list, a chat's tools, a tool
call, the connection check). Documented in gateway-routing.md.
Run (mote, at
|
||
|
|
e2a65cbc9b |
dsh: a start on a found group's old id moves onto the id its route lists (zyh6036 on X)
zyh6036 on X: DeepSeek Harness Desktop showed no model after magpie turned dsh on and the app restarted, while the profile's patch file was full of magpie's gateway. Cause: a dsh start (agent-default-model) magpie had set to a found routing group keeps the id the group had then, group/auto-<slug>. Since |
||
|
|
d6e1116380 |
codex: each end of the Codex app's app-server says why, and list flaps are guarded (#4550)
|
||
|
|
e484b1e936 |
provider: an account Codex holds in another of its folders can be removed in magpie (charliepu)
charliepu on Discord (Windows), after v0.1.2385: the account that read no
allowance couldn't be removed. Remove answered "<email> is signed in to
Codex in C:\Users\charl\.codex-db-backup-20260803: sign it out there
(CODEX_HOME=... codex logout) to remove it". That folder is a backup no
Codex runs in. appdir.CodexHomes finds it by name (".codex*" holding an
auth.json), and rememberLogins read its account back at every look, so
forgetLogin refused rather than have it come back.
Now Remove forgets the account and sets that folder's sign-in aside in a
record of magpie's own (codex-homes-removed.json: the folder to a sha256
of its refresh token, or of its access token when it has none).
codexHomeLogins passes over a folder while it holds that sign-in. The
folder's files are left as they are: nothing in it is written, moved or
deleted. A sign-in made
in that folder again (Codex run there, a new token) isn't named by the
record, and is listed again with no step of the user's. With the record
unreadable, which sign-ins were removed is unknown, and no other folder's
account is read that time (accounts saved already stay listed).
Not done: treating ".codex-db-backup-*" folders as not Codex homes by
name. They are found by the same rule as ~/.codex-work, and their
sessions/ are still read for Sessions and usage as before; a name rule
would guess at what a user's folder is for. Removing is the user's own
answer, and works for any such folder.
Run at this head (origin/main
|
||
|
|
70d50254cb |
codex: a change to the model list alone no longer ends the Codex app's app-server
The Codex app crashed and relaunched every few minutes (indekkusu141209 on X, #4550: 08:06, 08:12, 08:26). Cause. KeepCodexAppOnItsProvider ends the app's app-server whenever codexAppRoute changes. Since |
||
|
|
b9e5bc6cb3 |
gui: Rex is a session terminal, opened through its rex CLI (#4565)
Rex (com.superlogical.rex) claims no .command file, so Launch Services never listed it and `open -a` can't hand it a script (StringKe). Sessions' terminal list now offers Rex when its CLI is found: a native `rex` on PATH, or one inside a Rex*.app in /Applications or ~/Applications (Rex puts rex on PATH only in its own terminals). Perl's Rex installs a script named rex too, so only a Mach-O or ELF program counts. Resume, carry and an agent's Open then run `rex run --label <title> -- /bin/sh -c '<command>; exec login shell'`: no shell parses the label or the command on the way. With no session to add a tab to (exit 3) it runs `rex new`; with Rex's server not running (exit 4) the error says to open Rex. Rex is then brought forward with `open -b`. The GUI already lists s.terminalApps, so no JS changed. reference.md's Session terminal says it. Parts 2 to 4 of #4565 (accounts run per account, OSC 7501 status, folder mapping) build on #992, which isn't merged; not done here. Ran, at this tree on origin/main |
||
|
|
01813c681a |
accounts: switch next takes accounts that are off too, as Use does (#4532)
`magpie accounts switch claude next` (v0.1.2376) took only accounts switched On. An account the user signed in to themselves, picked up by rememberLogins, starts off, so next said there was nothing to switch to while the switch list and the GUI's Use took that same account (StringKe). On is whether the gateway routes to an account beside the one signed in, not whether the agent may be signed in to it, so NextInOrder now takes every switchable account (no token, no home of its own) that isn't the signed-in one and isn't spent, On or not. NextLogin, the automatic switch when one is used up, still moves only to accounts that are On; that is unchanged. reference.md and providers-accounts.md say so. Ran, at this tree on origin/main |
||
|
|
bec9df0888 |
sessions: a provider move leaves a thread a Codex has open (#3751)
#3751's second half; |
||
|
|
7e0fe83d4b |
provider: Listed as works for signed-in accounts and plugins (zeewell on X)
zeewell asked to list SuperGrok's grok/grok-4.6@500k as grok-4.6, and Cursor, Devin and WorkBuddy models (all plugins) under ids of their own. v0.1.2345's "Listed as" took ids only for key/relay providers (takesModelIDs was p.Account == nil). Why the restriction was there: the wire rewrite (Settings.Wires) turns the request body's model back into the own id, but some code reads the model by the vendor's id before that and got the listed one: - plugin model lookup (pluginModel: the plugin's APIs, tiers, prices); - the Claude subscription run (--model given to Claude Code); - Code Assist/Antigravity variant choice (codeAssistBody, SentNameOnIn); - account plan lists (fallback's Account.Lists, effort Levels/Tiers, AccountServes); - moveModelRefs refused a provider with no providers.json entry, which is every plugin and account provider until a pick is set. Each now translates with OwnModelID / the provider's ModelIDs, so the upstream request still carries the vendor's or plugin's own id. Only a decide-only provider refuses an id. The GUI box already follows TakesModelIDs, so no GUI file changed. Tests (red on the old code, each fix reverted by hand one at a time): - TestModelIDRefused, TestModelIDAtAnAccount (takesModelIDs, AccountServes, SentNameOnIn); - TestLocalModelIDAtAPlugin (Bun fake plugin: /v1/models, upstream path, X-Plugin-Model, body, usage; red on pluginModel and on moveModelRefs); - TestLocalModelIDAtAnAntigravityAccount (codeAssistBody); - TestLocalModelIDAtAClaudeAccount (claude got --model my-sonnet); - antigravity pool test (fallback Lists, Levels). Run on mote: gofmt clean; go vet darwin/linux/windows ok; go test -tags nogui -count=1 -timeout 45m on internal/provider, gateway, cli, gui, settings, access, usage, plugin: all ok except internal/gui's TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll), red on main since |
||
|
|
d8cf4f74f9 |
plugins: a plugin's package.json names its row with magpie.name (#4558, MYCF711)
A plugin installed from git whose package.json says
"magpie": { "name": "华为云 HUAWEI" } read as its dependency key
(magpie-officeace) on Settings → Plugins. Bun takes no non-ASCII key, so
a package outside the community's list had no way to show a readable
name. magpie.name was never read at all: #3608's route (MYCF711's branch
1cc33700) didn't reach main, so no release has it, git or npm.
plugin.InstalledName reads magpie.name from the installed package's own
package.json, beside magpie.icon (installedOwn, one parse for both): one
line of at most 80 bytes, no control or format characters (a bidi
override would show it as another name), else nothing. /api/plugins gives
each row it as ownName, and plugins.js's shownName takes it after the
community list's name and before the git package or the spec, so a
listed package is still named by the list. The row's page, the "is up to
date" status and every message that names the row (options, prefer, Update
all) go through shownName; a page plugin's sidebar tab takes it when the
page names no title (windowParts). It is never used to resolve a name and
never shown with the community badge. Not changed: the CLI's plugin list
(the dependency key, as the reporter expects), Discover's cards for
uninstalled GitHub/npm packages, and magpie.summary. Documented in
docs/reference.md and site/public/docs (en, zh, ja).
Run:
- mote: go test -timeout 45m ./internal/plugin/ ./internal/gui/ — plugin
ok; gui red only in TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
the AppKit window tests killed at their deadline (TestPanelCloseHidesIt,
TestPluginPageLoadsItsFilesInTheWindow, TestMainWindowCorners, …;
#4125, #2645). The first three run the same red on origin/main
|
||
|
|
64cdb68035 |
accounts: import claude reads claude-swap's export (#4532)
StringKe (#4532) is moving from claude-swap (cswap 0.29.0) to magpie, and `magpie accounts import claude` didn't read cswap's export. It does now: parseLoginImport takes cswap's format-1 envelope ({version: 1, swapVersion, encrypted, accounts: [...]}, read from cswap 0.29.0's transfer.py) and cswapEntry reads each account's credentials.claudeAiOauth and config.oauthAccount: email, account and organization uuid, and the organization's name. The tokens are kept as the file has them; magpie asks Anthropic nothing. Refused, each with what to do: an encrypted export (decrypt with gpg -d first), another format version, a Codex entry, and an API-key entry (added as a key instead). An entry with no refresh token is accessOnly, as for every other file. cswap's alias becomes the account's name in magpie (importNames) when the account was added or updated, has no name yet, and no other account is called that or signed in as it, so the name stays a selector for one account (the previous commit's rule). testdata/cswap_0.29.0_export.json is claude-swap 0.29.0's own `cswap export` output, made from its source in a sandbox HOME in WSL with two accounts and fake tokens (cswap's add step asked Anthropic once with the fake refresh token, which it called dead; no real account was involved). Run (mote unless said): - At this commit's tree (on origin/main |
||
|
|
a7b47d57ec |
accounts: removing the account Claude Code is signed in to switches it to another first (#4532)
StringKe (#4532): removing the signed-in Claude account was refused with SignedInError, while Codex's switched away first. ForgetLogin now does the same for Claude Code: nextOnForget picks another account (on first, then one whose sign-in holds), SwitchLogin signs Claude Code in to it, and only then is this one forgotten. If that switch fails, nothing is removed and the error says why. nextOnForget leaves out accounts Claude Code or Codex can't be signed in to (switchable: not a setup-token account, not a Codex account held in another folder). Claude Code is never signed out: when the account is the only one it can be signed in to, it is kept, with SignedInError{Only} (GUI code signed_in_only), which says to add another account first or sign out in Claude Code. The GUI gives the signed-in Claude row a Remove when another account it can use exists, and no Remove or Sign out otherwise. Claude Code's own credential is never deleted; forgetClaudeDir removes only the forgotten account's own folder and its folder's Keychain item, and claudeHolders' check of other records holding the same token is unchanged. Tests: TestForgetLiveClaudeSwitchesFirst, TestForgetOnlyClaudeIsKept (replacing TestClaudeInUseStillRefused, which held the old refusal); codex-signout.test.cjs gets three Claude cases (Remove with another; only + setup-token: no Remove, reason in zh/zh-TW/ja/de; the signed_in_only refusal in en/zh). Run (mote, sandbox HOME through the test helpers): - go test ./internal/provider ./internal/cli, vet and gofmt at the stack head: in the next commit's body (one tree, same run). - Broken by hand, each red: Claude not switched first (TestForgetLiveClaudeSwitchesFirst), Only left false, a setup-token account counted as another, nextOnForget unfiltered (TestForgetOnlyClaudeIsKept). - GUI on Linux (WSL magpie-desktop), Chromium and WebKit: codex-signout, own-signin-remove, saved-signedout-remove, login-import, claude-signin, account-alias and i18n-keys all pass but i18n-keys' "a plugin's words are its own", red on main (#4524). On mote, codex-signout passed in Chromium; its WebKit launches were killed with mote at load ~25 under other sessions' suites (#4125), so WebKit's record is Linux's. CLI in a sandbox HOME (WSL, file credentials): forget of the signed-in account by its name switched Claude Code to the other (.claude.json then says max@x.com); forget of the only one was refused with the message above and left it signed in. Not tried: a real Claude Code switch on removal with real accounts, or in the CLI against a live ~/.claude (sandbox only). |
||
|
|
149e763e9e |
accounts: a name you gave an account picks it wherever an email does (#4532)
StringKe (#4532): `magpie accounts switch claude work` failed when "work" was the alias; accountNamed matched the email only. provider.AccountByName resolves a name (magpie accounts alias) among an agent's accounts. It refuses a name two accounts share, and a name that is another account's email or email part, so a name never picks the wrong account. It is used by: - accountNamed: accounts switch/on/off/remove/alias/cap and the rest that take <email>; - provider pool --accounts; - accountRef (GUI and account-cap): the exact email first, then a name, so another account's alias never shadows an email; - account-cap's display, through AccountRefOf (it filtered by email). Run (mote, at this commit): - go test -timeout 45m -count=1 ./internal/provider ./internal/cli: ok (104.9s, 33.2s). - TestAccountsAliasPicksTheAccount, new: switch, alias, pool --accounts and account-cap by name; a shared name and another account's email refused. Red with each part removed by hand: the accountNamed call, pool's resolution, the clash check, the shared-name check, accountRef's name step. Not run: the GUI suite (no GUI file changed); real accounts. |
||
|
|
15b83901ac |
accounts: switch to the next account with room, or the one with the most left (#4532)
StringKe (#4532), comparing magpie with cswap 0.29.0: there was no "switch to the next account", and when every account was past its line the automatic switch stayed on the spent one, where cswap moves to the account with the most room left. - `magpie accounts switch <claude|codex> next` (provider.NextInOrder) takes the other accounts that are on in magpie, from the one after the account the agent is on, wrapping round: the first whose allowance is known and has room, else the one with the most room left, and says it is past its line. A saved Claude account not read yet is read first (readSpare), as the automatic switch's spares are. With no reading of any it refuses rather than guess; for any other agent it asks for the account by name. - NextLogin (shared by Codex and Claude Code): when the account the agent is on is spent and every spare is past its line too, it moves to the spare with the most room left (roomLeft: the fullest stopping window's distance below the switch share, or the account's own cap when lower), when that has at least roomMargin (1 point) more than the one it is on, so two all but even accounts don't trade the agent each look. A held, failed or unknown reading is never moved to. One model's own window still counts for nothing, as before. - docs: reference.md (the automatic switch and `next`; its "a Claude account magpie knows nothing of is not moved to" was stale since readSpare), providers-accounts.md's Used-up switch row, the en/zh/ja start pages' command table, `magpie help`. Run (on mote, sandbox HOME through the packages' TestMain): - go test -timeout 45m -count=1 ./internal/provider ./internal/cli: ok (144s, 44s), at this change's tree before the next commit's edits. - TestNextLoginTakesTheMostRoomWhenAllArePast and TestNextInOrder, each over codex and claude with three accounts: green; red with the fallback taken out of NextLogin (the two "most room" cases, both agents) and with NextInOrder not starting after the signed-in account ("the one after it", both agents). The "none has more by the margin" case fails without roomMargin. - Built the nogui binary and ran in a fresh sandbox HOME on mote: `accounts switch claude next --help` (prints the accounts help), `switch claude next` and `switch codex next` with no accounts ("has no other account that is on"), `switch gemini next` (asks for a name), `switch claude nxt` (no such account), `switch claude` (usage). - gofmt -l clean. Cross-OS vet: run at the head of this stack. Not tried: a real switch between real Claude or Codex accounts; the CLI `next` with real saved accounts (the provider tests cover the choice). |