ac4af582301a4e8a29245dbba767eba31334ddf9
7089
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
94d4866b5e |
sessions: a Claude session's calls list grows to the rate its file was read at
claudeCall appended each call to st.Calls, and append grows a long list by about a quarter at a time, so a session's calls were copied through lists holding ~5.2 times them on the way to its length: 616 MB of a 120s cold start's allocations on mote over real history copies, the largest single line in it. When the list is full and past 256 calls, growCalls makes room for the calls the rest of the file is likely to hold at the rate read so far (calls / bytes read, times the file's size, an eighth more), at most twice the calls so far, so a misjudged rate costs no more than a short list's doubling. A file read from its cache's offset counts from there the same way; a packed file, whose offsets run past its size, is left to append. TestClaudeCallsListGrownToTheFile reads 20k replies through claudeCallLine: the lists on the way hold 2.84 times the calls (bar 3.5), the last 1.14 times; by hand, growCalls returning at once, 5.2 times, red. A file whose second half is ten times as long per call ends at 1.44 times, under the bar of twice. Measured on mote, 120s cold, rc5 (the parent) against rc6 (this change) under load 67-112: heap peak 244 MB and 243 MB, the same. The list's growth over the Sessions read of the same lines (claudeLine) 616/1234 = 0.50 -> (535 + growCalls' 192)/1778 = 0.41: most of a real history's sessions stay under 256 calls, which append still grows. Run at the rebased head on mote: gofmt; go vet ./internal/sessions for darwin, linux and windows; go test -count=1 ./internal/sessions ok. Not run: the full suite (last at v0.1.3152's change, 85 packages ok). |
||
|
|
19c45d5d4e |
gateway: a vendor's error on the client's own API keeps its status, type, code and fields
ne9ko9 on Discord: an error from a vendor that speaks the client's own API was rebuilt from its status. writeVendorError (via writeErrorSaid) set the type from the status, kept only a string code and param, and dropped every field magpie doesn't know (a numeric code, request_id, extra). That happened in the native relay's error branch (gateway.go), passthrough, translate's and streamTranslated's. Now writeVendorErrorFrom checks the upstream's error shape. When it is the client's own (Chat/Responses to Chat/Responses, Anthropic to Anthropic, Gemini to Gemini) and the body is a JSON error object with a string message, the vendor's status, Content-Type and bytes go to the client, except error.message. Only the message is magpie's: the provider's name before the vendor's words, as before. A describer asking for another model, the Claude sign-in's rewording (claude_signin.go) and the agent read which provider said it there, so taking the name out broke them. The message also carries a note where magpie has one (an account's Explain, a region, the wrong endpoint), a busy relay said so (saysBusy) and a 413's byte-limit hint. A prompt too long for the model (tooLong) is said as the client's API says it: status 400 and type/code, or Gemini's code/status, so the agent compacts. setErrorField splices each change in place, so every other byte is the vendor's. A non-JSON body, or one from another API, is rebuilt as before. For the vendor's message untouched too, the next commit's errors=pass sends the body byte-for-byte. Tests (internal/gateway/kept_error_test.go): - TestSameAPIErrorKeptAsSent: literal bodies with numeric codes (1214, 20031) and extra fields (extra, details, request_id, param) on Chat, Anthropic (403) and Responses. Exact bytes and status. - TestSameAPIOverflowKeepsTheRest: a Zhipu-like 1261 overflow keeps extra and request_id, with code context_length_exceeded. - TestOtherAPIErrorRebuilt: an Anthropic client to a Chat vendor. - TestSetErrorField. Run: - Broken by hand: the new gateway tests copied onto origin/main |
||
|
|
8c97edc802 |
sessions: a calls write goes to its file a frame at a time, its patch list made once
writeCalls held a whole write in one bytes.Buffer, grown by doublings, before any of it went to the file, and the frame's patch list grew by append from empty whenever a collection had emptied its pool, as it does all through a first start. In a 120s cold start on mote over real history copies (#2278 recipe), the list's growth was 148 MB and the buffer's 150 MB of writeCalls' 556 MB. Now each frame is encoded into one pooled buffer and written to the file at once, so a write holds at most one frame (~1 MB, where a 52k-call session held 8 MB), and the list is grown once to the first frame's size. A write that fails after its first frame leaves frames ending in More, which loadCalls already reads as a write cut off: the file is read again. Measured, rc4 (303a31dd6's tree) against rc5 (this change), 120s cold on mote: the list's line is gone from the profile, bytes.growSlice 150 -> 70 MB while rc5 did 1.39x the writes (gob's encoder buffers 240 -> 334 MB); writeCalls 556 -> 583 MB for that 1.39x, ~25% less a write. What is left is each frame's gob encoder's own buffer, which a frame decoded on its own needs. TestCallsWriteAfterACollection writes 10240 calls after two collections: 4.9 MB, bar 6 MB. By hand: the list not grown at once 7.4 MB red, the whole write held 6.8 MB red; the old code 9.3 MB. It reads the file back call for call. Run at the rebased head on mote: gofmt; go vet ./internal/sessions for darwin, linux and windows; go test -count=1 ./internal/sessions ok. Not run: the full suite (last at v0.1.3152's change, 85 packages ok). |
||
|
|
251cce2059 |
usage: a click on All N accounts folds that provider's accounts under it (justfreefall on X)
justfreefall on X (CODEX (2), "既然已经有汇总信息了,能不能出个按钮把下面两个折叠?"): the All N accounts strip already sums the accounts, so its accounts can go. The strip gets the per-account card's own chevron (quota-acct-fold, aria-expanded, Fold/Unfold title, no new strings). A click on the strip or the chevron, or Enter/Space on the chevron, folds that provider's account cards in the Usage page and in the tray panel's Allowances; again unfolds. Default open. Kept per provider in localStorage magpie.usageAllFolded beside the other view choices, and a storage event redraws the other window. The head's "Show ..." button stays in its room, hidden and inert, so the strip does not move under the pointer. A menu-bar cell that asks for one folded account unfolds them first (focusQuotaCard). quotaall.js reads the choice on first use, so loading it touches no app.js global (usage-merge runs it in a bare vm). Core script budget: not raised. app.js +35 bytes, met by shortening comments. Run (mote, macOS 27, unless said): - go test -tags nogui ./internal/gui/: ok at the rebased head (130s); Budget tests again after the last edit: ok. gofmt -l: clean. - usage-all-fold.test.cjs (new): 10/10, chromium + webkit x en zh zh-TW ja de, window 440x520 and panel 360x760. Broken by hand: with main's assets it is red (no .quota-all-fold). - usage-merge, usage-all-fold, tray-cell-click, quota-caption-contrast, old-webkit after the last edit: all ok except tray-cell-click 4/4, red the same at origin/main |
||
|
|
559bf71e99 |
gateway: every ChatGPT account used up reaches Codex as the backend's usage_limit_reached
bitssly on X (11-06): with Codex's quota used up, the Codex app on Windows flickered and errored, and only a restart fixed it. With two or more ChatGPT accounts on, Codex's turn is routed through serve. When every account refused with the backend's 429 usage_limit_reached (or 403 usage_not_included), passthrough wrote it through writeVendorError. That re-typed it as rate_limit_error and dropped the x-codex-* headers. codex-rs's api_bridge maps only usage_limit_reached to UsageLimitReached (plan, reset, windows from the x-codex-* headers). Any other 429 is a retryable status ending in "exceeded retry limit, last status 429", so the app had no limit or reset to show. On one account the refusal was already relayed as sent. codexOutRefusal/writeCodexOut (codex_out_reply.go) now relay a ChatGPT account's usage_limit_reached/usage_not_included on Responses as the backend wrote it: its status, its error object (plan_type, resets_at kept as written, through json.Number) with magpie's message, and its x-codex-* headers. A rate_limit_exceeded 429, a key's 429 and other protocols keep magpie's shape. Turns held before any account is asked (a cap the user set, credits not to be spent) keep rate_limit_error and magpie's advice: Codex shows no message on a usage_limit_reached, and TestCodexNoCreditsEveryAccount guards that advice. The full-window "hit a snag" page itself is the #4550 class: magpie ends the app-server at the used-up takeover or a switch off a spent account, and the ChatGPT app's identity check throws. v0.1.3045 and later reopen the app when it logged fatal_error_broadcasted. That still needs bitssly's version and logs to confirm. Run at origin/main |
||
|
|
10d7f9fcf4 |
provider: Cursor's mover min is 0.2.42 (plugins#788)
cursor 0.2.42 no longer seals a parallel tool batch on a mid-batch checkpoint after an upfront tool count. npm has 0.2.42 (npm view --prefer-online, registry time 11:05Z). Run: go test ./internal/provider/ on mote, ok (173s), gofmt clean. |
||
|
|
303a31dd6b |
sessions: a Claude prompt's content and a reply's usage are read in place
The Sessions read of a Claude history decoded a prompt line whole, so its content (pasted text, images) was copied into a json.RawMessage for each line, then copied again as the prompt's text; and each reply's usage object, a few numbers, went through a json.Unmarshal of its own. - claudeFull decodes its line as the calls' read does (ccDecode, now ccDecodeLess for any line): content nulled, given as the bytes of the line that hold it. Nothing keeps those bytes: the prompt's text and title are copies, as before. - ccReply reads its usage with ccDecodeUsage, in place through gjson. What it can't be sure of reading as json.Unmarshal does (a known key in another case, a number that isn't a plain integer, a value of another type, cache_creation twice, invalid JSON) goes to json.Unmarshal. Measured on mote, cold start over a copy of real Claude and Codex histories (acold.sh, 120s), against v0.1.3155's build at the same base: ccReply 540MB -> 395MB, claudeFull 450MB -> 412MB, encoding/json.(*RawMessage).UnmarshalJSON 209MB -> gone. mote's load was 74 to 126 from other sessions' runs, so the 120s totals and peaks moved between runs of one binary (footprint peak 193-228MB, heap peak 164-194MB for this build; 180-181MB and 163-176MB for the base); neither is claimed as a change. Tests: - TestCCUsageDecodedAsJSONUnmarshal: the same fields or the same refusal as json.Unmarshal for 30 hand-made shapes and 3000 random objects. Red by hand with the case-folded key check taken out. - TestCCUsageReadInPlace: Claude Code's usage read with at most 1 allocation (its cache_creation); 7 by hand with json.Unmarshal. - TestClaudePromptContentNotCopied: a 1 MB prompt line read whole makes 1.05 MB (its text once), bar 1.5x the line; 2.09 MB by hand with the old decode. The content given is the line's own bytes, and the title, prompt count, cwd and session id are read as before. Run on mote at the pushed tree: go vet and go test ./internal/sessions. Not run: the full suite (last at v0.1.3152's change: 85 packages ok, reds only #3949 and #5481). |
||
|
|
37c1bc043b |
agent: a group whose members all serve Responses, one best there, is asked on Responses
zyh6036 on X: several subscriptions that all serve the Responses API were asked on Chat once they were put in a routing group. Pi, OmO, omp, StepCode, droid, dsh, Hermes, Grok CLI and the live agents ask each model on the one API catalog.Model.APIs names, and a group had Responses only when every member's Native was Responses (allResponses, #1594). A relay that serves Chat and Responses, best on Chat (no Base URL API given, not OpenAI's own host), counts as Chat there, so one such member put the whole group on Chat, and the gateway then translated Chat to Responses for the ChatGPT, Copilot GPT or Responses-relay members. Found groups (auto-<slug>) hit this without the user doing anything: a new relay that also lists gpt-5.5 moved auto/gpt-5.5 from openai-responses to Chat (pi_api_test shows it). provider.GroupAPI now gives Responses when one member is best on Responses and every other takes a Responses request as it is (Responses among the APIs it relays), or translates every request anyway (a Claude Code subscription). So no member is translated that Chat would have relayed, and the ones best on Responses are relayed, not translated from Chat. The gateway already relays a /v1/responses request to each member that serves it (usable), so nothing changes there. Mixed groups: a member that Responses doesn't reach (a Chat-only key, a Messages-only Claude) keeps the group on Chat, where that member is relayed; picking Responses there would translate it on every turn. A Messages-only group stays on Chat as before (#1594's reason: a Claude member's thinking is known by its own model id, not the group's). An agent plugin's connect is told a group's native_endpoints now (provider.GroupEndpoints: the APIs every member relays), where it had none. /v1/models still leaves them out for a group: TestRemoteMagpieNativeAPI holds that a remote magpie sends a group's request on in the client's API for the other side to pick per member. No setting added: the group's API follows from its members. Run (mote, through mote-run): - go test ./... -timeout 45m at 65780f04f on |
||
|
|
fcc0daa23e |
usage: Tuned for you tells Claude Code's cache here with no calls, and an hour of the user's has Use 5 min
linkaww (Discord, #help) set Claude Code's prompt cache to 1 hour from Usage > Context > Tuned for you and asked how to go back to 5 minutes. On the computer that sends its requests to a Remote magpie the card was empty, so there was nothing to see or undo. Cause: the card's rows came only from advice, which needs 50 calls read from this computer's session files, or from a knob tune put in itself (TuneKept, v0.1.3120). A Remote-magpie client with too few calls read here, or a 1 hour it didn't put in through magpie (set on the other computer's card and copied, set by hand, or stashed by a version before 3120), had no row. The setting itself is Claude Code's settings.json on the computer where Claude Code runs (promptCacheTtl, subagentPromptCacheTtl); a Remote magpie's requests read B's, not A's. Now: - agent.TuneCacheHere reads Claude Code's two cache lifetimes on this computer whoever set them: the main conversation's always, the subagents' when something sets it, nothing when there is no ~/.claude. adviseOf adds them to the kept knobs, so Claude Code's card shows with no calls at all, each row's Now saying 1 hour, 5 minutes or Default. - A row with too few calls at 1 hour that magpie didn't put in has Use 5 minutes (tooltip: Replaces your 1 hour; Undo puts it back); after it, Undo gives the hour back from the stash. A variable that comes first (CLAUDE_CODE_PROMPT_CACHE_TTL, FORCE_PROMPT_CACHING_5M) still locks it. - A row with too few calls no longer reads "Already the leanest". - The three Use buttons share one helper, which pays for the new one: context.js is 82 bytes smaller, TestCoreScriptBudget's budget untouched. No new strings. Run (mote, via mote-run): - go test ./internal/agent ./internal/gui -count=1: agent ok; gui's only reds are TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote) and, before the helper, TestCoreScriptBudget (fixed as above); after: -run 'CoreScriptBudget|Tune' ok. - context-tune.test.cjs in Chromium and WebKit, all five languages, 360 and 1100 wide: 24 of 24 ok. i18n-keys: every test ok but "a plugin's words are its own", red on main for three strings in other files (#5332, #5426, #5482). - gofmt -l clean; go vet darwin (touched packages), GOOS=linux -tags nogui ./... and GOOS=windows ./... ok; builds for all three ok. Broken by hand: - old internal/gui/tune.go: TestTuneTellsTheCacheHere red ("the user's own 1h, no calls: rows []") and TestTuneKeepsWhatItPutIn red. - old context.js: the new GUI test red in both engines (Now read "—" where Default is expected). Not tried: a real Remote magpie pair (two computers) with linkaww's settings, and a real Claude Code session reading the 5m after the press; the whole GUI suite ran after the push, not before (suite lock held). Reported-by: linkaww (Discord) |
||
|
|
d6f59f9fd0 |
sessions: a Claude message is looked up without making its key again
Every line of a Claude reply looked its message up by "message:"+id, a
new string each time, though only the line that adds the message keeps
it. The key is now built in a stack buffer for the lookup, made a
string only when a message is added, and a second branch of a message
takes the key its first one made.
Measured on mote, cold start over a copy of real Claude and Codex
histories (acold.sh, 120s), against v0.1.3152 built at the same base:
message() 157MB -> 142MB, footprint peak 186MB -> 180MB,
heap peak 169MB -> 163MB, GCs 129 -> 122; total allocated the same
within noise (3.67GB vs 3.70GB). Most replies are one line, so most
lookups add the message.
Test: TestClaudeMessageLookupAllocations: a message's later line makes
0 allocations; a second branch shares the first's key string; a
request-only message is keyed by its request. Red by hand with the old
lookup ("made 1 allocations, want 0").
Run on mote at the pushed tree: go vet and go test ./internal/sessions.
Not run: the full suite (last run at v0.1.3152's change, 85 packages
ok, reds only #3949 and #5481).
|
||
|
|
6cc78e8aad |
provider: the keep-alive tests' Claude week resets days from now, not on Nov 6 (#5481)
TestRenewLoginsKeepsClaudeReading was red on every run since 07:00 UTC 11-06. Its /usage fixture says "resets Nov 6 at 11am (Asia/Dubai)", which is 07:00 UTC 11-06, and the keep-alive reads it at the real time. Once that hour went by the week counted as reset, so the reading had Used 0 where the test wants 37. The issue was filed at 07:15 UTC. resetsAhead writes the reset three days past now, for this test and for TestRenewLoginsKeepsSavedClaudeSignedIn, which had the same fixed date and didn't yet check Used. TestClaudeUsageWeeklyOnly holds its own clock and keeps the reporter's text. Run on mote: without the fix, -run TestRenewLoginsKeepsClaudeReading -count=5 is red 5 of 5 now. With it, -run 'TestRenewLogins| TestClaudeUsageWeeklyOnly' -count=3 is green under TZ=UTC, Pacific/Kiritimati and America/Los_Angeles. internal/provider whole: ok at |
||
|
|
e0a7664b53 |
image: GPT Image 2.6's complexity and 2.5's quality xhigh/max go through
StarBits on X asked whether magpie draws with the newest GPT Image (v0.1.3055/3056). This follows it: the images API and both image MCPs take GPT Image 2.6's `complexity` (low, medium, high) and pass it on, and the tools' quality text names xhigh and max (GPT Image 2.5 and later). - draw.go: complexity is read from JSON and form bodies (drawingRead) and sent, as given, to an images API that takes OpenAI's fields: generations (JSON and form) and multipart edits. Not sent to a ChatGPT (Codex) account, Copilot, OpenRouter, WorkBuddy, Grok or Volcengine. Volcengine used to get an unread complexity through Extra; it is now read, so it no longer goes there. - A ChatGPT account's image backend ignores it. Tried with a real account today: complexity none, low and a bogus value drew alike, and quality high, xhigh and max all came back quality "low" at the same size and tokens. So its request stays the one Codex CLI sends. - image_mcp.go, imagemcp.go: a `complexity` argument, forwarded; quality text lists xhigh and max. Run on mote at this tree (rebased on origin/main |
||
|
|
8f69ca29c4 |
browser: Magpie Browser acts like a person and stays out of the user's tabs
The owner, 11-05: Magpie Browser interrupts the user's own browsing, and driving Discord with it gets the account flagged by Discord's bot check, which never happened under Claude's Chrome extension. What a site could see, and what changed (extension 0.1.6): - CDP's Runtime domain was on in every tab, which bot checks look for. It is now off until browser_console is asked for (on localhost, 127.x, [::1], *.localhost and *.test it is on from the start, as before). The first console call says it reads the console from then on. - Every read and helper (the clickable scan's getComputedStyle and querySelectorAll on each element, focus, readyState, innerText, scroll position) ran in the page's own world, where a page's patched functions see each call. They now run in an isolated world of the extension's (Page.createIsolatedWorld, DOM.resolveNode in it). browser_evaluate stays in the page's world, since the agent's script is for the page's JavaScript. - A click jumped to an element's exact middle. The mouse now moves along a curved, eased path to a spot drawn around the middle, then presses and lets go at uneven timings. Hover and drag go the same way. - Text went in with Input.insertText, with no key events. It is now typed a key at a time with US key codes, Shift held for capitals and symbols, at a typist's uneven rhythm (35s at most for a whole text). Chinese, Japanese and Korean come through an IME composition, emoji through insertText, and a newline as Shift+Enter so a chat box doesn't send early. A field's old text is cleared with Backspace only when it has some, and submit waits a moment before Enter. - A scroll was one wheel event. It is several notches now. - Actions follow each other at a person's pace (350 to 1600ms apart), and the debugger stays attached for 5 minutes idle, not 2, so Chrome's bar doesn't come and go between calls. The user's tabs: - A call naming one of the user's own tabs (one outside every Magpie group) now opens that page in a background tab of the agent's own, in its group, and the agent is told so; naming it again goes on in that copy. This is how Claude's extension keeps to its own group. - tab_close refuses a tab of the user's. - A tab an action opens always goes in the agent's group, and a page that opens a window of its own gives focus back to the window the user was in. - The tool's instructions said calls go to the tab the user is looking at. They now say the agent works in tabs of its own, that naming the user's tab copies it, that steps take a person's time, and how the console starts. Run at this head (rebased on |
||
|
|
9a0aab32c1 |
sessions: a Claude reply evicted from the window is used again for the next
A Claude history's read keeps a window of recent messages to fold
revisions together. Each message made a contribution, a branch map and
its tool and block maps, and dropped them when it left the window: on a
cold start of a real history copy that was ~750MB of message() and
~690MB of ccTool's maps. An evicted contribution and its emptied branch
map now go on a short free list (16 contributions, maps over 64 entries
dropped) and the next message takes them, cleared.
Measured on mote, cold start over a copy of real Claude and Codex
histories (acold.sh, 120s), against v0.1.3128's build:
allocated 8.96GB -> 8.79GB, GCs 277 -> 266,
footprint peak 197MB -> 189MB, heap peak 194MB -> 186MB.
message() 750MB -> 565MB, ccTool 689MB -> 466MB.
Tried and dropped: doubling the calls list by hand saved ~0.5GB of
allocation but raised the footprint peak to 265MB (lists held at up to
twice their size while read), so the calls list grows as before.
Tests:
- TestClaudeEvictedContributionsLeaveNothing: 3 windows of replies
through both reads; every live contribution holds only its own
message's tools and blocks, usage, calls, replies and output totals
are right, a replayed reply makes no call. Red by hand without the
maps' clear ("holds another message's tool") and without recycling
("nothing evicted was kept").
- TestClaudeHistoryReadAllocations: 3156 bytes a reply once the window
is full, bar 4200; 5348 without recycling (red by hand).
Full suite on mote (gofmt, vet darwin/linux/windows, go test -timeout 45m ./...):
85 packages ok; red only TestMainWindowCorners (#3949) and
TestRenewLoginsKeepsClaudeReading (#5481), both filed and red on main.
internal/sessions run again at the rebased head.
|
||
|
|
2b2abec457 |
redact: a one-word name the model flags goes out only beside a thing's word, never alone or in tool arguments
With a model that labels Rina a PERSON, at origin/main |
||
|
|
d7714b3f3b |
redact: every tool call's arguments are the tool's, mcp_tool_use and Responses *_call included
With Secrets and Personal masking on, at origin/main |
||
|
|
dc133b88fe |
redact: an address before a file's extension (alice.smith@acme.com.pdf) is masked
With Secrets and Personal masking on, at origin/main |
||
|
|
64b563cee8 |
gateway: the MCP router keeps Magpie Browser, the image server and other routers to this computer
A gateway key from another computer (LAN, tunnel, or a proxy here) or a web page could reach, through /mcp/magpie/hub, servers that act as this computer's user: - Magpie Browser, which /mcp/magpie/browser itself refuses to such a caller, so a LAN key could drive the user's signed-in browser; - magpie's image server, which draws with this magpie's own token, past the key's model, account and spend holds; - another magpie's router, which passes calls on to its own browser. These are now HereOnly (keepsSession or isSelf in the library) and are neither listed nor run for an away caller. The check sits both in the gateway (hubServersOf, hubTools) and in the library (visitorServers, Call), so a call by name is refused too. A held key (nativeHeld) from another computer also no longer gets programs run here (stdio commands, plugins), only HTTP servers elsewhere. Local callers are unchanged. The mcp-router subsystem page says both rules. Run on mote (macOS 27) at this tree, base |
||
|
|
fe61503e60 |
provider: a Remote magpie whose computer took another address is found on the network
luckymanjc (Discord) uses computer A's magpie from computer B over the
LAN. A's router hands it a new DHCP address after a boot, and B's Remote
magpie, saved at the old one, reached nothing until the address was
typed in again.
When B can't connect to a Remote magpie at all (a dial error, not an
answer), the list fetch (models.go) and the gateway's request (forward
in gateway.go) now call provider.SeekMoved (remote_moved.go). It dials
every address of the old one's /24 and of up to four of B's own private
/24s at A's port (500ms each, 128 at once). The first that lists
/v1/models 200 for the provider's key, and whose list this magpie didn't
make (magpie_via), is A: a LAN caller always needs a gateway key, so
another magpie answers 401. That address is saved as the provider's and
the request is made again there. A name or a public address is never
looked around, an address the user changed meanwhile stands, and a
provider is looked for once a minute at most, callers at once sharing
one look.
Run:
- mote-run go test -count=1 -run 'TestRemoteMagpie|TestLANNeighbours|TestDialable|TestRemoteSelf' ./internal/provider ./internal/gateway: ok
- mote-run go vet, GOOS=windows and GOOS=linux go vet of both packages: ok; gofmt -l clean
- Live: A was a real magpie on mote (10.0.0.121:3511), B a -tags nogui
build in WSL magpie-desktop (127.0.0.1:3522), sandbox HOMEs. B's
provider was saved at the dead 10.0.0.250:3511. B's start fetch found
A ("found at 10.0.0.121:3511, saved there") and a chat answered 200 in
4.2s. Then, with B running, the address was set dead again: a request
to office/group/rot found A and answered 200 in 4.4s, saved at .121.
Broken by hand, each red: the gateway hook off (502), the fetch hook off
(fetch error), the self check off (saved at this magpie itself).
Not tried: a real Windows A; a mDNS name (.local) that changed address
(left to the name); A on a different /24 than B. On Linux a dial to a
dead LAN address took ~54s (no route to host) before the look starts;
not changed here.
Reported-by: luckymanjc. (Discord)
|
||
|
|
c6b7bbedfc |
usage: a narrow Requests list makes the rest tighter before it leaves the first token's column out
unscientific9 saw Requests' 首字耗时 column on one Windows machine and not
on another, with the same settings and version. The column is left out
when the table doesn't fit the window (ledFit), and that width is each
machine's own: the saved window size (660 by default), Windows' display
scaling and the text size. It was the first thing to go after Sent,
Effort and the cache, before names were cut shorter, headers wrapped and
the price reference line dropped (tighter). Now tighter comes first, and
the column goes (tight2, its value under the duration since
|
||
|
|
49c9491b73 |
update: the Windows app asks where to install, the first time
The Windows exe opened from Downloads (or the Desktop, or temp)
installed itself into %LOCALAPPDATA%\Programs\magpie without a word.
Now, the first time, with nothing installed yet, Windows' task dialog
asks "Install magpie in this folder?". It shows the folder and offers
Install, Change… and Cancel, in the tray's language (en, zh, zh-TW,
ja, de).
- Change… opens the system folder picker. A picked folder gets
"magpie" added unless it is already named that (update.InstallDir).
- A folder other than the default is recorded at HKCU\Software\magpie
InstallLocation. So the next exe downloaded replaces the copy there
in place and asks nothing (installed(), forwards()).
- Cancel runs the exe where it is, as a portable copy, and nothing is
recorded.
- Uninstall forgets the record (update.ForgetInstallDir, a new System
step).
- The shortcut, App Paths, autostart, magpie://, the PATH entry and
self-update already take the running exe's folder, so they follow
the choice.
Program Files and other folders only an administrator can write to
are refused in the dialog (update.Installable test-writes and maps a
permission error to ErrNeedsAdmin). They are not elevated into.
magpie installs per user (HKCU Run, the user's PATH), and its
self-update replaces the exe without elevation (CanElevate is false on
Windows). So an admin folder would make every update fail, or would
need a UAC prompt on each one. A downloads folder is refused too.
Refusing is the simplest correct choice: it costs a user nothing they
had before, and keeps updates silent. Any folders the test-write made
are removed again.
Docs: gui-shell.md, "Where Windows installs magpie".
Run (mote, at this head on origin/main
|
||
|
|
f9e6061b85 |
claude: claude-magpie runs Claude Code through magpie, a plain claude left on the user's account
baranwang on X (11-06): `claude` stays on the user's own Claude account, `claude-magpie` goes through magpie, and nothing is switched back and forth. `claude-magpie` runs `magpie claude run [args…]`. That writes a settings file of magpie's own, <config>/claude-launch/settings.json, connected as Connect connects Claude Code (the gateway, its key, the shared LAN key when sharing is on, the model, the tiers) and starts `claude --settings <file> args…`. Claude Code puts a --settings file's env and model over the user's settings.json, a claude.ai sign-in and the shell's variables (tried on 2.1.318), so ~/.claude/settings.json is never rewritten. ANTHROPIC_API_KEY and the cloud switches (Bedrock, Vertex…) are blanked in the file, so neither the user's file nor the shell can take a request past magpie. The file is the agent `claude#launch`, listed nowhere: the Agents page, Check and Notice see only the user's file. It is set again when the gateway moved or its key changed. - /model in a claude-magpie session saves to the user's settings.json (Claude Code never writes a --settings file). After the session a magpie model picked there moves into the launch file, for the next claude-magpie, and the user's file gets its model back. A Claude alias (sonnet) stays. - Claude Code's own one-time `opus` -> `opus[1m]` rewrite of the user's file (migration_opus_to_opus1m), which the launch file's 1M opus tier sets off, is undone the same way. Found in the end-to-end run below. - claude runs as a child so that can happen: on Unix a stopped child stops magpie too (^Z, fg; proc.WaitFollowingStops reaps it with WUNTRACED, as cmd.Wait can't see a stop), and claude's exit code is magpie's. On Windows magpie ignores Ctrl+C while claude has it. - The command: a launcher beside the `magpie` command. Settings › Command line (AddCLI) writes it; `magpie claude launcher [add|remove]` adds it for a command put there before. It is a `#!/bin/sh` exec of magpie's stable path, or on Windows a .cmd running "%~dp0magpie". A file by that name without "written by magpie" is never written over. - Docs: agent-wiring.md, and the start page in en/zh/ja. Run at this commit (rebased on origin/main |
||
|
|
11df525f06 |
gateway: only the vendors seen to hide an overflow have a bare failure told as too long (#5486)
NEKO-CwC asked, after v0.1.3141, why a custom API-key Responses relay's 400/413/422 is still turned into context_length_exceeded when the relay never said so. It shouldn't be. tooLongUnsaid read any provider's 400/413/422 that said nothing of length, for a request 1.2 times past the model's window, as "prompt is too long". That rule came from three vendors' refusals in |
||
|
|
e8df78f33e |
routing: a dsh fork's requests are named by the reply its client was given (#5491)
dsh's chat and messages routes send no session id, so Routing and Context found a dsh session by the hash of the conversation's opening. A fork repeats its source's opening, so every request the fork made showed under the source, and the fork's name never appeared. Flandern1211's patch, ported: - The gateway keeps the id of the reply it gave the client (Route.ResponseID). It is set from clientResponseID in the same update that marks the route done, so a poll that sees Done also sees the id, with no race against the usage ledger. When magpie translates, it is the id after translation, e.g. chatcmpl-…, not the upstream's msg_…. - sessions reads dsh's replayState.response.responseId into Session.ResponseIDs. Only main files are read, only replies served by the gateway, and only the fork's own replies after its session/end-seed (seedLength for version 1). - Routing (pricedRoutes) and Context (joinConvs) look up a finished request by its reply id first, then by its opening. A request logged before this keeps the opening's session. Changed from the patch: - A reply id names a session over the opening only when the opening is that session's own, or a session it was forked from, or the opening is unknown. Vendors' ids can repeat: an encoder keeps the upstream's id, and Ollama's is chatcmpl-<0..999>. Without the guard, two unrelated conversations could swap names. Session.ForkOf comes from the fork header's parentSession, isSeeded and delegationDepth 0, which is how dsh's buildForkSeed writes it. ownerOf walks that chain, so a fork of a fork works too. - Poll cost: dsh never writes down some reply ids (a title call, a refused turn). Under the patch, each such id made Routing list every session again every 2s, for as long as the route was on the page. Now an id is waited for only up to a minute (convsKept) after its request ended (looseKeys). After that the regular one-minute rebuild covers it. - A page whose loose routes carry only a reply id still builds the map (looseRoute). - The patch's synthetic fork headers gain parentSession, as dsh writes them. - docs/subsystems/gateway-routing.md describes the reply-id join. Tests: - TestDshForkNamedByTheReplyTheGatewayGave sends dsh 0.2.0-rc.2's real captured completions request (testdata/dsh-gateway) through gateway.New() twice, to an Anthropic-only upstream, so the reply is translated. It writes the source's real session file with the first client id, and a fork shaped like dsh's buildForkSeed output with the second. It then checks that pricedRoutes and contextOf put each request under its own session, and an old route without an id under the source. - TestDshForkOfARealSessionListsItsOwnReplies forks the real fixture session: the fork lists only its own reply and ForkOf, the source keeps [c1]. - TestDshReplyIDOfAnotherConversationNamesNoOne covers the guard. - TestRoutingWaitsForAReplyIDOnlyAWhile covers the poll bound. - The patch's own tests: TestDoneRouteKeepsTheClientResponseID (json and stream), TestDshResponseIDs*, TestRoutingTellsAForkByItsReply, TestContextTellsAForkByItsReply. Run on mote (mote-run), at this tree on origin/main |
||
|
|
8b4029adfe |
routing: a long session name is cut short inside its own block, in WebKit 17 too (tz_188 on Discord)
tz_188 on v0.1.3122: three ZCode sessions at once on Routing, each named
by a long one-line prompt ("这个commit 中的内容帮我再核对一下
51538fc170c6…", a path under /Users/lbx_16/work/b2b/b2b-platform). Every
name ran past its block and over the next blocks' names, so the three
read as one smear.
|
||
|
|
e6b9d1199c |
readme: Kimi's thanks sits just above the sponsor row
The owner wants the line up top: "Thanks to Kimi for supporting magpie
and the open source community" now sits between the badges and the
Sponsors (赞助商) label, centred like them, in README.md and
README.zh-CN.md. The Acknowledgements (致谢) section
|
||
|
|
218b38c596 |
readme: Kimi is thanked in its own section instead of the sponsor row
Kimi asked not to sit in a row of gateways. Its logo leaves the sponsor row in README.md and README.zh-CN.md, and an Acknowledgements (致谢) section before the license says "Thanks to Kimi for supporting magpie and the open source community", linked through the same /go/kimi/readme and /go/kimi-cn/readme redirects (both checked: 302 to kimi.ai/code and kimi.com/code with aff=magpie). The other five logos keep their order, three in the first row and two in the second. Run: no code changed; checked the rows' alt texts and both redirects. |
||
|
|
de0f5691a8 |
library: a Remote magpie's MCP server says why it isn't synced, its switch held off
treeman_26897 (Discord), on v0.1.3135: the MCP server added from a Remote magpie can't have "Sync to your other computers" turned on. That is meant: the server holds this computer's key for that Remote magpie and goes with the provider, so adoptBridges keeps it Local. But the editor showed a live switch: it turned on, Save took it, and the next read put it back off, with nothing saying why. Now a server with a bridge has the switch off and held (aria-disabled, a click does nothing), and the field's hint and the row's "Not synced" tag say "Added from a Remote magpie with this computer's key for it, so it stays on this computer", in every language. A server edited to another address or key is the user's own (keptBridge drops its bridge) and its switch works as any other's. Nothing changes in Go. Run (mote, at this tree): - node --test mcp-local-server (Chromium + WebKit, en zh zh-TW ja de, 1100 and 390 wide): 22 of 22 ok. - node --test i18n-keys: ok but "a plugin's words are its own", red the same on origin/main and filed (#5332, #5426, #5482; none of its three words are this change's). - node --test library-mcp-*, mcp-*, library-all, library-items, library-servers-bulk, library-toggle-status, old-webkit: 480 of 480 ok, both engines. Broken by hand: origin/main's library client.js under the new test: red in every language at the tag's title ("Sync never carries it to your other computers") and, with the hint and title checks taken out, at "a click doesn't turn it on" ('true' !== 'false'). Not tried: the real app with a real Remote magpie's server; the test fakes /api/library with a bridge server. Reported-by: treeman_26897 (Discord) |
||
|
|
be5e8f29f1 |
dsh: its own models are the two it ships, deepseek-flash named DeepSeek-V4.1-Flash (Kylin_Cloud on X)
Kylin_Cloud (X, 11-06, v0.1.2606): DeepSeek Harness's direct models in magpie listed deepseek-v4-flash, which dsh doesn't have, and showed deepseek-flash as "DeepSeek-V41-Flash"; dsh's built-ins are only DeepSeek-V4.1-Flash and DeepSeek-V4-Pro. Cause: dshModels is a table copied by hand from dsh 0.1.5 ( |
||
|
|
b020ae1022 |
agent: Claude Desktop 4.23118.0's gateway window still has no Chinese (xwoffice)
xwoffice on Discord: "Claude Desktop 接入以后界面会变成英文 取消了又恢复成中文".
Nothing changes in behaviour; this records that the cause is still
Desktop's, in the newest release too.
On magpie, Desktop runs in its 3p mode, whose window is its bundled UI.
Read from Desktop 4.23118.0 (darwin RELEASES.json currentRelease,
published 11-05, downloaded and unpacked, not run):
- Resources/ion-dist.asar's i18n has en-US de-DE fr-FR ko-KR ja-JP es-419
es-ES it-IT hi-IN pt-BR id-ID, no zh. Its supported list in
assets/v1/shared-99 and shared-67 is the same 11, and the window maps
navigator.languages onto them, else en-US, then calls
electronIntl.requestLocaleChange with that pick on mount.
- app.asar's resources/frame/shell/i18n/frame-shell has the same 11.
- app.asar's resources/i18n has zh-Hans and zh-Hant, for the signed-in
(claude.ai) window only. So disconnecting brings Chinese back.
magpie carries the signed-in "locale" into Claude-3p/config.json
(desktopCarryLocale), but Desktop writes its own pick over it at every
start. Nothing magpie can write keeps Chinese there, and magpie doesn't
patch Anthropic's signed app. Chinese readers are told so on the
Agents row and in the switch-on notice since v0.1.2123 (
|
||
|
|
978284dd69 |
gateway: a transport failure or a plain 502 is not told as too long
Filed as #5486. ne9ko9 runs Codex through magpie to a custom OpenAI Responses relay (gpt-6-astra, effort max). Three failures reached Codex as HTTP 400 "prompt is too long: about 385K/404K tokens, more than gpt-6-astra's context window of 272000": a plain 502 "Upstream service temporarily unavailable", a TCP connect timeout (dial tcp … connectex) and a TCP read timeout. Codex took them as context_window_exceeded and ended the turn instead of asking again, although the same session had just been answered at 454K and 474K, and Codex's own window was 828,400. tooLongUnsaid now: - reads a 5xx as an overflow only for Devin (busyOverflows: p.ID or its plugin's host), the vendor |
||
|
|
f47390bf35 |
usage: the speed chart draws every model timed at a point, over 7 and 30 days too
zzzkl3994 on Discord: Usage → Requests, Speed, on 7 or 30 days, today's
column showed one of the five models used today. The chart's colours were
the ranking's top 7, ranked by speed, so a month's fastest models of a
reply or two on an older day took every colour; a speed chart has no
"Other" column, so a model past the colours was drawn nowhere, in the
columns, the lines and the tooltip alike. Today has fewer models, so it
looked right.
Now the chart's colours (ledCategories with chart set) go to the models
most timed (decode_n), ones with a measured speed only, and a model past
them is a faint mark (and a faint line) of its own and a row in the
tooltip. The ranking keeps its speed order and takes the chart's colours,
as it already did for a picked day (chartBy). Tokens, cost and requests
keep their rule: top 7 by that metric, the rest stacked as grey "Other",
which drops nobody. The tray panel draws through the same functions.
Run on mote:
- new internal/gui/tests/usage-speed-all-models.test.cjs: Today, 7 days
and 30 days, columns and lines, tooltip, ranking colours = chart's;
chromium + webkit, en/zh/zh-TW/ja/de, 1100 and 420: 22/22 pass.
Against origin/main's app.js and usage/page.js: 22/22 red, Today passes
and 7 days loses glm-5.1 etc. (the report's shape).
- node --test internal/gui/tests/{usage,panel,reasoning-speed,i18n}*.test.cjs
(100 files, at
|
||
|
|
1615e5a149 |
gui tests: routing-answered-still reads the account dot's pulse from ::after
|
||
|
|
ff415f39cb |
gateway: a compaction refused for an input kind it doesn't take is asked again as text (#5181, #5259)
Command Code's /responses takes messages, function calls, their outputs and reasoning only. A Codex subagent's compaction carries agent_message, custom_tool_call and compaction_trigger items, and Command Code answered 400 unsupported_input_item (param input). codexCompact didn't count that as a reason to ask again with the conversation as text, so the 400 went back to Codex three times and compactFails held the conversation for 5 minutes. inputKindRefused now asks again as text on unsupported_input_item or "unknown item type" (Grok's 422) in a 400, 422 or 502 (another magpie in front wraps it), or in a stream's error / response.failed event. A 401, 403 or 429 with the same words still goes back as it came. itemText reads an agent_message as the user's turn, so the subagent's task and follow-ups are in the text summary and in the local one. No plugin change: the Command Code plugin passes /responses through, and the fallback covers it direct, through a remote magpie and in a stream. Run (mote): - go test -run 'TestCodexCompact|TestCodexCompacts|AgentMessage' ./internal/gateway: ok - go test -timeout 45m -count=1 ./internal/gateway: ok (809.6s) - gofmt -l clean; go vet ./internal/gateway native, GOOS=linux -tags nogui and GOOS=windows: ok Broken by hand: - origin/main's codex_backend.go: every AsksAgainAsText subtest red (400 / 502 back to Codex). - agent_message case removed: the text lacks the subagent's task. - status guard loosened: the 401/403/429 test red. Not tried: a real Command Code account (the keys on this machine are answered 401), the reporters' own sessions; why the compaction reached /responses rather than chat is not confirmed. Reported-by: Mmx233 <36563672+Mmx233@users.noreply.github.com> Reported-by: Edward4226 <Edward4226@users.noreply.github.com> Reported-by: mahiro233 (Discord) Co-authored-by: Mmx233 <36563672+Mmx233@users.noreply.github.com> |
||
|
|
0ad0f42411 |
gateway: Ollama's options reach no Chat upstream, so Hermes Agent's requests to Mistral are not turned away (lijiho96940561 on X)
Hermes Agent pointed at magpie (provider "custom", base URL on this
machine) probes the server as Ollama: detect_local_server_type GETs
/api/tags, which magpie answers in Ollama's shape for VS Code's Copilot,
and the body has "models", so it is "ollama". agent_init_ollama.py then
asks /api/show for the model's context and the custom profile sends it as
extra_body {"options": {"num_ctx": N}} on every chat request
(plugins/model-providers/custom/__init__.py, NousResearch/hermes-agent
90d6b98f). magpie relayed that top-level options to Mistral as it came,
and Mistral's chat API forbids extra fields: 422 extra_forbidden on
["body","options"] for every request. Mistral's own request model
(mistralai/client-python d3da3bd, ChatCompletionRequest) has no options;
it does take reasoning_effort "medium", the other field Hermes adds.
|
||
|
|
ead0bf0059 |
agents, sessions: open in a terminal on Windows and Linux too, and copy any CLI agent's launch line
lileo0668 on Discord: clicking an agent should start it in a terminal,
and a history session should resume there. Opening a terminal was the
Mac app's only (Open in terminal on an Agents row, and Sessions' Open in
the selected terminal and Continue with another agent), and Copy launch
command was only for agy, Cursor (local) and Claude Science.
- terminal_open.go: openTerminal off a Mac.
- Windows: Windows PowerShell (the system default), PowerShell 7 and
Windows Terminal. The line, PowerShell's as Sessions already copies
it, goes as -EncodedCommand: no script file, so no execution policy,
no file encoding and no quoting in between. A shell gets its own
console through cmd's start (magpie's children are CREATE_NO_WINDOW);
wt is started directly, on pwsh or else powershell.
- Linux: $TERMINAL, then xdg-terminal-exec, then x-terminal-emulator,
then the first of GNOME Terminal, Konsole, Xfce Terminal, kitty,
Alacritty, Ghostty, foot, WezTerm, Terminator and XTerm, each with its
own words before the command. The line runs from a script of its own
in sh, then the user's shell, as the Mac's .command file does.
- A terminal that quits failing within a second says so, with what it
printed ("cannot open display").
- Settings' Session terminal row lists the terminals found on Windows and
Linux too; no row when none is found.
- Every agent row with a program now carries `command`, the line the
server builds (Launch, or the program quoted for this system's shell;
an agent in a WSL distro is started through wsl.exe on Windows). The
row menu (right-click or the grip) has Copy launch command after Open in
terminal, on the web build and in the panel too.
Run:
- mote (macOS 27, go1.26.8): go vet of internal/gui and internal/settings
for darwin, for linux with -tags nogui, and for windows; GOOS=windows
and GOOS=linux (nogui) builds of the binary; go test ./internal/gui
./internal/settings ./internal/agent. Everything passes except
TestMainWindowCorners/macOS_26_SDK, which is #3949.
- Windows (win-run, xiaomi-gpu): go test ./internal/gui ./internal/settings.
The new tests pass, among them TestAgentLineWindows, where real
PowerShell runs the encoded line on a claude.cmd in a folder named
`it's a $(New-Item made1) & New-Item made2 #` and runs nothing else.
The six reds are filed: TestLodyImportHandoff,
TestImportStatusUnreadableIsUnknown and TestAionUiImportRow (#4115),
TestUpdateThatWontStart (#1827), and TestPluginAgentMissingSaysSo and
TestGatewayHeldByAContainer (#5324).
- Linux (wsl-run, magpie-desktop): go test -tags nogui -timeout 45m
./internal/gui ./internal/settings: both ok (internal/gui 630s; at
the default 10m it timed out with nothing hung)
- Real use. A throwaway test called openTerminal, not committed.
- On xiaomi-gpu's console desktop (schtasks /IT): system default and
wt each opened a window and ran a line with ' and 中文. pwsh isn't
installed there and was refused by name.
- On magpie-desktop under Xvfb: the system default
(x-terminal-emulator, the xfce4-terminal wrapper) and xfce4-terminal
each ran it (TERM=xterm-256color, set by the terminal). xterm isn't
installed there and was refused. Without a display, xfce4-terminal's
"cannot open display" came back as the error.
- GUI (mote, Playwright Chromium and WebKit): agent-open-terminal (five
languages, 980px and 420px; Copy sends the server's line to /api/copy
unchanged), session-terminal (Win32 and Linux platforms at 420px, and
no row when nothing is found), settings-general, and the agent-*,
sessions-*, session-*, gui-de, gui-ja and gui-zh-tw files with
fold-show-grip, grip-inset, tap-click, menu-input-scroll and
click-scroll (102 files): 1689 pass, 5 fail. The fails:
menu-input-scroll, 4 of 4 red alone on origin/main
|
||
|
|
152c3852ff |
routing: a switched-off group's words stay readable, its logos go grey (jiabubu on Discord)
A group switched off had everything but its switch at opacity .5, and
one with no member ready either (.off, .6) was dimmed twice, to .3: its
name read at 1.92:1 (light) and 2.49:1 (dark). jiabubu found such
groups too faint to read.
Now a switched-off card is not dimmed. Its name is --fg-2 at weight 500
instead of --fg at 600, its handle's logos are grayscale at .6, and the
off switch and the "switched off" tag stay as they were. Its members
keep the same --muted as an on group's. .off does not dim it again. No
new colours, only existing tokens.
Measured contrast (both engines, en and zh):
- light: name 8.64:1 (on: 16.97), members 3.66 (on: 3.66), id 8.22
- dark: name 8.03:1 (on: 13.41), members 4.64 (on: 4.64), id 8.43
Tests:
- group-disabled-contrast.test.cjs (new). Composites each text's colour
and every opacity above it over its backgrounds and checks:
- the name and id are at least 4.5:1;
- the members read no fainter than an on group's;
- the name is quieter than an on group's;
- the switch is off, the tag is there, and the logos are grey (an on
group's are not).
Runs in chromium and webkit, light and dark, en and zh.
- group-switch-add-many.test.cjs checked that every child but the switch
was at .5. It now checks the new look: the handle is grey at .6 and
the rest is not dimmed.
Run (on mote):
- At the pushed base
|
||
|
|
4c8e1cfdfc |
providers: a Remote magpie's MCP servers go to the Library only when switched on, and follow its rename
treeman_26897 (Discord) on v0.1.3127's bridge MCP auto-discovery: - Renamed (name and id), a Remote magpie's auto-added MCP server went: adoptBridges keyed it on the provider id, and after provider.Rename that id is gone, so the server was taken out as the provider's. Now RemoteHub carries the provider's Was, and adoptBridges moves the server's bridge, bridgesOn and bridgesOffered from an id it had to the id it has (one that another provider has now stays that one's). The server keeps its name. - The add dialog had only the address and key. A new Remote magpie's editor has a Name and an ID under the key; blank, they are the preset's as before (provider.Add numbers them when taken), and the ID follows the name until one is typed. - Adding its MCP servers is opt-in: a switch, "Add its MCP servers to the Library", in the add dialog (off) and in a saved one's editor. It lives in library.json (bridgesOn); /api/providers says it as libraryMCP and the save takes it (library.SetRemoteMCP). On asks the remote at once (provider.AskRemoteHub) when no model list is fetched on that save; off takes its server out. Only one switched on is asked (bridgeWanted). A server auto-added before this (no bridgesOn) is kept, and its switch shows on. A server removed in the Library turns its switch off; the provider gone takes its switch with it. Run (mote, at this tree): - go test ./internal/library ./internal/provider ./internal/gui: library ok; provider ok but TestRenewLoginsKeepsClaudeReading (#5481, red the same at the base); gui ok but TestMainWindowCorners (#3949). The first gui run had TestCoreScriptBudget red (app.js over by ~1.2KB); the new code was made compact and seven editor comment blocks cut to one line each. Rebased on |
||
|
|
09812e66bc |
routing: a group's patterns, models and id can be selected and copied on its card and in its editor (jiabubu on Discord)
The window is user-select: none outside text it marks as text, and a
group's card is one big click target that opens the editor. So on the
Routing page a group's 模式 (patterns) line, its members line, its quota
lines and its name could not be copied: the members and names were not
selectable at all, and a drag across a pattern's code (selectable) ended
in a click on the card that opened the editor and threw the selection
away. The editor's model and account-provider names were not
selectable either.
Now:
- routing.css: a card's name, group/<id>, and every .mem line
(members, patterns, quota, classifier failure), and the editor's
member, pattern and account rows' names (.fbrow > .n) are
user-select: text, except while their list is being sorted. Controls
(routing tag, handle, Edit, switches, Remove, Up/Down) stay none.
- client.js groupRow: a click that ends a drag-select inside the card
does not open the editor; it compares the selection at pointerdown,
so a plain click with an old selection still opens it.
Not changed: a double-click on a word in the card still opens the
editor on its first click (the card opens on click, as before).
Test: internal/gui/tests/group-select-copy.test.cjs, chromium + webkit,
en + zh: drags across the pattern, the members line and group/free on
the card select them and leave the editor shut, no scroll moves; a click
still opens the editor; in the editor a model's name and a pattern drag
to a selection; controls compute user-select none; nothing is posted.
Broken by hand: client.js reverted alone -> 4/4 red ('' !== 'or/*:free',
the editor opened); routing.css reverted alone -> 4/4 red (members line
not selected).
Run on mote at base
|
||
|
|
ee91d86ea0 |
provider: a custom provider can be held to HTTP/1.1, and a TLS record error on HTTP/2 moves its host there
kepner_53726 (Discord, magpie 0.1.2926): a custom Anthropic provider at a
company intranet gateway failed 124 turns in 3 days mid-stream with "tls:
bad record MAC" / "received record with version eaf1", each a 200 with 0
output tokens, until a restart; a plain Go 1.26.8 client to the gateway held.
Cause: none found in magpie. The bytes are read by stdlib crypto/tls, and
every conn wrapper on the path only passes them through, so a record whose
MAC fails was mangled before it reached us: by the gateway or a box between
(the system proxy route, a TLS-inspecting middlebox). HTTP/2 meets it far
more than one-off clients do: one long-lived connection carries every
stream, plus magpie's health pings (netproxy.HTTP2Health), so a gateway
that interleaves its writes racily breaks it.
- Provider.HTTP1 ("HTTP version" row, "HTTP/1.1 only" tick, under the
editor's Advanced; shown for a provider of the user's own at an https://
address, the same set InsecureTLS takes). Via adds netproxy.WithHTTP1 for
its own base URLs' hosts; Dispatch sends those over its HTTP/1.1 copy.
Another host, and a request made for another provider (With), keep HTTP/2.
Save refuses it on a preset's; a save that leaves the key out keeps it.
- With no setting: a TLS record error read on an HTTP/2 reply (h2Watch) or
round trip marks the host:port, and Dispatch speaks HTTP/1.1 to it for 6
hours. Go's transport already drops the broken connection. Zero-config
default otherwise unchanged.
- Advanced opens by itself when the tick is set. No note under the row
(the core script budget, not raised).
Run (mote, at
|
||
|
|
a10ad0ec8e |
routing: a Codex memory call put on its conversation's model says why (#5413)
The Routing page read every Codex memory move as codex-turn: "asked for
{model} ..., which magpie doesn't serve". The #4765 branch of
codexMemoryStandIn moves a bare Codex default that magpie does serve
(a provider has a model by the same name) when Codex's config names no
memory model, so that sentence was wrong for it. That branch now
records codex-follow, said as "{agent} asked for {model}, one of its
own default models, for its memories, and its config names no model
for them; magpie served it on {to}, the model of its conversation.",
in en, zh, zh-TW, ja and de. Models magpie doesn't serve stay
codex-turn.
Run (mote): go test ./internal/gateway -run
'TestCodexMemory|TestCodexSide|TestCodexMemories|TestCodex.*Follow'
-count=1: ok. node --test routing-moved-why (chromium + webkit, every
language, 1100 and 420px), i18n-keys, i18n-en-no-cjk: 27 of 28; the red
is i18n-keys "a plugin's words are its own", red the same at
origin/main
|
||
|
|
73324357ed |
gateway: a Codex memory call on a provider/model id keeps it (#5413)
Codex's memories.extract_model and consolidation_model, set to remote-magpie/sub2api/gpt-6.1-terra on the user's computer, reached the Remote magpie as sub2api/gpt-6.1-terra, which it serves. The branch of codexMemoryStandIn added for #4765 (a bare Codex default that a provider happens to serve under the same name) moved any memory call that resolves onto the conversation's model unless CodexSideSet saw [memories] set, and the remote has no Codex config to read (GetTOMLTable's absent file reads as "nothing set"). So the user's pick went to sub2api/gpt-6.1-sol, recorded as codex-turn. A "provider/model" id is never one of Codex's defaults, which are bare, so it is the user's pick and goes as it came, as codexFollowTo (the ChatGPT backend's path) already does. The same holds locally for a Codex on a profile or a CODEX_HOME of its own, whose config magpie doesn't read. A bare name that resolves still follows the conversation when the config here names no memory model (#4765 unchanged). Run (mote): go test ./internal/gateway -run 'TestCodexMemory|TestCodexSide|TestCodexMemories' -count=1: ok. Broken by hand: with the "/" check taken out, TestCodexMemoryOnAQualifiedModelKeepsIt fails with "memory_consolidation moved to "third/gpt-6-astra" (codex-turn)", the reporter's move. Not tried: a real Local -> Remote magpie pair with Sub2API; a bare memory model named in the config of a Codex on another computer still can't be seen by the remote. Reported-by: MariaMatrix (GitHub) Reported-by: mahiro233 (Discord) |
||
|
|
1ccad582d8 |
library: a skill the user has in ~/.agents/skills under another folder or with other files is not given a second time
math_milian (Discord #feedback, 11-06) still saw skills twice after |
||
|
|
6bc5702cd4 |
agent: magpie's OpenCode provider sets setCacheKey, so OpenCode sends its session's prompt_cache_key (#5468)
mariamatrix (#5468) and mahiro233 on Discord: magpie writes OpenCode's magpie provider with @ai-sdk/openai-compatible and only baseURL/apiKey, so OpenCode sends no prompt_cache_key and an upstream that caches by it misses. Checked against OpenCode's source and real runs (sandbox HOME on mote, a recording Chat server): - 2.2.5: v1/config/migrate.ts maps options.setCacheKey to compatibility.supportsPromptCacheKey, and openai-chat.ts sends prompt_cache_key only then. Without it: no key; with it: "prompt_cache_key":"ses_…" on the turn and the title request. A config with magpie's provider under providers, compatibility.supportsPromptCacheKey true, sends it too; without, none. - 1.19.5: setCacheKey true sends camelCase promptCacheKey (the previous commit sends it on as prompt_cache_key). - 2.0.25: ignores the option; the run answers as before, no error. Now: - the "opencode" shape's options have setCacheKey: true. Every writer of provider.magpie goes through it and openCodeKept: OpenCode, its OPENCODE_CONFIG_DIR copies, MiMo Code, DevEco, Air's OpenCode and OpenChamber's. - openCodeNative writes it as OpenCode 2 does: compatibility .supportsPromptCacheKey, not a setting. - a setCacheKey the file has already under provider.magpie.options, or a supportsPromptCacheKey under providers.magpie.compatibility, is the user's (false too) and stays, through a sync and a pick. Kilo has no wiring in magpie; no other agent's config has this option. TestAirProviderWritesKeepCustomFields compared every option as a string; it now compares a bool as its JSON. Run on mote: go test ./internal/agent (full package) ok; go test -run 'OpenCode|CacheKey|Air|OpenChamber|Deveco|Mimo|KeepTheir' ./internal/agent ./internal/gateway ok; go vet on darwin, GOOS=linux, GOOS=windows; go build ./... (darwin, windows); gofmt clean. Broken by hand, each failing TestOpenCodeSetsCacheKey: no setCacheKey in the shape ("no setCacheKey"); no keep under provider ("the user's false not kept"); no keep under providers (same); no move out of settings ("setCacheKey in OpenCode 2's settings"). Not tried: a config written by a running magpie fed to a real OpenCode (the real runs used configs of the same shape, written by hand); a real upstream's cache hit rate before and after. Reported-by: mariamatrix Reported-by: mahiro233 |
||
|
|
2979fbdc99 |
gateway: OpenCode 1's promptCacheKey reaches the upstream as prompt_cache_key (#5468)
OpenCode 1 (opencode-ai 1.19.5) with its provider's setCacheKey writes the session's key into a Chat body as camelCase promptCacheKey (a real run on mote against a recording server: "promptCacheKey":"ses_…"), a field no Chat API reads; a passthrough upstream got it as written and no cache key, a translated route never read it. The next commit has magpie set setCacheKey for OpenCode, so this comes first. Now a Chat request's promptCacheKey is taken out and sent as prompt_cache_key, for every route (handle, beside thinkingEffort), so req.CacheKey and the relay both see it. A prompt_cache_key the body has already is the one kept. The body is re-encoded without HTML escaping. Run on mote: go test -run 'OpenCode|CacheKey' ./internal/gateway ok; go vet ./internal/gateway on darwin, GOOS=linux and GOOS=windows; go build ./... (darwin, windows). Broken by hand: without the cacheKeyCamel call, TestOpenCodeCamelCacheKey fails (upstream body still "promptCacheKey":"ses_1a2b", no prompt_cache_key). Not tried: OpenCode 1 through a running magpie gateway end to end (the recording server saw OpenCode's body; the test covers magpie's half). Reported-by: mariamatrix Reported-by: mahiro233 |
||
|
|
81d6a3294b |
sessions: a first start's read of Claude Code history makes 39% less garbage (#2278)
A first start (or one after the session caches are gone) reads every
Claude Code transcript to count calls. On a real 21 GB history this
allocated 14.6 GB and ran 460 GCs. Three things made most of what was
thrown away right after:
- ccWithoutContent made a new copy of each reply line with its content
set to null (82 MB), and gjson.GetBytes copied the content to find it
(27 MB). ccDecode now builds the stripped line in a pooled buffer and
finds the content through an unsafe.String view, with no copy.
- ccStr.UnmarshalJSON went through json.Unmarshal for each string, which
made a decoder for each one (29 MB). A string with no escapes and valid
UTF-8 is now taken as its bytes. Anything else still goes to
json.Unmarshal, which writes U+FFFD for bad bytes.
- writeCalls made a new Patches list for each frame (1 GB). It now reuses
one list from a pool and clears it before putting it back, so the pool
keeps no reference to the call state.
Measured on mote with the real 21 GB history copied into a sandbox HOME,
with the session caches deleted before each run, over 120s:
v0.1.3118: 14.6 GB allocated, 460 GCs, CPU 3:17, footprint peak 195 MB
this: 8.96 GB allocated, 277 GCs, CPU 3:19, footprint peak 197 MB
The footprint peak is what is live (the caches), so it does not change.
Tests:
- TestCCDecodeAsUnmarshal holds ccDecode to json.Unmarshal of the whole
line. Its cases are escaped content, non-UTF-8 bytes, content first,
an error line, not JSON, and an empty line.
- TestCCDecodeAllocations allows at most 1300 bytes for a 41 KB reply
line.
- TestCallsWriteKeepsNoPatchListPerFrame allows at most 6 MB for a
6144-call write.
Both allocation tests turn GC off while they measure, because a GC
empties the pool; they passed 5 of 5. Broken by hand: with the line
pool removed, the decode test made 1984 bytes and went red. With the
Patches list made per frame again, the write test made 13056 KB and
went red.
Full suite on mote at
|
||
|
|
cd9c52c16e |
library: a Remote magpie's MCP router is a Library server of its own
With another magpie as a provider (preset remote-magpie), its router's
MCP servers took adding that same magpie again under Library -> MCP.
Now the gateway's info (GET /v1) says "mcp_hub": true to a caller it
serves MCP to while its router is on with a server that isn't itself
another magpie's router. A fetch of a Remote magpie's models asks that
info with the provider's key, only while the library would still give
it a server, and the library then adds one: named for the provider,
http at <root>/mcp/magpie/hub with Authorization: Bearer <key>, kept to
this computer (local), on for the agents given the hub's entry.
- Offered once (bridgesOffered in library.json): removed or switched
off by the user, it stays so until the provider is removed and added
again.
- A server the user already has at that magpie's router (same origin,
the router's path) is the one; none is added beside it.
- The provider removed takes its server out (adoptBridges, at Sync and
the View read); providers.json unreadable takes nothing out; the
provider's address or key changed changes the server's; edited to
another address or key it becomes the user's own (keptBridge).
- No loop: every dial to a URL under /mcp/magpie/hub carries
X-Magpie-Router, and a request with it is given no such server,
neither listed (library Tools, gateway hubServersOf) nor run (Call,
hubToolNamed). A server carried in by sync is never a bridge.
- No GUI change: it is a server row as any other.
Run (mote, at base
|
||
|
|
e9c720a3ff |
gateway: OpenAI's 429 credit_balance_exhausted is out of credit, not a rate limit
OpenAI's prepaid API credits answer an organization whose balance is
spent with HTTP 429 and the code credit_balance_exhausted (asked about by
hey_boyce on X, 11-06). brokeWords' "credits exhausted" needs a space, so
the underscores kept it from matching: failure() read it as "rate", and
the same key was asked again after a minute instead of the request moving
to the next account. brokeWords now takes credit.?balance.?exhausted.
The fixture is OpenAI's documented error code alone, not a captured
reply; no account with spent credits was tried.
Run:
- TestOpenAICreditBalanceExhaustedIsCredit red without the regex change
("rate, want credit" for both bodies), green with it (mote).
- go test ./internal/gateway -count=1 -timeout 45m: ok (877s, mote) at
base
|
||
|
|
dd2be65656 |
gateway: a Responses request translated to Mistral carries its thinking as parts, not reasoning_content (#4906)
Codex on /v1/responses with a DeepSeek-named model served at Mistral (preset mistral or api.mistral.ai, here deepseek-v4-1-flash-1017) broke after its first tool call: the Chat build replays an earlier turn's thinking in reasoning_content for any model whose name says DeepSeek, wherever it is served (chatReplaysReasoning keys on the name), and Mistral answers that field with 422 extra_forbidden. The #494 fix converted it to Mistral's typed thinking part (mistralThinking) only on the Chat passthrough route, so /v1/chat/completions on the same provider answered 200 while every follow-up on /v1/responses was refused. forwardTranslated now runs mistralThinking on the body built for a Mistral upstream, with the same gate the relayed route uses. Other upstreams keep the #1462 replay (a DeepSeek at DeepSeek still gets reasoning_content), and the relayed route is unchanged. MystryMocha's nit: a whitespace-only thinking (the " " placeholder the replay gives a tool turn with no reasoning item) is now dropped instead of being sent as a blank thinking part. This applies to the relayed route too; Mistral accepts the dropped field (MystryMocha's raw table). Ported from skygunner's 29b0ea308 (branch fix/4906-mistral-translated-reasoning), on origin/main |
||
|
|
3f53fa1f31 |
gui: a browser tab's font probe yields, and measures the generics once
Opening Settings in a browser tab (magpie web) held the page for 2.5 to
2.9 s on a cold start with the CPU slowed 4x (unscientific9: "冷启动进入设置"
is slow). The profile put the whole long task in webfonts.js drawn() ->
measureText: list() probed every installed family in one task, and each
probe measured monospace and serif again, so a Mac's few hundred families
cost up to four measures each, and a measure of a family not drawn yet
loads it.
Now the two generics' widths are measured once, so each family costs one
or two measures, and list() gives the page back every 8 ms.
Measured on mote (headless Chromium, 1280x820, CPU 4x, sandbox HOME with a
300k-row ledger, magpie web, Settings opened from Usage), two runs each:
- before (a build of
|