b64ec9d64f80799f4e2b699854e1cd05d148e8da
1266
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b64ec9d64f |
gateway: a picked model that turns an image away gets it described, not another provider (xyenon)
xyenon (Discord #feedback) picked provider-1/DeepSeek-V4.1-Flash in pi with an Image recognition model set. An image they sent wasn't described; the request was answered by provider-2/DeepSeek-V4.1-Flash. Cause: provider-1's list says nothing of images, so magpie took models.dev's word for the model (catalog.SeesImages: text+image) and sent the raw image. The relay answered DeepSeek's 400 "Failed to deserialize the JSON body ... unknown variant `image_url`, expected `text`". That matches shapeWords, so the try failed as a shape refusal and went on to the next candidate: provider-1's fallback (or the next group member), the same model at provider-2, which sees. The describer was never asked. Fix: a 400/415/422 whose words say images aren't taken (imageRefused: unknown variant image_url/input_image/image, OpenAI's "only supported by certain models", OpenRouter's "no endpoints found that support image", vLLM's "not a multimodal model", 不支持图片 and the like) marks the model blind for this server's run (refuseSight; blindTo checks it first). With a describer, the same candidate is asked again at once with the images described (seenBody, or seenGroup for a group), before any fallback or other member; the try reads failSight, which the Routing page tells as its own story (en/zh/zh-TW/ja/de); the row then reads answered, as for floor's and foreign's re-asks. Later requests are described up front, for a direct pick and a group (user or auto) alike, on Chat, Responses and Messages. Kept on purpose: with no describer (Image recognition off, or no model that sees), going on to a candidate whose copy sees is the only way to answer, so it still does (TestRefusedImageWithNoDescriberGoesToOneThatSees). Documented in docs/subsystems/gateway-routing.md, "A model that turns an image away". Run (on mote, through mote-run): - TestPickedModelThatRefusesAnImageIsGivenItDescribed (9 subtests: direct pick with a fallback, user group, group/auto-…; each API), TestRefusedImageWithNoDescriberGoesToOneThatSees, TestImageRefused: ok. - Broken by hand: with gateway.go/vision.go/routing.go reverted to origin/main ( |
||
|
|
4534561f6b |
codex: a thread open when magpie quits goes on through a relay, not a 503
idkatbro on X: a Codex session started while magpie was open keeps failing after magpie quits with "unexpected status 503 Service Unavailable: Unknown error, url: http://127.0.0.1:3425/backend-api/codex/responses", until magpie is opened again. Cause: Codex signed in to ChatGPT, with more of its accounts on in magpie, gets openai_base_url = the gateway's /backend-api/codex (failover). At quit EndCodexFailover takes it out of config.toml, but a thread already open, in the Codex app and its app-server above all, keeps the base URL it started with. Every turn after went to a closed port. With a system or env proxy in between, the proxy answers 503 with an empty body, which Codex shows as "Unknown error"; without one Codex says "Connection refused" and reconnects. Reproduced on mote with codex 0.162.1 and a proxy answering 503 for the closed port. Masking plays no part: it runs only in the gateway, is opt-in, and its own 503 carries a readable message. Fix: when quit really ends failover (EndCodexFailover now says so), the gateway is on loopback, and Codex processes run (provider.CodexPIDs), magpie starts a detached `magpie codex-relay` (internal/codexrelay). It waits up to 60s for the gateway's port, then passes /backend-api/codex/* on to the ChatGPT backend with the same transforms the gateway applies to Codex's own turns, signed by the caller's own Authorization; it adds no credential (gateway.CodexRelay). - Refused with a readable 400 (Codex retries a 5xx five times over): a magpie model, a turn naming one of magpie's Codex accounts, and a turn masking would have masked, which is never sent unmasked. - 403 for any Origin (null too) or a non-loopback Host, as corsGuard. - Any other path gets 503 "magpie isn't running", never readable as magpie by ServedBy. - It ends once every Codex process it was left for is gone and nothing is in flight. - The next magpie (GUI or `magpie serve`) calls codexrelay.Leave first: a POST with the token from a 0600 state file. The relay closes its listener at once, so the port is free when Leave returns, and finishes its streams (up to 30 minutes). No running turn is cut. Run (at 6df7dc287 on origin/main |
||
|
|
1198cff601 |
gui: a model picker's row says how fast its provider answered this week, fastest first under a search
axuhere on X: with several providers serving one model, the list and the model picker should show each one's speed and sort by it. Each row of an agent's model picker now carries a quiet tag from the usage ledger's last seven days: tokens a second, or the first token's wait when only that was timed (title: "first token in Xs, N tokens a second"). Under a search, rows that match equally go fastest first by about how long a 200-token reply takes, the untimed last. Without a search the rows keep catalog order, grouped by provider. "Fastest first" for a routing group already existed as Speed first ( |
||
|
|
bb3565309d |
gateway: a provider's listed reply headers and the vendor's request ids reach the agent (#4145)
codex-cn (#4145, and smtmsnyw on X: "Magpie代理把我原始模型响应头给吃了"): a relay's X-OneAPI-Request-ID never reached the agent, so a failed or slow call couldn't be matched with the relay's logs. What changes - provider.ReplyHeaders (`replyHeaders` in providers.json, the editor's Advanced > Reply headers, comma-separated): headers of the vendor's reply passed on to the agent, matched whatever their case, saved canonical. Request-Id, X-Request-Id and X-Oneapi-Request-Id go from every provider without being listed (DefaultReplyHeaders): opaque ids, under names magpie sets nothing of its own, and passthrough already passed the first two on a 2xx. Nothing the user set is overridden: the list only adds. - Never passed on, listed or not (ReplyHeaderPassable): Content-*, hop-by-hop and Transfer-Encoding (magpie writes the body it sends), Set-Cookie/Cookie/Authorization/WWW-Authenticate/Proxy-*/API keys, Access-Control-* and Sec-* (would let a page read magpie), Location, HSTS, CSP, Alt-Svc and the like, Retry-After/Cache-Control/Date/ Server/Vary/X-Accel-Buffering (magpie's own), and X-Magpie-* (the gateway reads those as notes of a try). Save refuses such a name (ReplyHeadersOK); the editor says why before the save in every language (replyHeadersOf), its list held to Go's by TestReplyHeadersNeverAsTheProvidersAre; a name written by hand is dropped on read. Where it's applied - One choke point: forward (every model API, relayed or translated, a plugin's fetch, a signed-in account) and retrieveAs (embeddings, audio) tell the reply they return to the try that asked, through the try's context (withReplySink/heardReply). The sink is the try's holdWriter, so a try that fails and is let go takes its vendor's headers with it: a fallback's reply carries the answering provider's alone, and a failure released to the agent carries its own. Only the try's own provider is heard (a side model or searcher isn't); within a try the last reply replaces earlier ones (a refused beta asked again, a Mantle reroute); after the try has its status nothing more is heard (a cut reply's continuation). count_tokens writes them directly, and the passthrough effort-none probe's kept refusal counts as the reply. - Not covered: images and video (#4211), and the Codex backend relay (which copies its reply's headers whole already). A stream whose headers keepAlive sent before the vendor answered (past keepHeldAfter) can't carry them. - Docs: providers-accounts.md (Reply headers row), gateway-routing.md. What was run - New tests: TestReplyHeadersPassedOn (Anthropic relayed and Chat translated x whole and stream x 200 and 400), TestReplyHeadersOfThe- ReplyGiven (429 then fallback to another provider), TestReplyHeadersOnCountTokens, TestReplyHeadersOnEmbeddings (200 and 400), TestReplyHeadersList, TestReplyHeadersNeverAsTheProvidersAre: pass on mote (macOS), on xiaomi-gpu (win-run) and in WSL (wsl-run). - Broken by hand: without the main loop's withReplySink every TestReplyHeadersPassedOn subtest and the fallback test go red (ids ""); with the deny map ignored, Set-Cookie passes and 8 subtests go red; without count_tokens' passReplyHeaders its test goes red. - gofmt -l clean; go vet ./internal/... for darwin, linux (-tags nogui) and windows: ok. - At this commit rebased on |
||
|
|
d95822eb35 |
provider: a keyless public plugin stays listed with subscription accounts off, and its name isn't blurred (lileo0668)
lileo0668 on Discord (#help): OpenCode Zen Free (plugin 0.1.18, the public credential) said 已登录 on the Plugins page, the Add sheet had one blurred row for it, a red line said "<name> 已登录,但 magpie 无法列出它", and Zen's free models were nowhere. Cause, reproduced on a sandbox magpie (HOME and XDG dirs under a scratch folder, :3561, `magpie web` on :3562) built from origin/main |
||
|
|
296f66a74b |
provider: Kimi Code's monthly allowance shows as a Month window beside 5h and weekly (lidazi2016)
lidazi2016 on Discord (#feedback): a Kimi Code plan has a 5-hour, a
weekly and a monthly limit, and magpie showed only the first two.
Kimi's /coding/v1/usages tells a plan on its monthly allowance in a
third block magpie didn't read: "usages", each entry a share
{"used_ratio", "reset_time"} keyed limit_5h, limit_7d,
limit_month_total and limit_month_code. kimi-cli 1.52.0 (the Python CLI,
latest on PyPI) reads only "usage" and "limits"; Kimi's newer kimi-code
(MoonshotAI/kimi-code, packages/oauth/src/managed-usage.ts and
apps/kimi-code/src/utils/usage/usage-format.ts) reads "usages" and shows
"5h limit", "Weekly limit" and "Monthly limit" from limit_5h, limit_7d
and limit_month_total. limit_month_code is the part of the month code
has used, drawn on limit_month_total, not an allowance of its own.
readKimiCode now reads usages the same way: limit_5h as "5 hours",
limit_7d as "7 days", limit_month_total as "Month" (30-day Span, reset
at its reset_time, the name Volcengine, Tencent, Cline and Ollama's
month windows already use, translated in zh, zh-TW, ja and de), and
leaves limit_month_code out. A window told both ways (the 300-minute
limits[] entry beside limit_5h, the weekly usage beside limit_7d) is the
share's, as kimi-code takes it; a share that isn't a number is skipped
and the counted window stands. The windows come shortest first.
Test: TestReadKimiCodeMonth. Its first body is a live reply of
2026-09-23 posted in narumiruna/pi-extensions#1390 (limits[] + usages
with limit_5h, limit_month_total, limit_month_code, no weekly usage);
the second has every window kimi-code reads, plus usage and limits[];
the third a null used_ratio. With planquota.go put back to origin/main
it fails: "planquota_test.go:462: [{... Name:5 hours Used:44 ...}]", the
month missing; with the change it passes. TestReadKimiCode (the counted
shape) passes unchanged.
Run on mote (mote-run): gofmt -l (nothing), go vet -tags nogui ./...,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go build,
GOOS=linux go build -tags nogui, GOOS=windows go build, and go test
-tags nogui -count=1 -timeout 45m on internal/provider, internal/gui,
internal/tui, internal/cli, internal/usage and internal/usageapi:
all ok (provider 290s, gui 195s, tui 28s, cli 155s, usage 101s, usageapi 2s).
Not run: the whole go test ./... (mote was at load ~99 running two other
sessions' full suites; one suite a machine), and the GUI suite (no
change under internal/gui/assets; "Month" and its translations are
already there). Not tried: a real Kimi Code account or key; the reply
shape is Kimi's own client's parser and a live reply posted by another
user, not one read here.
|
||
|
|
c201fe2266 |
usage: Codex's auto-review through a ChatGPT sign-in costs nothing (silverzhou)
silverzhou (Discord): codex-auto-review has been free for a long time,
but magpie still estimates a cost for it. OpenAI's Codex lead
(thsottiaux, "Day 2.1"): "We have made Auto-review free for all users
signed in through a ChatGPT account."
provider.ListPrice now prices codex-auto-review at $0 on the "codex"
provider, the one that holds only ChatGPT sign-ins, unless that sign-in
is on the Free plan: cybercaius measured auto-review spending the Free
allowance, which is why the gateway's freeOnChatGPT already left Free
out. That rule now has one owner, provider.ChatGPTReviewFree, and
freeOnChatGPT calls it. The plan is read from Codex's current sign-in;
an unreadable plan or a Codex signed out since counts as a paid plan
(priceOf's unknown-model branch answers $0 for it too).
Still priced, since nothing says those are free: codex-auto-review sent
with an API key (openai, chatgpt-api), through a relay, or a review
magpie made follow the session's model (the row's served model is that
model). A price the user set for the model wins over the $0.
PricedNameFor names the model itself, so the Requests list no longer
says "priced as gpt-5.6-luna". The usage summary cache key carries the
Codex plan, so a plan change re-prices cached views.
Old rows: prices are applied when the log is read, so every past
codex-auto-review row through a ChatGPT sign-in reads $0 after the
upgrade: Usage's Overview and Requests, the tray, the ledger and key
limits' estimated-cost caps (their in-memory sums are rebuilt at start).
Nothing is rewritten on disk.
Left alone: a Codex window's holds (apiPricer) still count these calls,
filed as #4181. docs/subsystems/providers-accounts.md has the rule.
Run at this tree (rebased on
|
||
|
|
5f6a46630a |
gateway: images, videos and embeddings are listed on Routing (zzzkl3994)
zzzkl3994 on Discord: a video made through the magpie-image MCP was in Usage → Requests but never on Routing → Requests. The MCP's requests do go through the gateway, but `images`, `videosCreate` and `retrieve` (embeddings, rerank, audio transcriptions) wrote their usage row and began no route, so the routing trace never had them. Only the chat path, the Codex backend, titles and System One began routes. Each now begins one route (media_route.go, sideRoute) with the caller's agent and session, the model as asked, the provider and the routing group. Each key, account or group member asked is a try, put in Order so the page finds its seat. The route ends with the status, error and tokens, and the usage row names it in RouteID. Route.Usage is for display and is not a second ledger row, so nothing is counted twice. An image's accounts are tried in drawOnAccounts, which gets the route through the request's context. A video's polls and its download are the same generation; they add no route, as they add no usage row. A video turned away before any vendor was asked ends its route as failed. Route.Kind stays empty. Run: - New tests (media_route_test.go): TestImageIsOnRouting, TestFailedImageIsOnRouting, TestVideoIsOnRoutingOnce (create, three polls and the download give one route and one usage row), TestRefusedVideoIsOnRouting and TestEmbeddingAndRerankAreOnRouting. All are red at |
||
|
|
da8039368f |
library: skills kept in ~/.agents/skills can be handed over to the library, and then turned off per agent
tnt1223 on Discord asked for the skills in ~/.agents/skills to move into
magpie's library folder and be managed there ("统一移入 magpie 的资源库文件
夹,交给 magpie 管理"), since a skill there can't be turned off for one agent
("不能决定某个 skill 是否自由开启"). Codex, Gemini CLI and the other readers
of that folder read it themselves, whatever the library ticks. Goose, Kimi
Code and Cindy use it as their own folder.
HandOverSkills (POST /api/library/skills/hand-over with names) does the
hand-over only when the user asks for it:
- A folder kept in ~/.agents/skills moves into library/skills/<name>
(moveIn). It is renamed, or, across disks, copied. A copy has to read
back the same (sameTree) before the original is set aside with the
backups. On any failure the folder stays where it was and the library's
link stays as it was.
- An entry there that only links to a folder elsewhere is removed, and
the library links straight to that folder. The folder itself stays.
- The user's own links to the skill in agents' folders are removed too,
since they would point at nothing. The library gives those agents its
own link.
- Every agent here that read the skill there (readsSharedHere, plus the
agent of each such link) is ticked. So each agent keeps the skill, now
from the library, until the user unticks it or turns it off here.
- A skill found there that isn't in the library yet is imported first.
- A name that can't be handed over is listed in Result.Unmoved, and the
other names are handed over all the same.
HandBackSkill moves the folder back and links the library to it again.
"Kept there" is now sharedEntry: the skill's own entry in the shared
folder, by its name, or, for a library link into it under another
folder's name, by that folder's name. Everything that read the old
by-name check follows it:
- SkillView.Always, plus the new Shared and SharedElsewhere fields;
- syncSkills' in-shared check;
- the shared folder's own target, which no longer gets a second link
beside such an entry. TestSharedUnderAnotherName covers this, and it
fails without the guard.
Where:
- GUI, Library > Skills: a row kept there has "Manage in magpie"
("交给 magpie 管理") in its source line. With more than one such row,
the skills heading has "Manage {n} in magpie". Each asks first, in the
page, and says:
- where the folder goes, or that only the link goes;
- which agents keep the skill, ticked;
- how to put it back.
Cancel sends nothing. The strings are in en, zh, zh-TW, ja and de.
- CLI: `magpie library skill hand-over <name…>|--all` and
`magpie library skill hand-back <name>`.
Existing users: nothing changes until they click. A library.json gains
no new key.
Run (mote, at 58e926e5d/d4b7c0586 rebased on
|
||
|
|
d9cf85ae8b |
images: a routing group can be Settings > Images' image model (7up6666 on X)
Settings > Images > Image generation now offers each routing group with a member that draws (gateway.GroupDraws: a member among its provider's Drawers), with no provider of its own, so the picker puts it under Routing groups as the Image recognition picker does. Picked, "group/<id>" is what a request naming no model draws with, the Magpie Image MCP's included: the gateway already drew on a group member by member in its routing's order (drawingGroup, #2005), it was only never offered. A picked group none of whose members draws any more (all removed, or a group of chat models) is DrawerMissing (drawerMissing): the row says the pick is missing and Automatic draws in its place, as for a removed model. Before, a group of chat models would have been sent the drawing. ListedDrawer and DrawerHidden leave a group ref as it is. Run: - mote, at this change on |
||
|
|
ded4935745 |
providers: an image model can be unticked in its provider's editor, and leaves the lists (321sssrt on X)
A provider's editor lists its image models as chips under "Image models"
("图像模型"); a click unticks one, and Save keeps it as the provider's
HiddenDrawers, a deny list beside the Models allow list. An unticked
model leaves Settings > Images' picker, Automatic's choice (and so the
Magpie Image MCP's when nothing is picked), the gateway's /v1/models
image entries and Aside's image options (gateway.OfferedDrawers).
A hidden model still draws when a request names it (resolveDrawing reads
Drawers), and a Settings > Images pick made before it was hidden stays
the pick: it is still listed, as picked, and the row says it is unticked
in its provider and leaves the list once another is picked
(ImageGenHidden), so a pick never stops drawing in silence. A Save that
leaves hiddenDrawers out keeps them; [] clears them. Strings in en, zh,
zh-TW, ja, de. docs/subsystems/gateway-routing.md has the section.
Run, at this and the next commit on
|
||
|
|
0366e35c11 |
catalog: a model models.dev lists under another spelling takes its limits
xyenon (Discord #feedback, 10-29): Volcengine Ark lists
kimi-k3-1-pro-261024 where models.dev lists kimi-k3.1-pro, so magpie
knew neither its context window nor its reply limit. The ids differ only
in what the provider package's sameModel already folds when it groups
models: a version's dot written as "-" (or Fireworks' "p"), and Ark's
six-digit YYMMDD date.
Design
- sameModel moves to internal/catalog as SameModel, word for word
(snapshotDate, modelGaps and atoi2 with it). provider's sameModel calls
it, so grouping and catalog lookups fold ids by one rule.
- Exact matches go first and are unchanged: found (exact, Bedrock
profile, "(variant)", ":tag"), then renamed (relay prefixes, window
marks). Only when both miss does normalFor look up the id models.dev
spells as SameModel(id) folds it. When several spellings fold into one
key, the spelling most providers use wins, and then the lowest id, so
Venice's kimi-k3-1-pro keeps its own 1000000/131072 and the other
spelling gets the majority's 1048576/1048576.
- Decorate (a vendor's live list against the provider's own models.dev
entries) tries the same provider's entry under another spelling before
anything else. It fills only what the vendor's list leaves at zero and
never copies a price, so a limit the upstream states always wins.
ListedBy (a provider's own levels) gets the same last pass, per
provider, after its exact passes.
- What is not borrowed: a price (PricedBy has no such pass, so nothing is
priced from another provider's or another spelling's row) and a display
name (NameOf; the upstream id stays the id).
- What is not matched: -pro-max, -mini, another version (k3.2, k3), a
four-digit release (-2610), a six-digit number that isn't a date
(261324), and OpenAI's dashed date. SameModel already kept those apart.
- Re-derived: everything that reads these tables goes through
ContextOf/OutputOf/lookup, so ListedWindow, replyLimit, the Codex
catalog, efforts and thinks get the fallback with them. Knows now takes
other spellings too, so the usage report (stats modelLabel), which may
send only ids models.dev lists, reads the new KnowsAsWritten, which
doesn't.
- docs/subsystems/providers-accounts.md says all this.
Tests (internal/catalog/spelling_test.go, a fixture from models.dev's
rows for these ids, no network)
- TestOtherSpellingLimits: the report's literal ids
(kimi-k3-1-pro-261024, volcengine/…, Kimi-K3.1-Pro-20261024) and
twelve near misses; levels; Knows vs KnowsAsWritten; no name.
- TestOtherSpellingIsNotPriced: no provider prices the dated id, and the
plan's price isn't taken for pay-as-you-go's id.
- TestDecorateOtherSpelling: the vendor's 200000 stays, the reply limit,
levels and name are filled, no price; a -max id and kimi-k3 vs
kimi-k3.1-pro are kept apart; ListedBy likewise.
- TestSameModelReportIDs.
- stats_test: a dated id models.dev knows only under another spelling is
sent as "other".
Red on the old code (catalog.go and live.go reverted, KnowsAsWritten
stubbed): TestOtherSpellingLimits "ContextOf("kimi-k3-1-pro-261024") = 0,
want 1048576" and the rest; TestDecorateOtherSpelling Output 0, ListedBy
false.
Broken by hand
- The majority vote inverted: Venice's spelling wins, and the test asks
for 1048576 and gets 1000000/131072. Red.
- KnowsAsWritten taking other spellings: TestOtherSpellingLimits red.
- stats reading Knows: "deepseek/DeepSeek_V4-260101", want
"deepseek/other". Red.
Real catalog (models.dev cache on the WSL box, a throwaway test since
deleted): kimi-k3-1-pro-261024 gets 1048576/1048576 and levels
low,high,max, is not priced by volcengine, and isn't KnowsAsWritten;
kimi-k3-1-pro-max-261024 gets 0; Decorate of glm-5-3-flash-260828
against volcengine-coding-plan gets 1000000/131072 and the name
GLM-5.3-Flash with no price; claude-opus-5-5-20260801 gets
1000000/128000; gpt-4o-2024-08-06 is unchanged.
Run
- Full suite on the Linux box (wsl-run, Go 1.26.8) at 242e5c68d on base
|
||
|
|
1801c96bfb |
warm-up: Warm up now sends one account its warm-up at once (Codex and Claude)
A Windows user on Discord asked for a manual warm-up of a Codex account.
Settings > Warm-up and check-in now ends both the ChatGPT and the Claude
tab with a "Warm up now" row. Its text button sends the account's warm-up
right away. With one account it sends straight off. With several it opens
the app menu ("Warm up which account"), not a select. The row then says
"Warmed up {who} {when}", or "Couldn't warm up {who}: {why}" in red, and
the status line says the same.
What is sent: provider.WarmNow(agent, user) sends the scheduled warm-up's
own request to that one account and to no other. For Codex that is
warmCodexLogin; for Claude it is warmClaudeLogin over the gateway's
warmClaude (Claude Code's run in that account's config directory), set
through WarmClaudeVia. It works whether the warm-ups are on or off. An
account whose sign-in lapsed is refused with the reason. Afterwards the
allowance is read again (StaleAllowance / claudeWarmedNow), as after a
scheduled warm-up. The schedule's file is left to the schedule. The
Codex prompt, identity and base_instructions are unchanged: it is the
same body. The route is POST /api/warm-now, and /api/settings carries
claudeUsers beside codexUsers.
Claude gets the item too. It shares the warm-up engine and the same tab,
and the send is the same warmClaude the schedule uses.
No size budget was raised.
Run:
- WSL (wsl-run), Chromium and WebKit, with the GUI test
warm-now.test.cjs in en/zh/zh-TW/ja/de at 900px and 440px: 22/22.
The pressed button stays in place within 1px after two frames.
- WSL, the related files (warm-now, warm-at-own, warm-at-times,
warm-reset-asleep, settings-groups, settings-search, i18n-keys):
102/102.
- WSL, the other files that touch these lists (checkin-account,
checkin-reason, checkin-reason-once, plugin-checkin, segs-press-redraw,
settings-sections, usage-checkin): 169/170. The red is segs-press-redraw
"webkit ja 440px: every Settings option..." with "could not bring the
option into view" after 103s under load. It passed 3/3 alone and is
filed as #4189.
- mote (macOS) at the final tree: go vet for internal/gui, provider and
gateway; go test -run 'WarmNow|Budget|Warm' ./internal/gui
./internal/provider: ok. An earlier mote run, before the route move,
ran go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
vet ./..., go build ./... and the budget tests: ok.
- Windows (win-run): go test -run 'TestWarmNow|TestCodexWarm|TestClaudeWarm'
./internal/provider/ ./internal/gui/: ok.
- WSL: go vet -tags nogui ./... is ok and gofmt -l is empty.
go test -tags nogui -timeout 45m ./...: 75 packages ok, including
internal/gui and internal/provider. internal/agent has 4 reds on the WSL
box (TestInstalledVersion, TestGrokInstalled,
TestCursorFolderFromTheEditorIsNotTheCLI, TestOmpDetectedWithPiDir). They
are already filed as #4033 and #3548 (fake binaries hit WSL interop).
internal/gateway has 1 red, TestUnroutedRequestShownThenAnswered: giveUp
answers the 504 before it marks the route done. That is not this change,
and it is filed as #4200.
At the head rebased on origin/main
|
||
|
|
9474eaf9cb |
sessions: Raft's Pi agents' sessions are listed as Raft's, with their prompts, calls and delete
Raft (slock's raft-computer) runs its agents on Pi and keeps each one's Pi SDK session files in that agent's folder: <slock>/agents/<id>/ .pi-sessions/<ts>_<id>.jsonl, or .builtin-sessions/ for its built-in runtime. <slock> is $SLOCK_HOME or ~/.slock (%USERPROFILE%\.slock on Windows, the distro's ~/.slock under WSL). Read from raft-computer 1.0.14's PiDriver (buildPiSessionDir), BuiltInDriver and resolveSlockHome, and a read-only listing of ~/.slock here. runtime-sessions/ holds handoff notes, no sessions, and is not read. - The Sessions page lists them as Raft's (agent "raft", in agent.Clients' others), titled and opened with their prompts as Pi's are. - Their calls count on the Usage page as Raft's; calls through magpie stay the gateway's, as Pi's do. - Raft's Pi uses the user's own ~/.pi/agent, so a request it sends through magpie reaches the gateway as Pi's under the same session id. sessions.GatewayKeys gives a Raft session both "raft|ID" and "pi|ID", so the gateway's copy is not listed twice nor counted twice (Merge, stats, NativeIDs, the GUI's Via). - Delete and restore work as Pi's: the one file goes to the trash, and a folder beside it is left (the agent's workspace is not the session's). A session written in the last minutes is refused as active. - No resume command, no carry and no trace export: Raft starts its own agents, and nothing outside it can resume one. - SLOCK_HOME is passed through agentenv like the other agents' homes. Run (at 958ad9f10 on |
||
|
|
5d24bc6ccd |
gateway: every thinking block a Messages client gets says its signature (Grok Build on MiniMax)
uk.jent (Discord): Grok Build on minimax-code-global/MiniMax-M3.1-Flash
showed "Couldn't read the response: serialization error: missing field
`signature`". Grok Build (grok 1.0.67, Rust/serde) reads a Messages
thinking block as ContentBlock::Thinking {thinking, signature}, both
required, so one block without the field fails the whole reply.
Cause, two routes:
- Relayed: MiniMax's Anthropic-compatible endpoint writes thinking blocks
with no signature (its docs name only type/thinking/thinking_delta), and
passthrough gave them to the client as they came.
- Translated: anthropicEncoder.thinking opened the block with no
signature (renderAnthropic and whole_stream.go already wrote one).
Fix:
- anthropicEncoder starts a thinking block {"thinking":"","signature":""},
as Anthropic's own stream does.
- sigFieldTidy (thinking_signature.go), chained in passthrough for the
Anthropic protocol, gives a relayed thinking block with no signature (or
a null one) an empty string: a stream's content_block_start line or a
whole reply's content[]. A signed block goes byte for byte;
redacted_thinking is untouched. magpie never makes up a signature: an
empty one is no signature to anthropicBody, which leaves the block out
for Anthropic and keeps only its text where reasoning is replayed.
- docs/subsystems/gateway-routing.md says the rule.
Fixtures are built from MiniMax's documented shape, not real bytes: there
is no MiniMax Code account here.
Run (mote, at this rebased head on origin/main
|
||
|
|
046093bf7b |
gateway: a plugin's try with another candidate after it is told so, and gives way to a queue (#4049)
axuhere on X: on free models a request sat behind "模型请求正在排队 · 预计等待超过 10 分钟" with other providers configured for the same model, and asked for magpie to move on to the next provider and say why. |
||
|
|
34b2dd9b70 |
gateway: a used-up Codex sign-in, the one account, is heard on its relayed turns and served without a restart
unsplashz on Discord: Codex beside its ChatGPT sign-in, one Codex account in magpie. When the account ran out, Codex couldn't send until it was restarted, after which its turns went through magpie. Cause. With Codex's sign-in the only account on, an own-model turn is relayed to ChatGPT as Codex sent it (codexUpstreamOn, no account). That path never kept the reply's x-codex-* / codex.rate_limits windows (heardCodexLimits) and never asked for the account to be read again on a usage_limit_reached refusal (codexMayBeUsedUp). Only turns served through magpie's accounts did. So magpie learned the account was out at the next look, one to five minutes on, and until then wrote no codex.out and left the Codex app's app-server alone, its Send greyed. A Codex started before codex.out also kept sending own-model turns to its built-in provider, each relayed to the same refusal, until it was restarted. Fix. - codexUpstreamOn: for a /responses relay on magpie's ChatGPT account (codexRelayedAccount: the account signed with, or Codex's sign-in when the request's chatgpt-account-id names it), the reply's windows are heard, and a quota refusal calls codexMayBeUsedUp. codexServed now uses the same lookup. - codexAccounts: while the sign-in is known out (CodexUsedUpKnown, the cached reading only) and the request signs as it, an own-model turn goes through routing as codex/<model>, as a restarted Codex's does. Another sign-in (a Codex in WSL) still goes as it came. Run: - go test ./internal/gateway -run 'TestCodexUsedUp|TestCodexRelayedWindowsHeard|TestCodexHeldSignInServedWithoutRestart|TestCodexOwnModel|TestCodexPaused|OneAccount' (mote): ok. - GOOS=darwin/linux/windows go vet ./internal/gateway (mote): clean. gofmt -l: clean. - go test ./... -timeout 45m -count=1 at 25fbbd03e on the Linux VM (wsl-run, mote had another session's full suite): 73 ok, internal/gateway ok (738s). Reds: ., internal/cli and internal/gui don't build there (no gtk4/webkitgtk-6.0 dev packages); internal/agent TestInstalledVersion, TestGrokInstalled, TestOmpDetectedWithPiDir, TestZedAppPath, all #4033 (and #3548). The first three are red the same on origin/main |
||
|
|
be8b0f3816 |
gateway: a decision model's tries share the one classifier wait
Settings says the Classifier timeout is "how long the classifier is given to answer, its provider's failover included". askDecideTries gave each key, account or decision-group member a fresh classifyTimeout of its own (askJev made its own context), so a decision provider whose keys didn't answer held the turn one whole wait per try before its route began: 3 keys at the 60s maximum is 3m, past the 2m unrouted limit that stops a request with a 504. Found while looking for what held Jason's Codex request for 2m (Discord, #general). Whether his setup has a decision model is not known, so this is one possible cause, not the confirmed one. Now askDecideTries makes one context of classifyTimeout for all its tries, and askJev asks within it. Once a try spends the wait, the rest are neither asked nor rested. The chat-model classifier (askChat) already had one wait, failover included, through s.serve. TestDecisionTriesShareTheClassifierWait: a decision provider of three keys that never answer, the 8s default at 25ms a second. It wants the error "no answer in 200ms" with only the first key asked. Broken by hand (a fresh wait per try, the stop removed): red, "asked [w1 w2 w3] in one classifier's wait, want the first key alone". Fixed: green. Run: - mote: go test ./internal/gateway -run 'Decision|Decide|Jev|Classif|SystemOne|Unrouted|Held': ok (63s). - Full suite: go test ./... -timeout 45m -count=1 on the Windows box at this commit (mote was unreachable), still running at push; owner rule: ship at once, any new red filed afterwards. Not tried: a real decision provider with several keys. |
||
|
|
29185e3bbc |
gateway: a request held too long before routing leaves a report its user can copy
Jason on Discord (#general, v0.1.1995, AirbuildEnvironment over Codex's
/backend-api/codex/responses) got the 2m 504: "magpie held this request
for 2m0s without routing it to any provider ... report it with magpie's
log". The desktop app runs the gateway in-process and logs only to
stderr, so there is no log for him to send.
giveUp now writes a report of the held request to a small file in
magpie's cache (held/, folder 0700, temp file renamed into place, the
newest 5 kept). It holds the time, version, OS, the method and path, the
model and agent, how long it was held, each named wait with its time and
whether it was still under way (noteWait now takes a kind: body, body
room, decision model, image description, plugin hooks, JS middleware,
Codex reset, masking), the body room's state, the requests in flight,
and a goroutine profile (function names and lines only, cut at 128KB).
It holds no body and no headers. Route.Held names the file. On the
Routing page, the request's story then says a report was saved, with
Copy Report and Open Folder (Open Folder is left out in magpie web).
GET /api/gateway/held/{name} reads only a report's own name. The 504's
text no longer points to a log: it names Copy Report on the Routing page
and the folder. The log line names the waits too. i18n is in zh, zh-TW,
ja and de, and docs/subsystems/gateway-routing.md has the section.
What held Jason's request is not known from what he sent. The waits that
count before routing are: the body arriving (idle deadline only), body
room (up to 100s, then 503), the decision model (see the next commit),
plugin hooks (11s), JS middleware (250ms a hook), image description
(bounded by the request) and the Codex reset (20s). Slots, RPM and
upstream come after the route begins. A WebSocket upgrade gets a 426.
The report names the wait, so the next one says which.
Run:
- mote, at 57b21abd9 before the rebase: go test ./internal/gateway
-run 'Unrouted|Held|...' passed. The full go test ./... -timeout 45m
was cut off when mote dropped off the network (2 packages ok). The
full suite then went to the Windows box (see the next commit).
- xiaomi-gpu (Windows), node --test: routing-held-report 50/50 in
chromium and webkit, 5 languages, 1100/420px, app and web.
routing-held-request and i18n-keys pass. All routing-* and i18n*:
1742 tests, 94 reds, none in i18n*. The same files are red alone at
origin/main
|
||
|
|
6915c8cdea |
agents: a model list's button says its ticks: all, one or two by name, or how many of how many (NG_shiyu on X)
NG_shiyu on X: the closed model field reads 「路由组,模型+数字」 on one row and just 「路由」 on another, while the menu opened shows every model either way. Why: two different controls stand in that place. An agent whose own model menu is the list picked here (ZCode, Claude Desktop, Cursor Private Inference, WorkBuddy, T3 Code, ...: listsMenu) has a multi-select list, and menuSaid named its first two ticked models and "+N". Routing groups are listed first, so with every model on it read "Never stuck, DeepSeek Pro +2": like a pick of one group and one model. Every other agent's start picker names the one model or group it starts on, e.g. a group named 路由. Neither said "all". Decided: the list's button (and the panel row's words) says what its ticks are, as the open checklist shows them and as the Models entry already words it (fillModelsEntry): - every model ticked: "All N models"; - one or two ticked: their names (蓝猫's few-picked case, |
||
|
|
317aa54d9c |
agents: a click anywhere on a connected agent's row opens or closes it (NG_shiyu on X)
NG_shiyu, new from CC Switch: on the Agents page the space between a
row's name and its model did nothing; only the small "Models {n}" link
with its arrow opened the row, which is a long way to aim on a large
screen. A disclosure row on the Mac opens on a click anywhere on it,
and the panel's rows already did.
connectRow now hands a click on a connected row to that link
(expandLink), so the link stays the one control the keyboard and a
screen reader use, with its aria-expanded. Buttons, links, inputs,
labels, anything with a role (the start picker, the switch), the grip
(still hover-only) and the opened sheet (.ag-exp) keep their own
clicks, and a click that ends a text selection does nothing. An
unwired row has nothing to open and is unchanged.
Run:
- agent-row-disclose.test.cjs (new): window at 1100px and 560px, en
zh zh-TW ja de, Chromium and WebKit: 20/20 pass. It clicks the empty
gap between the name and the link, checks aria-expanded follows, that
a click inside the sheet keeps it open, the name and the link toggle
it, Enter on the link toggles it, the picker opens #pop.model-picker,
the grip .pop.row-menu and the switch its #modal ask without opening
the row, the scroll position is unchanged, no overflow, no page
errors. On the old app.js it fails ("the row didn't open", webkit en
1100).
- click-scroll, agent-expand-steady, zcode-models, cursor-local-models,
desktop-model-menu, agent-menu-label, i18n-keys, both engines: all
pass except i18n-keys' "a plugin's words are its own" ("Runs as" in
plugins/library/i18n.js vs internal/cli/claude_code_cli.go), which
this change doesn't touch (#3897).
All of the above ran at base
|
||
|
|
f594b452e3 |
sessions: a Claude fork after a compaction is a branch under its session, read from the start
neo_o11 (Discord, after v0.1.1809): one conversation still showed as ~9
rows with the same title, and opening one showed "Session start" and a
single turn.
Cause, reproduced with real Claude Code 2.1.312 in a sandbox
CLAUDE_CONFIG_DIR: the reporter's session was compacted, then forked
several times (headless --fork-session per task, or /branch). Each fork
starts at the compact boundary and summary, and copies the session's
last reply under the same uuid. So every fork holds the original's
Leaf, and ccCopies hid the original as a fork's copy, though it alone
holds the conversation before the compaction. Each fork had a Leaf of
its own and stayed a row, with the copied title. Opening a fork read
its own file: the summary and one turn.
Fix:
- cc_copies.go: ccFamily returns copies and branches. A file is a
copy of another only when that one holds its Leaf and its Root too,
so a file with what came before the other's start is never hidden.
The members of a family left visible pick a head (holds the other's
Root, then named in the other's forkedFrom, then the earlier start,
then the lower key); the rest are branches of it.
- sessions.go, manage.go: a branch has role "branch" and
parent_session = its head, in List, Find/get and ListAgent.
- transcript.go: a branch's transcript is its head up to the fork
point (the last line of the head holding one of the branch's
uuids), then the branch's own lines. Search still reads its file.
- stats.go: a branch counts only its own lines, so tokens are not
counted twice.
- GUI sessions plugin: the fold under a session names branches apart
("2 branches · 1 subagent"), in en/zh/zh-TW/ja/de.
- Fixtures in testdata/claude-forks/tasks*.jsonl are trimmed from real
2.1.312 output: a session compacted once, two --fork-session task
forks and a /branch copy with forkedFrom.
- docs/subsystems/gateway-sessions.md: copies and branches.
Run:
- go test ./internal/sessions -run 'TestClaude|TestQoder|TestMergeExternal'
on mote, at
|
||
|
|
033b17bafe |
library: every skill named in another script is listed, under its folder's name
|
||
|
|
4db65681c1 |
library: a skill named in another script goes by its folder's name, so every one is listed
tnt1223 on Discord: Library › Skills listed 16 skills for https://github.com/asdfgh1445/ctf-super-hub, which has 35 (one folder each at the top, 35 SKILL.md in its recursive tree, not truncated). Cause: the listing found all 35, but nameFor made each SKILL.md's `name` fit for a file name by dropping everything outside ASCII. "CTF•密码学" and ten more became "CTF", "Strix•RCE 测试" and nine more "Strix", "头脑风暴" nothing, and unhiddenFirst lists skills of the same name once, so 35 became 16. Not a depth limit, cap, pagination or truncated tree: the probe downloads the tarball and walks it; a truncated tree and GitHub's rate limit are already said (skilltree.go, fetch). Fix: a declared name that would lose a letter or digit (another script) or comes out empty goes by its folder's name, which a repository keeps apart. An ASCII name goes as before ("My Skill" is still My-Skill), so a skill installed from one is still the library's. A skill at a repository's top now falls back to the repository's name (srcFolder), not the temporary download folder; candidates takes that name from each caller (probe, Group again, CC Switch origin, new-skill check). Tests: TestSkillsNamedInAnotherScriptAllListed probes and installs from a fake of the repository built from its real tree (35 folders, front matter names as written at 7715719); TestSkillNameFallsBackToFolderOnlyWhenLettersAreLost and TestSkillAtTheTopNamedInAnotherScript cover the rule and the top folder. No network. Run: - mote: go vet ./internal/library; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/library; gofmt -l internal docs (empty); go test ./internal/library -run 'TestSkillsNamedInAnotherScript| TestSkillNameFallsBack|TestSkillAtTheTop|TestRepoWithAPlugin|Probe| CCSwitch|Regroup|NewSkill|From' -count=1: ok. - wsl-run (magpie-desktop): go test -tags nogui ./internal/library -timeout 45m -count=1: ok 94.9s. - Live, sandbox HOME (the package's TestMain/testenv), a throwaway test calling ProbeSkills("https://github.com/asdfgh1445/ctf-super-hub") against the real GitHub: 35 candidates, each named by its folder, nothing left out. Not committed. Broken by hand: nameFor using the declared name whenever it isn't empty (the old rule): TestSkillsNamedInAnotherScriptAllListed lists 16 with names CTF/Strix/..., and the rule test fails on "CTF•密码学" and "Café notes". Restored, green. Not tried: the full ./... suite (mote at load ~350 from other runs; only internal/library changed); the GUI suite (no app.js change); Windows test run; installing the real repository's skills into a real agent. Not changed: two different skills declaring the same ASCII name in folders of different names are still listed once, as copies of one skill are (unhiddenFirst). |
||
|
|
5eab14a8cc |
plugin pages: magpie web reaches a page's local service on its own address, so the chat page works from another computer
aigcfree (Discord DM) runs `magpie web --addr 0.0.0.0:3430` on an Ubuntu
server behind nginx and opens it from a Windows PC. Plugins -> 对话
(@magpie-community/page-chat) showed "127.0.0.1 refused to connect": the
page sends its frame to the chat server on 127.0.0.1, which in that
browser is the Windows PC.
A plugin now declares its page's service (package.json
magpie.page.service {port, option}: the port, or the plugin option that
holds it, from its plugins.json options; plugin.ServiceSpec). Served to a
browser (isWeb), /api/plugin-pages gives the page `service`:
_magpie/service/ under its token, and the bridge hands the frame
magpie.service as an absolute address. The desktop window and slot pages
get none, and the routes answer 404 there, so the local path is as before.
servePageService reverse-proxies /_magpie/plugin/<token>/_magpie/service/…
to 127.0.0.1:<port>. The service stays on loopback. The way in is the
page's own: the per-run token that only a signed-in /api hands out,
behind AllowGuard. Nothing is weakened:
- Host is set to 127.0.0.1:<port>, which the service's rebinding check
wants.
- The window's cookie is taken off.
- Origin must be absent or null (403 otherwise).
- Set-Cookie is dropped.
- Every reply is sandboxed (sandbox allow-scripts; frame-ancestors
'self'), with Referrer-Policy no-referrer and nosniff.
- The gateway's own port is never served, since a request from this
server is loopback and the gateway takes that without a key.
- Event streams flush as they come (FlushInterval -1, X-Accel-Buffering:
no for nginx). webCompressed no longer gzips text/event-stream, which
held a stream back until gzip's buffer filled.
- A redirect to the service's own address is made relative.
- The entry starts the plugin host as the page's HTML does (pageHost).
- A service not up yet answers its frame with a 502 page that tries
again in 2s.
page-chat 0.1.2 (magpie-community/plugins 4a46212, on dist) declares the
service, goes to magpie.service when given one (else 0.1.1's path:
127.0.0.1 on loopback, the SSH-tunnel note from elsewhere), and asks
api/… by relative address.
Docs: plugin-runtime.md P4 (the page row), gui-shell.md (no gzip for event
streams).
Tests: TestPluginPageServiceListedToBrowserOnly, TestPluginPageServiceSpec,
TestPluginPageServiceProxied (through webHandler: Host, cookie, Set-Cookie,
CSP, escaped path and query, foreign Origin 403, made-up token 404,
redirects, SSE first event before the end and not gzipped),
TestPluginPageServiceDown, TestServiceLocation; plugin-page.test.cjs
checks magpie.service in a browser page and its absence in a slot.
Run at 276683d85, this change on origin/main
|
||
|
|
e61e10535d |
privacy: AstrLink Guard reads several requests at once, on 4 cores between them
yyhhyyyyyy (Discord, 10-28) saw an agent's parallel requests queue behind
Guard's one turn and asked for a concurrency setting (16). The turn now has
guard.Cores() places (half GOMAXPROCS, 4 at most). The cores are shared: a
process-wide pool of Cores() tokens, each window takes one before it reads
and more only while they are free (guard.take), so requests together never
use more cores than one did (the 4-core cap of 10-28, xinvxueyuan and
shensmart). The model loads once (guardLoading), the idle unload waits for
every place (guardIdle), and a text one request is reading another waits
for instead of reading it too (backend.reading). On CoreML windows are read
one at a time; only windows under coremlMin or after a failure take CPU
tokens.
No setting: measured, the bound is cores, not the request count.
Bench (zz bench, not committed): requests/s at 1/2/4/8 concurrent.
- Linux (WSL magpie-desktop, Ryzen AI Max+ 395, Cores()=4):
512 B shared 4.2/6.1/8.1/8.4 on 1.9-3.9 cores, rss ~150 MB
one turn (before) 4.2 whatever came
unshared 4.4/8.8/14.1/20.4, on 12 cores at 8
4 KB shared 0.6/0.5/0.6/0.7 (one 4 KB already reads 3 windows on 3.6 cores)
unshared 0.6/1.1/1.7/2.2, 20 cores and 521 MB at 8
- Windows (xiaomi-gpu, same box, busy with other runs):
512 B shared 7.5/9.2/11.3/12.1 on <=3.8 cores; unshared 5.1/9.6/15.9/24.1 on 13 cores
4 KB shared 0.7/0.8/0.8/0.8; unshared 0.9/1.2/1.8/2.4, 18 cores, 519 MB
- mote (M5 Pro, load 25-45): CoreML 4 KB 23.0/19.6/25.1/24.9, a model a
worker 15.7/25.6/25.5/23.4, rss ~190 MB flat: the GPU is the bound.
CPU unshared 4 KB at 8: 953 MB.
Tests: turns_test.go (TestGuardReadsRequestsAtOnce, TestGuardIdleWaitsForEveryTurn,
TestOneTextReadOnceAtOnce), guard/cores_test.go (TestTakeHoldsOnlyWhatIsFree,
TestFindsAtOnceReadAsOneAtATime: concurrent finds equal serial ones).
Broken by hand, each red: one turn ("1 turns, 4 cores"), no load lock
("4 loads"), idle taking one place ("let go while a request read it"), no
in-flight check (TestOneTextReadOnceAtOnce), take waiting for more (10s
timeout fail).
Run:
- wsl-run: go test ./internal/pii/... ok; -race -count=3 ./internal/pii ok;
-race guard TakeHolds/FindsAtOnce ok.
- mote-run: gofmt -l internal clean; GOOS=darwin/linux/windows go vet
./internal/pii/... ./internal/masking/ ok; MAGPIE_GUARD_DIR=real model
go test ./internal/pii/... ./internal/masking/ ok (CoreML).
- win-run: go test ./internal/pii/... ./internal/masking/ with the real model ok.
- mote-run full go test -timeout 45m ./... of this and the commit before
(at
|
||
|
|
1b7a087565 |
privacy: Settings names what reads AstrLink Guard, CoreML on its device or the CPU
yyhhyyyyyy (Discord, 10-27) saw Settings say "On, on the CPU" while Guard
read through CoreML. The status now names the backend in use: CoreML on the
device most of the compiled program's estimated cost is on, read from
CoreML's own compute plan (MLComputePlan, macOS 14.4+; coreml.Plan,
coreml.Most, Model.Device), or the CPU, and after a CoreML read fails the
CPU with why (guard.Backend, mlFail; Status.Via, Device, GPUError; pmSub in
app.js, 5 words in zh, zh-TW, ja and de).
On mote (M5 Pro, macOS 27) the plan reads Neural Engine 0.000, GPU 1.000,
CPU 0.000, so Settings says "On, with CoreML on the GPU".
No budget raised: on main after #4133 moved Web search's rows out, app.js
is 1,294,410 bytes with this change, under its 1,311,735.
Tests: coreml/plan_test.go TestMost; guard/coreml_test.go TestBackend,
TestFailedCoreMLReadIsSaid, TestCoreMLPlanNamesADevice (real model);
astrlink_test.go TestGuardNowNamesItsBackend; privacy-model.test.cjs
"AstrLink Guard says what runs it".
Run:
- mote-run: gofmt -l internal clean; GOOS=darwin/linux/windows go vet
./internal/pii/... ok; MAGPIE_GUARD_DIR=real model go test
./internal/pii/... ok; go test -run Budget ./internal/gui ok (again after the rebase
onto
|
||
|
|
3870ddf0a2 |
Revert "plugin pages: magpie web forwards a page's local service under the page's address"
This reverts commit
|
||
|
|
181fd0a682 |
plugin pages: magpie web forwards a page's local service under the page's address
A page whose plugin runs a service on 127.0.0.1 (the community chat page) sent its frame there, which works only in a browser on magpie's machine: opened from another computer through magpie web it was refused (Discord DM: AIGCFREE). magpie.page.service names the port (or the option holding it); /_magpie/plugin/<token>/_service/ forwards to it with the page token as the key, without magpie's cookies, and the bridge tells the page (magpie.service). |
||
|
|
d5eac64f23 |
sessions: a deleted Codex session leaves the Codex app's list too
zhuddan (Discord, Codex app 26.1023): a Codex conversation deleted in magpie went on showing in the Codex app. The app lists threads from its own catalog, <CODEX_HOME>/sqlite/codex.db (codex-dev.db for a non-prod build), table local_thread_catalog, and drops a row only on the app-server's thread/deleted or thread/archived. After its first full sweep it takes in only threads newer than its watermark, so a row of a thread whose rollout magpie moved to its trash stayed. Delete now does what the app does on thread/deleted: the local host's rows of threads whose rollout is gone from that Codex folder's sessions and archived_sessions (as Codex's state database names them; neither the file nor its packed twin there, and a file that can't be looked at counts as there) are deleted and catalog_revision raised, in one BEGIN IMMEDIATE transaction that waits for the app's own. The rows go into the trash note (codex_catalog) and Restore puts them back, since the app wouldn't take in a thread that old by itself. /api/sessions/manage does the same once a run (TidyCodexCatalog) for threads deleted before this release. Run (Windows, win-run, go1.26.8): - go test -count=1 -v -timeout 25m ./internal/sessions/: 339 PASS, including TestDeleteForgetsCodexAppCatalog, TestTidyCodexCatalogForgetsEarlierDeletes and TestTidyCodexCatalogKeepsWhatItCantJudge. Red: TestAgySessions, TestAgyRowOnly (#4115), TestOneListing and TestShareListing hanging the package (#4114). The same four are red at origin/main |
||
|
|
bc247a8cc4 |
sessions: the Sessions page answers before a first read of a long history
hey_boyce on X: "会话tab等的时间有点长", the page standing on its skeleton rows on its first open. /api/sessions/manage read every file it had no usable parse of whole before answering: the agent shown, and every agent with a gateway session for its ids (Codex's 52 GB too while Claude Code's page was shown). That is every file after a first start, a cacheVersion bump, or a Claude Code or Codex file whose kept parse can't be read on after a restart. |
||
|
|
3959192e94 |
gui: Settings' web search rows move out of app.js to plugins/search/settings.js (#4133)
TestCoreScriptBudget was red on main: the context map's tile wording ( |
||
|
|
0ee31d4736 |
gui: Routing and Usage keep the reader's place when wheeled as they open, heard late or never (issennknight)
issennknight on Discord (macOS 13.7.8, v0.1.1902), after |
||
|
|
c3462d5fe8 |
gateway: a held stream gets its 200 after 3s, and a comment every 5s, so a proxy's 10s header cut no longer ends it 499
mrten_95615 (Discord, Windows): Codex through magpie to a relay ended 499
about 10s in once a turn's first token took longer than that. It happened
with a Clash-style app in system-proxy mode, not in TUN mode.
Cause:
- Codex (reqwest, hyper-util Matcher::from_system) sends its request for
127.0.0.1 through the Windows system proxy. ProxyOverride is read only as
IPs/CIDRs, so "127.*;localhost;<local>" doesn't keep it off. This was
checked on xiaomi-gpu with Codex 0.165.0: mihomo logged 127.0.0.1:18431
through the proxy.
- magpie held a stream's headers for up to holdLongest (15s) before
keepAlive sent the 200 and its first `: keepalive`. A proxy that stops
waiting for response headers after about 10s cut the request first, and
Codex's context ended, which shows as 499.
Fix: keepHeldAfter is 3s, not 15s. Once the 200 is out, keepHeldEvery
(5s) is the most a held stream goes without a comment. Another candidate
can still answer in the same stream, and a failure before 3s is still a
status with its Retry-After. gateway-routing.md is updated.
Run:
- TestHeldStreamHeardBeforeAProxyCuts (new) is red on the old code with
"headers 200 after 15.004s" and green after. It is green on mote together
with the keepalive, queue and held tests (-run
'TestHeldStreamHeardBeforeAProxyCuts|TestSilentHeld|Queue|Keepalive|KeptAlive|Held',
ok 68.6s).
- End to end on xiaomi-gpu (Windows 11): Codex 0.165.0 goes through the
system proxy, which is a Go proxy that cuts after 10s without headers,
then magpie serve in a sandbox HOME, then a relay that holds its headers
for 15s.
- Old build: the proxy logged "CUT after 10.001s" on every try, the relay
logged "client gone after ~10s", and Codex kept "Reconnecting... n/5".
- New build: "headers 200 after 3.005s", then done at 15.0s, and Codex
printed pong (exit 0).
- The registry proxy settings were restored afterwards (ProxyEnable 0, no
server or override), and none of the test processes were left running.
- On mote: gofmt -l is clean, and GOOS=windows/linux go vet -tags nogui
./internal/gateway/ is ok.
- On mote: go test -tags nogui -count=1 -timeout 45m ./... is ok except
internal/gui TestCoreScriptBudget (1531531 > 1530861). That is red on
main already, filed as #4133, and is not touched here.
Not tried:
- The reporter's own proxy app. mihomo's HTTP inbound doesn't cut by
default, so which part of their setup cuts at 10s isn't known.
- A proxy that cuts on idle bytes rather than headers, end to end. Only the
test's gap check covers the 5s cadence.
- Why turning the system proxy off didn't help until the app quit.
|
||
|
|
f02390544d |
edit: a JSONC delete takes the last member's trailing comma, so the MCP hub never leaves OpenCode's mcp as {,}
chenxiang0010 (Discord #general, Windows): turning the Library's MCP hub on
for OpenCode and off again left a comma at the end of opencode.jsonc's
"mcp", and OpenCode said "opencode.jsonc: invalid"; deleting the comma by
hand fixed it, and a second try didn't reproduce.
Cause: delJSONBytes looked for the deleted member's trailing comma in the
tidwall/jsonc copy, which blanks every comma before a closing bracket.
So when the member was the last one and had a trailing comma (as OpenCode,
editors and users allow), the comma was left behind; when it was the only
member, it was left with nothing before it: "mcp": {\n,\n}. The hub sync
then inserted the magpie entry in front of it ("magpie": {...},\n,) — a
double comma. OpenCode parses with jsonc-parser allowTrailingComma
(packages/opencode/src/config/parse.ts at v1.19.5, packages/core/src/config.ts
on dev): a trailing comma after a value is fine, a lone one is an error.
magpie's own validity check went through the same tidwall copy, so it
passed the broken file. Once the comma was deleted by hand there was no
trailing comma left, which is why it didn't happen again.
- delJSONBytes takes the last member's own trailing comma (nextToken, as
delItem already did for arrays), and its line with trailing blanks.
- insertKey adds no comma after the first member of an object that holds
comments only (it used to, leaving a trailing comma only some apps read).
- edit.ValidJSONC reads JSONC as jsonc-parser with allowTrailingComma does.
SetJSON, DelJSON, PatchJSON, SetJSONItem and DelJSONItem refuse an edit
that would turn a file the app reads into one it can't (checkJSONC):
nothing is written, and the error names the file.
- A lone comma an older magpie left is dropped by the next object edit of
that file (dropLoneCommas), so users already hit are mended by the next
sync that writes it. A file nothing writes again keeps it until then.
Every JSON/JSONC object writer goes through SetJSON/DelJSON/PatchJSON
(library MCP for OpenCode, Zed, VS Code, Claude, etc., agent wiring for
DevEco, MiMo Code, OpenCode, ...), so all of them get it.
Tests (red on the old json.go/jsonarray.go, put back by hand, green now):
- TestHubToggleLeavesValidJSONC: 12 file shapes (LF, CRLF, tabs, compact,
trailing commas, comment-only, comment after, comma after a comment) x 7
add/delete orders; old code: invalid in the trailing-comma and
comment-only shapes.
- TestDelOnlyMemberTakesItsTrailingComma, TestInsertIntoCommentOnly-
ObjectNoTrailingComma, TestLoneCommaMendedOnNextEdit: red on old code.
- TestValidJSONC, TestInvalidEditNotWritten.
- internal/library TestHubToggleKeepsOpenCodeJSONCValid: the real
SetMCPHub on/off twice for OpenCode, LF and CRLF; old code: invalid at
the first "hub on" ("magpie": {...},\n,\n}).
|
||
|
|
628ac36fc9 |
agents: Add magpie says when nothing here opens the app's import link (sungt)
sungt (Discord #feedback, Windows, magpie 0.1.1976, Cindy 0.1.119, Cindy
open): on the Agents page Cindy's 添加 magpie "spins, no response".
What magpie got wrong: Cindy, AionUi and Lody take magpie only through
their import link, which magpie hands to rundll32 / open / xdg-open and
never waits on. A link nothing opens did nothing, the button never awaited
/api/open nor caught its error, and `magpie cindy add` printed "opened"
whatever happened.
- agent.OpenAppLink asks the system, without opening anything, whether
something opens the link's scheme: Windows' HKCR\<scheme> (what
Electron's setAsDefaultProtocolClient writes) and then the user's
UrlAssociations UserChoice; macOS Launch Services (cgo builds); Linux
`xdg-mime query default`. Only "none", or a registered program whose
full path is gone, refuses the link (NoLinkHandlerError); anything
unknown hands it over as before.
- /api/open (Cindy, AionUi, Lody after OpenLody) answers
code no_link_handler with app, exe and said, an i18n.js key from
linkSaid that api() puts through t() as it does bunSaid's.
- The import button now waits for /api/open and shows the result: "Sent
to {name}: confirm adding magpie there", or the reason in the
reader's language.
- The CLI's add returns the same error.
This is not verified as sungt's cause. Cindy was open, and Cindy
registers cindy:// at every start, so the check most likely passes on
their machine. If so, the spinner is Cindy's own import dialog
(previewProviderImport / fetching magpie's /v1/models). Cindy 0.1.119
wasn't available here. We still need Cindy's log around "received deep
link" from sungt.
Run (worktree at origin/main
|
||
|
|
eee8ea027b |
docs: why magpie writes OpenCode's provider, not 2.x's providers
chenxiang0010 (Discord #general) asked why opencode.json still gets `provider` rather than OpenCode 2's `providers`. Nothing changes in code: `provider` is the one key both OpenCode lines read. - OpenCode 2.2.0 migrates `provider` in memory (migrateProviders in packages/core/src/config/normalize.ts) and its "Migrate from V1" page says the V1 format stays supported and converting is optional. - OpenCode 1.19.5 (npm latest) ignores `providers` with a warning (ConfigV2Compat.lower, packages/opencode/src/config/v2-compat.ts), and both read the same opencode.json. Run on mote in a sandbox HOME against a fake server: @opencode/cli 2.2.0 listed magpie/gpt-5.5 from magpie's `provider` entry and sent `#high-fast` as reasoning_effort high + service_tier priority; opencode-ai 1.19.5 used the same file; 1.19.5 with the entry moved under native `providers` listed no magpie model and its run errored. Not tried: Windows/Linux OpenCode builds. Docs only, no tests run. |
||
|
|
a14f5c9c9d |
gateway: a whole reply with a masked value isn't lost when it names the member (#4129)
versun's non-streamed /v1/chat/completions came back 200 with Content-Length: 0 whenever masking replaced a value, while the stream was whole. Cause: with Settings' "reply names the member" (MemberModel) or a request's X-Magpie-Response-Model: member, serve wraps the reply in two writers that each hold a whole body until the handler is done: memberWriter outside, redact.Writer inside it. Their finishes were deferred in the wrong order: memberWriter's ran first and wrote what it held (nothing yet), and redact.Writer's ran after it and wrote the restored body into memberWriter's buffer, which no one wrote. A stream goes through both writers as it comes, so it was whole. The provider, protocol, response_format and engine didn't matter; a warn (n=0) wraps no writer, so it was fine. - serve: the values are put back first, then the member is named (one deferred func, unmask then named). - memberWriter: a write after its finish goes through to the agent (named when it is a whole JSON body; a stream's held tail too), instead of into a buffer no one writes. - docs/subsystems/gateway-routing.md says the order. Restoring itself can't turn a non-empty body into an empty one (restoreJSON falls back to a text restore), so there is no failure left to turn into an error status here; the loss was the writer order. Tests: TestMaskedWholeReplyNamesMember sends the reporter's literal request (复述这句话:我的手机号是 13800138000。, non-stream, his redactActions) through a real httptest server to a fake vendor that says the placeholder back, on /v1/chat/completions (group/subagent as reported, direct, json_object, the header instead of the setting, an Anthropic vendor, a Gemini vendor), /v1/messages (Anthropic vendor and a chat vendor), /v1/responses and /v1beta generateContent. It checks the number is back, no placeholder, the member named, Content-Length equal to the body. TestMemberWriterWrittenAfterFinish holds memberWriter to the late write. Run (on mote, at this tree): - old code: all 10 subtests red, each "200, Content-Length "0" ... """. - broken by hand: memberWriter's late-write guard taken out (order kept): TestMemberWriterWrittenAfterFinish red. The defer order put back (guard kept): TestMaskedWholeReplyNamesMember stays green, since the guard alone delivers the body; the two together are what the old code lacked. - go test -count=1 -timeout 45m ./internal/gateway/: ok (478s) - GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok; gofmt -l: clean. - Real run: magpie built and run with `magpie serve` on 127.0.0.1:3481 in a sandbox HOME on mote, a fake OpenAI/Anthropic vendor on 3482, the reporter's settings plus MemberModel. Old binary: group/subagent, fake/m1, an Anthropic vendor and /v1/responses non-stream were each 200 Content-Length: 0. Fixed: Content-Length 230/401/596 with "我的手机号是 13800138000。" and the member's model; streams unchanged. - Rebased on |
||
|
|
0e2739743b |
codex: a reset set to go when the week runs out is spent before the credits
tongzhenbao on X: a Codex Pro account with "when its week runs out" on,
its week at 0% left, one reset held until 11-06 (after the week's own
reset on 11-03) and Use credits on. Overnight ~10k credits went and the
reset stayed; the card said "not auto-used" beside the switch on.
Cause: the week's auto-use ran only on a vendor refusal. autoReset in
routing needs a 429 usage_limit_reached on the last candidate, and the
relay's autoResetSignedIn the same on its 429. An account let spend its
credits is never refused for its week: ChatGPT answers on the credits,
and routing never benches it (full() and onCredits). So the week's reset
could only ever be spent with credits off.
Decision (product call delegated): a reset is free, credits cost money,
so a reset the user set to go when the week runs out goes before any
credits. resetBeforeCredits runs before a try is sent to a Codex account
on its credits whose last reading has its week used up, with the week's
switch on; AutoUseCodexReset reads the week again and keeps one a week
at most, so a second time in the same week goes on the credits. Hooked
in the routing loop and in codexUpstreamOn (the relay, signed-in or an
account). With no reset held, or the week's switch off, nothing changes.
The card's summary: with only the week's switch on it now says "auto-used
when the week runs out" (zh 周额度用完时自动使用), not "not auto-used",
with its title in all five languages. CLI help and auto-reset messages
say "or before its credits are spent". gateway-routing.md names it.
Siblings: the expiring switch already spends regardless of credits
(usedUp ignores them); the credits-off path (planned.held) is unchanged.
Run (mote, through mote-run, at this tree):
- go test ./internal/gateway -run 'TestCodexResetBeforeCredits|TestCodexAutoReset|TestCodexCredits|TestCodexNoCredits': ok
- broken by hand: gateway.go and codex_backend.go at origin/main:
TestCodexResetBeforeCredits/relayed and /routed red (200, spent ""),
the two negative cases green
- node --test codex-auto-reset, i18n-keys, codex-auto-reset-settings,
codex-resets-used, panel-options-fold, quota-curve: 96/96 (chromium +
webkit, en/zh/zh-TW/ja/de); codex-auto-reset red with origin/main's
app.js ("· not auto-used")
- full suite, before the rebase onto
|
||
|
|
300b7eee08 |
redact: a package's name goes as written where it was masked before, and in manifests and errors (dniray on Discord)
dniray, on v0.1.1965 after v0.1.1932's fix: "问题还在", with
import { and, eq } from ' drizzle-orm ' still going out as
from ' {{SECRET_o2tu7vej}} '.
v0.1.1932 let the module an import loads go as written only where the
local model found it on that line (moduleAt in modelFits). A value
masked once is known (knownSpans) and masked wherever it is, with no
look at what is around it. So once the model took drizzle-orm for a
secret anywhere in a request (package.json's dependencies, a tsc
error, a sentence: none of those was exempt), the import line was
masked as known: in the same request (MaskJSON walks the texts in
order) and in every later one.
- knownSpans skips a known value where packageAt says it is a
package's name.
- packageAt: moduleAt, plus a manifest's dependency pinned at a version
("drizzle-orm": "^0.36.4", workspace:*, TOML x = "9";
dependencyAt), a folder under node_modules or site-packages, the
module an error could not find (Cannot find module 'x', No module
named 'x', Can't resolve 'x'; missingModuleAt), a package an install
names (pnpm add x, npm i -D x, pip install x, cargo add x;
installedAt, not after a --token-like flag), one pinned with @
(x@0.36.4, lower case, not an IPv4 address; pinnedAt). A piece of a
name (drizzle-orm of drizzle-orm/pg-core, of @acme/drizzle-orm) is
judged as the whole name.
- moduleAt reads past an editor's line number and a diff's mark
(codeHead): Claude Code's Read gives " 1→import drizzle from
'drizzle-orm'", and a default import there wasn't an import line.
Tests: package_known_test.go.
TestKnownPackageNameGoesAsWrittenWhereCodeLoadsIt has the reporter's
literal line in a Claude Code tool_result after a sentence with the
name, in one Anthropic body, then alone (Mask, no model) and in a
second body: red on the old code at all three
(from ' {{SECRET_…}} '). TestModelPackageNamesInManifestsAndOutput: 22
shapes, red on the old code. TestPackageShapesKeepSecrets: a JSON key
with a non-version value, a password before @ip, a quoted secret on a
numbered line, prose with "install", a known secret in prose and on a
numbered line are masked still.
Run, at
|
||
|
|
fae438b4a5 |
agent: Codex switched on again is joined, and its own models say where a pick goes
NancyTom18 on X: Codex on a routing group, Disconnect and restore, switched on again, then an OpenAI model picked: every OpenAI row said 直连. After a routing group again they said 经 magpie. Reproduced in a sandbox HOME (ChatGPT sign-in, a group): reconnect put the group back by Apply alone, so Codex was beside its sign-in and not joined (codex.joined went with the Disconnect). Picking one of its own models then took magpie out (set → unroute, #940): config.toml had no openai_base_url and no model_provider, so Codex went straight to OpenAI and the 直连 tags were true. Back on the group, the rows said via magpie from routed(), while a pick would again go straight to OpenAI, with no ask: that label was false. - reconnect calls Join first where the agent has one, so a Codex switched on again comes back as the switch first connects it: joined, its own models staying through magpie. - modelOptions: beside its sign-in, not joined (with ChatGPT), and failover off, Codex's own models say Direct "OpenAI", so the picker tags them 直连 and asks before a pick takes Codex off magpie. Tests: TestCodexReconnectStaysJoined (red on the old applied.go: "connected again, not joined"), TestCodexBesideOwnModelsSayDirect (red on the old codex.go: "gpt-5.5 says via"). Each fix reverted by hand, its test went red. Run on mote at this tree: go test -timeout 45m ./... all ok except internal/gui TestMainWindowCorners/macOS_26_SDK, mote's macOS 27 red filed as #3949 (window chrome, untouched here). go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go build ./..., gofmt -l clean. GUI files unchanged; agent-leave-magpie and agent-path-same pass in Chromium and WebKit (4/4 each). Not tried: a real Codex binary with a real ChatGPT sign-in sending a turn; the route is read from config.toml as Codex's own provider rules read it. A Codex already beside a group from before this release stays so: its OpenAI rows now say 直连 and ask; switching it off and on joins it. |
||
|
|
5637cca141 |
settings: a notification when masking swaps a value for the first time (Must2333 on X)
Must2333 on X: "我还希望能即时的知道发生了替换,但不是通过随时监控网关的方式".
They want to know when magpie masks something without watching the
gateway or the 脱敏 page.
Settings › Usage has a new row, "Masking alert" (zh 脱敏提醒), after the
task done alert. Off/On, off by default. When on, a value masked for the
first time gives a system notification through the same notifier as the
other alerts. It says only how many new values, each kind and its count,
and the agents that sent them (two named, "+N" for more). It never says
the value, any piece of it, or the Head hint the 脱敏 page keeps. A click
opens the 脱敏 page on the latest record (clickView, "masking&key=<key>").
Why off by default: every other notification in this group is off until
turned on; turning one on asks macOS for notification permission; for
most users a notice each time masking works is noise, since masking's
expected behaviour is quiet protection. It is one row, in the group that
already holds the alerts, hidden while masking is switched off
(data-feature="redact") and in gateway mode.
Staying quiet:
- First time only: maskrec.Fresh says which values a record has that no
record before it had. A conversation sends its whole history each turn,
so a value is masked again every turn after its first. The index is by
placeholder (HMAC-stable across restarts), filled from memory and from
the days kept on disk, so a restart doesn't make a history new again.
The days are read off the lock, since Hold takes it on the request's
way. Values sent as written (Action "warn") are left out.
- A burst is one notification: records gather for 3s (maskGather).
- At most one every minute (maskGap); what comes in between is said
together after it. At most 5000 records wait.
- With the setting off, nothing is kept.
The gateway tells the app through gateway.OnMasked, after maskrec.Hold,
with Snips and Back taken out; nil under `magpie serve`.
Strings: en, zh, zh-TW, ja, de, in i18n.js (the row) and in
mask_alert.go (the notification's title and kind names, the 脱敏 page's
own words for the kinds). docs/subsystems/gateway-routing.md has the
bullet. The core script budget isn't raised: main's 10-29 budget leaves
room for the row's 287 bytes.
Tests, each broken by hand and seen red:
- TestMaskAlertFirstTimeOnly: masks through redact.Mask as the gateway
does; the history masked again says nothing, a new email in turn 4 is
said alone. Red when flush counts r.Values instead of the fresh ones.
- TestMaskAlertNeverSaysTheValue: no 4-character piece of the key, email
or phone, and no Head, in any of the 5 languages. Red with the Head
added to the kind's name.
- TestMaskAlertCoalesces: a burst of 5 from 3 agents is one wait of
maskGather and one notification ("+1"); two more 10s later wait
maskGap-10s and are said as one; off keeps nothing. Red without the
waiting check (5 waits) and without the maskGap wait ("waits 3s want
50s").
- TestFreshOnlyTheFirstTime, TestFreshHeldWhileReading (maskrec). Red
with loadFirst skipping the disk read (the history new after a
restart), and with the index broken (both).
- TestDismissedAlertOpensNothing covers the mask notice's click.
- mask-alert.test.cjs: every language at 900 and 380px, both engines:
the row after the task done alert, Off at first, On saves maskAlert,
another save keeps it, Off saves false, no click moves the page, no
left border, gone with masking switched off. Red with maskAlert taken
out of prefsKeep, and with data-feature taken off the row.
Run:
- This change on main
|
||
|
|
85d159a288 |
library: Connect an app is two tabs, agents in groups with a switch each (#2679)
The sheet behind Connect… is redesigned, closer to how Composio's MCP
router reads, and holds up with 25+ agents.
Agents tab: agents → magpie → servers drawn as icon stacks with
magpie's own bird in the middle (no accent block), one line of where
things stand ("19 of 23 agents use…", or the lone agent named), then
the agents in three groups: not connected, connected, keeping each
server's own entry. Each row is a switch (servers/agents-all
{agents:[id], on}); a kept agent shows a short word for why with the
full reason behind (i). Connect all in the bar connects the rest in
one post. With more than 8 agents a search narrows every group, and
the connected and kept groups fold to one row each ("Claude Code,
Cursor and 17 more") so the sheet fits the window.
Other apps tab: the address, then a row per app (Cursor when it isn't
an agent, VS Code, Windsurf, any JSON app) saying where its entry goes,
with Copy entry; Cursor and VS Code get Add in the app (hub-open).
Behaviour change: the switch's off takes every Library server away from
that agent (as By agent's Turn all off does), so turning it on again
gives it all of them, not the ones it had before.
"Why", "Connected" and "Not connected" moved to the core i18n.js: Go
files say them too, so i18n-keys refuses them as plugin words. zh says
已连接 / 未连接.
docs/subsystems/mcp-hub.md's GUI row describes the new sheet (and loses
a duplicated cell).
Run at 239981794 (rebased on origin/main
|
||
|
|
b4267de595 |
gateway: a provider's fallback can be a routing group, routed as the group
01huadalang on Discord: "还有备用模型增加路由组的选择,现在只能选模型". A
provider's Fallback list held models only; a "group/<id>" entry resolved
to the group's first member alone. Now such an entry is served through the
group, as a request to the group would be:
- plan → planPaused: a fallback naming a group (provider.FallbackGroup,
the group as routed, Live) hands its members to planLevel
(planFallbackGroup): the group's own routing, its sink and asides, and
its pause rules (serve passes provider.PausedOut for the agent's folder).
Its trace rows are marked Fallback with the group in Via.
- No loop, each provider/model once a round: a member that is the primary,
a model named earlier, or another fallback group's member is left out
where it comes second. Groups have no fallbacks of their own and a
member's fallbacks are not followed, so nothing leads back. A group that
is gone or off is passed over, as a model none serves is.
- Every sibling that reads p.Fallback now reads a group's members through
provider.FallbackModels: redaction (unredactedRoute: an unmasked
provider with a fallback group holding a remote model is masked),
careful accounts (carefulOf), native compaction, Codex's own turns
(codexFallsBack) and Claude's auto-mode review (claudeReviewed, which
moves from provider.Resolve to ResolveRoute, as the gateway reads
fallbacks).
- CLI: `magpie provider fallback` already took group/<id> (Resolve knows
groups); its usage and error now say so. Pinned by
TestFallbackCmdTakesGroup.
- GUI: the provider editor's Fallback picker lists the routing groups
(providers.gateway.groups) beside the models as chips with the Routing
fan and a muted "routing group" tell; a picked group's row has the same
fan and tell, and a gone one says "No routing group {id} now; it is
skipped". A filter matches a group's name, id and its members'
providers. New strings in zh, zh-TW, ja and de.
- app.js budget raised 187 bytes on main (1,311,922; core 1,531,060), the core's
own editor, no room added; the addition was cut from ~900 bytes first.
- docs/subsystems/gateway-routing.md: the Candidates row says all this.
Not done: a fallback group's turn rules (ruleFor/ruleOver, which can ask
a classifier) are not applied. The plan is made before the primary is
tried, so they would cost a classifier call on every request the primary
answers. Its routing order, sink and pause rules are applied.
Run (at f6e7214af; after the rebase, the last bullet):
- gofmt -l: clean. mote: go build ./...; go vet on the touched packages;
GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...: ok.
- mote: go test -timeout 45m ./...: every package ok except internal/gui:
TestCoreScriptBudget (fixed above, then ok) and ten AppKit window tests
(TestDockJoinLeadsCommandTab, TestPanelCloseHidesIt, TestMainWindowCorners
…) killed at their 30s bars while four other sessions' GUI suites held
mote at load 70-110. Run alone, all ten
pass (TestDockJoinLeadsCommandTab skips) except TestMainWindowCorners,
red at base
|
||
|
|
0daf363325 |
gateway: a key resting after an outage is asked again in the background
heatonz on Discord: a key or provider paused after a failure stayed out
for its whole rest, even after its vendor was back. Only Try now got it
back early. probeOne asks only the resting candidate that comes back
soonest, so a key behind ready ones was never asked again early.
What changed:
- gateway/rest_probe.go: the background ask, with no setting.
- Which rests it asks: a key's own rest from a failure that names no
time (a 5xx, a 408, no connection), resting by backoff, at a vendor
whose model list is asked over the network (provider.ListAsks).
- How it asks: the vendor's model list, with the key and its p.Via
proxy. A list costs no allowance.
- When: 1m into the rest, then 2m, 5m and every 10m, each ask at least
half a step before the rest ends. The rest is lifted as soon as the
list answers, the way Try now lifts it (unsink, trace).
- Cost: one list per resting key per step, so at most 4 lists in a
10-minute rest.
- The loop runs from ListenAndServe. A Server whose loop isn't running
(a test's) queues nothing. A loop that ends waits for the asks under way.
- Not asked: a Retry-After or ratelimit reset header, quota or credit, a
rate limit, a refused key, a 4xx, one model's rest, a subscription's
account, a plugin. Those still end on time.
- Rate limits are left out on purpose. A model list answers while chat
still gets 429, so lifting early would undo Sink and go around the
vendor's limit.
- A list answers for the vendor, not for every model behind it. A key
that fails again within 30 minutes of a lift is not asked again until
it answers a real request (probeAnswered in served).
- Rest.Probed / KeyRest.Probed. The provider's key row and Routing's
words for the try add "checked in the background, back as soon as it
answers", in en, zh, zh-TW, ja and de.
- app.js stays under its budget with no raise: a shared hhmm helper, and
resetUsedWhen folded into the identical stamp.
- docs/subsystems/gateway-routing.md describes it.
Tests:
- rest_probe_test.go:
- lifted after one failed ask and one answered, asked with the resting
key;
- no ask again after a missed lift;
- each excluded rest: never queued, 0 asks;
- no loop, no queue; the loop waits for its asks, and a cut-short ask
doesn't lift.
- gui/tests/rest-probed.test.cjs: 5 languages x 1100/420px x chromium and
webkit, 40/40. Red on origin/main's assets.
Broken by hand on mote, each red:
- no lift: test 1 times out;
- no status check: refused key and bad request get asked;
- Retry-After ignored;
- no miss guard;
- no asks.Wait() in the loop's exit.
Run:
- go test -race -count=5 -run TestRestProbe ./internal/gateway: ok.
- mote: internal/gateway ok (636s); internal/provider ok.
internal/gui TestMainWindowCorners/macOS_26_SDK is red on macOS 27,
unrelated, #3949.
- Linux Go full suite (wsl-run, -timeout 45m) at 6cbd77608 (the same
change on
|
||
|
|
3c6b7d585f |
agent: OpenClaw is wired up like the other agents
arthur041691 (Discord #help) runs OpenClaw for WhatsApp and asked for it in
Agents. Connecting writes magpie as a custom provider of OpenClaw's own, in
openclaw.json, and makes the picked model agents.defaults.model's primary.
What is written, from OpenClaw's source at 5bab0c14 (npm 2026.10.8, dc2523e):
- the file: OPENCLAW_CONFIG_PATH, else $OPENCLAW_STATE_DIR/openclaw.json,
else ~/.openclaw-<profile> for a named OPENCLAW_PROFILE, else
~/.openclaw; ~ is OPENCLAW_HOME when set (src/config/paths.ts,
src/config/state-dir.ts, src/cli/profile-utils.ts). OPENCLAW_PROFILE is
a name, not a path (agentenv.NotPaths); the other three expand a
leading ~, as resolveUserPath does (appdir.usable).
- models.providers.magpie: baseUrl (the gateway's /v1), apiKey (the
OpenClaw-named gateway key), api "openai-completions", and every model
magpie serves with id, name, input, reasoning and contextWindow
(src/config/zod-schema.core.ts, docs/gateway/config-tools/custom-providers.md).
A user's own keys on a model entry (headers, maxTokens…) stay on Sync.
- agents.defaults.model keeps its shape (string or {primary, fallbacks});
agents.defaults.models gets the ref's {} entry as `openclaw models set`
adds it (src/commands/models/shared.ts), only when that map exists; a
non-empty modelPolicy.allow gets "magpie/*" when nothing there lets
magpie's models in (src/agents/model-selection-normalize.ts).
- Model changes are hot-reloaded (docs/gateway/configuration/hot-reload.md);
a chat that already has a model keeps it (docs/concepts/models.md), so
the notice says to send /model default there. Translated in every
language.
- The file is written through temp-and-rename; a new one is 0600 in a
0700 folder, as OpenClaw makes it (src/config/io.write.ts). A file that
isn't JSON after comments are blanked (JSON5's bare keys) is left alone
with an error, never read as empty.
- Disconnect puts back the model there was, removes magpie's provider,
its {} entries, the allow entry and any object magpie made, and the
file itself if magpie made it.
Icon: a mask drawn from OpenClaw's ui/public/favicon.svg (MIT).
Run, on mote at this tree:
- go test -tags nogui ./internal/agent -run OpenClaw plus the every-agent
tests (drift, port move, sync on another machine, reverse proxy, LAN,
pinned key per writer, notices translated), ./internal/appdir,
./internal/agentenv: ok.
- Broken by hand, each red then green again: no stash restore
(TestOpenClaw, Shapes, AllowList), user keys dropped
(SyncKeepsTheirs), no allow entry (AllowList), no JSON5 guard
(JSON5LeftAlone), profile ignored (Paths), OPENCLAW_PROFILE back as a
path variable (Paths).
- Real OpenClaw 2026.10.8 from npm, Node 24.22.2, sandbox HOME on mote:
onboard --non-interactive made the file (its bytes are the test
fixture); magpie's code connected it; `openclaw config validate` ok;
`openclaw models list` shows magpie/kimi/k2 as default; `openclaw agent
--local` sent POST /v1/chat/completions with Bearer magpie-openclaw and
model kimi/k2 to a fake gateway on 3425 and showed its reply; no
agents/*/models.json override was written; Disconnect gave the file
back byte for byte and it validates.
- GUI: i18n-keys, agent-notice-lang, icon-tile, about-notices,
agent-connect (Chromium and WebKit): 53/53.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- Full suite, go test -tags nogui -timeout 45m ./... at
|
||
|
|
b2d005bf38 |
gateway: a MiniMax API key makes videos with H3 (_tigerqueen_05867)
A MiniMax API-key provider (api.minimax.io, api.minimaxi.com, api.minimax.cn) now lists MiniMax-H3, -H3-Highspeed, -H3-Lite and -H3-Max as video models. They are never in chat lists. generate_video and /v1/videos start a task at <host>/v2/video_generation, poll /v2/query/video_generation/<id> and hand back the MP4. The prompt, seconds (raised to each model's minimum and capped at 15), resolution (from Extra or size, clamped to the model), ratio, first and last frame and up to 9 reference images go through. /v1/videos now reads last_frame; MiniMax and a remote magpie pass it on, other videomakers ignore it. The MCP schema is unchanged. Failures say which one it is: a turned-away key (1004/2049/401), no pay-as-you-go balance (1008/402), refused input or output (1026/1027), a Token Plan key without H3 (2061/2068/2057, which moves on to the next key), or the rate limit. AutoVideomaker puts MiniMax last, so generate_video, which has no model argument, uses MiniMax-H3 only when nothing else makes videos. All of it is gated on a MiniMax host, so no other vendor changes. Run on mote at 798c8fd48 (base |
||
|
|
a0ba8e1f2e |
grok: each model's context_window follows Long conversations, and one set by hand stays through a sync (uk.jent)
uk.jent (Discord #feedback) reported that magpie writes every Grok Build model's context_window as the model's whole window. They wanted about 300K without editing dozens of models, and they lost hand edits on each sync, because SetTOMLTables replaces the [model."magpie/..."] tables whole. Grok Build now uses Long conversations, the mechanism Codex and Claude Code already use. grokWindow gives: - min(window, Compact) when the model or provider has its own threshold; - otherwise settings.Working(window): 272K by default on longer windows, the typed size, or the whole window with Full context. What magpie wrote is stashed under grok:<path>:windows, and grokOwnWindow uses it to tell a hand edit apart: - A value that differs from what magpie last wrote is the user's, and it stays. - In a config written before the record, a value other than the model's whole window is the user's. - Disconnect forgets the record. The agent sheet's Long conversations row now shows for Grok Build (AGENT_PREFS). Its texts, the provider editor's hint, the Context tab's note and `magpie model compact` now name Grok Build, in en/zh/zh-TW/ja/de. setCompact and setAsync now share prefWrite. That dedupe keeps app.js under its budget, which is not raised. Behaviour change: a Grok Build model whose window is over 272K now gets 272K by default, as Codex does, unless Full context is on. Run on mote, at this head (c893c2229, rebased on |
||
|
|
fe05f0a721 |
library: a skill can be turned off on this computer alone, and a sync neither carries that nor turns it on
hanslin1666 on Discord (#general 1565016936344191096) wanted a library
skill off on one computer only ("只在这台电脑上关掉"). The only way to do
that was to untick its agents, and the ticks are what a sync carries, so
every other computer lost it too. A sync from a computer that had it on
also gave it back here.
Skill.OffHere (library.json "offHere", omitempty) turns a skill off on
this computer. No agent here gets it, whatever Agents says. Every reader
that gives a skill to an agent now asks gives():
- syncSkills, including the shared ~/.agents/skills check;
- desktop_skills.go;
- skill_changed.go;
- skill_edits.go;
- behind;
- Targets.
Agents stays what a sync carries, and the page shows those chips faded.
Collect never carries OffHere, so turning a skill off changes no part a
sync uploads. Put keeps this computer's OffHere for a skill it puts, so
a sync from a computer that has it on (or that gives it to more agents)
leaves it off here.
Where to turn it off:
- GUI: a power button on the skill row (aria-pressed). When off, an
"Off on this computer" tag sits on its own line under the name; it
says why and turns the skill on when clicked.
- CLI: `magpie library skill off-here|on-here <name>`.
- TUI: the row says the skill is off.
The strings are in en, zh, zh-TW, ja and de.
Existing users: nothing changes. An older library.json has no offHere,
so every skill stays on, and a skill that was never turned off writes no
key (TestSkillOffHereOldLibraryIsOn).
Not covered:
- a project's skills;
- a library skill whose own folder is inside ~/.agents/skills, which
agents read in place;
- a skill another computer removes (the flag goes with it).
The skill's files in the library folder still update while it is off.
Docs: docs/subsystems/library.md and sync-backup.md.
Run at the parent
|
||
|
|
ec3dad75ae |
provider, gateway, gui, cli: Claude's accounts can be kept to Claude Code's own sign-in, magpie serving nothing on them (myduso)
myduso on Discord asked for an exclusive mode on Claude's subscription: switch the credentials locally and proxy no traffic, since Claude Code is used on its own and the SDK run magpie's bridge makes spends more of the allowance than the interactive client. The switch-only setting Codex has (#1907) now also takes claude. On it, Provider.KeptToAgent is true and On() false, so the gateway, catalog, groups, fallbacks, search, draw and embeddings serve nothing on the Claude accounts, and a request naming them is refused 404 saying they are kept to Claude Code's own sign-in and how to undo it (switchedOff). Switching Claude Code's sign-in when an account is used up, and reading usage, go on: both are gated by leftAlone on the raw Off, which this doesn't set. Groups magpie found keep their Claude members (heldOffEntries). Nothing is sent as Claude Code: magpie only writes and restores Claude Code's own credentials as it already did. GUI: the tick under Claude's accounts, shown with one account too, drawn by the block Codex's tick had (one block now, its strings picked by agent). app.js stays under its budget with no raise (1,311,711 of 1,311,735). CLI: magpie accounts switch-only <codex|claude> [on|off]. Docs: reference.md, subsystems/providers-accounts.md. Run on mote at this tree on 06950fbbb; then rebased on |