4794de398ea8337d223a91e207181c56fcf4ad76
521
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
93c5d846ca |
plugin: a plugin's requests to a host on the user's own network go direct, as magpie's own do (#1572, ggbdpq)
What changed: with a proxy set (magpie's, the environment's or the system's), the plugin host sent a plugin's requests for a host on the user's own network - a Remote magpie, an LLM relay on the NAS - through that proxy, which can't reach it (502 Bad Gateway) or resolve its name. Go's netproxy.Func leaves such a host direct since #982 (lan.go onLAN); host.js's proxyFor and its node:http2 sessions (#1035) were that rule's siblings without it. - host.js ports lan.go's rule: onLAN takes a private (10/8, 172.16/12, 192.168/16, fc00::/7), link-local, loopback or CGNAT (100.64/10) address, a .local name, or a name every address of which is one of those; looked up for 400 ms at most, kept a minute (256 names), a failed or slow lookup is "not on the network". It is asked only when the global proxy would be taken (after loopback, a provider's own proxy or "direct", and NO_PROXY), as Func asks it, so a user without a proxy pays no lookup and a provider's own proxy is still taken as is. IPv6 is compared on its bytes, so a v4-mapped address in hex form (::ffff:a00:1, how URL writes it) is judged as its IPv4 address. - http2.connect returns its session at once, so tunnel() now takes a promise of the proxy and connects when onLAN has answered: straight to the host for one on the user's network, through the CONNECT otherwise. Unlike the issue's patch, a LAN name that needs a lookup is covered on this path too. - The issue's patch was reviewed, not applied: its lanIP missed loopback and hex v4-mapped IPv6, it didn't strip a trailing dot, it never cleared its lookup timer, and it left HTTP/2 to LAN names proxied. New TestPluginLeavesTheUserNetworkDirect (real Bun, a proxy that keeps every target it is asked): a fetch to this computer's private address over http:// (absolute form) and https:// (CONNECT; a certificate for that address via NODE_EXTRA_CA_CERTS), to "localhost." (a name decided by what it resolves to), and an HTTP/2 session to the private address all reach the server directly; a public address (203.0.113.5) and a name that resolves nowhere (vendor.invalid) still go through the proxy. Run: the new test against the old host.js fails on all three fetches (proxy asked for each); with only the HTTP/2 check removed it fails on the session ("h2: proxyconnect tcp: 502 Bad Gateway"); with every host taken as LAN it fails on the public address and the vendor name. A bun check of lanIP over 24 addresses (both sides of every range) matched lan.go. go test ./internal/plugin ./internal/netproxy ok; full go test -tags nogui ./... ok in every package (the five whose build hit another session's go-build cache prune were rerun, all ok: ., agent, gateway, gui, library); gofmt -l clean; go vet -tags nogui internal/plugin on darwin, GOOS=linux and GOOS=windows clean. Not tried with a real NAS or Remote magpie behind a real proxy. |
||
|
|
5fa908c087 |
gateway, provider: Claude Desktop's requests to ModelScope go on its Responses API, which reports the cache and reasoning that its Chat API leaves out (#1578, sparrowbits)
What changed
- provider.ResponsesTellsCache: ModelScope's API-Inference (the
"modelscope" preset, or a provider whose Responses URL is
api-inference.modelscope.cn) with both a Chat and a Responses URL.
ResponsesFirst is true there for every model, so `usable` puts
Responses before Chat. A translated request (Claude Desktop / Claude
Code's /v1/messages, a Gemini client) goes to /responses, and
Provider.Native wires Pi, omp and droid to Responses. A Chat client's
request is still relayed on Chat, and Codex's on Responses, as before.
- forwardTranslated: when Responses is first only for the cache report,
a 404 there marks the model unfit on Responses and asks it on Chat. A
ModelScope model with no Responses route then works as it did before.
This fallback is scoped to ResponsesTellsCache.
- docs/subsystems/gateway-routing.md: the "One try" row names it.
Why
The reporter's usage.jsonl covers 202 Claude Desktop requests, all
/v1/messages -> /v1/chat/completions: 0 cache_read over 34.9M input
tokens, and reasoning 0/202. Codex on /v1/responses with the same model,
on the same day, read 94% from cache. Their direct calls show why.
ModelScope's /responses answers
input_tokens_details.cached_tokens = 12288 on the second identical
prompt. Its /chat/completions answers only prompt_tokens /
completion_tokens / total_tokens, though it is served from the same
cache. magpie already maps Chat's prompt_tokens_details.cached_tokens
(and prompt_cache_hit_tokens, cached_tokens, cache_read_input_tokens) to
cache_read_input_tokens (cUsage.usage). The new test
TestOtherChatAndResponsesKeepChat pins that. So the missing figure was
not a mapping gap: ModelScope's Chat API never sends one. The fix is to
ask on the API that does.
Scope: other presets with both Chat and Responses URLs keep Chat.
- DeepSeek, xAI, Zhipu, MiMo, Qianfan, Tencent TokenHub, Volcengine's
plans, OpenCode Zen/Go, Command Code, PipeLLM and CherryIn have an
Anthropic URL, so Claude-format requests are relayed on Messages as
they are.
- Groq's and Volcengine Ark's Chat APIs report
prompt_tokens_details.cached_tokens, and Groq's Responses API is a
partial beta.
- OpenAI keeps its existing OpenAI-model rule.
- Nothing is known of a custom relay's Responses API.
What was run
- New tests in internal/gateway/responses_tells_cache_test.go, against
an httptest fake that answers with the reporter's literal usage
bodies:
- TestModelScopeMessagesTellTheCache: streamed and whole Messages go
to /v1/responses, and the client gets cache_read_input_tokens 12288,
input_tokens 108 and output_tokens 32.
- TestModelScopeModelNotOnResponsesGoesToChat: a 404 on Responses
goes to Chat, and stays on Chat for the next request.
- TestOtherChatAndResponsesKeepChat
- TestModelScopeNativeIsResponses
- Broken by hand:
- Without the ResponsesTellsCache check in ResponsesFirst,
TestModelScopeMessagesTellTheCache fails ("Messages went to
[/v1/chat/completions], want /v1/responses"), and so do
TestModelScopeNativeIsResponses and the fallback test.
- Without the 404 fallback, TestModelScopeModelNotOnResponsesGoesToChat
fails with "404 ModelScope: Not Found".
- gofmt -l is clean. go vet, and GOOS=linux and GOOS=windows go vet
-tags nogui, pass on internal/gateway and internal/provider.
- Full suite: go test -tags nogui ./... under a temp HOME at base
|
||
|
|
f1001ec991 |
library, gui: each of an MCP server's tools has a switch, and the agents that can leave one out are told to (nf1qaz2w on Discord)
nf1qaz2w asked to turn single tools of a Library MCP server on and off.
|
||
|
|
05cf7814eb |
gateway: a translated reply cut short reaches a client that asked for no stream as the error too (#1563, ggbdpq)
What changed: every translated request is asked of its upstream as a stream, and a client that asked for no stream gets its reply assembled from it. translate read that stream and rendered whatever came as the whole reply, so an Anthropic upstream that stopped with no stop_reason and no message_stop, or a Responses one with no response.completed, handed the client a truncated answer presented as finished — the same cut a streaming client is told of in its stream (errEndedShort). The read now watches for the upstream's last event the same way (upstreamEnds), and ends with the 502 "the reply ended before it was complete" instead: nothing has been sent, so the next candidate is asked, and the last one's error reaches the agent. An error the upstream said still reports itself; a stream that said its last event (stop_reason, message_stop, response.completed) is served as it came. Review (yetone's session): with the cut check disabled by hand TestNonStreamEndedShort fails (both subtests 200 with "Let me look at the"); restored, green. The 502 takes the same path as the read-error 502 beside it (cutMidReply): nothing written yet, retryable() lets the next candidate answer, and no account is rested for it as content. The full suite, gofmt and the cross-OS vets were run on the series. Author's run: TestNonStreamEndedShort (new; Anthropic and Responses cases) fails on the old code — both cuts came back 200 with finish_reason "stop"; with the change both come back 502 naming the cut, and a reply whose last event came is served 200 whole. gofmt -l clean; go vet and go build on darwin, linux, windows; go test -tags nogui -race -count=20 on the relay-stop tests; the full go test -tags nogui ./... (TestOffline and TestSearchFollowsTheSearchersProxy red on the clean baseline too). Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> |
||
|
|
e435fe00f1 |
gateway: a translated Responses reply the upstream cut short ends in an error, not as if whole (#1562, ggbdpq)
What changed: streamTranslated ended a translated reply in "the reply ended before it was complete" when an Anthropic upstream's stream stopped with no stop_reason and no message_stop; a Responses upstream's stream that stopped with no terminal event (no response.completed, response.incomplete, response.failed) was still finished as if whole, and the agent's turn ended a few words in with nothing to say why — the same reply the passthrough already tells apart (sniff.whole, #370). It now ends in the same error, asked again in place where the upstream goes on from a prefill, as an Anthropic cut is. The event that ends a stream is read by its type as the passthrough reads it (upstreamEnds, was anthropicEnds, already lastEvent), so a response.completed carrying no status field still counts as the reply's last. Chat (may end without [DONE] and be whole) and Gemini stay as the passthrough treats them. Run (review, yetone's session): TestResponsesUpstreamEndedShort passes; with the Responses half of the end check taken out by hand it fails ("a cut reply finished as whole", finish_reason "stop", no error). TestRelayStream*, TestRelayStop* ok. The full suite, gofmt and the cross-OS vets are in the series' last commit. Author's run: the red/green above, -race -count=20 on the relay-stop tests, gofmt, go vet and go build on darwin, linux, windows, go test ./... (TestOffline red on the clean baseline too, offline machine). Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> |
||
|
|
440fded2dc |
gateway: a turn stopped with its tool call out is answered on Google's APIs, not refused by them (#1560, ggbdpq)
What changed: a client replaying a conversation whose turn was interrupted with the tool call still out — the call in the history, no result for it — had every later turn refused by Google's APIs with 400 "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn", the conversation with it, however it was routed: a Google sign-in (Code Assist), Vertex AI, a custom provider's Gemini URL (#1346) and a model pinned to Gemini ( |
||
|
|
fa5ef88d63 |
gateway: a Chat client's sampling is asked again without it when the Claude it is translated to refuses it by a name magpie can't read (#1559, ggbdpq)
What changed: forwardTranslated's retry loop now answers the "`temperature` is deprecated for this model" refusal (#1454) the way passthrough's does: asked once more with temperature and top_p left out. samplingAsTaken drops the sampling up front only where the model's name on the wire is one claudeLine reads; a Chat or Responses client's request to a Claude behind a relay that spells it otherwise carried the sampling into a 400 that reached the client, where the same request relayed from an Anthropic client was asked again without it. Review (yetone's session): the new case fails on the old code (400 "`temperature` is deprecated for this model" reaching the Chat client) and passes with the retry. The retry is scoped to an Anthropic upstream, a 400 matching samplingDeprecated and a request that carried sampling, so it is asked at most once and before anything reached the client; no account is rested for it. The doc conflict with main's prefill line was resolved keeping main's line. The full suite, gofmt and the cross-OS vets were run on the series. Author's run: the new case "a name magpie can't read is asked again from chat" red then green; the sampling/thinking/prefill tests ok; go test -tags nogui ./... ok except internal/testenv TestOffline (offline machine, red on the baseline too); gofmt -l clean; go vet and go build on darwin, linux, windows. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> |
||
|
|
1d016ee3f3 |
provider, gui: Token Plan 企业版 shows its usage on the Usage page, read with the account's SecretId and SecretKey (#1574, undirectlookable)
#1574 asks for Tencent Cloud Token Plan's usage on the Usage page through TokenHub's cloud API (api/1823/132270). That API covers the enterprise plan only (Token Plan 企业版; the previous commit added its regions). The personal plan (api.lkeap.cloud.tencent.com/plan) has no usage API, only the console, so it has no card. The API takes the account's API key, a SecretId and SecretKey signed TC3-HMAC-SHA256, never the plan's sk- key. provider (tencent_usage.go): - A provider at /plan on tokenhub.tencentmaas.com (ap-guangzhou) or tokenhub-intl.tencentmaas.com (ap-singapore) with a SecretId and SecretKey gets a card per team plan in PlanQuotas (tencentPlanQuotas), each key and region asked once. - It asks DescribeTokenPlanList, then DescribeTokenPlan per plan (version 2026-03-22), all at tokenhub.tencentcloudapi.com. Where a reply leaves a part out, the list's copy of it is kept. - The window is TotalUsed of CycleQuota (else TotalQuota), in credits (专业套餐) or tokens (轻享套餐, enterprise-auto). It resets at TokenSummary.CycleEndTime. Without that, it counts months from StartTime and stops at ExpireTime. - The docs don't say whether TotalUsed is the cycle's or the package's. This reads it as the cycle's. - A plan that isn't enable shows its status beside the plan's name. - An AuthFailure or UnauthorizedOperation reply says to check the key and its CAM rights. No plan visible to the key says so (a sub-user sees only the plans it made). - The SecretId and SecretKey sit in the AccessKeyID and SecretAccessKey fields Volcengine's access key uses (#1427). They are stored, kept out of key-less backups and dropped from cached cards the same way. AccessKeyVendor tells the two vendors apart. gui: - The listing tells whose access key a provider or preset takes. presetAccessKey lists the regions that take one: Tencent Cloud's two Enterprise regions. - The editor names the fields SecretId and SecretKey, with Tencent's hint, and shows them only at those regions (or at an endpoint none of the regions has). - A SecretId with no SecretKey is refused only where the fields are shown. The new strings are in zh, zh-TW, ja and de. - docs/subsystems/providers-accounts.md and the GUI tests README describe it. Run: - TestTC3SignMatchesDoc pins the signing doc's worked example (payload hash 35e9c5b0…, Signature 10b1a37a…). - TestTencentPlanRegion, TestTencentPlanWindow and TestTencentPlanQuotas use the API docs' own response examples. The last is an httptest fake that rechecks each TC3 signature and the X-TC-* headers, and fails if the plan's key is ever sent. - TestProviderListTellsTencentAccessKey covers the listing, alongside TestVolc* and TestPlanQuotas. - Breaking the action's lowercasing in the signature, or dropping TokenSummary, turns them red. - GUI: tencent-access-key.test.cjs (new) 12/12 in Chromium and WebKit at 420px, en and zh. It goes red with the region hook or the vendor labels taken out. volc-access-key, tencent-cloud, i18n-keys, gui-ja and gui-de pass. - gofmt; go vet on darwin, linux and windows; the full go test ./... Not tried against the real API: we have no Tencent Cloud account. What is read is what the docs show, and the reporter is asked to try it. |
||
|
|
47269f448f |
usage, gateway, gui: the Requests card counts requests once, a try handed on to the next isn't a failure, and says how many were answered on a retry (小一 on Discord)
小一's Codex-on-credits ledger read "5,482 · 1,094 failed" while many rows said "2 tries/3 tries" and had been answered. "Failed" counted usage rows, not requests: besides each request's final row, the gateway writes a row for every try a vendor refused or turned away (hw.refused/hw.turnedAway), and each of those was counted as a call and a failure even when a later member answered. (Ordinary failovers write no row; 499 cancels and the agent's own client-side retries are separate requests.) In the owner's own usage.jsonl, 24 of the 71 "failed" rows were such refusals a later member answered. Now a request counts once, by how it ended: - usage.Record gains `tries` (final row, when the route took more than one) and `handed_on` (the row of a try that failed and handed the request on). Totals.count skips handed-on rows; a failure is a request whose agent got an error (LostRequest); one answered after a failed try is Totals.Retried (RetriedRequest), with a `retried=1` filter. - Logs written before this are read the same way: the log index marks a failed, non-rejected row followed by another of the same route id as handed on and raises the later row's tries (routeRows); the packed row and its snapshot carry both. - Panel card, Usage overview tile, ledger card, rankings and group rows, `magpie usage` and the TUI say "N answered on a retry"; the CSV adds `tries` and `handed_on` at the end. A row says "· handed on" (with why in its title) or "· N tries". - On the ledger's Requests card "N failed" and "N answered on a retry" are buttons that switch the list to the Failed / new Retried filter, and back when pressed again. The lines wrap rather than cut a button off (German). zh, zh-TW, ja, de strings added. - Docs: reference.md (counting, filter, CSV columns), gateway-routing.md. Run: - go test -tags nogui ./internal/usage ./internal/usageapi ./internal/tui ./internal/gateway . : ok. New TestRequestsCountedOnceWithTheirRetries (JSONL fixture: legacy refused row + 200, handed_on + 200 tries 3, 502 tries 2, plain 200, routeless 429 → 5 calls, 2 failed, 2 retried, across Ledger, QueryPage, Summarize, heatmap, filters, CSV) and TestRetriedRequestCountsOnce (group a refuses, b 500s, c answers → 1 call, 0 errors, 1 retried; a lone 400 → 1 error). - Broke each by hand (count without the HandedOn skip, gateway without HandedOn, log index without routeRows): each test went red; restored. - go test -tags nogui -timeout 40m ./... under the gotest lock, rebased on origin/main |
||
|
|
310991d78f |
gui: a group with measured replies and floors shows both, the measured speed first, "125 tok/s (1) · ≥50 tok/s (259)" (Fallmonkey on Discord)
A group's speed showed its measured speed when it had one and dropped its floors. With the commits before this one, a Codex model can have one measured reply and hundreds of floors, and "125 tok/s (1)" stood for all of them. Fallmonkey asked to see both. ledGroupSpeed now joins the two, the measured one first: "125 tok/s (1) · ≥50 tok/s (259)". Its tooltip has a line for each, and the measured line drops "the others tell no speed" when the others tell a floor (new strings in zh, zh-TW, ja and de). The Output speed card keeps the measured speed as its figure, so a narrow card isn't clipped, and puts the floor in its sub line. A ranking by speed still orders and bars a group by its measured speed, or by its floor when it has none. docs/reference.md says so. Tests: usage-speed-count.test.cjs adds floors to sol and a new measured-only group (astra, 62). It checks the joined text and the two tooltip lines, the card's figure and sub line, and the ranking order and bar, in en, zh, zh-TW, ja and de, in Chromium and WebKit, at 1400 and 560 px, with no clipping. It fails on the old app.js. Ran: usage-speed-count, usage-session-speed, usage-ledger-detail, usage-speed, reasoning-speed, usage-ledger-fit, usage-model-at-provider, routing-request-metrics, gui-ja, gui-de, gui-zh-tw and i18n-keys in both engines; go test ./internal/gui; gofmt -l; GOOS=linux/windows go vet. |
||
|
|
e5b82cf38a |
usage, gui: Codex rows tell the least they wrote at: a call in a turn of several over its whole time, a turn of one call that reasoned by its answer after the first token (Fallmonkey on Discord)
Codex's session rows told no floor. A call in a turn of several could be
timed from inside itself; the commit before this one times it from what
asked for it, before its first output item, to its last, as Claude Code's
is. So Codex joins usage.FloorAgents and app.js's LED_FLOOR_AGENTS, and
such a call tells its output over its whole time, by the same 1,000-token
rule. On 622 stripped recent rollouts only 4 of 1,367 such calls have
1,000 tokens or more, so the floors will be few, but they are true.
A Codex turn of one call that reasoned has its first token (the turn's
time_to_first_token_ms) but not its first text, so DecodeOf tells no
speed. Fallmonkey asked for its whole output, reasoning too, over the
time after the first token. That reads high: OpenAI's reasoning is
written before the first content, so it isn't in that time. On a gateway
reply of 496 tokens, 224 of them reasoning, 827 ms after a 10.2 s first
token, that is 600 tok/s against a measured answer speed of 415 (the
bug
|
||
|
|
de1ba9f123 |
settings, gui: a masking rule can be edited in place, not only removed (nf1qaz2w on Discord)
nf1qaz2w on Discord: "自定义脱敏规则现在只有移除,能否增加一个编辑功能方便调整规则". Settings → Privacy listed each custom masking rule with Remove only, so changing a pattern meant removing it and typing it again at the end. Each rule's row now has Edit beside Remove. Edit opens the rule in its own row, where it stands, with its name, Prefix/Regex (the app's segs, no <select>) and match filled in, laid out like the add row; a narrow window puts the match, Save and Cancel on a line under the name and Prefix/Regex. Save (or Enter) sends that one rule to the new POST /api/settings/redact-rule with its index and its current value; editRedactRule tidies and checks it with redact.CheckRules as an added rule is, and refuses one that doesn't compile, matches the empty string, is left with no prefix or pattern, repeats another rule, or is no longer at that index (changed or removed meanwhile). A refusal is said in the row in red, what was typed kept, and every rule stays as it was. Cancel or Escape leaves the rule untouched and sends nothing. The gateway reads the rules from settings per request (redactionOptions), so the edit masks the next request. The two fixed refusals are translated (zh, zh-TW, ja, de); the other strings (Edit, Save, Cancel, Name, Prefix, Regex) were already there. docs/subsystems/gateway-routing.md now describes the user's own rules and the edit. Run: - TestRedactRuleEdit (internal/gui): a valid edit is saved in place and redact.Mask with the saved rules follows it; a bad regex, a pattern that matches nothing, a short prefix, an empty rule, a duplicate, an index out of range, a negative one and a stale "was" are each refused with the reason, the rules unchanged. With api.go from before this change it fails: "edit: 404 404 page not found". - internal/gui/tests/redact-rule-edit.test.cjs: Chromium and WebKit, en, zh, zh-TW, ja, de, 1100px and 420px (20 tests, all pass): Edit opens the rule in its place with its values, fields don't overlap and stay in the row, the page doesn't scroll sideways, no click moves the page, Cancel sends nothing, a refused regex is shown with the typed values kept, a good one is saved by Enter in the same place. With the old app.js it fails: no button.rule-edit (locator timeout). redact-rule-row.test.cjs and i18n-keys.test.cjs pass. - Whole GUI suite in both engines, under heavy machine load: 5647 of 5667 pass. Each failing file was run again alone: agent-expand-steady, azure-endpoint, balance-currencies, gateway-key-groups, library-desktop-skills, library-all, plain-names, purpose-filter and usage-ledger pass. skill-install-agents-all (chromium 420px "view:5,0") failed the same on the base commit and passes after rebasing onto |
||
|
|
afe0c59d2d |
gui: on a Mac window a popover that opens upward stops under the traffic lights, not over them (#1573, lyston11)
In a short Mac window, Pick (an agent's model list), the field picker (#pop) and every app menu (placeMenu) were held only 8px from the top when they opened upward or were held to the window's top, so they covered the traffic lights and header.top, which the system draws them over. popTop(pad) is now the highest a popover's top edge may go: 8px under header.top's measured bottom on a Mac window (so it follows --zoom), and 8px from the top everywhere else, as before. openAgentModels, placePop and placeMenu use it in place of pad for the top. placePop also holds #pop's max-height to the room between that edge and the foot when its CSS max-height doesn't fit, so a picker held to the top scrolls inside itself instead of running off the bottom (it already did run off before this change in a very short window; moving the edge down would have made that worse). Nothing else clamps a popover to the top: the remaining getBoundingClientRect placements (profiles in the panel, the heat-map tip, the rail tip) are kept inside their own card or panel. Run: - new internal/gui/tests/popover-mac-chrome.test.cjs: Chromium and WebKit, en and zh, MacIntel and Win32, 480px wide: 8/8 pass, 4 runs in a row. On the old app.js it fails (model list top 8 < 58 on Mac, the picker off the bottom on Windows). Breaking each placer by hand turns it red on its own: model list top 8, picker top 8, menu top 17. - related GUI tests, Chromium and WebKit, all pass: click-scroll, agent-models, agent-models-picker, -all-hidden, -loading, -only-picked, -redraw, agent-model-groups, menu-scroll, proto-menu-overflow, codex-app-menu-cap, desktop-model-menu, editor-short-window, removed-groups-menu-scroll, agent-start-pick, agent-leave-magpie, claude-picker-fold, header-zoom-fit, header-centre, text-size. - HOME=<scratch> go test -tags nogui ./internal/gui: ok. - GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gui: ok. |
||
|
|
9bb68615b0 |
gui: a scroll not the reader's made just before a click is put back, not kept as where the reader was (#1554)
skill-install-agents-all.test.cjs was red on main in Chromium at 420px (en, ja, de): the install picker's All chip, clicked, left the Library view 5px down. Cause: the browser tells the page of a scroll at the next frame. The test clicks while the Library view is still sliding in (view-in, translateY 5px), and Playwright's click scrolls the chip into view first; with the view 5px taller than it is high at 420px, that scroll takes the view to its 5px foot. The click came in before that scroll's event, so the click guard took its snapshot (held.chain, held.top) at 5px and every hold() after kept it there, the scroll event included. A real click can do the same: WebKit scrolls a field focused on the press, or code scrolls just before the click, and the scroll was adopted as the reader's. Fix (app.js, the click guard): before taking a click's snapshot, a view not scrolled by the reader (no purposeUntil window, no scrollbar drag) is put back where the reader left it (backToReader), as the scroll listener would have done a frame later. A click in quick turn after another still holds that one first, as before. The guard is shared by every view, so every picker and button is covered; the library picker needs no change of its own (the MCP editor's picker is in #modal, outside any view). Tests: - click-scroll.test.cjs: new "a scroll the page hears of after the click is still put back" (scrollTop += 40 and a click in one task). Red on the old app.js in Chromium and WebKit (expected 2020, actual 2060), green with the fix. - sessions-manage-paging.test.cjs scrolled with Playwright's scrollIntoViewIfNeeded and clicked Show more before the next frame, so it passed in Chromium only through this bug (the guard puts that scroll back a frame later; it was red in WebKit on main). It now scrolls with the reader's wheel; green in both engines. - docs/subsystems/gui-shell.md says a click is taken where the reader left the view. Run: skill-install-agents-all.test.cjs red before (en/ja/de 420px, "view:5,0"), green after in Chromium and WebKit, every language; click-scroll.test.cjs green in both engines; 306 GUI test files that assert on scrolling or touch the library/skills/MCP, then the other 253, both engines. Failures seen there were rerun alone: purpose-filter (WebKit, 1px, #1291) and search-api (WebKit zh, #1442) fail the same on the old app.js; the rest pass alone. No Go changed. |
||
|
|
909d767472 |
gui: with MAGPIE_PUBLIC_URL set, Gateway's Connect starts at it until the user picks an address, and magpie web shows it as the gateway's address (#1551, everpcpc)
everpcpc runs magpie web in Docker behind a reverse proxy with
MAGPIE_PUBLIC_URL=https://magpie.example.com. The page is opened from
other machines, yet Connect's Base URL, the copied shell/curl/Python/Node
snippets and the gateway's address on the Gateway page started at
http://127.0.0.1:3425. v0.1.1174 kept a picked address; the public one
still had to be picked once on every browser.
- /api/providers' gateway carries publicURL: MAGPIE_PUBLIC_URL when it is
among the addresses Connect offers (shared, or MAGPIE_ADDR on the
network). With no address kept in magpie.connectAddress, Connect starts
there, so the snippets and the gateway key picked for it follow. An
address the user picked, this computer's included, still wins.
- The option is labelled "Public address" instead of "Local network".
- /api/settings carries publicURL under the same condition, and Settings >
About lists it beside the local Gateway URL, which stays the address
agents here are pointed at.
- In magpie web, a page served to other machines, the Gateway page's
address and Settings' web-search MCP server show the public URL; in the
app they stay local. Agents' own config wiring is unchanged (#373).
- New strings in zh, zh-TW, ja, de; docs/reference.md says where it shows.
Run: public-url-default.test.cjs (new) on chromium and webkit, en, zh,
zh-TW, ja, de, at 1100 and 420 wide, 26 pass; on the old app.js 12 of 13
chromium cases fail. Making the public URL override a kept pick turns it
red too. TestPublicURLInConsole and the new TestPublicURLOnlyWhereOffered
pass. Sibling GUI tests (connect-address-kept, the gateway-key-* and
gateway-connect/caller-keys tests, api-key-theme, public-url, lan-docker,
phone-web, search-mcp, settings-sections/groups, gui-ja/de/zh-tw): 192
pass; phone-web failed once under the parallel run and passes alone on
both engines. gofmt, GOOS=linux and GOOS=windows go vet -tags nogui
./internal/gui, go test -tags nogui ./... under the queue lock: its one red
is TestAccountDiscoveryOffReadsNoSignIn (internal/provider, from
|
||
|
|
4ee491e7c7 |
provider: a routing group shared as text leaves out its rules by folder, which name the sharer's own paths
|
||
|
|
3f57024211 |
provider, gui: a routing group is shared as text and imported into another magpie (laincatx on X)
A group row's menu has Copy to share: the group as JSON marked "magpie": "routing-group" with a format version (provider.ShareGroup), holding its members as it names them, patterns, routing, rules, classifier and settings. A group holds provider/model ids only, so no key, account or address goes with it; derived matches and the found/hidden/off flags stay behind. The Routing page's Import (by New group) opens a box the text is pasted into, words or a code fence around it allowed. POST /api/groups/import (provider.ImportGroup) adds it under a free name, never over a group. A member whose provider the importer has is kept; else the same model under one of their providers (listed as used instead); else it is left out and listed, with the rules that send to it and its off/fast place; a classifier gone takes the intent rules and auto effort. Nothing is added when no member is left. Other text, a newer format or none is refused in the reader's language (provider.ShareError, code "share"). Run: - go test -tags nogui ./... (gateway failed once on a full disk, then passed alone); new TestSharedGroupRoundTrip/MissingMembers/BadText and TestGroupShareAndImport; the version check broken by hand turns them red - gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...; go build - group-share.test.cjs in chromium and webkit, en/zh/zh-TW/ja/de, 420px; every group-*, settings-groups, filter-ime, panel-routing GUI test (210 pass); routing-* (550/557: webkit fold tests timed out only under --test-concurrency=6 and pass alone; a webkit routing-* run under the same load fails one test on origin/main too, a different one each run) - real use: the owner's 12 groups from a sandbox copy of providers.json each shared (no key in the text) and imported back whole |
||
|
|
ae70d8eac8 |
routing: a group's rule can hold by the folder the agent works in (Cario0x on X)
Cario0x on X asked to route by the project being worked on. A group's rule now has a "folders" condition: it matches when the request's working folder is one of the listed folders or inside one. It combines (AND) with the existing conditions: tokens, images, intent, time, agents and quota. - gateway/workdir.go reads the folder each agent states in its own request: - Claude Code: "Primary working directory", including "(was …)" after a move. - Codex: <environment_context><cwd>. - Pi: <cwd>. - OpenCode: <env> "Working directory". The last one stated wins. Assistant text and tool results are ignored. A request that states no folder matches no folder rule: unknown, never empty. - provider/rulefolder.go matches a folder only at a path boundary. - ~ is the home folder. - C:\x is the same folder as /mnt/c/x, and \\wsl$\Distro\x as /x. - Case is ignored on macOS and Windows, and always for a drive. - A rule's folder must be a whole path. Pause rules can't have folders. - The trace's RuleHit.Folder makes the Routing page say "The agent works in …". - GUI: an "in folder" condition in the group editor, hidden on pause rules. Strings in zh, zh-TW, ja and de. - CLI: `magpie group rule add … folders=~/oss,"~/My Project"`. The TUI shows the condition. - Docs: docs/subsystems/gateway-routing.md and site start.html (en, zh, ja). Fixtures are real requests from Claude Code 2.1.296, Codex 0.162.0 and Pi 1.1.0, run in a sandbox from a folder named "a&b <c> 中文" or "My Proj", with the sandbox path replaced. Run at this head: - go test ./... green. - gofmt -l clean. - go vet green for darwin, GOOS=linux -tags nogui and GOOS=windows. - GUI routing-folder.test.cjs: chromium and webkit, en, zh, zh-TW, ja and de, 1100px and 390px (no horizontal scroll). It fails on the old routing.js. - Related routing, group and i18n GUI tests: 85/85. - Full GUI suite: 5611/5631 under --test-concurrency=6. Rerun alone, every failure passes except: - skill-install-agents-all (chromium, 420px), which is red on origin/main too: #1554. - The menu-scroll track flake, which flakes on main as well: #1550. - e2e: a sandbox HOME, a dev build and fake upstreams, with real Claude Code 2.1.296 (`claude -p --model group/fd`). - From proj/acme/web, rule 1 matched and the request went to kb. - From proj/acme-old, no rule matched and the request went to ka. The trace and UI showed the folder. |
||
|
|
3964ea656c |
usage, gui: a group's speed says how many replies it is of, "125 tok/s (1)", and one with only floors says "≥100 tok/s (30)" (Fallmonkey on Discord)
Fallmonkey: the Usage ranking and the Output speed card showed
gpt-6.1-sol's tok/s from the one reply of its 260 that used no tool (the
only Codex turn its session file times) beside "260 requests", while
Claude Code, whose Requests rows say "≥N tok/s" by the dozen since
|
||
|
|
6f4fb883eb |
library, gui: an MCP server's tools are listed by name and description (nf1qaz2w on Discord)
nf1qaz2w on Discord: "mcp现在好像只能看到有几个工具,看不到具体的工具名和描述等, 能否支持下?" The Library's MCP check kept only len(tools) from tools/list. What changed: - internal/library/mcp_check.go: ServerHealth carries ToolList (json "toolList"): each tool's name and the first paragraph of its description, whitespace collapsed and cut at 500 runes (a tool with only a title gets the title); names cut at 128; at most 500 tools kept while Tools still counts all. tools/list is now asked through listTools, shared by the stdio, streamable HTTP and SSE checks: it follows nextCursor up to 10 pages, each page with a step budget of its own (the #1467 per-step timeout), and a page after the first that is refused ends the list there. Before, nextCursor was ignored and only the first page counted. - internal/gui/assets/library.js/.css: a server whose check listed tools shows a chevron on its "N tools" status; a click opens the list under the row (name in the code font, description under it, "N more not shown" when magpie kept fewer than the server has, and Check again). Clicking the count again shuts it. A server with no listed tools keeps the old click, which checks it again. The list stays while it is checked again, no editor opens, no left-border stripe, no native select. The click guard keeps the clicked status in place (a centred row gives up 1px as it grows). - i18n: "Click to see them", "Click to hide them", "{n} more not shown" in zh, zh-TW, ja, de. - docs/subsystems/library.md: the check's tool list and paging. There is no CLI/TUI output of a server's check, so nothing changed there. What was run: - go test ./internal/library: TestCheckKeepsToolNames runs the check on the tools/list reply @modelcontextprotocol/server-filesystem really gave (captured with npx, testdata/filesystem-tools-list.json, 14 tools, the longest description 457 chars); TestCheckToolPages (no description, title only, a 1000-char description cut, two pages by nextCursor, the JSON the page reads); TestCheckToolPagesEnd (a server that pages forever is asked 10 times). With the list not kept and paging off, the first two fail: "got {State:ok Tools:14 ToolList:[] ...}, want ok with 14 tools, each listed" and "...Tools:3 ToolList:[]..., want ok with 4 tools over 2 pages". - GUI: internal/gui/tests/library-mcp-tools.test.cjs, Chromium and WebKit, en/zh/zh-TW/ja/de, at 980 and 420 wide: 20/20 pass; against the old library.js it fails. library-*.test.cjs, mcp-signin, search-mcp, i18n-keys and click-scroll in both engines: 377/377 pass. - gofmt -l (nothing), go vet / GOOS=linux / GOOS=windows go vet -tags nogui on internal/library and internal/gui, go build for darwin, linux and windows (nogui). Full go test -tags nogui ./... under the queue lock: every package ok but internal/provider, where TestClaudeSavedAccountDir failed "sign-in never finished" (waitDone's 2s bound on a fake claude process under full-suite load); alone it passes 5/5. Not touched here. |
||
|
|
1c9747f611 |
usage: a Remote magpie provider's gateway keys each show their own limit, used and left, period and reset on the Usage page (#1547, PennyVibe)
A computer that uses another magpie through gateway keys that magpie gave it saw the other magpie's subscription cards, but not what each key may still spend there. What changed: - provider/remote_key_limits.go: each key of a remote-magpie provider gets a section on one card, "<remote>/~keys", read from the remote's existing GET /v1/magpie/limit asked with that key alone (the endpoint answers only the calling key, from access.Caller; nothing in the request picks another key, so a key never sees another's numbers). A window per cap (tokens, spend) named for its period (today / this week / this month / this cycle), used against the cap, with its reset; SubscriptionQuota.GatewayKey carries what is left, calls, the cycle's days, used up and unpriced calls. A key with no limit shows one "Limit: Unlimited" window. Kept for remoteCardsFor like the remote's cards; the card's refresh reads the named key again. - A failed read keeps the last numbers, dated (AsOf); with nothing read the section says why, never zero and never "no limit". A remote from before /v1/magpie/limit (404) says it is too old to tell. - GUI: the card is named "Gateway keys · <remote>" (main page and the tray panel), a line under each key says the cycle, calls and "used up", and the two new errors are said plainly; strings in zh, zh-TW, ja, de. - magpie quota (CLI) shows the same cards; a window with no cap now reads "Limit unlimited" there, not "Limit 0%" (quotaCell). - docs: providers-accounts (Allowance), gateway-routing (Remote magpie APIs, verification), reference (/v1/magpie/limit). Run: - New tests fail on the old code: TestRemoteMagpieKeyLimits (provider) and TestRemoteMagpieKeyLimitCards (gateway, a real Handler, real chat requests moving the numbers) with the key cards taken out of RemoteCards; usage-remote-key-limits.test.cjs on HEAD's app.js. TestKeyLimitTellsOnlyTheCaller guards what was already so (key A can't read key B by query, header or no key from the LAN), so it passes on both. TestQuotaCell's unlimited case reads "Limit 0%" on the old code. - provider, gateway -count=3; go test -tags nogui ./... (full suite). - GUI: the new test in chromium and webkit x en/zh/zh-TW/ja/de x 900/400px (20 pass); the whole GUI suite. - gofmt -l clean; go vet -tags nogui darwin, linux, windows. - Real two-magpie run, both this build, sandbox HOMEs, 127.0.0.1:38461 (remote) and :38471 (local); the upstream was a fake OpenAI server (fixed 175 tokens a reply). Remote keys laptop (1000 tokens/day), desk (5000/week), spare (no limit); local "office" Remote magpie with all three, routing rotate. After 17 chats through the local gateway, magpie quota on the local read laptop 1050/1000 (100%), desk 1050/5000 (21%), spare unlimited (in --json; the text line read "Limit 0%", which the quotaCell change above fixes), matching the remote's own gateway-key list; laptop's spent key was passed over (every chat 200). With the remote stopped each key said it couldn't be reached, never 0. Not run against a real vendor, nor a real magpie older than /v1/magpie/limit (unit-tested with a 404). |
||
|
|
26816de2f9 |
library, agentplug: an agent a plugin adds is given the Library's instructions, MCP servers and skills where its agent.library says (AlmarionAI on X)
Agent plugins wired models and keys only: library.targetOf had no case
for them, so the Library's instructions, MCP servers and skills never
reached an agent a plugin adds, while the announcement said the
Library carries over.
An agent export can now say
library: { instructions, mcp, mcpFormat, skills }
each a path (~ and $VAR expanded, as config is). mcpFormat names the
agent whose MCP file it is shaped like (agentplug.MCPFormats: claude,
codex, gemini, opencode, cursor, zed, ... 18 of the library's
mcpFormats). A format outside the list, or an mcp without one, keeps
the plugin from loading. library.pluginTarget makes such an agent a
Target, so it is written as any agent is: magpie's marker block in the
instructions file, servers merged beside the user's own (their fields
kept), skills linked or copied, Applied recording only magpie's part,
backups kept. Takes refuses a place the plugin doesn't name, and says
which agent.library key would give it.
Docs: docs/subsystems/library.md and agent-wiring.md; plugins.html
(en, zh, ja) gets the library field and what magpie does with it.
Run:
- internal/library/agent_plugin_test.go: TestPluginAgentGetsTheLibrary,
TestPluginAgentWithoutAPlaceIsRefused, TestPluginAgentMCPFormat,
TestPluginMCPFormatsAreWritten. With targetOf's plugin case and the
check() validation taken out by hand, the first three go red.
- e2e: a nogui build in a scratchpad HOME (env -i, no live configs),
`magpie plugin add` of a throwaway toy agent plugin; `library
instructions set/agents`, `library mcp add/rm` wrote and took back
only magpie's block and server, the user's "mine" server, its "note"
field and other keys kept, backups made; with mcp dropped from the
plugin, `library mcp add ... agents=toy` is refused naming
agent.library.mcp.
- go test -tags nogui ./... (one unrelated FIFO flake in internal/agent,
fixed in the commit before), gofmt -l clean, go vet for GOOS=linux
and GOOS=windows clean. No GUI code changed.
|
||
|
|
6b8dc4cdd8 |
proc, agent: magpie finds an agent CLI under the Node nvm's default names, not the folder whose name sorts last (v9 after v22)
proc.UserPath added "the newest-looking" nvm Node to magpie's PATH, the
last folder of ~/.nvm/versions/node/*/bin in string order. That isn't
the Node a terminal gets, and string order puts v9.11.2 after v22.12.0
and v22.3.0 after v22.12.0. So magpie could find, run and update a
codex/claude/gemini under a Node the user's terminal doesn't use (found
while answering 悠悠哥 on Discord,
|
||
|
|
8c5b9f928d |
provider, agent, gui: subscription accounts can be turned off, and then no agent's sign-in is read (#1535, MaxHaiCom)
What changed: Settings → Privacy → Subscription accounts (On/Off), `magpie accounts discovery [on|off]` and MAGPIE_NO_ACCOUNTS=1 turn off account discovery. It stays on by default. While it is off, magpie reads none of the agents' sign-ins: ~/.claude/.credentials.json, .claude.json's account, ~/.codex/auth.json, Copilot's, Cursor's, Devin's, Kiro's, Gemini's, ZCode's, Command Code's and OpenCode's files. It runs no `security` / `secret-tool` for the Keychain or Secret Service, and asks no agent CLI who is signed in. It serves no subscription. API-key providers, middleware plugins and Pi extensions work as before. Why: the reporter runs magpie on machines where reading other tools' credentials isn't wanted. The owner delegated the call. How: settings.NoAccountDiscovery (kept per computer by KeepOwn) and settings.AccountDiscoveryOff(). The variable only ever turns discovery off. The gates sit at every reader (readAccountFile, discoveryOff) and at every route that reads or writes a sign-in, so a route that skips Accounts still reads nothing: - Accounts, All, Logins, usage, renewal, warm-up, session identities, check-ins; - switching, forgetting, SetLoginOn, StartSignIn, the imports; - moves onto plugins. The ones that write refuse with an error that names how to turn it back on. On the agent side, Agent.Source and OpenCode's auth.json are gated, and Codex wiring goes by magpie's stash instead of auth.json, so a toggle never rewires Codex. logins.json and plugin-auth.json are left untouched and serve again when discovery is turned back on. A change applies at once (ForgetAccounts). Docs: providers-accounts.md, README (en, zh-CN), and the site's CLI table (en, zh, ja). Run: - TestAccountDiscoveryOffReadsNoSignIn (provider) and TestAccountDiscoveryOffAgentsReadNoSignIn (agent). Every credential path is a FIFO that records each open, and security, secret-tool, claude, codex, cursor-agent, devin, kiro-cli, copilot and grok are fakes on PATH. Both fail with the gate removed: they show the opens and `security find-generic-password -s Claude Code-credentials`, among others. Both pass with the gate in place. - TestAccountDiscoverySetting and TestAccountsDiscoveryCmd. - account-discovery.test.cjs: chromium and webkit, 900 and 360 wide, en/zh/zh-TW/ja/de, 32/32. The neighbouring privacy, redact, settings-sections and i18n-keys GUI tests: 49/49. - The full `go test -tags nogui ./...`, gofmt -l, and go vet for darwin, linux and windows on the touched packages. Not tried: a real machine under fs_usage, and Linux and Windows at runtime. The FIFO tests are !windows. |
||
|
|
0192edf133 |
gui: a long Claude Code reply read from its session file shows the least it wrote at (≥98 tok/s), and a short one no longer says it wasn't streamed (Fallmonkey on Discord)
Claude Code's session file has no first token, only when the line that
asked for a reply and its last line were written, so every Claude Code and
Claude Desktop call that didn't go through the gateway showed no speed,
with "Not streamed" though it was streamed. A reply of 1,000 output tokens
or more over a second or more now shows its tokens over that whole time as
a floor (ledFloorSpeed, "≥" in the cell, "At least: …" in its tooltip and
the row's details); the wait for the first token is inside it, so the
speed after the first token is never under it. Gateway rows and timed
session rows are unchanged, and the period's speed counts timed calls only.
Only Claude Code's and Claude Desktop's rows tell one. The contributed
version gave every session-file row a floor; a Codex call in a turn of
several is timed from the last tool output before its token count, and in
a month of real rollouts (4,588 multi-call calls) 2,968 were timed from the
output of a tool that same call asked for, written before its count, so
the window begins inside the call and a floor from it could read high.
Those rows keep "—" with "The session file has no first token". OpenCode's
created→completed time isn't checked against real sessions, so it tells
none either.
Checked against the shape of real Claude Code files (read-only, 30 days,
~198k messages, 2,011 files incl. subagents): block lines are stamped at
each block's end (single-line 1,000+ token text replies read a median 110
tok/s, not the thousands a start stamp would give); no sidechain lines in
main files; no assistant line out of clock order; a message's later lines
keep the time its first was asked (Began), so the 15,779 tool results
written between one message's blocks don't shorten it. Floors shown: 23,518,
p50 102, p99 141, max 156 tok/s for claude-opus-5-5.
Run: usage-session-speed.test.cjs (now also a Codex multi-call row, a
Claude Desktop row, and a 560px window) in Chromium and WebKit, en and zh;
red with the agent check taken out ('≥500 tok/s' !== '—'). The related
suites (gui-de/ja/zh-tw, i18n-keys, ledger-*, usage-ledger*, usage-speed,
reasoning-speed, routing-burst-speed, usage-ttft-rounding,
usage-computers): 146/146 in both engines. go test -tags nogui ./...,
gofmt, and go vet for darwin/linux/windows on internal/gui.
Co-authored-by: Ted Li <tl2493@columbia.edu>
|
||
|
|
9f407cafa1 |
agent, gui: an agent CLI found off the terminal's PATH says where it is (悠悠哥 on Discord)
悠悠哥 (macOS) saw "Codex 0.162.1 · 未接入" under 未设置 on the Agents page while `which -a codex` found nothing and ~/.codex wasn't there. Detected() is true when the agent's command is on magpie's own PATH, and proc.UserPath adds to it the folders users' tools go in (~/.local/bin, npm's prefixes, nvm's newest Node, bun, volta, pnpm, Homebrew), which a desktop app launched from the Finder needs. A codex left in one of those that the terminal's PATH no longer has (an npm install under a Node nvm no longer uses) is found, runs, and gives its version, so the row looked made up. Reproduced in a sandbox HOME: PATH=/usr/bin:/bin, no ~/.codex, @openai/codex 0.162.1 under ~/.nvm/versions/node/v22.12.0; after UserPath, Codex is detected with CLI 0.162.1. ChatGPT.app's bundled codex (Contents/Resources/codex-cli, 0.162.0-alpha here) is never on magpie's PATH and isn't what was found. The agent is still listed: the CLI is real and runs (a lazy-loaded nvm leaves the same folder off a login shell's PATH while the user does run codex from it). What changes is that it says so. CLI gains path (the file magpie runs) and offPath (its folder isn't in proc.LoginPath; false when the login PATH can't be told, or for a CLI found at a fixed path rather than through PATH). The Agents row shows "Not on your terminal's PATH" after the version, its tip and the version's naming the file and that it can be deleted if left from an uninstall; en/zh/zh-TW/ja/de. The note gives way at the narrow width, where the version's tip still says it. docs/subsystems/agent-wiring.md says how detection and the note work. Run: TestCLIFoundOffTerminalPath (red with OffPath forced false); agent-cli-offpath.test.cjs in Chromium and WebKit, five languages, 560 and 440px (16 failures on the old app.js), with agent-app-version, agent-cli-missing, cli-update and agent-update-all (66 pass); go test ./internal/agent ./internal/gui; full go test -tags nogui ./...; gofmt; GOOS=linux and GOOS=windows go vet -tags nogui on both packages. |
||
|
|
cb25d3861b |
gateway: a Claude subscription's tool calls reach their run on a MAGPIE_ADDR that isn't loopback (#1546, jiayeZhu)
With MAGPIE_ADDR pinned to a concrete address outside 127/8 and gateway keys on, the Claude subscription bridge's MCP helper posted its tool calls to http://<that address>/_magpie/claude-mcp/<token> with no key. lanGuard answered 401, the call never reached the run, and every turn of tool results found "no run waiting" and started a new Claude Code told the whole conversation; the reporter's cache hits fell from ~95% to ~30%. - lanGuard lets that callback in by its run's own token: a POST to /_magpie/claude-mcp/<token> whose token (24 random bytes) is one a live run registered (addCallback in startRun, dropCallback in removeRun), compared in constant time. No path is exempt on its own: an unknown, ended, truncated, extended, percent-encoded or GET form is still asked for a key, and so is every other route. - The helper is handed the callback URL in a 0600 file in the run's own temp dir rather than as an argument; RunMCP reads a path as that file. The test fakes read it from there. - docs: claude-subscription-bridge, gateway-routing's HTTP surface and reference.md's network section say how the callback is let in. Run: - TestClaudeToolCallbackOnANonLoopbackAddress (new): a gateway behind lanGuard on this machine's own non-loopback IP, MAGPIE_ADDR set to it, fake Claude Code making a real helper call; red on the old guard with the reporter's "refused POST /_magpie/claude-mcp/... no API key was sent" line, green now. - TestOnlyALiveRunsCallbackSkipsTheKey (new) and TestNetworkGatewayGuardsEveryRoute (now also tried with a live run's token as a Bearer key): red with a blanket path exemption put in by hand, green now. - Real use: sandbox HOME, magpie serve on MAGPIE_ADDR=10.0.0.111:3561 with a gateway key, a fake claude driving the real claude-mcp-helper. origin/main: callback refused, "tool results no run waiting", a new Claude Code told the whole conversation. This build: the result reached the same process (pid unchanged), nothing refused, a made-up token still 401. - go test -tags nogui ./... (full suite), gofmt -l, GOOS=linux and GOOS=windows go vet -tags nogui on internal/gateway and internal/claudebridge. |
||
|
|
6536982756 |
edit: an agent's config saved with a UTF-8 BOM is edited through it and keeps it — magpie claude <model> no longer says "invalid JSON/JSONC" (#1534, AnxForever)
On Windows, PowerShell 5.1's `Set-Content -Encoding UTF8`, Notepad and
Claude Code channel switchers save ~/.claude/settings.json with a UTF-8
BOM in front. Claude Code reads such a file; magpie's JSON layer handed
the BOM to json.Valid and gjson, so `magpie claude <model>` failed with
"<path>: invalid JSON/JSONC" and the agent couldn't be wired at all. TOML
refused the same with "UTF-8 BOM is not supported", though Codex's own
parser (toml_parser's lexer) skips a BOM, and env/YAML files glued the BOM
to their first key's name.
The fix is at the package's two choke points, so every format and every
caller of edit.Read gets it:
- edit.Read returns the file without a leading BOM (the agent package's
own readers, Claude Desktop, Ante, Empryo, Snow, Pi MCP etc. go through
it).
- WriteAtomic puts the BOM back when the file it replaces starts with one
and the new bytes don't (keepBOM). The user's file keeps the encoding it
was saved in: the tools that wrote it may expect it, and the agent read
it with the mark before, so keeping it is the user's own bytes, not a
guess. A file without a BOM never gets one; an emptied file stays empty.
This is what astrbot.go already did for AstrBot's cmd_config.json.
- PatchJSON (bytes in, bytes out) reads through and keeps a BOM too.
- The TOML "BOM is not supported" error is gone with the case it named.
- Siblings read outside edit.Read: Claude Code's settings.json and CC
Switch's legacy config.json in the importer, and Crush's provider list,
trim it with the new edit.TrimBOM.
- Prime Agent's Disconnect (beforeMagpie.restore, on main since this
work began) compares the file with its copy from before through the
BOM, so a BOM'd settings.json is put back byte for byte and the copy
removed; it used to stay as magpie left it, the copy beside it.
The reporter's fork commit (AnxForever/magpie 0bb750c1) was reviewed: it
trimmed the BOM in the seven JSON entry points and wrote the file back
without it; this change keeps the BOM instead and covers TOML, YAML, env
and the readers outside the JSON layer.
Run:
- New tests built on a Windows-shaped settings.json (BOM + CRLF + the
user's env and permissions): TestJSONSettingsWithBOM, TestPatchJSONKeepsBOM,
TestJSONItemWithBOM, TestTOMLConfigWithBOM, TestEnvAndYAMLWithBOM fail on
the old code ("invalid JSON/JSONC", nothing found) and pass; with keepBOM
disabled by hand four of them go red. TestWriteAtomicAddsNoBOM.
TestPrimeAgentRoundTripWithBOM fails on main (not put back) and passes.
TestClaudeConfigDirImport (BOM case) and TestImportCCSwitchConfigWithBOM
fail on the old importer ("invalid character 'ï'") and pass.
- Full chain in a sandbox HOME: old binary `magpie claude
deepseek/deepseek-flash` on a BOM'd settings.json -> "invalid
JSON/JSONC"; new binary -> "✓ Claude Code model", BOM and CRLF kept, the
user's env untouched; `magpie claude model default` after it leaves no
blank line. Old `magpie codex gpt-5.5` on a BOM'd config.toml -> "UTF-8
BOM is not supported"; new -> set, BOM kept.
- Windows box: the edit package's test binary passes whole; magpie.exe
`claude deepseek/deepseek-flash` on a settings.json written by
PowerShell 5.1 Set-Content -Encoding UTF8 (sandboxed USERPROFILE/APPDATA)
sets the model and keeps ef bb bf.
- go test -tags nogui ./internal/edit ./internal/agent ./internal/provider
./internal/library; gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows)
on the touched packages; the full suite.
|
||
|
|
7c632ad0b4 |
lessons: 10-10/10-11 review; tests ending with their test and timing room move to the code standards
The nightly review of 10-10 13:51 to 10-11 05:20 (191 commits, v0.1.1155 to v0.1.1172, every tag on a green run). - Two lessons hit a third day and move into docs/code-standards.md: whatever a test starts ends when it does (#1524's three-step fix), and a timing test leaves room on both sides (TestMaxRPM was a real gap). - "A failed read means unknown" seen again: stash.json had readLogins' bug (fixed in |
||
|
|
26ddb0d62f |
gateway: a tool-call id a client shortened goes to Gemini unsigned, not as a corrupt thought signature (#1536, jueda12)
Gemini 3's thought signature rides in the call id magpie gives the client (<id>__ts__<base64url>). A client that caps ids (40 characters in the report) sends back part of it, and unpadded base64 only rejects a length that is 1 mod 4, so at three of four lengths unsignedID decoded the leftover into a partial signature. Gemini answered it with 400 "Corrupted thought signature" instead of the call going with skip_thought_signature_validator. The mark now carries the signature's length: <id>__ts<n>__<sig> and <id>__tsr<n>__<text>. unsignedID reads the first mark; a length that doesn't match what is left, or a mark cut inside its digits, is no signature, and the id stays as the client sent it. Ids from earlier versions (__ts__, __tsr__, no length) are still read as before. Every path that takes a signature off an id goes through unsignedID: the Chat relay (chatCallSignatures), unsignCalls for translated requests (Chat, Gemini, Code Assist/Antigravity, Vertex), and geminiParts. The anthropic mp_ id wrapper already checks its round trip, so a cut one is left alone. Tests: realistic ids (Gemini's function-call-N and magpie's call_<newID>, with vertexCallSig, a 315-byte signature as measured in the report, and a non-canonical one) cut at every length carry no signature; through chatCallSignatures, buildChat, buildCodeAssist and geminiParts each cut sends skip or nothing; the reporter's 40-character cut through the gateway reaches Gemini as skip; old-format ids still read. All four new tests fail on the old code. Run: go test -tags nogui ./... (full suite, under the queue lock), gofmt -l, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway. ump45nose posted the same root cause and an equivalent fix on #1536 (fork commit 415e45f2, `__tsn__<len>_` marks). Its handling matched this one case for case; the two literal old-form ids from its test are taken into TestOldSignedIDsStillRead. Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com> |
||
|
|
814a5ed73c |
agent: dsh asks each of magpie's models on its own API, a route per protocol (01huadalang on Discord)
dsh's llm-pi-ai sets one api for a whole route, so magpie's single "magpie" route asked every model over Chat Completions. A GPT served on Responses, or a Claude served on Messages, was translated from Chat, and its sealed reasoning was lost between tool calls. 01huadalang asked for a group per protocol. What changed: - dshPutRoute writes up to three routes from each model's catalog APIs (dshRouteOf): magpie (openai-completions, as before, for Chat models, Gemini-native ones, groups and agent-bridged sign-ins), magpie-responses (openai-responses, gateway /v1) and magpie-anthropic (anthropic-messages, the gateway root, forceAdaptiveThinking where gateway.AdaptiveThinking). A route left with no models is taken out. An api the user picked for a route in dsh's Models page is kept, and so are keys they added to it. - The start (agent-default-model) names its model's route on a pick, an effort change, and the home layer's mirror. Sync moves a start on one of magpie's routes to the route its model is now on (dshStartOnItsRoute), keeping its mark, effort and other keys. A start on the user's own route stays. - dshCheck checks each route's baseURL against its own api, and asks the route the start names to list its model. - Disconnect, dshOurs, dshKeepPick and dshFillNewProfiles know all three routes. sessions' dshGatewayProvider counts dsh sessions on any of them as magpie's. - docs/subsystems/agent-wiring.md: a line on the routes. Known limit: a dsh session resumed on a model that has since moved routes asks for the model to be picked again once, since dsh finds a model by route and id. Run: - go test -tags nogui ./internal/agent (whole package, default order) and ./internal/sessions -run TestDsh: pass. New tests TestDshRoutesAModelOnItsNativeAPI, TestDshSyncMovesAStartToItsModelsRoute, TestDshCheckSaysAStartOnAnotherRoutesModel and TestDshGatewayProviderTakesEveryRouteOfMagpies. With dshRouteOf forced back to the single route, the three agent tests go red. - Real dsh (headless, sandbox HOME and DSH_HOME) on patches magpie wrote, pointed at a fake gateway: the start on magpie answered from /v1/chat/completions, the one on magpie-responses from /v1/responses (reasoning.effort high), and the one on magpie-anthropic sent /v1/messages with thinking adaptive and output_config.effort high. dsh accepted all three routes. Its Anthropic turn then ended on my fake's SSE, not on the wiring. - gofmt -l clean. go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on internal/agent and internal/sessions. |
||
|
|
99fcddeeba |
usage: the Requests tab, its filters and refresh, the charts, the TUI and magpie usage answer at once over a long history (Vantiboo1ean)
Vantiboo1ean (Discord, macOS M2, v0.1.1157) has ~750,000 requests in usage.jsonl. On Usage > Requests every filter, model pick and refresh spun forever and the page never updated. Reproduced in a sandbox HOME with 750k generated records in the real format (400 MB usage.jsonl, ~84k sessions), on magpie web and in process. The cause: the #563 budget dropped the index's blocks once they passed 24 MB (60 MB here), so every read, of any period, parsed the whole file again (6 s CPU) and priced every call again; All took 12 s of CPU, the heatmap 13 s, and the page read both at once. What changed: - log_index: the gateway's blocks are always kept (about 80 bytes a call, S2-compressed instead of flate); the file is parsed once, then only what was appended. - block_price: the gateway's blocks are priced per query, once per set of provider/model/served/effort names rather than per call, into pooled buffers; range loops go by pointer (a packed row is 264 bytes). - request_page: pages are always cached (16 at most), session-file chunks stay in the budget, and a page asked again while it is worked out (the refresh button, the timer) waits for that one instead of starting a second scan. - Siblings that read the same history: - The heatmap names each day once. - A day filter no longer allocates per call. - The ledger behind the TUI, magpie usage, the CSV export and sync (LedgerOf, OwnDays) reads the gateway's calls from the index instead of Load parsing the whole file. - Direct/Summaries matches the session files' calls against the index's blocks without pricing all 750k gateway calls. - A summary of more than 1024 sessions is now cached with its top 1024 (it was not cached at all). The Usage page's /api/usage gets the top 100 (it was sent all 84k, 19 MB, which it never draws) plus a new sessionCount. /v1/magpie/usage still lists every session, and magpie usage says "top 10 of <sessionCount>". Timings, CPU (the box was at load 130-190 on 14 cores, so wall is inflated; min of repeated runs), before -> after: Requests today 6.0 s -> 20 ms Requests 7d 5.8 s -> 93 ms Requests 30d ~6 s -> 362 ms Requests all 12.4 s -> 2.4 s first, ~8 ms again all, model filter 12.3 s -> 1.5 s all, agent filter 11.3 s -> 1.8 s 30d, search "opus" 6.7 s -> 353 ms day filter 6.0 s -> ~0.1 s heatmap 13.7 s -> ~2.3 s first summary today / all 6.0 / 9.2 s -> 25 ms / 1.6 s first, <1 ms again /api/usage?period=all 1.6 s + 19 MB JSON each time -> <1 ms, 53 KB TUI Summaries(all) ~8.5 s (Load + ledger) -> 1.1 s first, <1 ms again TUI Summaries(today) ~6 s -> 29 ms Visit 7d (budget, codex) 5.9 s -> 10 ms The first read of the file after start costs ~5 s of CPU, once. Tests (each seen red with its guarantee broken by hand): - TestUsageOverBudgetHistoryIsReadOnce - TestUsageSessionChunksStayInBudget - TestUsageOverBudgetPageIsCached - TestUsagePageAskedTwiceIsWorkedOutOnce - TestUsageLedgerReadsTheIndexNotTheFile - TestUsageLargeSummaryIsCompleteAndKeptTrimmed (was ...ButNotCached) - TestDirectCountsOnlySessionFileCalls, now with a request-id match, checks that Direct/Summaries equal the ledger's. Run: go test -tags nogui ./... (temp HOME), gofmt -l, GOOS=linux and GOOS=windows go vet on the touched packages. |
||
|
|
7a9cf4dd4d |
gui, provider: Detect APIs and Each picked model ask with the form as it stands before any Save, and say what is missing in place (#1545, thedavidweng)
What the user saw: on a custom provider being added (or a Duplicate not
added yet), "Each picked model" said "Pick models first" although models
were typed in the Models field, and on a relay with no model list "Detect
APIs" said "no model to try" on every API. Both worked only after a Save,
when the models became the provider's own. A Duplicate not added sent no
key at all. Hints for a missing URL or models went to the toast at the top.
Why: chosenIds() reads a saved provider's chips only, not a new one's
draft.extra; Detect picked its model from the saved provider's list or the
vendor's, never from the form; an unsaved copy posted no id, so the server
had no key to fill in.
What changed:
- provider.Detect takes the form's picks (picked ...string) and tries one
of them per API before the saved list or the vendor's.
- /api/provider/detect takes `picked`, and for `new` + `copyOf` fills
what the draft left empty from the copied provider, as a saved edit
fills from its id. It still only reads: nothing is written, no provider
is added, no route or health check changes. No new route; magpie web's
key guard is the same.
- detectAPIs sends the add form's models (draft.extra) for a new
provider, copyOf for an unsaved copy, and says a missing URL, missing
models, a refusal, and "none answered, and no API key is typed" inline
under the buttons (amber/red text, no border). One new string in zh,
zh-TW, ja, de.
- docs/subsystems/providers-accounts.md: the detection row says so.
What was run:
- TestProviderDetectDraft (new): new draft with picked models on a relay
with no list, Each picked model, saved provider with a masked key and an
unsaved pick, an unsaved copy with no key typed and with a key typed,
config folder bytes unchanged, provider.All unchanged, magpie web without
its key -> 401 and the vendor never asked. Fails on the old detect.go /
providers.go ("no model to try").
- provider-detect-draft.test.cjs (new): chromium + webkit, en/zh/zh-TW/ja/
de, 900 and 360px, 20/20 pass; no scroll on click, no <select>, no
left-border, no sideways scroll, nothing but detect posted. Fails on the
old app.js (no inline hint).
- provider-detect, provider-detect-models, provider-add-models,
duplicate-pause, i18n-keys: 29/29, both engines.
- go test -tags nogui ./internal/gui/ ./internal/provider/ ok; gofmt -l
clean; GOOS=linux and GOOS=windows go vet -tags nogui ok.
- Real use: sandbox `magpie web` (nogui build) with a fake upstream. New
provider, relay with no model list: Detect APIs and Each picked model
answered with the typed key and models, no providers.json written. Saved
provider with its key masked plus a model typed in its add box: both
asked with the saved key. Duplicate not added: asked with the copied
key. providers.json bytes unchanged. Without the web key: 401, the
upstream got nothing.
|
||
|
|
9c11abbd00 |
agent: jcode is an agent magpie connects: a magpie profile with magpie's models, jcode started on the one picked (wani on Discord)
wani asked on Discord for jcode (1jehuang/jcode, a coding agent in Rust)
as an agent magpie connects. There was no earlier request in issues or
history.
What changed:
- internal/agent/jcode.go: a new agent for jcode's config.toml in
$JCODE_HOME, else ~/.jcode (jcode-storage's jcode_dir). Detected by the
file, the folder, or `jcode` on PATH.
- Connecting adds a named profile, [providers.magpie], with the keys
`jcode provider add` writes: type "openai-compatible", the gateway's
/v1, an inline api_key naming jcode (magpie-jcode; jcode's requests
carry nothing else that tells it apart) and requires_api_key = true.
Without that key, jcode sends no key to a loopback base URL.
- Its models list has one entry per model of magpie's: context_window
(128000 when magpie doesn't know it; jcode would assume 200k), input
text/image, and reasoning = true for a model with effort levels, so
jcode's /effort offers them.
- It sets [provider] default_provider = "magpie" and default_model, the
model picked. What was there is stashed, and Disconnect puts it back.
- Picking a model of jcode's own while it is on magpie takes magpie
out: the profile goes and the user's provider comes back with that
model.
- Each key is set alone, so the user's other keys and tables stay, as
do their own keys in magpie's profile (headers, extra_body) and a
reasoning_effort they set on one of its models while the model has
that level.
- jcode writes a profile's models as [[providers.magpie.models]]
tables when it rewrites the file itself (Config::save,
to_string_pretty). Those are replaced by the one list.
- A sync with nothing to change doesn't write.
- Disconnect drops the profile whole, sub-tables included.
- Check says when the profile is gone while jcode still starts on it,
or when its base_url or key is off.
- While jcode runs, the notice says to restart open jcode sessions,
since it reads the file when it starts. The notice is a newNotice
template, translated in i18n.js (zh-CN, zh-TW, ja, de) and listed in
NOTICES, as TestEveryNoticeIsTranslated asks.
- agents.go, agentenv.go: registers it; JCODE_HOME joins the agent env.
- icons/jcode.svg: jcode's halftone mark (jcode.sh/favicon.svg) as a
mask icon, every other dot of its lattice.
- docs/reference.md, docs/subsystems/agent-wiring.md, README.md,
README.zh-CN.md: jcode's row and its place in the agent list.
- WSL isn't covered: jcodeAt reads the place's home and JCODE_HOME, but
it isn't added to the WSL agent list (another session has wsl.go open).
What was run:
- go test -tags nogui ./internal/agent -run '^TestJcode'. The fixture is
the bytes jcode 0.94.0 wrote for `jcode provider add`. The tests went
red when, by hand, I:
- made a no-op sync write;
- dropped the user's reasoning_effort;
- skipped the stash, so Disconnect wasn't byte-identical;
- left jcode's [[providers.magpie.models]] tables in, which makes
invalid TOML;
- dropped requires_api_key.
- Real use:
- jcode v0.94.0 (release binary, sha256 checked) ran under a sandbox
HOME with JCODE_HOME set and JCODE_NO_TELEMETRY=1. Its config.toml
was the one jcode wrote for its own "probe" profile.
- A sandbox magpie (MAGPIE_ADDR 127.0.0.1:3671) with a fake OpenAI
upstream on 3672 ran `magpie jcode magpie/fake/org/echo-1`, a model id
with two slashes.
- `jcode run 'Say hello in one word.'` answered with the upstream's
reply, streamed. The upstream saw model org/echo-1, and usage.jsonl
recorded the turn under agent "jcode".
- `jcode provider add two …` while connected appended its own profile
and left magpie's as it was.
- `magpie jcode default` then gave back the file jcode wrote,
byte-identical, with jcode's new [providers.two] kept.
- The icon rendered as a mask in Chromium and WebKit. The only GUI
change is the notice's translations; TestEveryNoticeIsTranslated and
internal/gui pass, and node --check accepts i18n.js.
- gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows) on internal/agent
and internal/agentenv; go test -tags nogui ./internal/agent
./internal/agentenv ./internal/gui; go test -tags nogui ./... under a
temp HOME (load ~80): every package passed. After rebasing on
origin/main, internal/agent and internal/agentenv were run again,
along with internal/gui, gofmt and the linux/windows vet.
|
||
|
|
ce11b18015 |
gateway: Codex compacts on Gemini after a tool's output, no "Requests ending with a model turn" (#1533, yycsyu)
What the user saw: Codex on Google Vertex AI (gemini-3.8-flash) failed
every compaction that came right after a tool's output with
"Google Vertex AI: Requests ending with a model turn are not supported."
Why: codexInput turns compaction_trigger into a user message holding the
compaction prompt; mergeTurns and then buildCodeAssistSent merged it with
the function_call_output's user turn, so Gemini got one user content
holding a functionResponse and text. Vertex answers that with the
"ending with a model turn" 400 although the last role is user; #1533
showed the same history with the two as separate user contents gets 200.
What changed:
- buildCodeAssistSent (every Gemini-shaped request: Vertex AI, Factory's
Gemini, Gemini CLI's and Antigravity's Code Assist, Google sign-in)
puts what the user said after tools' responses in a user turn of its
own, and never merges text into a responses turn or the other way.
Tools' images stay with their response; parallel calls' responses stay
in one turn. A Claude model on Antigravity keeps its single tool_result
turn as before.
- It also never ends contents with the model's turn: a user turn goes
after it ("Continue.", or compactLastText when an agent compacts with
the ask in its system prompt). prefillRefusal knows Gemini's wording.
- docs/subsystems/gateway-routing.md says both.
Tests: gemini_model_last_test.go uses #1533's exact Responses request
(read_sample / call_diagnostic_1 / compaction_trigger) on /v1/responses
and Codex's path against a fake Vertex that refuses as the real one did;
with the split disabled it fails with the reporter's exact message, and
TestGeminiToolResponseTurnHoldsNoText fails for all four builders.
ump45nose's fork patch on #1533 (93a2afca) found the same cause and
split the turn on Vertex AI only; this does it for every Gemini builder,
and takes its Anthropic case (a tool_result beside text in one message)
into the end-to-end test, which fails on the old code too.
TestBuildCodeAssistForGemini, TestCodeAssistToolImagesAfterEveryResponse
and TestGeminiHistoryOpeningWithModel held the old one-turn merge (from
|
||
|
|
8b393938f5 |
agent: StepCode can be connected to magpie, and Disconnect puts back its own model (#1526, BUKOWSKIREAL)
StepCode (StepFun's coding CLI, `step`) is a Pi fork that keeps Pi's settings as TOML in ~/.stepcode/config.toml and Pi's models.json beside it. It is now an agent target: Connect sets defaultProvider/defaultModel to magpie, appends the magpie pattern to enabledModels when the user scopes models, and writes providers.magpie into models.json with the per-agent key. Disconnect puts back the user's own provider, model and scope (only the patterns magpie added are taken out if the user changed the scope since), restores or removes providers.magpie, and removes a models.json magpie created. STEP_CODING_AGENT_DIR and STEPCODE_CONFIG_DIR move the folder as StepCode's own resolveStepConfigRoot does; WSL is covered. The patch is BUKOWSKIREAL's (7cc88463 in their fork), reviewed line by line: no network, telemetry or credential reads, writes only to the two StepCode files and magpie's stash. Added here: a test that StepCode's real User-Agent, "step (darwin 25.2.0; arm64)", counts as StepCode, and the real-CLI test now looks for a "magpie" row in `step --list-models` rather than the word anywhere (the docs path step prints can contain it). Run: - Config format checked against stepfun-ai/Step-Code at 3d70bae5 and the official 0.1.3 darwin-arm64 binary (sha256 matches latest.json): `step config path --json` names ~/.stepcode/config.toml and models.json. - Sandbox HOME, sandbox gateway on 127.0.0.1:3647: a user config with defaultProvider "step", step-3.7-flash, thinking high, two scoped models, telemetry off. `magpie stepcode magpie/deepseek/deepseek-flash`, then `step -p` answered PONG through the gateway (usage record: agent stepcode, deepseek-flash, 200). `magpie stepcode default` put config.toml back value for value, removed models.json, and `step --list-models` no longer listed magpie. - The same round trip from the real web page (sandbox `magpie web`), switch on, then off through the disconnect preview, which listed the three values it puts back; config.toml came back byte-identical. The row and icon checked in Chromium and WebKit, en and zh; no GUI assets change. - Broke the guarantee: with unwire never restoring the defaults, TestStepCodeLifecycle, ...NativeChangedAndPreexisting and ...StrictValidationAndRollback go red. Without the "step" alias the new UA check goes red. - MAGPIE_TEST_STEPCODE_BIN=<0.1.3> go test -run TestStepCodeRealCLISandbox passes (it failed before the row check above). - go test -tags nogui ./... ; gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows) on internal/agent and internal/agentenv; go build for darwin, linux (nogui) and windows. Not tried on a real Windows, Linux or WSL machine. Co-authored-by: BUKOWSKIREAL <233685554+BUKOWSKIREAL@users.noreply.github.com> |
||
|
|
cd93bbec0e |
provider, gui: a signed-in account can be given a name of the user's own, and a GLM seat's account card keeps the key plan's name and no longer flickers back to two cards (#1515, aindijrncom)
The same GLM Coding Plan team seat was added twice: as a key provider the
user had named, and as a ZCode plugin account. The Usage page kept only the
account's card, which read "31****36@qq.com" or just "ZCode", and whenever
either read failed ("BigModel API keys: not JSON") or a window had no reset
yet, the key's card came back beside it.
Seat (the flicker): the old check returned "different" on any error. It
now returns same, different or unknown (seatMatch). A match is remembered in
seats.json beside quotas.json; while the remembered account is signed in an
unknown check keeps the key card hidden, windows that disagree forget it,
and a signed-out account brings the key card back (seatCards, used by
quotas, Allotted and CachedCards). A failed read is "unknown", never "not
the same".
Names: providers.json gains accountNames (by the account in lower case,
like accountCaps), set by provider.SetAccountName. They are magpie's own
and never written into the vendor's or a plugin's sign-in. Built-in and
plugin accounts both take one; key providers are refused. Each card carries
Alias (the user's name, else the seat) and Seat (the key provider's name,
and the key's when it has several).
- GUI: the editor's account row shows the name with the address beside
it, or the address with "≡ <key plan>"; a click or Enter renames it in
place (posted once to provider/accountname; Escape leaves it, empty
clears it). The name stays selectable text: dragging across it renames
nothing.
The Usage page's cards and the tray panel name the account the same way.
Hide accounts hides the name too. Strings in zh, zh-TW, ja, de.
- The tray tooltip says "ZCode · <name>".
- CLI: `magpie accounts alias <agent> <email> [<name>|--clear]`.
`magpie accounts` and `magpie quota` show the name; quota also matches
on it.
- /v1/magpie/quotas carries alias and seat.
Run:
- account_seats_test TestSeatKeptThroughAFailedRead fails on the old code
("a failed read brought the key's card back") and passes now.
TestAccountNameOfAPluginAccount uses the fake plugin and checks that
plugin-auth.json and logins.json are byte-for-byte unchanged.
TestAccountsAlias checks that Codex's auth.json is unchanged.
TestTrayNamesTheAccountByItsAlias.
- account-alias.test.cjs: Chromium and WebKit; en, zh, zh-TW, ja, de;
900 and 360px; 20/20 pass. It covers no scroll on a click, keyboard,
selectable text, no select, no stripe, no sideways scroll and masking.
With the post-once guard removed it goes red. account-arrange (text
selection) passes in both engines.
- Sandbox HOME, built binary, vendors behind a dead proxy:
- `magpie accounts alias codex Me@Example.com 某某·GLM高级版`, then
`magpie accounts` and `magpie quota` showed the name.
- An unknown account was refused.
- `magpie web` on spare ports: POST /api/provider/accountname saved
"Team seat" (whitespace folded), and an unknown account got an error.
- Gateway /v1/magpie/quotas and /api/usage/quotas carried the alias.
- auth.json's sha was unchanged throughout.
- go test -tags nogui ./... (temp HOME, load ~200): all ok except
TestSetAnswersWhileDevinAndProvidersHang (15.5s under load), which
passes alone 3/3 at ~250ms.
- gofmt -l; GOOS=linux and GOOS=windows go vet on internal/provider,
internal/gui and the root package.
- The whole GUI suite in Chromium and WebKit, each failed file rerun
alone. These are red on the parent commit
|
||
|
|
3144868538 |
gui, gateway: the Providers and Gateway pages no longer download every recent call's bodies; an opened call reads its own (#1521, xiaohei-info)
GET /api/providers carried up to 40 recent gateway calls with their request and response previews (up to 256 KB each) in gateway.calls, and every provider write returned the same state. The Providers page never shows them; only an opened row on Gateway does. With 40 calls of ~300 KB each, /api/providers was 21,019,635 bytes on origin/main. Taken from xiaohei-info's patch (bb26b802, attached to #1521 as external PRs are closed): providersState drops the bodies from the calls it sends; GET /api/gateway/call returns one call's previews and truncation flags with Cache-Control: no-store, 404 once it has left the ring; the page fetches on open, dedupes a pending read, keeps loaded bodies across refreshes, drops them with their call, shows "Fetching…" and a "Try again" on a failed read; the strings in zh, zh-TW, ja and de; the Go and Playwright tests; the gui-shell note. Changed from the patch: a call is asked for by a number the gateway gives it in the ring (Call.ID, Server.RecentCall), not by time, agent and model, which two calls of one agent to one model can share. The page keys a row by that id too (callRow), so two such calls no longer open, or show the bodies of, each other. The tests ask with ids, and the Playwright fixture gives two calls the same time, agent and model. The route is on the same mux as the rest of the API, so magpie web's key guard covers it, and the gateway's own port doesn't serve it. The bodies are the ones the ring kept, masked as before (redacted runs before capture). Nothing else reads gateway.calls' bodies: Routing reads /api/gateway/trace, and the tray, TUI, CLI and /api/state don't read the ring. Run: - Real use: magpie web built from origin/main and from this commit, sandbox HOME, a local upstream answering 300 KB, 40 calls of 300 KB. /api/providers 21,019,635 bytes before, 45,525 after (calls: 14,503 bytes). Opening a row in Chromium and WebKit fetched /api/gateway/call once (524,412 bytes) and showed both bodies with their "first 256 KB" marks. Without the key: 401, also for a rebound Host; on the gateway port: 404; an evicted id: 404. - TestRecentCallBodiesOnDemand fails with the bodies left in providersState ("providers must keep call metadata without sending bodies"), and with RecentCall ignoring the id ("the second call's detail isn't its own"). - recent-call-bodies.test.cjs fails on main's app.js, and with callRow keyed by time|agent|model again. - GUI: gateway-fold, json-tree, phone-rows, recent-calls-more, request-archive, recent-call-bodies, sse-body: 24/24 in Chromium and 24/24 in WebKit (en, zh, zh-TW, ja, de). - gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on internal/gui and internal/gateway. - Full GUI suite: 5225 tests, 71 failures under load ~200, none in a gateway or recent-call file. The 20 files with failures, rerun on this commit and on origin/main: 54 and 58 fail; what fails on one only (Sessions checkbox colour, Sessions paging scroll, account dragging, ZCode block) moves between runs on both. - go test -tags nogui ./...: every package ok on the rebased head. Co-authored-by: xiaohei-info <14011749+xiaohei-info@users.noreply.github.com> |
||
|
|
64262a19f0 |
agent: Prime Agent is an Agents-page row, wired like Pi into ~/.prime/agent, and Disconnect puts its files back (#1528, takltc)
What changed
- internal/agent/primeagent.go: Prime Agent (PrimeIntellect-ai/prime-agent,
CLI prime-agent) through the piLike path, as OmO was added. Its folder is
~/.prime/agent or PRIME_AGENT_CODING_AGENT_DIR (~ expands, as upstream's
agent_dir does; appdir now lets that variable carry ~). models.json and
settings.json were checked against upstream v0.10.0 (pa-core settings and
models registry): Pi's camelCase fields, the same thinking levels and
enabledModels rules. Connect writes providers.magpie, defaultProvider and
defaultModel and keeps the user's providers and settings. Only the global
settings.json is written; allowedModels and subagentDefaultModel are left
alone.
- Prime Agent sends no User-Agent, so its provider block carries the key
magpie-prime-agent and the usage log names it (piLikeKeyed). The block is
Pi's otherwise, compat.sendSessionAffinityHeaders included (Prime Agent's
openai_completions honours it), kept as the user set it (piBlockKept).
- Disconnect restores both files byte-for-byte: before magpie's first write
a copy is kept (*.before-magpie, or a note that the file was absent), and
Disconnect puts it back when nothing else changed since (Agent.Restore). A
file changed while connected is left with only magpie's part taken out.
- WSL kind, agentenv, the icon, PICKS_ITSELF in the GUI, docs and READMEs.
Run
- go test -tags nogui ./internal/agent ./internal/appdir ./internal/agentenv
./internal/library ./internal/usage; the new tests went red with the key,
the restore, the ~ expansion, PICKS_ITSELF and the icon each taken out.
- pi-default-note.test.cjs in chromium and webkit.
- Real use: prime-agent 0.10.0 installed into a sandbox HOME, a sandbox
gateway on 127.0.0.1:3651 and a fake upstream on 3652. The interactive
TUI with no flags started on magpie/fake/echo-1, the fake got the request
and usage.jsonl recorded agent "prime-agent". `magpie prime-agent default`
put models.json back byte-for-byte; settings.json got its values back, but
Prime Agent rewrites the whole file when it runs (every key, nulls), so
that file is equal in content, not bytes. Reconnecting over that
null-filled file and disconnecting again left it byte-identical. After
the rebase onto
|
||
|
|
6f0301f3c3 |
gui: magpie web gzips its page and JSON, and keeps each versioned script for good (akic404 on Discord)
akic404 runs `magpie web` on a public server over a ~3 Mbps link, and
the page took very long to load. Measured in a sandbox (`magpie web` on
127.0.0.1:3461/3463, sandbox HOME): every load sent the page's ~4.1 MB
of scripts and styles as they are (i18n.js 1.8 MB, app.js 1.1 MB,
app.css 282 KB, routing.js 279 KB, library.js 211 KB) with no
compression, whatever the browser's Accept-Encoding, and the API's JSON
the same way: a day of the Routing page's history
(/api/gateway/history, a real 267-request day copied in) was 1.23 MB,
and the routing trace's JSON grows with every account a request could
go to. Nothing is embedded, vendored or source-mapped in routing.js;
the bytes were the uncompressed transfer.
- webHandler wraps `magpie web`'s guarded handler in gzhttp
(klauspost/compress, already a dependency): text, scripts, CSS, JSON
and SVG are gzipped for a client that takes gzip, with Vary:
Accept-Encoding; PNG/WebP/ICO/JPEG go as they are. A gzipped
response's ETag ends -gzip, and If-None-Match with it is mapped back
so a revalidation is still a 304. A 32-byte content-keyed jitter keeps
the compressed size from being exact (BREACH), since the page carries
keys. The desktop windows read the page in-process through Wails'
asset server, with no network, so they stay uncompressed.
- revalidated: a script or stylesheet asked for under its current
content hash (?v=…, as versionedPage names it) is sent with
Cache-Control: max-age=31536000, immutable; any other hash, no hash,
and the page itself stay no-cache + ETag. Applies to both paths.
Numbers (curl, page + its 21 scripts/styles + /api/state):
before: 4,142,180 bytes, with or without Accept-Encoding: gzip
after: 1,258,298 bytes with gzip (i18n.js 565 KB, app.js 361 KB,
routing.js 89 KB), 4,142,180 without
/api/gateway/history?day=: 1,233,600 -> 72,538 bytes
Real browser (Playwright, ?view=routing, 6s, response body bytes):
Chromium first load 4,340,720 -> 1,362,922; reload 75,336 -> 10,597
WebKit first load 4,340,672 -> 1,362,843; reload 115,667 -> 34,006
both engines: Routing view shown, no page errors or console errors.
Tests: TestWebCompresses and TestVersionedFilesKept (web_compress_test.go).
Broken by hand, each goes red: webHandler without webCompressed
(Content-Encoding "" for app.js, routing.js, /, /api/state, SVG); no
immutable branch ("/app.js?v=…: Cache-Control no-cache"); no
If-None-Match mapping ("asked again with its gzipped ETag: 200, want
304"); compressing every type ("a PNG: Content-Encoding gzip"); no
ETag suffix ("gzipped keeps the ETag of other bytes").
Run: go test -tags nogui ./internal/gui (ok); full go test -tags nogui
-timeout 40m ./... under a sandbox HOME (all ok); gofmt -l clean; go vet
./internal/gui on darwin, GOOS=linux -tags nogui, GOOS=windows with and
without nogui. GUI: routing-*.test.cjs, panel-routing, web-page,
mobile-web, phone-web, gateway-mode in Chromium and WebKit; results
after rebase are in the report (mobile-web was red on the old base
before
|
||
|
|
ce1ecaa414 |
gateway: MaxRPM keeps a second's slack, so a first request's dial doesn't let the vendor see one over its minute
TestMaxRPMWaitsForRoomInTheMinute went red under CI load and
|
||
|
|
2305ab1fc6 |
gateway, netproxy: a web search goes through its searcher's proxy, not the direct line of the provider serving the turn (#1522, xixijay1988)
Claude Code on opencode-go (set to "direct"), with Codex as the search
delegate and the proxy on Auto (system proxy 127.0.0.1:7890): every
WebSearch dialed chatgpt.com directly, to the addresses a poisoned DNS
gave, and failed with "no answer in 2m0s". Codex's own requests through
the same gateway went through the proxy.
Cause: attempt() puts the turn provider's proxy choice on the request
context (Provider.Via -> netproxy.With). The search runs inside that
context, and its sub-request to Codex calls Provider.Via again, but
netproxy.With(ctx, "") returned ctx unchanged, so a provider that
follows the global proxy inherited the outer provider's "direct".
- netproxy.With: "" now replaces a choice ctx already names, so any
request made for one provider while serving another (search delegate,
vision describer, classifier, Codex titles, all through attempt's
p.Via) takes its own provider's proxy or the global one.
- webSearch clears the turn's choice up front: the search APIs, which
have no proxy of their own, follow the global one.
- kimiSearch now applies the Kimi Code plan's own proxy (p.Via); it
had none and went the turn's way.
Verified:
- New TestSearchFollowsTheSearchersProxy: a fake CONNECT proxy on a free
port; the turn's provider is reachable only directly, the searcher, a
Kimi Code search service and a search API only through the proxy.
Cases: Settings' proxy, Auto (from the environment), a searcher's own
proxy with the global direct, a search API. On the old code it fails
with "dial tcp search.test:443: ... (dialed directly)", CONNECTs [];
with only the With fix the search API case fails; with the kimiSearch
change reverted the Kimi case fails. -race -count=5 passes.
- TestWith in netproxy gains With(With(ctx, outer), "") follows the
global proxy; fails on the old With.
- go test -tags nogui: gateway, netproxy, provider, plugin, update pass;
the full ./... suite under load ~180 passed except
internal/agent TestDshHomePickSurvivesSyncAndEffort, which passes alone
(-count=3) and touches no proxy code (not this change; not yet filed).
After rebasing onto
|
||
|
|
552c2244dd |
gateway, gui: magpie's web search is an MCP server too (Kayphoon on Discord)
What: /mcp/magpie/web-search serves the gateway's existing web search
(webSearch: the searcher's model, a Kimi Code plan's service, the search
APIs, in the order Settings sets) as an MCP server with one web_search
tool, so Cursor, Claude Desktop (through mcp-remote) or any agent can
mount it. Streamable HTTP only: POSTed JSON-RPC messages and batches are
answered with JSON (initialize with version negotiation, ping, tools/list,
tools/call), notifications get 202, GET/DELETE 405. Legacy SSE isn't
served. Two segments under /mcp/, so it can't hide a signed-in server's
/mcp/{name}.
Guards: lanGuard as on every route (a gateway key from another machine,
only while shared; rebound browser hosts refused), plus a local/shared
backstop in the handler. Any web page Origin (localhost too) is refused
unless listed in Settings, as the MCP spec asks of a server. keyLimited
passes /mcp/ by, so each tools/call reserves the calling key's limit
(budget.Reserve) and a spent key gets a tool error with no search. The
search is marked CallFor{MCP: true}, and Routing says the agent called
magpie's web_search MCP tool. With nothing that can search, the tool error
says where to add a search API.
GUI: Settings > Models > Web search has an "MCP server" row with the
address (from the Settings page's gateway URL) and Copy, in en, zh, zh-TW,
ja, de. docs/subsystems/gateway-routing.md has a section on it.
Run:
- go test -tags nogui -timeout 40m ./... (all ok, at the first rebase),
then gateway/gui package tests again after rebasing onto
|
||
|
|
177fbdfe28 |
library, gui: the agents a skill is installed for have an All chip, one click takes them all off (#1531, liuweifeng)
Installing a skill from a repository starts with every agent lit, so installing it for one agent alone meant unticking each of the others. The picker now has the All chip the library's skill and server rows already have (allChip): lit while every agent that can take it is lit, a click takes them all off, another puts them all back. Only this one is then All + that agent's chip, two clicks, with the same control as the rows rather than a new idiom. The same fix reaches every sibling picker that chooses agents before an item is added: the market's skill install, the MCP server editor (add and edit), pasting several servers, and the market's server install. No new strings: All and its tooltips are already in every language. The CSS sets All a little apart from the icons outside a row. docs/subsystems/library.md says so. Run: - new internal/gui/tests/skill-install-agents-all.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de at 1100px and 420px, with the reporter's repository: All lit at first, All -> none, Codex -> install posts agents ["codex"]; All puts every agent back; the server editor's All too. 28/28 pass; on the old library.js/css 0/28. - the library's sibling GUI tests (by-agent, every-skill, group-skill-chips, library-*, market-have, market-featured-skill, pick-skills, project-servers, skill-install-skip, skill-name-many-agents, mcp-signin, import-all-skills) in both engines: all pass, except library-servers-bulk's known 2px flake (#1322), which fails the same way with this change reverted. - screenshots of the picker in zh at 1100px and de at 420px. No Go changed. |
||
|
|
b1396d2360 |
gateway, provider, gui: a routing group of decision models answers /v1/systemone, failing over between them (ARNO on Discord)
ARNO asked for decision models to get the group feature too: /v1/systemone
took only "<provider>/<model>" (xxx/jev-latest), so one refusing key or
vendor failed the call with nothing to fall back on.
A routing group may now be of decision models alone (provider.Group.Decides,
provider/decide_group.go). SaveGroup refuses one mixed with models that hold
a conversation, a decision group inside a chat group, and patterns, rules,
classifier, effort, levels, fast mode or a member effort on it. It is kept
out of the agents' catalog (groupEntries), and a chat request to it gets a
400 pointing at /v1/systemone.
POST /v1/systemone with "model":"group/<id>" (or the group's id or name, as
GroupFor reads them) goes to serveDecisionGroup (gateway/decide_group.go):
- the members' keys and accounts are planned with planGroup in the group's
routing order, resting ones last; perKeyBarred no longer drops a
decision-only provider's keys (it speaks no chat protocol), so each key
is a try of its own;
- a gateway key's model and account limits and pause rules hold as for chat;
- a retryable failure that isn't the request's own (shape/prompt/protection)
rests the candidate via restAfter and the next is asked; a transport error
rests it as a 502; the last one's answer and Retry-After are passed on;
- every try is a Try of one route in the routing log; one usage row for the
answer.
A group classifier naming a decision group fails over the same way
(askDecisionGroup; systemOne now returns decideRefused with the vendor's
status, headers and body, and postDecide returns the headers).
The GUI group editor offers a group of decision models only decision models
(groups.deciders), a chat group no decision model or decision group, a new
one both, and a decision model's row has no reasoning picker (groupJSON
.decides). The TUI member picker and `magpie group add` follow the same rule.
#1514's plugin_decide_test and TestMixedDecisionProvider now assert a mixed group is refused and a group
of decision models saves. Docs: reference.md (routing groups),
gateway-routing.md, provider-plugins.md.
Run:
- go test -tags nogui -timeout 40m . ./internal/provider ./internal/gateway
./internal/gui ./internal/tui: ok
- new: TestSystemOneDecisionGroupFailsOver (httptest System One fakes: a
provider with two keys answering 429 and 503, then a second provider
answering 200: tries ka1,ka2,kb, both failures rested and ask by name
goes to kb first; all failing passes the last answer on; chat to the
group is 400), TestDecisionGroupClassifierFailsOver, TestDecisionGroup,
TestGroupAddDecisionModels, TestMemberOptionsDecisionGroup,
group-decide-members.test.cjs (Chromium and WebKit, en and zh; no new
strings)
- each broken by hand and seen red: no dispatch (404), no perKeyBarred
change (ka2 skipped), no classifier failover, no rest, decision group in
the catalog, CLI resolver, TUI and GUI picker filters
- GUI: group-*, routing-effort*, routing-levels, routing-save*,
routing-intent-entry, routing-manual, i18n-keys in both engines: 169 pass
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on the
touched packages
- after rebasing on
|
||
|
|
f04792f906 |
icon: remote icons are fetched through usemagpie.ai/api/icon, so their hosts never see the user's IP
A plugin's package.json icon, an import link's icon= and the library's market icons sit on hosts their authors pick. magpie fetched each straight from there, so an author could log the IP of everyone who opened Discover or the library. The owner asked for icons to keep showing without that. - site/worker.js: /api/icon?url=<https URL> fetches the picture from Cloudflare with only Accept: image/* and its own User-Agent, follows redirects, caps it at 1 MB (the app's MaxIcon), passes on only PNG, JPEG, GIF, WebP, ICO or SVG (by bytes, as StoreIcon), and counts and keeps nothing. It refuses http, userinfo, a non-443 port and usemagpie.ai itself; 404s are cached 5 minutes, 5xx not at all. - internal/iconproxy: URL(u) is the proxied address (MAGPIE_ICON_PROXY for tests); a picture already on usemagpie.ai is asked for as it is. - provider.FetchIcon (plugin, import link and partner icons) and library.fetchImage (market icons, avatars) fetch through it. The import link's checks (https, public host) still come first; there is no direct fallback. provider.FaviconFor still reads the user's own provider's site directly: they already send it their requests. - Privacy text in README en/zh, docs/reference.md and site docs start/import in en/zh/ja says so. Ran: - node --test site/*.test.mjs: 28 pass. The new test asks with Cookie, UA, X-Forwarded-For and CF-Connecting-IP and checks only accept and user-agent go upstream; 415/413/502/400 cases; its fetch stub throws instead of reaching the network. With the usemagpie.ai refusal removed by hand it goes red (27/1). - TestFetchIconGoesThroughTheProxy and TestIconGoesThroughTheProxy (author host is .invalid; an httptest server stands in for the proxy): with the proxy taken out by hand both go red (provider: lookup author.invalid; library: the proxy was never asked), green restored. - go test ./internal/iconproxy ./internal/provider ./internal/library ./internal/gui: ok. gofmt -l clean; go vet darwin (those four), linux (iconproxy, provider, library), windows (all four): clean. |
||
|
|
bc2496dca8 |
gui, provider: the menu bar's "Account in use" moves as soon as another account answers, and a plugin's shows the one that answered last (#1516, ikxlpz)
|
||
|
|
f0834b6f0d |
gui, sessions: a session magpie's gateway recorded downloads as Markdown instead of a 400 (akic404 on Discord)
akic404's public magpie serves other magpies as a remote magpie and records
their agents' conversations. The Sessions page showed them, but Download as
Markdown in magpie web answered 400 {"error":"no such session"}: the export
(GET /api/sessions/markdown, and the app's POST /api/sessions/export) only
looked for the agent's own session file, and an agent that ran on another
machine has none here. The transcript endpoint already fell back to the
gateway's record; the export didn't.
sessionMarkdown now takes the same fallback: no native session, but a known
gateway session for that agent and id, is written from GatewayTranscript by
the new sessions.WriteGatewayMarkdown. It shares WriteMarkdown's layout
(writeMarkdown), says "Recorded by: magpie's gateway" in place of the file,
and notes when older turns or the end of a long part weren't kept. It is not
the Host check or CSRF: the GET with the web cookie reached the handler.
Run:
- Sandbox upstream (magpie web --gateway, MAGPIE_WEB_KEY) with recorded pi
and omp sessions reached through a downstream remote magpie: the old
binary's /api/sessions/markdown gave 400 "no such session"; the new one
gives 200 with the text, Content-Disposition
magpie-session-pi-01a126b7-2a4.md; without the cookie still 401.
- TestGatewaySessionExportsMarkdown fails on the old sessionMarkdown with
that 400 and passes now; TestSessionExportMarkdown, TestGatewayConversationAPI.
- go test ./internal/gui ./internal/sessions, gofmt -l, go vet for darwin,
GOOS=linux and GOOS=windows on internal/gui and internal/sessions.
|
||
|
|
7a5536793e |
agent: Pi's and omp's turns are recorded by "Record gateway conversations", as OpenCode's are (akic404 on Discord)
akic404 runs a public magpie as the upstream and a local magpie that reaches it as a remote magpie; with recording on, only OpenCode's conversations were kept, on either side. The gateway records a turn only under the session the client names (it never makes one up), and the configs magpie wrote for Pi and omp didn't have them name one: - Pi (1.1.0) sends x-session-affinity on Chat and Anthropic Messages only when the provider's compat says sendSessionAffinityHeaders (Responses sends session_id anyway). magpie's Pi provider block now sets it. A value the user set in that block is kept through a sync and a pick (piBlockKept, for pi, OmO and the aside's native Pi path). - omp (18.6.1) sends its session header on Chat/Responses only to OpenAI itself, unless the provider's compat.promptCacheSessionHeader names one (pi-catalog 16.0.6+). magpie's omp provider entry now names x-session-affinity for omp 16.0.6 and later; an older or unknown version is left as it was. withCaller already passes the session on to a remote magpie, so naming it once is enough for both sides to record. Run: - Header dump (fake upstream LLM): real pi and omp with these provider blocks send x-session-affinity / session_id on every API; without them, nothing on Chat/Messages. - End to end in sandbox HOMEs: an upstream (magpie web --gateway) and a downstream (serve, remote magpie to the upstream), both recording; the new binary wrote ~/.pi/agent/models.json and ~/.omp/agent/models.yml through `magpie pi …` / `magpie omp …`; real pi (Chat and Messages models) and real omp turns were recorded under gateway-conversations on both sides. - TestPiNamesItsSessionToTheGateway and TestOmpNamesItsSessionToTheGateway fail on the old code (no compat; Compat field missing) and pass now. - go test ./internal/agent (-timeout 40m), gofmt -l, go vet for darwin, GOOS=linux and GOOS=windows on internal/agent. |
||
|
|
78b3f1f21a |
agent: an agent pointed at magpie on another machine keeps that address and key through a start's sync (coeo91 on Discord)
coeo91: after an update or a restart, the base URL in an agent's config sometimes went from the LAN address back to 127.0.0.1. Every start of magpie (and a provider added, a catalog fetched) runs SyncCatalog, which runs each agent's Sync to bring magpie's models in its files up to date. Each Sync writes magpie's whole provider block, base URL and key included, from gateway.URL(), so a block the user had pointed at a magpie on another machine (a NAS's, or this machine's LAN address) went back to 127.0.0.1 with magpie's own key. Only ZCode (zcodeAddress), WorkBuddy (buddyWriteAt) and Codex (#816) kept such an address; in a sandbox HOME, 27 files of the other agents went back (Qoder, OpenCode, Pi, Crush, Cline, Qwen Code, Kimi, Grok, Hermes, omp, MiniMax, Snow, Hanako, VS Code, Copilot JetBrains, Goose, dsh, ...). The fix is one place for all of them: SyncCatalog runs each Sync through synced, which passes every file written through keptAway (edit.Filtered, a filter on edit.WriteAtomic while it runs). In a file without the gateway's own address, with an address on another machine and none a WSL distro was seen at, a write that brings gateway.URL() in place of that address keeps the address, and one that brings magpie's own key (gateway.Token, TokenFor, the LAN key, "Bearer " too) in place of another key keeps that key. An address on this machine's loopback (another port, localhost) still follows the gateway, a WSL distro's way to Windows is still magpie's to move, magpie's own files are never filtered, and with two addresses or keys gone the write is left as it is. A pick made in magpie still points the agent at this magpie. Tests: - TestSyncKeepsAnAddressOnAnotherMachine wires every agent in a sandbox HOME, points each file at 192.168.50.10 with a key of its own, adds a provider and runs SyncCatalog: no file is back on 127.0.0.1, the address and key are kept, and the new model is written. With SyncCatalog calling a.Sync() directly it fails on 27 files. - TestKeptAwayOnlyWhatIsSure: old port, localhost, WSL and two-gone cases follow the gateway; a NAS beside a local Ollama is kept; Qwen Code's key written on its own is kept. - TestKeyValuesFormats, TestFilteredWrites. Run: gofmt -l (clean); GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent ./internal/edit; go test -tags nogui ./... in a temp HOME. |