8a4cfe0e4e3e02f666f5ddbaff77dc68c2d6c2a7
155
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f71155591e |
provider: a provider at a vendor's own endpoint is priced from that endpoint's models.dev catalog (#2052, mengyianx)
A custom provider added by its address alone, with no catalog named, was priced only by the model's maker. Qwen3.8-27B, whose maker (Alibaba) sells no such model on any of its seven models.dev catalogs, read "no price is known for it" even at AMD's own endpoint, where models.dev's amd lists it at $0, a price. - catalog: models.dev's provider "api" is read; AtEndpoint names the catalogs at a base URL (trailing slash and case ignored). - provider: EndpointCatalog is the one catalog models.dev lists at one of a key's provider's endpoints (an Anthropic base, kept as its root, also with /v1), used by ListPrice when the provider has no catalog of its own. Never for a subscription's account, never when two catalogs share the address (minimax / minimax-coding-plan), never a plan's catalog (an id with -plan, or membershipCatalogs), whose $0 is the membership's. A user's price and a named catalog still come first; a relay's endpoint matches nothing and its model stays unpriced (no reseller guess). - cli: `magpie model price p/m` with no price gives the two commands that set one (p/m and */m); a price from an endpoint's catalog names it. - gui: the Catalog field's hint says it also sets list prices (en, zh, zh-TW, ja, de). - docs: reference.md's "What a model costs", providers-accounts.md row. What was run: - Reporter's exact case, built binary (go build -tags nogui), sandbox HOME with a copy of this machine's models.dev cache (2026-10-14, same amd entry as the report), providers 001 (relay), 002 and amd at https://developer.amd.com.cn/radeon/api/v1: 001/gpt-5.5 $5/$30, tiers, as before 001/Qwen3.8-27B no price, now with the two commands to set one 002/Qwen3.8-27B $0/$0, "what models.dev's amd lists at its endpoint" amd/Qwen3.8-27B $0/$0 The two suggested commands were run and took effect. - TestEndpointCatalogPrices / TestEndpointCatalogOnlyItsOwn, fixture testdata/endpoint_catalog.json trimmed from the real models.dev cache. Break checks, each FAILs with the case named: ListPrice not using EndpointCatalog -> 002/amd/001 at AMD unpriced, EffectivePrice(002, Qwen3.8-27B) unpriced plan exclusion removed -> "a plan's endpoint: EndpointCatalog() = alibaba-coding-plan", qwen3.5-plus at $0 instead of $0.4/$2.4 single-match rule removed -> "an endpoint two catalogs share: EndpointCatalog() = minimax" Account check removed -> "a subscription's account ... = amd" Anthropic /v1 match removed -> thinkingmachines unmatched - GUI: internal/gui/tests/catalog-hint.test.cjs, chromium and webkit, en zh zh-TW ja de, widths 1100 and 420: 20/20 pass, plus i18n-keys; with the old app.js/i18n.js it fails "one hint names list prices". - go test -tags nogui -timeout 45m ./internal/catalog ./internal/provider ./internal/cli: ok (provider 244s, cli 125s, catalog 3s). gofmt -l clean; go vet (darwin), GOOS=linux go vet -tags nogui and GOOS=windows go vet -tags nogui on those packages: clean. |
||
|
|
b6cf5e3eab |
gui: magpie web keeps its sign-in when another service on the same address fills or clears the host's cookies, and a page opened without it says why and takes the key (#2033, 321sssrt-bit)
A browser keeps cookies per host, not per port. magpie web's sign-in cookie on http://<tailscale-ip>:3430 is the same host's as every other service on that IP's other ports, so one of them could take it away, and a bookmark then answered only "open the link magpie web printed when it started". Reproduced in Docker (linux/arm64, MAGPIE_WEB_KEY fixed, as the reporter runs it) with Chromium and WebKit on the old binary: - docker restart, recreate (an update), browser restart: still signed in (the key, its derivation and the 400-day cookie are fine); - another port on the same host setting ~400 cookies: Chromium evicts the sign-in (401), WebKit keeps it; - another port answering Clear-Site-Data: "cookies" (a sign-out often does): 401 in both; - the page opened by another name for the host (localhost vs IP): 401. Changed: - the sign-in cookie is sent with Priority=High, so Chrome evicts it last when the host's cookies overflow (with it, the flood case stays signed in); - every magpie_web_<port> cookie the browser sends is tried, so a stale one sent first no longer hides the right one; - an HTML page opened without the sign-in gets a page that says which case it is (no cookie sent for this address, or a cookie holding another key) and a field to paste MAGPIE_WEB_KEY into; POST /_magpie/sign-in sets the cookie and goes back to the page asked for (local paths only: no scheme, host, //, /\ or the sign-in itself). The key is never in the page. API calls get a plain 401 that now says the reason too, and the turn-away is logged with it. - docs/reference.md's Docker web section says how long a sign-in lasts and what can take it away. Run: - TestWebGuardBookmark (link cookie has Priority=High; stale cookie first still passes; both reasons; API 401; wrong key 401 with no cookie; right key 303 to /?view=usage with a 400-day cookie; external, //, /\, javascript:, empty, sign-in-path and CRLF back values all go to /). Broken by hand: the old guard fails it (link without Priority), dropping Priority alone fails it, reading only the first cookie fails it (stale cookie: 401). - The Docker matrix above again on the new binary: the flood keeps the sign-in in Chromium; Clear-Site-Data and the other name get the form, and the form signs in (wrong key turned away, right key back to /?view=usage, 200) in Chromium and WebKit; the log says "turned away ... no cookie sent". - go test -tags nogui ./internal/gui (ok, 173s), gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows. Not tried: the reporter's own browser and Tailscale address; which service on their host takes the cookie is not known. |
||
|
|
bf25842714 |
gateway: a provider's own cap on how long a key that keeps failing rests (#2008, Gaudi-XIX)
A key that keeps failing doubles its rest from a minute up to 10 minutes, and one rate limited again as soon as its rest is over up to 30; both caps were fixed, so a free key down for hours was asked again every 10 or 30 minutes all the while. `magpie provider rest-cap <id> 4h` (Provider.RestCap, minutes, at most MaxQuotaRest, 8 days) sets where both ladders stop for that provider's keys and accounts (RestCapOr in restAfterMarked's default branch and in rateRest); `default` gives back the gateway's own. A time the vendor names still stands over it. Unset, nothing differs. It is kept by the editor's save, the account copy and normalize. Run: go test -tags nogui ./internal/provider ./internal/gateway ./internal/cli ./internal/gui (temp HOME). Broken by hand: both ladders back on the fixed caps fail TestOwnRestCap (rate-long #6: 30m, want 32m); the GUI keep removed fails TestSaveKeepsQuotaResetAt. Not tried against a real vendor's outage. |
||
|
|
064cffdbfd |
gateway: a key out of a daily allowance rests until the time of day it comes back (#2008, Gaudi-XIX)
A free tier's "You've reached today's free-model token quota" says nothing of when it is back, so it rested 15 minutes (or the provider's own quota-rest), and was asked again all day. A vendor Retry-After over an hour was cut to the hour, and that hour then stood over the user's own longer rest. - Provider.QuotaResetAt: "08:00" on this computer's clock, or "00:00+08:00" on the vendor's. `magpie provider quota-rest <id> until 08:00` sets it; a number of minutes set after it replaces it, and default clears both. normalize drops one that isn't a time of day. It is kept by the editor's save and the account copy. - restAfterMarked's quota branch rests until its next occurrence (OwnQuotaRest). A time the vendor names, or a window's end, still stands over it; a Retry-After stands unless it was cut to longestWait while the user's own rest is longer. - Defaults are unchanged: nothing set, nothing differs. Run: go test -tags nogui ./internal/provider ./internal/gateway ./internal/cli ./internal/gui (temp HOME). Broken by hand, each fails: OwnQuotaRest replaced by QuotaRestFor (TestQuotaRestsUntilTheTimeOfDaySet, 3 asserts), the Retry-After guard removed (the 7200 case), the GUI keep removed (TestSaveKeepsQuotaResetAt), default not clearing it (TestQuotaRestUntil). Not tried against a real free-tier vendor. |
||
|
|
591ed58b53 |
provider: Nous Portal is a vendor preset, Nous Research's API with a Portal key (#392, Vocllum, laojianzi)
Nous Research makes the Hermes models and serves them, with other makers' models, through Nous Portal. #392 was wrongly answered as a relay. A new preset, nous ("Nous Portal", KindVendor with Hosts, lobe-icons nousresearch icon), points chat completions at https://inference-api.nousresearch.com/v1. A Portal API key goes in as a Bearer, the way Hermes Agent's own nous-api provider uses NOUS_API_KEY. The model list is the Portal's /v1/models, which uses vendor/model ids. An entry another app has at that URL, such as Hermes Agent's base_url, now imports as the preset. The preset sets no Anthropic endpoint. The Portal's /v1/messages serves only its anthropic/* models (Hermes Agent's test_nous_portal_anthropic_wire.py), so Claude Code's requests are translated to chat completions for every model. It sets no Responses endpoint either, because none is documented. The preset is added to the README (en, zh), docs/reference.md, and the site's import pages and icon. Sources: - hermes-agent docs: integrations/nous-portal, integrations/providers, features/subscription-proxy. - hermes-agent source at 6e7b83a2: hermes_cli/auth_constants.py (DEFAULT_NOUS_INFERENCE_URL), plugins/model-providers/nous, cli-config.yaml.example ("nous-api - Nous Portal API key (requires: NOUS_API_KEY)"), agent/anthropic_endpoints.py, and tests/e2e/core/live/_helpers.py, whose live run calls the Portal with NOUS_API_KEY. Probed without a key: - /v1/models answers 200 with 423 models. - /v1/chat/completions with a bad Bearer answers 401 "Your API key is invalid, blocked or out of funds". - /v1/messages answers an Anthropic-shaped 401. Not tried: a real Portal key or a real request, since no key was available. Also not built: OAuth sign-in with the 1-hour token and its refresh (Hermes Agent's ~/.hermes/auth.json). Run: - TestNousPortalPreset fails without the preset (no preset "nous") and with an Anthropic endpoint added (endpoints: … "https://inference-api.nousresearch.com"). - go test -tags nogui of internal/provider, internal/gui and internal/catalog passes. - gofmt -l is clean. - go vet, GOOS=linux go vet and GOOS=windows go vet -tags nogui on ./internal/provider pass. - add-sheet and add-button GUI tests pass in Chromium and WebKit (6/6). |
||
|
|
916e30a4f8 |
docs: every file in ~/.config/magpie says what it is for (#2028, emo172)
#2028 asked to sort ~/.config/magpie into subfolders. It stays flat: backups, sync, Docker volume mounts and older magpies all find each file by its name there, and moving them would break each of those for a cosmetic gain. What the report really lacked is knowing what each file is, so the reference's Files section now lists every file magpie writes, grouped by what it holds (what you set, accounts and sign-ins, what magpie set on agents, the gateway and usage, the window's state, and ~/.cache/magpie), with which are written 0600 and what .lock and .bak files are. Each line was checked against the code that writes the file (the path helpers and their doc comments). Docs only; nothing was run. |
||
|
|
db0af71864 |
gui: the menu bar can show today's or the last 7 days' tokens and cost (#1984)
Settings → Usage → "In the menu bar" lists two more rows after the
subscriptions: "Tokens and cost today" and "Tokens and cost, last 7 days",
ticked and saved as a card is (ids "usage:today", "usage:7d" in
trayUsages; provider ids are [a-z0-9-], so the prefix can't collide). They
show beside the allowances or alone.
- trayusage.go: a total is a card built from usage.SummarizeTop(p, 0)'s
Totals (the Usage page's own cached numbers, Input+Output as its
tokensOf counts them): tokens over cost, in the currency Settings picks,
"+" when some requests had no known price. On the Mac it is a Plain cell
(no vendor logo; the bird beside it says whose it is); on Windows/Linux
the tray's text label and tooltip ("Today in magpie / 1.2M tokens (912K
in · 318K out) / ≈$3.40+ / 152 requests…"). Quotas aren't fetched when
only totals are picked.
- Clicked, a total opens the Usage page's Overview at its period
(quotaView → ?view=usage&tab=usage&period=…, read and dropped from the
URL) or the panel's Usage tab at that period (panelUseFocus).
- Only today and 7d: the Usage page has no 3-day window, and a menu-bar
number nobody can open in magpie at the same span would disagree with it.
- The pill names a lone total, and counts a mix as "{n} shown" rather than
calling it subscriptions. Strings in en/zh/zh-TW/ja/de.
- docs/reference.md and gui-shell.md say so.
Run:
- go test -tags nogui ./internal/gui/ (sandbox HOME): ok. The new
TestTrayTotals/BesideCards/TrayCount went red with each piece broken by
hand (no Plain, no text branch, no quotaView branch, 3d accepted).
- tray-totals.test.cjs (new) plus tray-usages, tray-inuse,
proto-menu-overflow (updated for the two rows), i18n-keys, panel-usage,
allowance-open-read, tray-cell-click: 46/46 in Chromium and WebKit, five
languages, 1100 and 420 wide. tray-totals fails 5/5 against the old
app.js.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- The Mac cell image rendered and looked at (bird, "1.2M" over "$3.40").
Not tried: a real macOS menu bar, nor a Windows or Linux tray; the tray
tooltip is English, as the existing tray tooltips are.
|
||
|
|
f64d9312ff |
site, docs: a Privacy page lists everything magpie sends and how to turn it off (#1986)
#1986 asked what the daily count sends, where the id lives and how to stop it. The answer was spread over one README paragraph and the reference. A new page, /docs/privacy (en, zh, ja), lists it from the code: - the daily PostHog batch (internal/stats): a whole example, the label rules for agents/providers/models, partner counts, the $process_person_profile:false flag; - every switch: Settings -> Privacy's two toggles, noStats/noUsageStats, DO_NOT_TRACK / MAGPIE_NO_STATS, noAutoUpdate (About -> Automatic updates), and that a change applies at the next hourly look; - the files: install-id (made at the first send, not at first run, as the issue said) and stats-sent in settings.Dir(), partner-counts.json in the cache folder, their paths per OS and portable, and deleting them; - what usemagpie.ai sees whatever the settings (update feed every 6h, notes, partner list with its 1-in-10 sampled count, /go links, the icon proxy) and the Cloudflare Web Analytics on the site's own pages; - public lists fetched (models.dev, open.er-api.com, npm, GitHub) and providers' quota reads with the user's own accounts; - OTLP export, off by default, its env vars; - why the count stays on by default in releases. Every docs page in all three languages gets a Privacy link in its nav and footer. README (en, zh) and start.html's "What does magpie send about me?" (en, zh, ja) link to the page. docs/reference.md's Files list gains install-id, stats-sent and partner-counts.json, and Counting users says when the id is made, the hourly try, and links the page. Checked against: internal/stats/stats.go, usage.go, provider/partner_events.go, settings (NoStats, NoUsageStats, NoAutoUpdate, UpdateEvery 360, otel.go), appdir, update, fx, catalog, site/worker.js, and the GUI's Settings tabs/labels in index.html, app.js and i18n.js (zh, ja). Run: Playwright (Chromium and WebKit) on all three pages at 1100 and 420 wide, light and dark: no horizontal scroll, no element past the viewport, no page errors (24/24), screenshots looked at for zh at 420 dark. Every href/anchor in site/public/docs resolves; relative links in README and reference resolve. node site/worker.test.mjs passes. Not run: the page on the deployed worker (the site deploys by hand with wrangler, so it is live at the next deploy); the language redirect for /docs/privacy was not exercised beyond the worker's existing tests. |
||
|
|
9e76fcdc68 |
plugin, cli, gui: a plugin's "password" question is typed unseen, as an API key is (#1982)
A sign-in method's prompts could only be "text" or "select", so a token a plugin asks for (the Qoder plugin's PAT sign-in, magpie-community/plugins#103) showed on screen as it was typed, in the app and in `magpie plugin login`. What changed: - internal/gui/assets/app.js renderPluginAsk: a prompt of type "password" gets a password field (masked), the same field an "api" method's key gets. A "text" prompt is unchanged. - internal/cli/plugins_cli.go askPrompt: on a terminal a "password" prompt is read with term.ReadPassword (no echo); piped in it is read as a line, as a script answers it, and an empty answer still goes to the plugin's validate, as a text one does. - internal/plugin/providers.go: the Prompt type lists "password". host.js passes the type through untouched, so nothing there changes. The TUI has no plugin sign-in. - Docs: docs/reference.md and site/public/docs (en, zh, ja) plugins.html say what "password" does and that it is magpie's own (OpenCode has text and select). The answer is only sent to /api/plugin-signin/prompt and the sign-in, as a text answer is; nothing logs or shows it. What was run: - TestAskPromptPasswordIsUnseen (internal/cli): with the password branch disabled by hand it fails with `password on a terminal = "typed-in-the-open", <nil>, hidden reads 0; want pt-secret read unseen`; restored it passes. - plugin-password-prompt.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 420 wide, 11/11 each. With app.js put back it fails with expected 'password', actual 'text'. plugin-signin and plugin-signed-out-account 16/16 in both engines; i18n-keys passes in both. - gofmt -l clean; go vet for darwin, GOOS=linux -tags nogui and GOOS=windows on internal/cli, internal/plugin, internal/gui; go test -tags nogui of those three packages in a sandbox HOME: ok. Not tried: a real Qoder PAT through the community plugin (its PR isn't merged), and the CLI on a real Windows console (term.ReadPassword is the same call `magpie plugin login` already uses for an API key). |
||
|
|
12ecb6d8e9 |
gateway: a gateway key held to a budget, models or accounts is told none of this magpie's accounts, only its own limit and routes (#1981)
321sssrt-bit shared magpie on the LAN with a gateway key held to a budget, and that key still read every account's quota and balance. A held key (heldKey: a budget, models or accounts) is someone else's to use, so it now gets 403 with code gateway_key_held (refuseHeld) on /v1/magpie/quotas, quotas/history, quotas/cards, POST quotas/refresh and /v1/magpie/concurrency. That holds from loopback as well as the LAN, the same as usageSummary already did. /v1/magpie/route tells it only the routes of its own requests. Route.callerKey is set by trace.beginFor at all five begin sites, so a route begun without it fails closed. It still reads its own limit at /v1/magpie/limit. Unrestricted keys and the local owner are unchanged. Client side (remote magpie): a 403 gateway_key_held drops the cards kept from before and shows only the key's own card, instead of "isn't shared". The cache is now keyed by provider and key (remoteCardsID), so a changed key never shows what the old one was told, and keepRemoteCards keeps a read only over one asked before it, so a slow pre-held answer can't bring cards back. Decided against letting an account-held key see its own accounts' cards: that would still show the host's account email and balance to the key's holder. Run: - New TestHeldKeyToldNoAccounts covers keys held by budget, models and accounts plus one held to nothing, from 127.0.0.1 and 192.168.1.9. Every route goes red with the refuseHeld calls or the route filter removed by hand. - New TestRemoteMagpieHeldKeyShowsOnlyItsOwnCard goes red with the errKeyHeld mapping removed. TestRemoteMagpieCardsKeptByKey goes red with the cache keyed by p.ID alone. - gofmt -l and go vet (darwin, linux -tags nogui, windows) are clean. - go test -tags nogui ./internal/gateway ./internal/provider -count=1 passes in a sandbox HOME. Not tried: two real machines over the LAN; the tests drive the handler with LAN remote addresses. An older client shows "isn't shared" (or its cached cards until they expire) against an updated host until it updates too. |
||
|
|
ea1ba22c32 |
gateway, gui: Codex's composer predictions go where Settings › General says, Off among them (#1970)
pluo's Usage view showed Codex calls of kind composer_predictions at
133k-231k tokens each with no cache read: ChatGPT.app's Codex guesses the
user's next message with a hidden turn on a fork of the thread, on the
thread's own model, reading the whole conversation again each time. It
asks only when the thread's provider is "openai", so through Codex's own
ChatGPT sign-in (and a custom table pointed at magpie). The app's bundle
(fge) asks for {suggestion: string|null} and uses b.suggestion||null.
What changed:
- settings.CodexPredictions: "" as Codex sends it, "off", or a model id
(provider/model, group/<id>); anything else is refused on load.
- gateway: codexPredictionsTo + codexPrediction, wired beside the
descriptions at both entrypoints (gateway.go and codex_backend.go).
Off answers {"suggestion":null} from magpie and sends nothing (the
title Off path made generic as sentNowhere). A model's answer goes back
only as the object Codex asked for (predictionJSON: think tags and code
fences stripped, suggestion trimmed, blank = null). Plain text is never
taken as a suggestion, since Codex would put it in the user's composer
as their next message; it gives null and is recorded as a failure
("prediction: ...").
- usage: purpose "Prediction" for composer_predictions (purposes.js
regenerated).
- gui: POST /api/settings/codex-predictions, kept by the general save;
Settings › General row "Codex composer predictions" (Codex's own / Off /
magpie's models, the app's picker), hidden in gateway mode; Routing's
story for the kind says Codex's own switch (Settings › General › Show
predictions) and magpie's. i18n in zh, zh-TW, ja, de.
- docs: gateway-routing.md's Codex section, reference.md's gateway-mode
list. site/ docs left for the owner.
What was run:
- go test -tags nogui ./internal/gateway/ (full, -timeout 40m),
./internal/gui/ ./internal/settings/ ./internal/usage/: pass.
New: TestCodexPredictionsSetting (default to ChatGPT, off sent nowhere,
model routed, plain turn untouched, ledger kinds), TestNoPrediction,
TestCodexPredictionOnMagpie (/v1/responses and the backend path),
TestPredictionJSON; gui TestCodexPredictionsSetting.
- Broken by hand, each went red: backend wiring removed; plain text
accepted as a suggestion; the general save not keeping the setting;
the Routing story's kind check.
- Playwright codex-predictions.test.cjs: chromium + webkit, 1100 and 420
wide, en/zh/zh-TW/ja/de (20 pass). routing-kind (with the new kind),
codex-descriptions, codex-titles, i18n-keys, gateway-mode,
purpose-filter, routing-purpose-state, settings-general,
settings-sections, settings-search: pass.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows.
Not tried: the real ChatGPT.app's predictions against magpie (the
feature is gated server-side by /wham/predictions/config and isn't on for
the owner's account); the reply shape is from the app's bundle.
|
||
|
|
05edac2c36 |
daemon: the service's PATH has the Node a terminal gets, nvm's default among them (bookyue on Discord)
What changed: `magpie daemon install` now widens PATH before writing it into the systemd unit or launch agent, the way the app does when opened from the Dock (proc.UserPath): the version managers' and npm's folders that exist, nvm's default Node (not its newest), then the login shell's own PATH (proc.LoginPath), each after the folders the install's shell already had. When no node is found even then, the install says so. Why: the service has only the PATH written into it. With nvm loaded lazily, or an install run over ssh without a login shell, that PATH had no node, and plugins (and the MCP servers and agent CLIs they start) couldn't find it under systemd (bookyue, #feedback 838099). Run: gofmt -l; go vet darwin, linux -tags nogui, windows (daemon, cli); go test ./internal/daemon ./internal/cli -count=1 on macOS; the daemon test binary for linux/arm64 in debian:bookworm-slim (all pass). TestInstallFindsNvmNode uses the real widening with a sandbox HOME holding nvm v20 (default) and v22: the unit's PATH has v20's bin, not v22's, after the shell's own. With the widenPath() call removed by hand it fails (PATH is the shell's alone, Node() empty). Not run: a real systemd install with nvm since this change (the earlier container run, before it, covered install/restart/linger); not tried with fnm or volta, which UserPath handles the same way for the app. |
||
|
|
5617281f55 |
cli: magpie daemon install|uninstall|start|stop|restart|status keeps the gateway running as a service (HuanCheng on Discord)
What changed: a new internal/daemon package and `magpie daemon`, which run
`magpie serve` as the user's own service, with no window and no desktop
session.
- Linux: a systemd user unit at ~/.config/systemd/user/magpie.service
(Restart=on-failure), driven by systemctl --user. status reads
`systemctl --user show`, and says `sudo loginctl enable-linger $USER`
when the user doesn't linger. su/sudo without the user's bus, no
systemd, and WSL without systemd each get an error that says what to
do.
- macOS: a launch agent, com.yetone.magpie.serve (RunAtLoad, KeepAlive on
failure), loaded with launchctl bootstrap gui/$UID. Its log is
~/Library/Logs/magpie/serve.log.
- Windows and Android: refused, pointing to `magpie autostart on` (or to
WSL).
- The service carries PATH, the proxy variables, MAGPIE_*, the XDG folders
and the agents' folder variables from the install shell. The file is
0600 because a proxy can hold a password. It runs magpie by its PATH
name when that is the same file, so Homebrew's link survives updates.
It refuses a go-build binary and an AppTranslocation copy.
- Install is refused while `magpie autostart` is on: the tray app serves
the gateway too, and the two would crash-loop on the port.
- Docs: a reference.md section, and one sentence on the site's start page
(en, zh, ja).
Why: users on headless Linux boxes asked for a supported way to keep
`magpie serve` up across reboots instead of hand-written units. The
existing `magpie autostart` needs a desktop session (an XDG autostart
entry).
What was run:
- gofmt -l; go vet on darwin, GOOS=linux -tags nogui, and GOOS=windows.
- go test ./internal/daemon ./internal/cli on macOS, at origin/main
|
||
|
|
5e30d58fe4 |
usage: a request's row says the upstream's own stop reason on the Requests page, in /v1/magpie/usage/requests and in the CSV (#1927, Gluxggg)
What changed: the gateway has recorded why the upstream said each reply ended (Record.Stop: a Responses reply's "completed", Chat's "stop" or "tool_calls", Anthropic's "end_turn") since |
||
|
|
b8e23db45a |
backup, davsync: an import or a sync installs the plugins and names the subscriptions to sign in to (yapechan)
yapechan on Discord (Windows, Synology WebDAV): after an import or a WebDAV
sync no providers showed on the other computer; adding the same provider by
hand made the synced settings and usage apply. No error, a restart didn't
help.
Cause. A backup and a sync carry providers.json as stored. For a
subscription that is its model picks and settings alone (no endpoint, no
key), and sign-ins are never carried by design; allProviders lists such an
entry only once an account is signed in here. plugins.json was not carried
at all, so a provider served by a plugin (every moved subscription, any
plugin provider) had nothing to come from on the other side. The import
said "N added" and "Needs a key: , " (the picks entries have no name and no
key), and the sync said nothing. API-key providers do come over: tried with
a nogui build in two sandbox HOMEs (DeepSeek, a custom relay, Kimi Code all
listed after `magpie restore`). No Windows-only path issue found.
What changed:
- provider.Carried(keys): the plugins added from npm or git, on/off and
their options (without keys, options whose names look like a key are left
out, as secret headers are). Folder plugins and plugin-auth.json stay.
- backup.Bundle.Plugins (nil from an older magpie). Restore installs the
ones not here through provider.AddPlugins (plugin.Add, then Off and
Options, then HandOver once); it never removes or changes one already
here. A failed install is reported, not a failed restore.
- Result.SignIn / provider.NotSignedIn: the subscriptions brought with no
account here. NeedKey no longer lists picks-only entries (provider.OnlyPicks).
- davsync: the providers part's hash covers the plugins (unchanged for a
setup without any), take/bring carry them, bring installs (logged on
failure), and Status().SignIn names what to sign in to.
- CLI restore and `magpie webdav`/`s3` status print both; the GUI's import
result and the sync row show them (en, zh, zh-TW, ja, de).
- docs/reference.md says what a backup carries now.
Run:
- go test -tags nogui ./internal/provider ./internal/backup ./internal/davsync
./internal/cli ./internal/gui in a sandbox HOME.
- New tests fail with the change broken by hand: TestPluginsCarried
(installed-skip and the HandOver guard), TestNotSignedIn,
TestRestorePluginsAndSignIn ("Needs a key: [ Acme]" without OnlyPicks),
TestSyncPluginsAndSignIn (bring not installing, Status not naming),
sync-sign-in.test.cjs (the lines removed).
- sync-sign-in.test.cjs: Chromium and WebKit, en/zh/ja/de, 900 and 440px,
16/16; it also caught subNames throwing while providers was still null.
sync-*.test.cjs, s3-sync, i18n-keys, gui-ja, gui-de pass.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui on the
touched packages.
Not tried: a real plugin install from a real sync (the installs are stubbed
in tests); a real Synology server.
|
||
|
|
f82aba090b |
davsync, gui, cli: GitHub sync refuses a repository that isn't private (#1130)
The sealed setup is committed on every sync, so a public repository would hand anyone every version of it, the whole history, to try passphrases on offline. prepare now reads the repository's "private" field and refuses before writing when it is false or missing, naming the repository and what to do. The form's hint, the CLI usage and docs/reference.md say the repository must be private; sync-backup.md lists the rule and its verification command now points at ./internal/cli. Run: go test -tags nogui ./internal/davsync/ and the cli tests (TestGitHubCmd|TestWebdavCmd|TestS3Cmd|Help) green; TestGitHubPublicRepositoryRefused goes red with the check removed. GUI: github-sync, s3-sync, webdav-settings-refresh, sync-other-kind, sync-not-backup, i18n-keys, gui-zh-tw, gui-ja, gui-de in Chromium and WebKit, 72/72. Not tried against the real GitHub API. |
||
|
|
1af326806f |
sync: magpie's setup syncs to an encrypted file in a GitHub repository, beside WebDAV and S3 (#1130)
A third sync kind: github://owner/repo[/folder] keeps the same sealed backup WebDAV and S3 keep, as <folder>/magpie/magpie.magpie-backup in a repository the user already has, written through GitHub's Contents API with a fine-grained token of its own (Contents read and write), kept in sync.json apart from the library's GitHub token. The token goes only to api.github.com: a redirect anywhere else is refused, and the passphrase may not equal it. Each update is a commit; an empty repository is initialised by the first backup. Settings › Sync gets a GitHub kind with Repository, Branch, Folder and token; magpie github mirrors magpie s3. Inactive servers of every kind are kept in Config.Servers (Other stays for older clients). Squashed from yetone/magpie#1130 at 6b5b1c693e1a3a23e177b4d376f3f7f70f3bc23d onto main. Merge resolutions: the CLI moved to internal/cli since the PR was cut, so github_cli_test.go moved there (package cli) and the github command, its help line and `magpie help github` were wired in internal/cli/main.go and help_cli.go; README's Sync row kept main's links and took the PR's wording; i18n.js zh-TW kept both sides. |
||
|
|
1133ca0fe2 |
gui: the window opens on the page you last left, as a Mac app comes back as it was
molvqingtai on Discord asked for Routing to be the first page, and lc for
the sidebar to be reordered by drag. Rather than a setting or a reorder,
the window now reopens on the page the reader last left: show() keeps the
page in localStorage magpie.lastView, and keptView() opens it at start.
- A page asked for in the address (?view=: the tray's links, a reload)
still wins, Agents too.
- A kept name that is no page opens the first page; one gateway mode
leaves out (Agents, Library) opens Providers, through show()'s and
setGatewayMode's existing fallback.
- localStorage is how the window already keeps magpie.navLayout and
magpie.panelTab across restarts; checked on a copy of the installed
app's WebKit store (~/Library/WebKit/com.yetone.magpie), which holds
those keys from earlier runs.
- Opening on the kept page scrolls nothing.
docs/reference.md and docs/subsystems/gui-shell.md say so.
Run:
- internal/gui/tests/last-page.test.cjs (new), Chromium and WebKit, at
1100 (sidebar) and 420 (header tabs): left on Routing, opened again with
no ?view= and reloaded -> Routing, nothing scrolled; Settings kept;
?view=usage and ?view=agents win; an unknown kept name -> Agents;
gateway mode with agents/library kept -> Providers, routing kept ->
Routing. Broken by hand, it goes red: with show() not saving, with the
kept page not restored, with the kept page beating ?view=, and with
both gateway fallbacks removed.
- model-rate.test.cjs opened "/" after Providers and took it for Agents;
it now asks for ?view=agents.
- 171 GUI files that navigate more than once or touch the start page
(gateway-mode, sidebar*, nav-*, click-scroll, view-*, getting-started,
side-toggle, panel-*...) plus 151 that open the bare root URL, both
engines, 5-6 files at once: all green but model-rate (fixed above) and
load flakes that pass alone here and on origin/main
|
||
|
|
419ef30219 |
gateway: Claude Code gets a safety refusal as Anthropic's own, and switches to its fallback model; how many more accounts are asked is a setting (#1925, DD on Discord)
DD on Discord: through magpie, Claude's safety filter refusing a turn never makes Claude Code move to its fallback model, as it does on Anthropic's API. magpie asked every other account and group member (#248), then told Claude Code a 400 "<model> refused this request", which it takes as an API error. Claude Code 2.1.296 switches on stop_reason "refusal" in a 200 reply (the stream's message_delta or a whole message, stop_details giving the category), and only with a fallback model set; a 400, Anthropic's "Output blocked by content filtering policy" or magpie's, is never retried. What changed: - When nobody is left after a refusal, an agent on Anthropic's Messages API gets the held refusal itself, the vendor's 200 with stop_reason and stop_details, streamed or whole (holdWriter.handBack): keyed Anthropic providers, groups, the Claude subscription. Codex and Chat clients keep the 400, since an empty-looking whole reply makes Codex ask again. - Settings' refusalRetries counts how many more candidates (accounts, then group members, another model among them) a refusal is asked of. Unset is every one, #248's behaviour (Koohoko asked for it); 0 hands it straight back. GUI: Settings > Models > Replies > "Ask again after a refusal" (Never ask again, 1, 2, 3, All), en/zh/zh-TW/ja/de. Global, no CLI: magpie has no general settings CLI (as noLoopGuard). Other 400s are still never asked again; refusals still rest nobody. - disabled-models.test.cjs wheels to Enable, which the new row put past the window's foot at webkit de 420. - Docs: reference.md "When the safety filter refuses", gateway-routing.md. Run: - go test -tags nogui ./internal/gateway (full, -timeout 40m: a first run hit the 10m default at load ~70 from other sessions), ./internal/gui, ./internal/settings; gofmt -l clean; GOOS=linux and windows go vet. - GUI: refusal-retries-setting (en, zh, zh-TW, ja, de at 1100 and 420) with gui-zh-tw, gui-ja, gui-de, i18n-keys and every tab=models suite (disabled-models, images-*, loop-guard-setting, member-model-setting, search-*, searcher-pick, vision-mcp), chromium and webkit: 176 pass. - refusal-retries-setting under load (8 runs at once, load ~200): first 4 of 8 failed at en/ja 420, a press landing on the first save's "Saved" note over the row, then WebKit's wheel still moving the view as the press was measured. It now reaches each button clear of anything drawn over it (reader.cjs reach) and waits for the scroll to rest: 16 of 16. Broken by hand: - handBack off: TestRefusalRetriesNoneHandsClaudeCodeTheRefusal, ...CountsTheTries, ...Group, ...ClaudeSubscription and TestRefusalWithNobodyLeftIsAnError fail (400 "refused this request"). - count ignored: those plus ...CodexStillTold400 fail (the next key answers). - GUI keep-on-omit dropped: TestSettingsRefusalRetries fails; the GUI test fails with All sent as undefined, and with the row not appended. Not tried: a real Claude account's refusal, or Claude Code's fallback switch end to end; the refusal shapes are from Claude Code's source and Anthropic's docs. |
||
|
|
ab1006bb80 |
gui: each WorkBuddy, Trae CN, MiniMax, Qoder or plugin account's daily check-in can be turned off on its own (#1902, magicLaLa)
settings.CheckinOff lists the accounts left out, by their entry in the
vendor's check-in file ("workbuddy|<uid>", "trae-cn|<uid>", a plugin's
"<provider>|<account>"). checkinNow skips them, both in the loop and on
Check in now. provider.CheckinAccounts() lists every account a check-in
reaches; /api/settings carries it as checkinAccounts, and
POST /api/settings/checkin-account {key,on} turns one off or on. A full
/api/settings save keeps the list. Settings shows an Off/On switch per
account under each vendor's Daily check-in row when it has 2 or more
accounts; the Usage card says "Auto check-in is off for this account" and
offers no Check in now for it. en, zh, zh-TW, ja, de.
Run (on 63a361b5f's tree, then targeted again on
|
||
|
|
d6fd9b3a36 |
provider, agent, gui, cli: Codex can switch only its own sign-in between accounts, never through the gateway (#1907, foobra)
foobra wants Codex Desktop and the CLI kept on their own ChatGPT subscription, moved to the next saved account when the signed-in one is used up and back when it resets, without magpie's gateway in the way. magpie already did the switch (codex_switch.go: 98%, 100% In order, back under 90%, unknown usage never switches), but with more than one Codex account on it also wrote openai_base_url into config.toml so a refused request fails over through the gateway (codexFailover). There was no way to have the first without the second. Now Codex's subscription has SwitchOnly (providers.json "switchOnly", opt-in, off by default so nothing changes for anyone who doesn't tick it): - provider.SetSwitchOnly / provider.SwitchOnly; only Codex's own subscription takes it. An unreadable providers.json reads as on, so magpie's own failover is never written on a guess. - agent.codexFailover is false when it is on: no openai_base_url, no failover note, no magpie models in Codex's list. A base URL the user wrote stays. - The account Save copy keeps it. - GUI: "Only switch Codex's sign-in" tick under Providers > Codex's accounts (with more than one on), posting provider/switchonly; the Agents row's failover title points at it. zh, zh-TW, ja, de. - CLI: magpie accounts switch-only codex [on|off]. - docs/reference.md and providers-accounts.md say what it does and that an open Codex app or app-server stays on its account until reopened. Run (darwin, sandbox HOME, -tags nogui): - go test ./internal/provider -run 'TestCodexSwitchOnly|TestCodexSwitchedWhenUsedUp|KeepLogin' - go test ./internal/agent -run 'TestCodexSwitchOnly|TestCodexFailover|TestCodexOwnModelThroughMagpie|TestCodexHandWritten' - Broken by hand, each red: codexFailover guard removed (agent test), SwitchOnly dropped from the Save copy, SwitchOnly reading false on an unreadable file (provider test), the tick drawn unticked (GUI, 16/16). - GUI: switch-only (new), keep-login, agent-failover, gui-ja, gui-de, gui-zh-tw in Chromium and WebKit, en/zh/ja/de at 1100 and 420: 77 pass. - The built binary's `accounts switch-only` in an empty sandbox HOME: reads off, refuses on with no Codex provider, refuses claude. - gofmt -l clean; darwin go vet. Reviewed and rerun after rebasing onto |
||
|
|
30869e35a7 |
usage, gateway: each request's log row says the service tier asked, the one each try was sent at, and the one the vendor said it ran at (#1784, zhenghaowen0967)
What changed
- usage.Record has tier_asked, tier_sent and tier_served, and the CSV gets
them as its last three columns.
- tier_asked is the client body's service_tier (Claude's speed fast reads
"fast").
- tier_sent is the tier the try's last request actually went out at. It
is noted in forwardOnce after every rewrite (a fast pick's priority,
Ultrafast turned to priority on a plan without it, buildResponses
dropping a tier the host can't take) onto the per-attempt wireAt. So a
handed-on try's own row has its own tier.
- tier_served is only what the reply said: service_tier at the top level,
in response.service_tier, or in an Anthropic usage. It is read by the
relay sniffer and by both translated readers, and is empty when the
reply says nothing. It is never filled in from the ask.
- Codex's own relayed sign-in (codex_backend) records the same three.
- /v1/magpie/route: Route.tier (asked), and each Try has tier and
tierServed. The session route has asked_tier, tier, tier_served and each
try's tier and tier_served.
- docs/reference.md (CSV columns) and gateway-routing.md describe them.
Why
zhenghaowen0967 asked that a request whose Ultrafast was sent as priority
to an account without it show that in usage, per try, without calling
the served tier confirmed unless the reply says so.
What was run
- TestTierRecordedPerTry. With Pro out, the first try is recorded
ultrafast, the second priority, and the final record has asked=ultrafast,
sent=priority and served empty while the fake doesn't echo. With an
echoing fake, served is what it said ("ultrafast", and "default" when
none was asked). It also checks the CSV columns, and the Codex relay path
with priority.
- TestUpstreamTierShapes covers the Chat chunk, Responses
response.completed, a Responses body, an Anthropic message_start and
message_delta usage, null, an over-long tier and non-JSON, as well as
bodyTier per protocol.
- Broke it by hand:
- with forwardOnce's noteWireTier removed, TestTierRecordedPerTry goes
red (route tries' tier empty, TierSent empty);
- with the sniffer's Tier line removed, TestUpstreamTierShapes goes red,
and so does the Codex relay case of TestTierRecordedPerTry.
- go test -tags nogui ./internal/gateway ./internal/usage ./internal/cli;
ledger_test's CSV expectations gain the three empty columns.
- gofmt -l; go vet on darwin; GOOS=linux and GOOS=windows go vet -tags
nogui.
Not done
- The served-tier fixtures are built from the shapes OpenAI and Anthropic
document, not from saved replies. Whether chatgpt.com's Codex backend
echoes service_tier wasn't tried against a real account.
- Bridges that don't go through forwardOnce (the Claude subscription,
Cursor's built-in) leave tier_sent empty.
- There is no price multiplier for priority/ultrafast and no GUI column.
|
||
|
|
eba7187368 |
gateway, provider, cli, gui: a group can route By weight, each member's share set beside it (#1910, DD on Discord)
DD asked for weighted round robin as a group routing, next to In turn.
A provider's keys could already route by weight (#841). Groups could not.
What changes:
- provider: Group.Weights maps a member's spelling to its weight, 1 to
1000. A member left out, or set to 0, weighs 1. SaveGroup accepts
routing "weight". It also cleans weights the way it cleans fast and
off: it strips :fast, drops weights of members that are gone and of
members weighing 1, and refuses a weight below 0 or above 1000.
Weights follow a member when it is renamed (RenameMember, Rename,
RenameGroup) and survive Share/Import.
- gateway: planLevel treats each member of a weight-routed group as one
unit: a model with its keys in its provider's order, or a nested group
routed its own way. weightedUnits orders the units by smooth WRR on a
round per group ("group/<id>"), sharing wrrPick with the keys. The
round's pick goes first and the rest stay in member order for
failover. A unit whose head is resting leaves the round. When a
conversation is kept on another member (session/turn/cache/strict),
the charge moves to that member (wrrSeat, wrrMove).
- cli: routing=weight (also weighted, wrr). weight=<model>=<n>[,...]
sets weights and keeps the rest; weight= on its own clears them. The
group view shows "· weight N" for each member.
- tui: By weight is in the group routing list.
- gui: the group editor offers By weight. Each member then shows
"Weight N · S%", its share among the members that are on. Clicking it
edits the number in place: Enter or blur keeps it, Escape cancels,
and a value outside 1 to 1000 shows a warning. The trace header uses
group wording for a weight-routed group. Strings are added in zh,
zh-TW, ja and de.
- docs: reference.md, gateway-routing.md, and site start pages in en,
zh and ja.
Run:
- go test -tags nogui ./internal/provider ./internal/cli ./internal/tui:
ok.
- ./internal/gateway: ok in 988s with -timeout 45m. The first run hit
the default 10m timeout at load average ~170. The test running at
that moment had been running for 2s; it was not a hang.
- go vet -tags nogui on those packages, for darwin, GOOS=linux and
GOOS=windows: clean. gofmt -l: clean.
- New group-member-weight.test.cjs: 8/8 in Chromium and WebKit, en and
zh at 1100, en and de at 420. The WebKit de 420 case also passed six
runs at once.
- gui-zh-tw, gui-ja, gui-de, i18n-keys, routing-*, group-*,
panel-routing*, settings-groups and agent-model-groups: all green
except two.
- routing-steady (WebKit) is #1804. It is red 2/3 alone on origin/main
|
||
|
|
c984adfbc7 |
sessions: a renamed or moved Claude Code project folder is relocated with its sessions, from the Sessions page or the CLI (#1131)
Renaming or moving a project folder left Claude Code's transcripts under the old encoded project path: magpie listed them with a resume command for a folder that no longer exists, and Claude Code in the new folder didn't find them. A Claude Code folder row on the Sessions page now has Relocate project, which opens magpie's own dialog with the new absolute path, a read-only preview and a confirm that carries the preview's token; `magpie sessions relocate-claude --from --to [--confirm <token>]` does the same in a terminal (inside WSL too). The whole project store moves, session ids, subagents, tool results and memory with it; the transcripts' top-level cwd and the sessions index are rewritten, message text is not. The originals and a recovery manifest are kept outside Claude's project list, writes are staged before the originals are renamed, a change since the preview is refused, and a failed publish rolls back. An existing target store, recently written files, a malformed transcript, a symlink, an ambiguous encoded path or a long hashed name are refused. Desktop's stores are left alone. Recovery is in docs/session-relocation.md. Jianyu's PR head e8263cde, which conflicted with main: the button moved into main's folder() row, the CLI test into internal/cli beside sessions_cli.go, and both sides of sessions_manage.go and i18n.js kept. Run: see the next commit, which adds the zh-TW/ja/de strings and the GUI test. |
||
|
|
087985c778 |
usage, gui: a Codex turn of one call too short to time tells its whole-turn floor only at 1,000 tokens or more, as Claude Code's does (Fallmonkey on Discord)
Fallmonkey's report: an 11-token gpt-6-astra answer in 2.75 s, too short
after its first token to be measured, showed "≥4 tok/s" from the
whole-turn fallback (
|
||
|
|
e528aeb3ce |
agent: DevEco Code, Huawei's OpenCode, as an agent (#1885)
foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's
HarmonyOS coding agent. It is OpenCode underneath, so it joins through
openCodeLike as MiMo Code did (
|
||
|
|
b0e3177d9d |
provider: Ollama Cloud shows its plan's included allowance and its bought credits in Usage and magpie quota (#1888)
What: an ollama-cloud key (any provider whose base is on ollama.com) is read at GET https://ollama.com/api/balance with Authorization: Bearer <key>. included.{balance_usd, allowance_usd, period} becomes a plan card (PlanQuotas, planQuotaSourceOf) with one window in USD: spent of the allowance, named Month when the period is a month long, resetting at period.until. purchased.balance_usd becomes the key's balance card (KeyBalances, balanceSourceOf). Routing weighs the key by that window as it does other plan keys (keyWindows), and the window is Aside while bought credits are left, since spending past the allowance draws on them. Absent fields are unknown, never $0: no included, no allowance, an allowance of 0 or no balance_usd gives no window (and, as for MiniMax and Command Code, no plan card); no purchased gives no balance card (new errNoBalance, which KeyBalances leaves out instead of showing an error); null period gives a window with no reset. A reply with neither object says its shape. A refused key's balance card says Ollama's reason. Why: #1888 asked for Ollama Cloud's balance and plan quota beside the other key-bought plans. Run: - go test ./internal/provider -run 'Ollama|TestPlanQuotaSource|TestBalanceSourceByHost|TestKeyBalances' in a sandbox HOME: pass. Broken by hand five ways, each red: no ollama.com plan source (TestOllamaCloudCards, TestPlanQuotaSource), missing purchased read as $0.00 (TestReadOllamaBalanceMissing, TestOllamaCloudCards), KeyBalances not skipping errNoBalance (TestOllamaCloudCards), missing included.balance_usd read as 0 (TestReadOllamaBalanceMissing: a $20 allowance shown 100% used), Aside dropped (TestReadOllamaBalance). - The built binary in a sandbox HOME with an ollama-cloud provider and a fake key: `magpie quota` asked the real ollama.com and showed `ollama-cloud balance 401 Unauthorized: {"error":"invalid credentials"}`, no plan card. - gofmt -l, go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet, go build for darwin, linux (nogui) and windows: clean. - go test -tags nogui ./... in a sandbox HOME at load ~27: 48 packages ok; internal/agent and internal/gateway hit the 10m timeout, and in gateway TestIntentClassifierGroup (#1813, 3.63s against its 3s bound) and TestHistoryKeepsDaysAndDropsOld (filed #1892) failed. Rerun with -timeout 40m both packages pass (1032s, 1138s). Neither package reads ollama.com or these readers. Not tried against the real API with a real key: the owner's magpie has no ollama-cloud provider, so the fixtures are the issue's literal JSON and the free-plan and missing-field shapes are guesses from it. Whether a spent allowance really falls through to bought credits (Aside) is not verified either. Reported-by: yangmingyuan380 |
||
|
|
b6831d83e1 |
gateway, gui: Codex's thread descriptions go to a model picked in Settings, apart from its titles (#1198, congee949)
Codex asks its own model, through its ChatGPT sign-in, for each thread's description (thread_description), even while the conversation runs on magpie's models. Settings › General gets "Codex thread descriptions" beside "Codex thread titles". It defaults to Codex's own, which sends the request as Codex sent it, or it can name one of magpie's models or a routing group. The answer is wrapped as description-only JSON. The titles setting is untouched. Usage and Routing show these requests under their own Description purpose. The setting is kept across unrelated Settings saves. There is no Off yet, because Codex's handling of an empty description hasn't been checked. This is a first slice of #742. Squashed from the PR and merged onto current main. Conflicts resolved: - codex_backend.go: the description branch comes after the title branch, ahead of main's subagent pick. - gateway.go: main's CC Switch #1301 comment above the compaction block is kept; the PR had shortened it. - app.js: the gateway-mode list of hidden rows takes the new row. - i18n.js and settings_keep_test.go: both sides kept. - purposes.js: regenerated with go generate ./internal/usage. Run on the merged tree: - gofmt -l is clean. - go vet passes on darwin, linux -tags nogui and windows; the builds on all three succeed. - go test -tags nogui passes for ./internal/gateway, ./internal/gui, ./internal/settings and ./internal/usage. - GUI, chromium and webkit: codex-titles, gateway-mode, purpose-filter, routing-purpose-state, gui-de, gui-ja, gui-zh-tw, i18n-keys, settings-general/-groups/-sections/-search and click-scroll: 118/118. Broken by hand: with the description branch removed from codexBackend and handle, TestCodexDescriptionsSetting, TestCodexDescriptionFallbackOnMagpie and TestNoDescription fail. Not tried: a real Codex thread_description request, and whether Codex's sidebar takes the answer. |
||
|
|
4419ebf7d6 |
cli, agent: magpie <agent> <field> shows that field and a field's name or DEFAULT is no longer written as the agent's model (#1129, waitingsnow)
What: `magpie codex model` wrote model = "model" into config.toml (and
applied.json, stash.json); any agent's field name given alone, or as a
value, was set as its model, and `magpie codex DEFAULT` wrote
model = "DEFAULT". Now:
- `magpie <agent> <field>` (any case) prints that one field and writes
nothing;
- a field's name given as a value is refused with a hint
(`magpie claude effort Ultracode`);
- DEFAULT in any case takes magpie out, as `default` does;
- Claude Code's tier names (opus/sonnet/haiku/fable) still set the model,
since agent.ModelAliases marks them, and the agent's help says so.
agent.Field matches key and label in any case; agent.Running is a var
so the cli tests can say Codex isn't open.
Why: ported from waitingsnow's #1129 (commits bbe75c91f, 00bb38581,
244b24a67) onto internal/cli, where the CLI moved after the PR was
opened. The PR's --help part landed earlier as
|
||
|
|
dfbe001ff9 |
usage, gui: re-land def3a41e3, a Codex one-call turn timed only over a second and 100 tokens after its first token
|
||
|
|
aabdd6126a |
gui: a model's speed leads with the figure from more replies, counts written out, TTFT on its own line
Fallmonkey (Discord) read "75 tok/s (3) · ≥54 tok/s (289)" on the Output
speed card and the Usage ranking as the 3-reply figure being the model's
speed, with the 289-reply floor tucked behind it, and "(3)" not saying
what was counted.
Now, everywhere a group's speed shows (the Output speed card, the
overview lists and the Usage ranking by speed):
- the figure from more replies comes first and is the big one; a tie
keeps the measured one first. The ranking orders and bars by it.
- counts are written out, without parentheses:
"≥54 tok/s · 289 replies; 75 tok/s · 3 timed replies"
zh "≥54 token/秒 · 289 次回复;75 token/秒 · 3 次计时",
with zh-TW, ja and de strings of their own.
- on the card the second figure is its own line, and the average wait
for the first token is a line of its own with its count
("first token in 1.2 s on average · 3 timed replies"), wrapping rather
than cut off. In the big figure the count is a muted caption without
the dot, so a wrapped count never starts a line with "·".
- the tooltips are unchanged; the threshold for the floor is unchanged.
What was run:
- usage-speed and usage-ttft-rounding now expect the TTFT line's
count; green in both engines.
- usage-speed-count.test.cjs (rewritten for the new rule) in Chromium
and WebKit, 5 languages x widths 1400/983/789/700/560: 26/26 each.
On origin/main's assets it fails ("125 tok/s (1) · ≥50 tok/s (259)").
- 55 related suites (usage-*, ledger-*, reasoning-speed, routing-*-speed/
metrics, panel-usage, gui-de/ja/zh-tw, i18n-keys, click-scroll,
tray-usages) in both engines: all green.
- gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/gui; go test -tags nogui ./internal/gui: ok.
- Screenshots of the card and ranking at 560 and 1400 in en, zh, de.
Reported-by: Fallmonkey (GitHub MonkeyLeeT)
Co-authored-by: MonkeyLeeT <MonkeyLeeT@users.noreply.github.com>
|
||
|
|
d4c2512d2d |
usage: apps report their own calls with POST /v1/magpie/usage/requests, backfill included (#1874)
What changed
- POST /v1/magpie/usage/requests (internal/gateway/usage_ingest.go) takes
one record or an array, in usage.jsonl's shape:
- the post may carry up to 5000 records and 32 MiB;
- t, agent, provider, model and rid are required.
Each field is checked: unknown fields, quoted numbers, negative or absurd
counts, a status outside 100-599, a cost over 10000 USD, and a t more
than an hour ahead or before 2000-01-01T00:00:00Z. Any fault refuses the
whole post with a 400 that names error.index and error.param, and nothing
is written. A past t is otherwise taken as given, so history can be
backfilled. The reply gives accepted and skipped counts and each
record's index, rid and status.
- Access: lanGuard's rule (this machine, or another with a key while
shared, behind the Host check). A browser page also needs a key, since
corsGuard lets localhost pages and Origin null through. A held key is
refused.
- usage.IngestReported writes under usage.mu to the same file as
usage.Append. Rows carry source "reported" and no caller key. A rid
already reported is skipped, as is one repeated in the post. The set of
reported rids is read back from the log: one scan after a restart (lines
without the reported mark aren't parsed), then only what was appended.
- Pricing: a record with cost keeps it (Record.OwnCost, the rowOwnCost
flag; packed flags widened to uint16). Otherwise it is priced at
magpie's prices.
- Display:
- SourceReported is a source of its own: RequestPage.Reported,
?via=reported, and Ledger now honours via.
- The Requests tab gains a fourth cell "reported by apps", shown once
there are some, and a "Reported" badge (en, zh, zh-TW, ja, de).
- Nothing live: Record.IsReported keeps reported rows out of:
- a key's budget/spend limit (budget.counts);
- window holds, and the log start that decides whether a window can be
reckoned (logSnapshot.firstOwn);
- gateway sessions and Vias;
- Codex's sealed answers and remembered model.
There is no OTel span, rate limit, rest or alert for them.
- Docs: gateway-sessions.md, reference.md (with a curl), integrating.md,
site integrate.html (en, zh).
Why: the reporter's apps call vendors directly, and their usage (and
history) should show on the Usage page without becoming live traffic.
Run, in a worktree with sandbox HOME and a private GOCACHE
- gofmt -l: clean.
- go vet ./...: darwin, GOOS=linux -tags nogui, and GOOS=windows.
- go test internal/usage, usageapi, budget, gateway, gui: ok.
- -race -count=3 of the new usage/gateway tests: ok.
- GUI with playwright 1.62.0:
- usage-ledger-reported.test.cjs, 26/26 in chromium and webkit (5
languages, 1180 and 420 wide, light and dark);
- usage-ledger*.test.cjs, ledger-*.test.cjs, usage-sum-whole,
usage-unpriced-sum and i18n-keys: all pass.
- Timings with 200k reported rows (47 MB log, darwin):
- 40 posts of 5000 took 0.40 s (worst batch 18 ms);
- the first post after a restart took 0.45 s (rid rescan), a later one
1.6 ms;
- the cold index build took 2.1 s (as for gateway rows);
- page all took 27 ms warm, page 30d 39 ms, all via=reported 0.53 s;
- summary all took 215 ms, 30d 20 ms.
Broken by hand, each went red, then restored
- Go: dedupe against stored rids; the restart scan; CostAt ignoring own
cost; the block pricer overwriting own cost; the Reported split;
fromBrowser's key rule; skipping bad records instead of refusing; the
max-records and body limits; the ingest lock (race); both locks;
firstOwn -> first; the IsReported guards in windowHolds,
buildGatewaySessions, buildVias, budget.counts and loggedAnswers.
- GUI: the fourth cell, the --vias column count and the badge class.
Not shown red on its own: the remote-no-key and evil.example refusals come
from lanGuard and corsGuard before the handler, so breaking only the
handler's own check stays green. The codex_memory guard is not tested
alone: a reported row has no Requested there anyway. Not tried: a real
client against a live gateway, Windows/Linux runs of the tests, the full
GUI suite.
|
||
|
|
1f0ff81dfc |
agent: Grok App's own route picked in magpie is taken, and Disconnect can put one back; a sync that isn't connected writes nothing (#1625)
Follow-up to fjrtdk's commit before this one, which this keeps: magpie never names itself as Grok App's route. - Set refused every own route (errGrokAppRoute) while Options still offered them, so the picker showed choices that only errored. It also broke Disconnect: when unwire leaves no route (Use set it to magpie, nothing stashed), Disconnect sets connect.was's route back through Set, got the error and stopped half done. An own route now takes magpie's channel out and is written as [models] default, the way picking another provider leaves magpie on other agents. That route can't be magpie, so the App's sign-in is never touched. - Sync ran rememberRoute/releaseRoute before checking for the channel, so every user with Grok App installed but not connected got stash entries. Now it returns before them unless the channel is there or the route is still magpie (an older magpie's takeover to put back). - Check again warns when the route is magpie and the channel is gone, which that commit dropped. - The notice uses the App's own labels (Settings › Account, Use; ja 「使う」, de Einstellungen › Konto / Verwenden, from grok-app 0.2.40's settings.nav.account and prov.useThis) and says a chat can pick magpie's models in its model picker (composer_prefs_set, which doesn't move the route). - Sibling: rtk init has no grok agent for Grok Build either (rtk 311ebcb agents: claude codex copilot cursor droid gemini hermes opencode pi trae vibe antigravity), so Grok Build is in rtkNoHook too. Run: gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows clean; go test ./internal/gateway ./internal/agent ./internal/library -count=1 pass; node --test i18n-keys and agent-notice-lang pass. Broken by hand: that commit's grokapp.go fails TestGrokAppOwnRouteStays, TestGrokAppDisconnectPutsTheRouteBack and TestGrokAppSyncUnconnected; dropping the Check branch fails TestGrokAppSyncUnconnected; dropping rtkNoHook["grok"] fails TestRTKNoHookGrokBuild. Not tried: the Grok App GUI itself; the config format and behaviour are from grok-app 0.2.40's source. Co-authored-by: fjrtdk <fjrtdk@gmail.com> |
||
|
|
ea3d480edf | agent: Grok App keeps its own route; magpie is a custom provider under Accounts, and the Library writes instructions, MCP and skills on agent-home (#1625) | ||
|
|
8b9d63f58a |
usage: a cost total says how many calls it couldn't price, never reads them as free (#1856)
cnlove7777777-art's Kimi K3 Auto and GLM-5.3 Max calls had "no price",
and Usage's sum counted them as $0 with nothing beside it but a "+" and a
tooltip. Now every total that sums cost says the count:
- GUI: Overview's and Requests' heads read "≈$0.001+ 2 calls unpriced";
with nothing priced, the count alone (Requests showed nothing at all
before). Overview's calls tile adds "2 unpriced". Sessions, which prices
by model, says "1 model unpriced" in its head and cost tile. The count
stays at every width: the narrow and .tight rules no longer hide it,
and the head goes tight when the count would be cut, sum or not.
"no price for these models" is no longer shown, its key removed.
- CLI `magpie usage`: "≈$0.001+ (2 calls unpriced)". TUI Usage page: the
same after its cost.
- docs/reference.md: unpriced calls are left out, said beside the total;
magpie doesn't guess a variant's price from a similar name.
No variant price is mapped: models.dev lists neither "Kimi K3 Auto" nor
"GLM-5.3 Max", Zhipu's "Max" is a Coding Plan tier, and -fast variants
are 1.5x their base, so a suffix strip would be a guess. The existing
per-model price override (provider editor, `magpie model price`) covers it.
Run: go test ./internal/cli ./internal/tui ./internal/gui (ok);
TestUsageSaysCallsUnpriced and TestUsagePageSaysCallsUnpriced fail with
the fix taken out. usage-unpriced-sum.test.cjs (new) passes in Chromium
and WebKit, en/zh/zh-TW/ja/de, 360-1240px, and fails 5 of 5 on
origin/main's assets. Related GUI files (every test naming usageCost,
unpriced, effective prices, usage-head or "{n} failed", plus i18n-keys,
gui-zh-tw/ja/de, number-units, text-size, usage-ledger, ledger-protocol,
usage-range, mobile-web, phone-web, view-no-sideways): 655 pass; the
WebKit text-size foot case and routing-sessions fail the same run alone
on origin/main
|
||
|
|
2c30e5cee7 |
usage, gui: revert def3a41e3 until Fallmonkey says what context it missed
Fallmonkey asked on Discord (#feedback, 10-12 19:55) to hold the
single-call Codex threshold: "先别做?感觉你漏掉context了". It is not in a
release yet, so take it off main until the rule is agreed, rather than
ship a speed rule its own requester has paused.
This reverts commit
|
||
|
|
def3a41e36 |
usage, gui: a Codex turn of one call is measured only over a second and 100 tokens after its first token, else told as the least it wrote over the whole turn (Fallmonkey on Discord)
Fallmonkey's repro: a Codex turn whose first token came at 6.8 s (the model working) and the rest 0.2 s later in one network push read as thousands of tok/s from its session file. The promised rule, now in: - A Codex turn of one call read from its session file (source "log", turn TTFT known) tells a measured speed only when the window after its first token is 1 s or more and its body 100 tokens or more (usage.CodexWindowMs, CodexBodyTokens; Row.Decode, app.js ledDecode). - The floor from |
||
|
|
248a68598c |
gateway, provider, gui, cli: a key+URL provider may be sent the agent's own User-Agent in place of magpie's (#1851)
Every forward went with User-Agent magpie/<version>. A coding plan that serves only the agents it names (pi, OpenCode, Claude Code…) knows them by their User-Agent, so it turned magpie away. What changed - provider: PassUserAgent (passUserAgent in providers.json), off by default. PassesUserAgent takes it only for a key+URL provider: never a signed-in account, a plugin's, or a vendor whose own client magpie goes as (OwnClient: OpenCode, Cline, Kilo, another magpie). A copy keeps it. - gateway: userAgentFor in forwardOnce (chat, Anthropic, Responses, Gemini, count_tokens) sends the inbound User-Agent unchanged where the provider passes it on. It sends magpie's where it doesn't, where the agent sent none, and on magpie's own requests (magpiesOwn: magpie/…, magpie-router/vision/search, the image tool's "<client> magpie-image/1", which is built from MCP clientInfo, not a User-Agent). magpie never invents another client's. The claude-cli/Codex header copies, the OpenCode/Cline/Kilo overrides and account signing run after it as before, and the user's header.User-Agent is put on at signing, so it wins. - gateway: embeddings, images and videos (retrieveFrom, sendWith, remoteVideoContent) now stamp the same for a key+URL provider through stampUA, from the caller's User-Agent kept on the request ctx (caller.ua, withCaller). Before, they went with Go's default (Go-http-client/1.1). Account and remote-magpie paths are untouched. - cli: `magpie provider set <id> user-agent=agent|magpie`, refused for a signed-in account; `magpie provider <id>` shows it. - gui: the provider editor's User-Agent row, "Send the agent's own User-Agent", with an explanation, for a provider with a key only (the JSON says ownClient for presets and providers); en/zh/zh-TW/ja/de. The TUI only adds presets, so it has no field for this. - docs: reference.md (provider set) and subsystems/gateway-routing.md. What was run - gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows. - go test -count=1 ./internal/gateway ./internal/provider ./internal/cli ./internal/gui: all ok (sandbox HOME, private GOCACHE). - TestUserAgentPassedOn covers 7 routes (messages, count_tokens, chat, responses, gemini, embeddings, images) x off / on / on with no UA / on with magpie-router/1 / on with the image tool's UA / the user's header with it on and off. TestUserAgentAccountUntouched: a Factory account with passUserAgent in providers.json is still asked as factory-cli/. Also TestUserAgentClaudeCodeAsBefore, TestUserAgentFor, TestPassesUserAgent, TestAddCopyPassUserAgent, TestProviderUserAgentPair. - Broken by hand, each went red: forwardOnce back to magpie's UA (5 routes red); stampUA removed from embeddings/draw (both red, seen as Go-http-client/1.1); PassesUserAgent ignoring accounts/OwnClient; magpiesOwn dropped (the internal UAs leaked on all 7 routes); the GUI row shown for OpenCode and Save not posting it. - provider-user-agent.test.cjs: 60/60 in chromium and webkit, en, zh, zh-TW, ja, de, at 900 and 440 wide. The provider/editor/add/i18n GUI tests in chromium: 244/244. Not run - Not tried against a real coding plan that checks User-Agent, nor with a real agent through a live gateway. Videos have no test of their own (they go through sendWith, which the images test covers). - The GUI suite was not run in full; the Windows box was not used. |
||
|
|
e08902e79d |
agent, library: Hermes Agent's folder is %LOCALAPPDATA%\hermes on Windows, and rtk's installer is told it (新v学员 on Discord)
新v学员 runs magpie on native Windows. Library -> RTK -> Hermes Agent
failed with "rtk's installer didn't add its hook to Hermes Agent:
Config: C:\Users\admin\AppData\Local\hermes\config.yaml ...". magpie
hard-coded ~/.hermes. Hermes' own default
(hermes_constants._get_platform_default_hermes_home) is
$LOCALAPPDATA\hermes on win32 (~/AppData/Local/hermes when LOCALAPPDATA
is empty) and ~/.hermes elsewhere, with $HERMES_HOME overriding it.
rtk 0.51's resolve_hermes_home knows only $HERMES_HOME and ~/.hermes,
on every OS.
What changed:
- appdir.HermesHome / HermesHomeIn / HermesDefaultIn: $HERMES_HOME,
else Hermes' per-OS default. This is the one place that resolves it.
- agent: hermesIn (Agents-page model wiring) and hermesProfiles use it
through place.hermesHome / hermesDefault. A WSL distro keeps
~/.hermes (Linux paths, Windows env not read). The Agents-page wiring
was wrong on native Windows too: without HERMES_HOME it wrote
%USERPROFILE%\.hermes\config.yaml, which Hermes never reads.
- sessions.HermesDir uses it, so Windows sessions are found.
- library/rtk: the hermes spec reads and writes the agent's own folder
(a.Dir), and rtkSpec.env passes HERMES_HOME=<that folder> to
`rtk init -g --agent hermes --auto-patch`.
- Tests resolve the folder through appdir instead of home/.hermes. New
TestHermesDefault/TestHermesHome (appdir), TestHermesFolder (agent:
Windows default, profiles under it, WSL unchanged), and
TestRTKHermesHome (library, a fake rtk that behaves like 0.51).
- docs/reference.md and docs/subsystems/library.md describe the
Windows folder and the env.
Run:
- gofmt -l clean. go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows.
- darwin: go test ./internal/appdir ./internal/library
./internal/sessions ./internal/agent ./internal/tui.
- TestRTKHermesHome against the old rtk.go fails with the reporter's
exact message ("didn't add its hook ... AppData/Local/hermes/
config.yaml"), and its default subtest fails with HERMES_HOME="".
- Windows box (cross-compiled test binaries, testenv sandbox
USERPROFILE/LOCALAPPDATA): appdir Hermes tests, agent
Hermes|Reseat|Effort (incl. TestHermesFolder) and library Hermes|RTK
pass. TestRTKHermesHome skips there (shell fake). The sessions binary
failed only TestHermesMessageVisibility, because its testdata wasn't
copied to the box.
- Real rtk.exe 0.51.0 on the Windows box: with
HERMES_HOME=<sandbox>\AppData\Local\hermes it wrote the plugin there
and patched that config.yaml. Without HERMES_HOME it wrote
C:\Users\<user>\.hermes, ignoring a sandbox USERPROFILE (rtk asks
Windows for the home folder). That confirms the cause and the fix.
The stray folder it made on the test box was removed.
Not run: real Hermes on Windows (no install, and running hermes under
a temp HERMES_HOME rewrites the live launcher); the GUI suite; the full
go test ./... ; the reporter's own machine.
|
||
|
|
7d9382db23 |
gateway, settings: an unreadable settings.json keeps the allow list read last, or lets in only this computer, never every address
Follow-up to
|
||
|
|
7a9490638d |
gateway, gui, settings: an IP / CIDR allow list for the gateway, from MAGPIE_ALLOW_IPS or Settings beside Share on local network (lc on Discord)
What changed: lc runs magpie in Docker on a public host and asked that
only some addresses reach it at all. With a list set, a request from an
address outside it is refused 403 ("magpie answers only the addresses on
its allow list ..., and this request came from <addr>: add it there to
let it in") before its gateway key is looked at, so a leaked key is no use from
elsewhere. No list is as before.
- internal/settings/allowips.go: SplitAllowIPs, ParseAllowIP (an IP or a
CIDR range, v4 or v6; zones dropped, v4-mapped unmapped), CleanAllowIPs.
Settings gets AllowIPs (allowIPs).
- internal/gateway/allow.go: MAGPIE_ALLOW_IPS (comma or space separated)
sets the list in place of Settings'. The address judged is the
connection's own (r.RemoteAddr); X-Forwarded-For and the rest are never
believed (magpie has no trusted-proxy list; MAGPIE_TRUST_PROXY never
reads forwarding headers, and this follows it). Loopback and this
computer's own interface addresses always pass. An entry that doesn't
read lets nothing in and is logged once, so a typo never opens magpie
to every address. lanGuard checks it after the OAuth callback and
before the rebound-Host and key checks; `magpie web` is wrapped with
AllowGuard too.
- GUI: Settings > Network shows an "Allowed addresses" row under Share on local
network when sharing is on, the page is open from another computer, or
the env var is set (then read-only, saying so). POST
/api/settings/allowips saves it, refuses it while the env var is set,
refuses an entry that doesn't read, and refuses a list that would shut
out the address the page itself is open from (KeepsOut). The generic
settings save keeps AllowIPs. Strings in zh, zh-TW, ja and de.
- Docs: the Docker page (en, zh, ja) lists MAGPIE_ALLOW_IPS with a note
that a request from the host itself arrives from the bridge's gateway
(172.17.0.1), that Docker Desktop and rootless Docker show clients as
one address of their own, and that behind a proxy every request comes
from the proxy; docs/reference.md and docs/subsystems/gateway-routing.md
describe it. The READMEs list no env vars, so they are unchanged.
Why: a gateway key is the only lock on a public host; an allow list keeps
everyone else from even trying it.
Run (machine load average 75-140 from other sessions, so the large
packages ran in slices of their top-level tests, each slice
-timeout 9m, private GOCACHE, sandbox HOME):
- New tests: internal/gateway/allow_test.go TestAllowList (allowed,
denied, CIDR v4/v6, IPv6 literal, link-local with zone, v4-mapped,
loopback and own address always in, on the list still needs a key,
a typo shuts everything out, env over settings), TestAllowListServed
(a real connection from loopback passes lanGuard under a list naming
nothing of this computer's; a request from elsewhere is 403 naming its
address and MAGPIE_ALLOW_IPS), TestKeepsOut; internal/settings/allowips_test.go
TestCleanAllowIPs; internal/gui/allowips_settings_test.go
TestAllowIPsSetting; internal/gui/tests/allow-ips.test.cjs (14/14 in
chromium and webkit, at a 390px panel, en and zh, keys in zh, zh-TW,
ja and de). Broken by
hand: with lanGuard's check removed TestAllowList and TestAllowListServed
FAIL; with KeepsOut skipped TestAllowIPsSetting FAILs; with renderAllow
not called the GUI test has 5 failures. Restored, all pass.
- internal/gui/settings_keep_test.go gains AllowIPs:
TestSettingsSaveKeepsWhatItDoesNotSend failed without it, as it should
for a new field.
- go test -tags nogui: every package ok. internal/gateway (4 slices),
internal/agent (4), internal/provider (3), internal/gui (2),
internal/plugin (2), the rest whole. GUI Network-settings test files
(11) 98/98 and i18n-keys ok, both engines.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... ok; linux and windows builds ok.
- Not tried: a real Docker container on a public host (the bridge note
is from Docker's docs, not checked here); behind a real reverse proxy.
|
||
|
|
908c910931 |
gateway, gui: Stays: Strict keeps a conversation on the account or key that answered it, even past its cap, and passes its error on rather than moving it (#1797)
miniers asked that a conversation never move to another account: a
move changes the account a vendor sees mid-conversation and loses its
prompt cache. Session affinity keeps the account while it can answer,
then moves on.
The new affinity mode "strict" (Stays: Strict) does what session does
for a new conversation. Once one has an account, strictKeep asks that
account alone (its other models too) and no other account, key or
provider:
- one resting or spent is still asked, and its error (429, 402, 5xx)
goes to the agent rather than to the next candidate;
- one over a user cap is asked past it (plan's capped candidates,
capHeldOnly);
- one held for credits answers 429 naming Stays: Strict rather than
moving;
- one removed, turned off, barred or not allowed for the key counts as
gone, and the conversation is routed as usual.
A last try that fails verification is not rested for a strict
conversation that had nowhere else to go.
Set in the provider editor and the Routing page's pool row (GUI, all
five languages), `magpie groups ... stays=strict` (strict-session,
never-move), and the TUI ("stays strictly"). Documented in
gateway-routing.md, reference.md and the site's start pages (en, zh,
ja).
Run:
- go test -tags nogui ./internal/gateway (-timeout 30m under load ~150),
./internal/provider ./internal/tui ./internal/cli: ok. The three
TestStrictAffinity* tests fail on the code before this commit (200
where 429 was expected, acct-2 answering).
- GUI: stays-strict.test.cjs, chromium and webkit, 900 and 560px, en,
zh, zh-TW, ja, de: 30 of 30. On the assets before this commit it
fails 15 of 15 in chromium. routing-*.test.cjs pass but for
routing-steady's webkit 1.69px shift, which fails on the old assets
too: filed as #1804.
- gofmt -l, go vet (darwin, linux, windows), full go test ./... before
the push.
Not tried: a real agent conversation held on a real rate-limited
account.
Known and left: planLevel doesn't merge a nested group's sub.held, as
before this commit.
|
||
|
|
50eeaae6ce |
gateway: a turn that names no reply limit is sent the model's own as max_tokens on Anthropic's API, not a flat 16384 (#1792, tensornull)
Anthropic's Messages API needs max_tokens. A request that names none (Codex's Responses turns, a Chat client's) was always sent 16384, so a long thinking and tool turn on a Claude-shaped relay hit the limit, and Codex showed "Incomplete response returned, reason: max_output_tokens". Now such a request is sent askedOutput(p, model). That is the plain Served entry's PublishedOutput(), the same number the agents are told: the user's Max output first, else the vendor's list or models.dev, within the window. 16384 (defaultMaxTokens) is used only when nobody knows the limit. A limit the client names still goes as it is. The thinking budget is still fitted under max_tokens (anthropicBody), whatever the limit is. Both places that build an Anthropic body are covered: forwardTranslated, for every translated route, and serveZed for a Zed subscription's Claude models. The provider editor's Max output hint now says this number is also sent as max_tokens (en, zh, zh-TW, ja, de). docs/reference.md and docs/subsystems/gateway-routing.md no longer say the gateway never uses the limit. Run: - TestAnthropicMaxTokensIsTheModels covers: the user's 65536 (Responses plain and streamed, and Chat), models.dev's 64000, a 500000 limit held to the 100000 window, an unknown model at 16384, the client's own 1000, and thinking under 8192. - TestZedClaudeMaxTokensIsTheModels expects 40000 when the client names no limit and 1000 when it does. - Both tests fail on the old code: 16384 where the model's number was expected. - go test ./internal/gateway/ passed (1270s, under load). - provider-max-output.test.cjs passes 28/28 in chromium and webkit: 5 languages at 900 and 420px. The hint names max_tokens and Anthropic, is translated, and doesn't overflow. - gofmt -l is clean. go vet passes on darwin, on linux with -tags nogui, and on windows. Not tried against a real Anthropic-compatible relay with a real Codex session. |
||
|
|
c533499446 |
provider, gui, cli: a group can keep its models out of the lists agents see, offered through the group alone (#1783)
cybershape asked for a client's model list to show only a group, not every model behind it. A provider could already be kept for routing groups (Provider.Unlisted), but that hides the whole provider, and the models a group names may come from providers used elsewhere too. Group.Unlists (json "unlists"): the models a group names (a member fixed at an effort counts as its model) and those its patterns match leave Catalog(), so `magpie models`, /v1/models and every agent's list (CatalogFor) show the group without them. They stay in Served(), so a group routes over them and a request naming one as provider/model is still answered, and Unlisted() returns them for the GUI as it does an unlisted provider's. A nested group keeps its own setting; a group switched off or hidden keeps nothing out. With no group unlisting, Catalog() takes a fast path and is unchanged. - Routing view: the group editor's "Model lists" (Its models too / The group alone, segmented, with a hint), saved with Save; the card shows "Its models unlisted". Both group Save paths send unlists. zh, zh-TW, ja, de. - CLI: `magpie group set <id> listed=no|yes`; `magpie group <id>` shows listed: no. - TUI: the group member picker offered Catalog(), so models kept out of the lists (an unlisted provider's, before this too) couldn't be put in a group from the TUI. It offers Served(), as the GUI's picker does. - docs/reference.md, Routing groups: listed=no. Product call: a per-group switch, off by default, rather than hiding members of every group, so existing lists don't change under anyone. Run: - go test ./internal/provider -run 'Group|Catalog|Unlisted|Served', ./internal/gui, root package, ./internal/tui: ok. TestGroupUnlistsItsModels fails with the Catalog filter removed; TestMemberOptionsOfferUnlistedModels fails with the picker on Catalog(); TestApplyGroupPairs covers listed=no/YES/maybe. - GUI group-unlists.test.cjs, Chromium and WebKit, en zh zh-TW ja de, at 1100px and 420px: 20/20. i18n-keys: ok. - gofmt; go vet darwin, windows, linux (-tags nogui): clean. Not tried: with the reporter's own client; a real agent's model file written after toggling (CatalogFor is covered by the test). |
||
|
|
0d58ec8dcb |
davsync: a write a server without conditional PUTs let another go over is merged again at the next sync (#1776)
On an S3 server that refuses If-Match (Aliyun OSS answers 400 NotImplemented), put falls back to HEAD then an unconditional PUT. Two computers writing in the moment between both pass the HEAD, both are told they wrote, and the later file is kept. Worse, the loser's next sync then took the winner's file as having seen its own: its st.Remote was the file it wrote, so its changed parts looked unchanged here and changed there, and the old parts were brought in over its own changes. The edit was lost on the server and on the computer that made it. - version.Blind marks a write the server didn't check (s3.go's fallback). - state.Blind keeps, for such a write, the file's sum and the remote and local part hashes from before it. The next sync that reads another file than that one merges from before the write. What this computer changed counts as changed again and goes back up beside the other's. A 304 or the same file clears it. Restore and Upload clear it. - docs/reference.md says what happens on such a server. No compare-and-swap exists on OSS, so the race itself isn't closed: the other computer's file is kept for up to one sync interval (3 minutes) before this computer's change is merged back. The reporter's AppendObject journal would close it but needs every computer upgraded and OSS-only signing. If the other computer saw this one's write and then changed the same part again, the next sync can't tell that from a write that went over it. It counts the part as changed on both sides: the newer stays, the other is saved, and a notice says so. Nothing is lost. Run: - TestS3BlindWriteGoneOverIsMergedAgain (fake S3 with no conditional writes, two computers): A renames a provider and B sets the theme, B's PUT goes over A's, then A's next sync puts both on the server with no conflict notice, B brings in the rename, and nothing more is written. With the reset taken out (broken by hand), it fails: "A's rename here after its next sync: \"DeepSeek\"". - go test ./internal/davsync whole. Not tried against real Aliyun OSS: the fake answers conditional PUTs the way the reporter quotes OSS (NotImplemented). |
||
|
|
446bffcac7 |
gateway, gui: a Routing row's share used renews with its own window, not the biggest one (#1778)
Vigilans' Factory account showed "32% used · renews in 27 days": the week's 32% beside the month's reset. Allowance.For gives the fullest window's share and the renewals biggest first, and routing.js paired the share with renews[0], so for any account of more than one window the row mixed two windows. - provider.Allowance.Fullest(model, now): the reset of the window For's share is of (the later of two as full; a window whose reset has passed counts as empty, as For does). - The trace's Weighed gains usedRenews (from weighRouted's left.fullest); routing.js's usedRenews(w) uses it in both the story rows and the account rows, and falls back to renews[0] only for an account of one window (a route recorded before this commit). - Smart's order is unchanged on purpose: it goes by the biggest window, and Factory's month holds less than its weeks add up to, so what a week leaves isn't lost at the week's reset. docs/reference.md says so, and gateway-routing.md names Fullest/usedRenews. Run: - go test ./internal/provider ./internal/gateway -run 'Fullest|UsedRenews|Weigh|Routing|Smart' and the packages whole. - TestUsedRenewsWithItsOwnWindow fails with left.fullest set to the biggest window's reset (broken by hand, then restored). - routing-key-windows.test.cjs: 44/44 in Chromium and WebKit, all languages and widths; it fails on HEAD's routing.js. - Every routing-*.test.cjs plus panel-routing in both engines: 594/601. The 7 WebKit failures are clicks waiting for an element to be "stable" under load average ~44, in routing-group-fold (#1612, #1672), routing-sessions (#1307) and routing-days-fit. routing-days-fit passes run alone. The other two fail the same alone with HEAD's routing.js. Not tried against a real Factory account: the windows are those the Factory plugin's limitWindows reports (5h/7d/30d with resetsAt). |
||
|
|
bfaedf1830 |
gui, profile: the profile in use is ticked and named on the panel's Profiles button, not a count read as its name (superhtoooth on X)
superhtoooth (macOS): 保存方案设置了方案名字,但是应用方案没有用这个名字。
menu 里面变成了方案 1,方案 2。而且在应用里面没有显示当前使用的方案.
The bug: the tray panel's Profiles button showed the number of saved
profiles next to its label ("方案" + "2"), which reads as a profile
named 方案 2. Profiles were saved and applied under the typed name all
along; nothing anywhere said which profile was in use.
What changed:
- profile.InUse: a profile is in use while applying it would change
nothing on this computer - every detected agent's saved field is as
the profile has it (compared with the same renamed-ref spelling Apply
writes), its model lists are held (provider.ModelListsHeld, a dry run
of SetModelLists via the extracted putModelLists) and its library
setup is as saved (library.Holds, the mirror of Restore). A profile
that touches no agent here is not in use.
- Why not "last applied": that would stay ticked after the user changes
a model by hand, a tick that lies. With this definition a profile
saved from the current setup is in use at once, a hand change clears
the tick, and applying puts it back. Two identical profiles are both
ticked; the button names the first.
- GUI: /api/state carries inUse. The panel's button names the profile
in use (a pop-up button showing what is picked), else counts them as
before; its chip gets a check mark and aria-current, in panel and
window; the chip's tooltip and its details say "In use" (string
already in every language). CLI `magpie profiles` marks it, the TUI
notes "in use". Docs (reference, start en/zh/ja) say so.
What was run:
- go test ./internal/profile (new TestProfileInUse: save, hand change,
apply, hidden model list, library instructions, absent agents) and
./internal/gui (new TestStateProfileInUse through the HTTP handler),
scratch HOME. Broken by hand: field compare, ModelListsHeld,
library.Holds and state's InUse each turned a test red.
- go test -tags nogui ./... in a scratch HOME (the four slow packages
rerun with -timeout 40m under load ~45).
- GUI: new profile-in-use.test.cjs (reporter's steps in the panel at
360px, every language, plus the window) and panel-profiles,
profile-confirm, profile-details, old-webkit, i18n-keys, gui-zh-tw,
gui-ja, gui-de in chromium and webkit: all pass. Old app.js fails the
new test.
- Real CLI in a sandbox HOME with a codex config: save/use/profiles
show the mark, and it goes after a hand edit.
- gofmt; go vet darwin, linux (nogui), windows.
Not tried: the real tray app with real agents, and Windows/Linux at
runtime.
|
||
|
|
ee7a9b24a6 |
agent: Grok App is an agent magpie connects: a magpie provider channel with magpie's models and their efforts (#1625, fjrtdk)
fjrtdk asked for Grok App (RongleCat/grok-app, a desktop GUI over the Grok
Build CLI) as a full agent: MCP, skills, RTK, models and effort.
What was already there, read in the App's source:
- MCP: the App reads ~/.grok/config.toml's [mcp_servers] in both of its
modes and hands them to the CLI it starts, so the Grok Build row's MCP
sync already reaches it.
- Skills: Grok Build's ~/.agents/skills, synced from the Grok Build row.
- RTK: rtk has no installer for Grok Build, so there is nothing to wire.
What was missing is models, and that is what changed:
- internal/agent/grokapp.go: a new agent, "grok-app" (alias grokapp), for
the App's agent-home/config.toml under its data folder: GROK_APP_HOME,
else ~/Library/Application Support/com.grokapp.grok-app or ~/.grok-app
on a Mac, %APPDATA%\grokapp\grok-app\data (and two older places) on
Windows, $XDG_DATA_HOME/grok-app or ~/.grok-app on Linux; the first
that exists.
- Connecting writes a [model.magpie] channel in the App's own format
(its custom routes): model, base_url = the gateway's /v1, name,
api_key (magpie-grok-app, so usage says the App), api_backend =
"chat_completions", app_provider_mode = "generic", app_models and
app_efforts as JSON strings (the App unquotes them with serde_json),
supports_reasoning_effort, app_supports_vision for a model that takes
images, and context_window when magpie knows it. app_models lists
magpie's models with their effort levels ("none" left out), so the
App's model and effort pickers show them.
- It sets [models] default = "magpie"; what was there is stashed, and
Disconnect puts it back and drops the channel: the file is
byte-identical to before (TestGrokApp).
- A sync keeps the model and the default effort the user picked in the
App while magpie still serves them, and writes nothing when nothing
changed.
- Picking one of the App's own routes (the official "grok", or a
channel of the user's with a base_url) takes magpie out.
- The notice says to start a new chat or restart the App, which reads
its providers when it starts an agent; translated in i18n.js (zh-CN,
zh-TW, ja, de) and listed in NOTICES.
- agents.go, agentenv.go (GROK_APP_HOME), docs/reference.md,
docs/subsystems/agent-wiring.md, both READMEs' agent lists.
Picking magpie in the App is a custom route, so the App runs that agent in
its independent mode (its own #557): it clears agent-home's auth.json
rather than syncing the official sign-in. ~/.grok is never written.
What was run:
- go test -tags nogui ./internal/agent ./internal/agentenv ./internal/gui:
ok. Full go test -tags nogui ./... under a temp HOME: ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui: ok.
- Broken by hand, each red: context_window written quoted (TestGrokApp);
the user's picked model ignored (TestGrokAppSyncKeepsTheirs); their
default effort dropped (SyncKeepsTheirs); Disconnect not unstashing
(TestGrokApp); a no-op sync writing (SyncKeepsTheirs); "none" listed
as an effort (TestGrokApp).
- Real use in a sandbox HOME: a built magpie on 127.0.0.1:3681 with a
fake upstream; `magpie grok-app magpie/fake/echo-1` wrote the channel;
the real grok 1.0.50, started as the App starts it on a custom route
(GROK_HOME=agent-home, --model magpie), answered through magpie, the
upstream saw echo-1 and usage.jsonl counted agent "grok-app". `magpie
grok-app default` restored the file (the only difference was grok's own
[marketplace] line written while it ran). ~/.grok/config.toml untouched.
Not tried: the real Grok App GUI (it would sign in through the keychain
and ~/.grok), a model with effort levels end to end, Windows and Linux
paths beyond TestGrokAppDir.
|
||
|
|
cec9647a2a |
access: a default gateway key the user removed isn't made again when sharing is turned off and on (#1655, GradientLive)
Turning on Settings -> Share on local network makes a default gateway key named "Magpie". A user who wants only their own, stronger key could remove it from Gateway -> Gateway keys, but configureLAN looked for the default key by LANKeyID, found none, and made a fresh enabled "Magpie" key the next time sharing was turned on. That reads as a default key that is always there. configureLAN now leaves a removed default key removed: when its id is recorded (LANKeyID), or an older magpie dropped the id and kept only the revoked mirror, sharing is turned on with the keys there are. Asking for a new sharing key (newKey / rotate) still makes one, as TestLANSettingSharesCallerKeyStore expects. A disabled default key already stayed disabled; the test now holds that too. First-time sharing is unchanged. docs/reference.md says so. Run: go test ./internal/access ./internal/gui ./internal/agent (ok); TestRemovedDefaultKeyStaysRemovedOnReshare goes red with the new check disabled by hand (a second "Magpie" key appears). gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/access clean. Not tried in the real GUI. |
||
|
|
6f1b432759 |
provider, gui: smart routing spends WorkBuddy credits that expire soonest first (cdredfox on X)
WorkBuddy's Credits window had no reset, so in a Smart group every WorkBuddy account ranked alike. workbuddy plugin 0.1.14 (plugins f0274d6) reads WorkBuddy's own package lists (billing/meter/get-user-resource-paid- packages and -free-packages, the calls WorkBuddy's client makes) and reports on the Credits window when the soonest-ending package that still has credits ends (runsOutAt) and how many credits it holds (runsOut). The daily Free Plan slice (CapacityType 4) and code 001 aren't counted: they renew daily. magpie carries runsOutAt from the plugin's usage window into QuotaWindow and the routing Limit. Allowance.Renewal, which only Smart ranks on, treats it as the window's reset when it is sooner than the real one. Pace, the tiers, For, Full and resting are unchanged. The mover's min is raised to 0.1.14 so moved users get the plugin. The usage card and account meter say "232.4 expire in 5h" in every language. Run: - plugin: bun test, 63 pass; 2 of the 3 new tests fail on 0.1.13's index.mjs. Verified live on a workbuddy-ai account in a sandbox HOME: Bonus Pack 232.4 left ending 10-12T16:39Z ranked before Pro (10-28). - TestWorkBuddyCreditsRunOutForRouting and TestSmartSpendsWorkBuddyCreditsRunningOutFirst: both fail with the Renewal change removed by hand. - GUI: credits-run-out.test.cjs in webkit and chromium, 5 languages, at 360/440/1000px, red on the old app.js; with i18n-keys, quota-*, panel-usage, reset-each-title, usage-fold: 117 pass. - go test ./... green (agent and gateway rerun with -timeout 30m after the default 10m ran out under load from other sessions; 378s and 492s). - gofmt -l clean; GOOS=linux and windows go vet of provider, plugin, gateway clean. Not tried: the CN workbuddy site (its token was stale, 401), so the CN package list is assumed to have the same shape. The built-in WorkBuddy (not moved users) doesn't get this. The account-line tooltip has no GUI test of its own. |