49f207c7845d372f65dd7909991c2c7cd9a2fb87
320
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6ac1e04244 |
provider: a Claude model on Copilot has its 1-hour cache write priced as Copilot bills it, at the 5-minute write (#3435)
Copilot bills a cache write at one price however long it is kept. Its copilot_usage counts a 1-hour write as the cache_write a 5-minute one is, and GitHub's "Models and pricing for GitHub Copilot" (docs.github.com/en/copilot/reference/copilot-billing/models-and-pricing) lists one "Cache write" price per Claude model, no 1-hour tier (Opus 5.5: input $4, cached input $0.20, cache write $5, output $20). magpie gave every Claude model's list price Anthropic's 1-hour write, 2x input (catalog.OneHourFor), so copilot/claude-opus-5.5 was priced at $8 per million for an hour's write where Copilot bills $5: on the reporter's request, $0.125456 against Copilot's own $0.078443. A Copilot price (tariffOf, cacheWritesAlike) now has no 1-hour write of its own, so an hour's write is billed as a 5-minute one (catalog.Price.OneHour), its tiers alike, copied as they may be the catalog's. This holds for a call read after Copilot was signed out too (tariffOf's unknown-provider path, MakerPrice), which the reporter's patch left at 2x. A price the user gave for a Copilot model keeps the 1-hour write they gave, and one they left out isn't filled with 2x input (userPrice, so UserBasePriceIn reads it alike). Every other provider is as before: Anthropic, Bedrock, Vertex and relays bill the hour at 2x, so the rule is scoped to Copilot's id, not taken off every non-Anthropic provider. Usage rows are priced as they are read (Record.CostAt), so calls already recorded read at the new price too. docs/reference.md and ModelPrice's comment say so. Run on mote (go1.26.8, macOS) at |
||
|
|
d55881730d |
gateway: a key can be held to some MCP servers and tools
wakaka on Discord (#help, 11-06) asked for gateway keys limited to some MCP servers and tools, as keys already are to models (#882). A key's MCP list (caller-keys.json "mcp") holds entries "server" (every tool of it) or "server/tool"; "-" alone is no MCP server; an empty list is every server, as before. A key issued under another is held to its issuer's list too. Every MCP route checks it: - magpie's own servers (web search, vision, image, Magpie Browser, plugin tools) through serveMCP: initialize/tools/list/tools/call are refused or filtered per server and tool, and /v1/magpie/key-limits names "mcp"; - the Library hub ("magpie"): only the backing servers and tools the key may use are listed, and a call by name or by fallback is refused; - /mcp/<name> and /mcp/run/<name>: the server is refused, tools/list is filtered in JSON and SSE replies, tools/call refused; a reply the filter can't read (an encoded body) is a 502, never passed through. GUI: "MCP servers" in the key row's menu opens the app's own picker (no native select) with All, No MCP server, each server and its tools (GET /api/caller-keys/mcp lists magpie's own servers and the Library's). A key held to some shows a badge saying which, that opens the same list; a free key shows nothing more in its row, on hover either. A hover badge was tried first: it pushed the row past 560px (gateway-caller-keys) and squeezed the masked key under a drag at 420px (gateway-key-arrange). CLI: magpie gateway-key mcp <id> github fs/read_file | none | all. zh, zh-TW, ja, de strings; docs/reference.md and the gateway-routing and library subsystem pages. Not covered: a model's own built-in web search (a vendor tool, not MCP). GET /api/caller-keys/mcp is named in the CLI parity test's notYet (its list is what `magpie gateway-key mcp` takes; TestEveryRouteHasACommandOrIsNamed caught it at the rebased head). Run on mote (mote-run), at the pushed head: - go test ./internal/access ./internal/cli ./internal/gui ./internal/library ./internal/gateway at a9c40186d (this change on |
||
|
|
80ae904c23 |
routing: routing groups get a page of their own, beside Routing
The owner asked for the groups to leave the Routing page (11-06): under the live stage and every request they were a long scroll down, and New group with them. The design was reviewed before this was built. - New page, Routing groups (#view-groups), drawn by the routing plugin's same script (routingPage), so the editor, its dirty/discard and every group action are unchanged. Toolbar: filter, "N groups · M on", Templates, Import, Select, and New group as the filled button. The list is right under it, and a Settings section under the list holds Found groups (with Exclude providers…) and Names in agents' lists. - No Export button: each group already has its own Copy to share. - Routing keeps the live stage and the requests. A request's group opens the groups page at its row. - The sidebar has a Routing groups tab right after Routing (from 1024 points). The header's row has no room for one: at 860px the extra tab pushed the logo out (brand.test). There the tab is hidden, Routing's tab is lit for both pages (markNav), and Routing's head has a "Routing groups ›" button, hidden beside the sidebar. - Every way in now goes to the groups page: the guide's Open routing groups, the panel's and the provider editor's Make a routing group (window/main?view=groups&newgroup=…). mainView still takes view=routing&newgroup from an older panel. - Words: "Routing groups", "Open routing groups", "Once saved, make a group of them in Routing groups.", and the editor's names note now says the setting is under the list, in zh, zh-TW, ja and de. "Open Routing" stays for the Agents page's button. - Docs: providers-accounts, gateway-routing, plugin-runtime, gui-shell and reference say "Routing groups page" where they mean the groups. - Core budget: the core's scripts are 1,533,774 of 1,533,802, paid for by three show()/setGatewayMode comments cut in app.js. No raise. Tests: routing-groups-page.test.cjs (new) covers the page in Chromium and WebKit, en/zh/zh-TW/ja/de, at 1280, 640 (window) and 420 (web): no groups on Routing, the tab or the head's button by width, the lit tab, toolbar order, New group primary and in sight, list then Settings, no sideways scroll, no native select, no left-border accent; a request's group to its row; quotas redrawn with an open editor left alone. The trace tests (routing-compact, -pause-folder, -rule-models, -folder) open Routing, then show the groups; routing-editor-foot and name-suffix-where-named scroll by wheel, as the scroll guard lets a reader; builtins expects the groups tab beside the sidebar only. Removed: routing-groups-jump (the head's "Routing groups ↓" that scrolled down to them, gone with them), routing-pointer-pin and routing-steady (the groups kept in place under requests streaming in above them: no request is above them now). Their guarantee that what redraws leaves an open editor and its typing alone is routing-groups-page's quotas case; Routing's own lists keep their keepInView. The groups page's jump: a request's group, or a pool's "Several keys" chip, opened the groups page and scrolled the row to the centre, and the next frame show()'s backAfterLoad put the page back where the reader last left it, then brought the focused segment in by "nearest": in WebKit the pool sat half under the window's foot (routing-mode-goes, 9 of its 10 WebKit cases). goRouting now jumps at once on a page it opens and marks it arrived(). The wheel in routing-many-keys turns over the keys: at the page's foot, now shorter, the mouse rested over the requests list (.rt-reqs, overscroll-behavior: contain), which took every wheel up, and the test stopped with 2 keys in sight. That is #4082's cause. routing-days-fit's fixture has 12 requests, a day that fills the window, since the day bar held needs room under it. Run on mote (macOS 27, load 25 to 65), Playwright 1.62.0: - Go: go vet, gofmt -l and go test ./... at the rebased head ( |
||
|
|
e1eeeed734 |
browser: the extension's key connects Magpie Browser and nothing else; own needs this computer; a key turned off closes its browser
|
||
|
|
650bf84128 |
docker: a daily tag that moves once a day, for Renovate
magpie releases many times a day, and YaoFur on X runs the image with
Renovate, which opened a PR on every tag ("改成每天凌晨更新一次").
Releases stay as fast as they are. ghcr.io/yetone/magpie:daily is new:
.github/workflows/docker-daily.yml points it at :latest's image once a
day, at 20:00 UTC (04:00 in China), by digest, as docker-stable.yml does
for :stable. It never builds, and touches no other tag; a click on Run
workflow moves it too. A Renovate user follows daily with its digest
pinned and gets at most one PR a day; stable is still there for one a
week.
The docs name it: the Tags row and the Updates line of the Docker page in
en, zh and ja, and the Docker section of docs/reference.md.
site/docker-tags.test.mjs holds that the three languages name the same
floating tags with daily among them, that a workflow writes each tag the
docs name, and that daily has one daily schedule, copies latest and
builds nothing.
The desktop app is unchanged: it already checks every 6 hours by
default, and Settings > About offers Check every 24 h and the Stable
channel (one a week).
Run (mote): node --test site/*.test.mjs, 90 of 90 ok; without the
workflow and the docs, two of docker-tags' three tests are red.
actionlint on docker-daily.yml and docker-stable.yml: clean. No Go file
changed; go test ./... -timeout 45m runs on the Linux box (wsl-run) at
this tree, since mote had another session's full suite running.
Not tried: the workflow itself before this push; it is run once with
workflow_dispatch right after it.
|
||
|
|
1f439ecc5e |
gateway keys: a limit can count only some models or providers (zola_xynb)
zola_xynb on X asked for a cap per model or per provider under one gateway key. A key limit can now name models (access.Limit.Models, "<provider>/<model>" or "<provider>/*"), so one key can have, for example, a month of $20 on openai/* next to a month for the whole key. Limits without models still cover the whole key, as before. - budget: sums are kept per window and scope, and count a ledger row only when its provider/model matches (any of the model's ids). reserve holds a request to a scoped limit only when the model it names is served there. windowsOf keeps every scope's sums, so the ledger is not read again on each request. - gateway: keyLimited puts the key's spent scopes on the caller (withSpent), count_tokens included. A direct request for a spent model gets a 429 with Retry-After and no X-Magpie-Limit-Reset, so a remote magpie rests only that model. A routing group, a provider's fallback and embedding/image/video/decision groups skip spent members (groupKeeps, allowedCandidates) and get a 429 only when none is left. System One, count_tokens and magpie's own calls for the key are held too. Model lists are unchanged. A refusal turned away before routing now records its ErrType in the ledger. - CLI: magpie gateway-key limit <id> add month --cost 20 --model openai/* (--model repeatable, --models a,b). - GUI: the key limit editor has a Models field that opens the app menu (multi-pick: All models, every model of a provider, each model). It has no <select> and no new screen. The badge, line and tabs name the models. Strings are in every language. - docs: reference.md and subsystems/gateway-routing.md. Run at d52725d32 (this change on |
||
|
|
483b131ef0 |
browser: magpie in Docker uses the host's own browser, through a key the page hands out
noahhrreion ran magpie in a container and its Magpie Browser never
connected. The host's Chrome dials ws://127.0.0.1:3425/v1/magpie/browser/
extension, which reaches the container from the bridge (172.17.0.1). That
is not loopback, so the gateway refused it (403). The browser MCP also
refused every caller from elsewhere, and the hub marked the browser
HereOnly. The extension's folder under the container's HOME can't be
loaded by the host's browser either.
Nothing is opened to the network without a key:
- The extension takes a gateway key: its popup has a Gateway key field,
and config.js carries KEY (extension 0.1.7). From another computer the
extension connects only with ?key= of a gateway key that is on, and
only from the extension's own Origin (checked first). Loopback is
unchanged, and a page's origin, null, a keyless call or a rebound Host
are all still refused (TestBrowserExtensionOnlyFromItsOrigin).
- A browser that connects with a key belongs to that key. Sessions are
tagged key:<id>/... (browserOwner, keyedSession), and a remote caller's
session is forced to its own key's whatever it names. The relay filters
every lookup (forSession, all, choose) through browserConn.serves. The
browser MCP admits a remote caller only with a gateway key; a web page
is refused as before.
- The key the page makes is recorded as this magpie's own browser's: its
id goes in settings.Dir()/browser-key, written temp-and-rename. This
goes by where the key came from, not by its name. A browser connecting
with it serves this computer's sessions too, so agents inside the
container use it as they would one on loopback. A record that can't be
read names no key, so no keyed browser is this computer's.
- Router: magpie mcp browser is HubServer.Keyed. A visitor from
elsewhere gets it only with a key (HubVisitor.Key), and hubCall names
its session key:<id>/..., so it reaches only that key's browser.
- GUI: a page whose browser can't reach magpie's folders (InContainer, or
a page from another computer) is "away". The Magpie Browser sheet's
button then reads Download the extension. It does a POST to
/api/library/browser/extension with the page's origin, which answers a
zip pointed at that origin (3430 passes the gateway's routes on) and
holding the recorded key's secret. The key is made the first time and
reused while it is on. The steps (unzip, chrome://extensions, Developer
mode, Load unpacked) are shown in every language. It is a POST so that
a link from another site can't mint a key.
- Docs: reference.md (Docker), subsystems/library.md and mcp-router.md,
and site docker.html in en, zh and ja.
Run, at this tree rebased on origin/main
|
||
|
|
fe61503e60 |
provider: a Remote magpie whose computer took another address is found on the network
luckymanjc (Discord) uses computer A's magpie from computer B over the
LAN. A's router hands it a new DHCP address after a boot, and B's Remote
magpie, saved at the old one, reached nothing until the address was
typed in again.
When B can't connect to a Remote magpie at all (a dial error, not an
answer), the list fetch (models.go) and the gateway's request (forward
in gateway.go) now call provider.SeekMoved (remote_moved.go). It dials
every address of the old one's /24 and of up to four of B's own private
/24s at A's port (500ms each, 128 at once). The first that lists
/v1/models 200 for the provider's key, and whose list this magpie didn't
make (magpie_via), is A: a LAN caller always needs a gateway key, so
another magpie answers 401. That address is saved as the provider's and
the request is made again there. A name or a public address is never
looked around, an address the user changed meanwhile stands, and a
provider is looked for once a minute at most, callers at once sharing
one look.
Run:
- mote-run go test -count=1 -run 'TestRemoteMagpie|TestLANNeighbours|TestDialable|TestRemoteSelf' ./internal/provider ./internal/gateway: ok
- mote-run go vet, GOOS=windows and GOOS=linux go vet of both packages: ok; gofmt -l clean
- Live: A was a real magpie on mote (10.0.0.121:3511), B a -tags nogui
build in WSL magpie-desktop (127.0.0.1:3522), sandbox HOMEs. B's
provider was saved at the dead 10.0.0.250:3511. B's start fetch found
A ("found at 10.0.0.121:3511, saved there") and a chat answered 200 in
4.2s. Then, with B running, the address was set dead again: a request
to office/group/rot found A and answered 200 in 4.4s, saved at .121.
Broken by hand, each red: the gateway hook off (502), the fetch hook off
(fetch error), the self check off (saved at this magpie itself).
Not tried: a real Windows A; a mDNS name (.local) that changed address
(left to the name); A on a different /24 than B. On Linux a dial to a
dead LAN address took ~54s (no route to host) before the look starts;
not changed here.
Reported-by: luckymanjc. (Discord)
|
||
|
|
f285426ac2 |
library: the MCP router turns on with no agent, and in gateway mode
treeman_26897 on Discord runs magpie as an MCP entry point for remote clients on a server with no agents. The router could only be turned on from the Library, and the Library said "No agents to write to" with no agent. In gateway mode (magpie web on a headless server, on by itself with no agents) GATEWAY_HIDES left the Library out altogether. The router's switch also showed only once a server was in the library. The gateway and `magpie library mcp router on` had no agent gate: the gate was the page's alone. Now, with no agent to write to, or in gateway mode (where no agent is shown), the Library is its MCP tab alone (`agentless` in client.js): - servers without agent chips, found servers or projects; - the router's switch, there before the first server too; - its lines and status say any app connects at its address, the router is on or off; - the servers it serves are checked once it is on; - Connect… has Other apps alone, with the gateway key line. Gateway mode hides only Agents now. The two keys of the empty state are gone; the gateway-mode subtitle no longer says "no Library". Remote use goes through the guard /v1 has, unchanged: lanGuard and serveMCP. TestHubMCPRemoteEntryNeedsKey holds /mcp/magpie/hub to it from another computer: not shared 403; shared with no key 401 (no Origin, tools/list, a wrong key); Origin null, chrome-extension://, file://, moz-extension://, a foreign site and another computer's page refused from there and from here; a rebound Host with a browser's marks (Origin = Host, Sec-Fetch only, a Mozilla UA) refused from here and there; a proxy or tunnel here (X-Forwarded-For, Cf-Connecting-IP) with no key refused; nothing ran for any of them; with the key it runs, through the proxy too. Run on mote at ef20ff690 (on origin/main |
||
|
|
c42522e241 |
quotas: the gateway's whole-page refresh reads saved Claude accounts again too (#5443)
POST /v1/magpie/quotas/refresh with no card named ran ReadAllCards, which only cleared the caches (AskUsage). A saved, inactive Claude account's /usage was never run again, so another magpie's refresh of this one, or an app with a gateway key, kept showing its old numbers. #5380 ( |
||
|
|
e17c6976b2 |
provider: Voyage AI preset, its embedding and rerank models (heatonz on Discord)
heatonz on Discord asked for Voyage AI, its embeddings and rerank. The gateway already had /v1/embeddings and /v1/rerank; what was missing was a way to add Voyage and have its models found there. - presets.go: `voyage`, a vendor with an API key at https://api.voyageai.com/v1 (docs.voyageai.com, keys at dashboard.voyageai.com). Voyage has no /models, so it is NoList and the preset names its models in two new PresetDef fields, Embeddings (voyage-4-large, -4, -4-lite, code-4, finance-2, law-2, 3-large, 3.5, 3.5-lite, code-3, code-2) and Rerankers (rerank-3, -3-lite, 2.5, 2.5-lite), as Voyage's docs list them on 11-06. Region gets Rerankers too. - models.go: planMedia marks each plan model with what it serves (catalog.Model.Serves), falls back to the preset's own lists when the provider has no region, and PlanRerankers / PlanRetrieval(kind) sit beside PlanEmbeddings. A NoList provider's ListAll has them too, marked, so catalog.Chat keeps them out of agents' lists, keys and Routing's chat pickers. - gateway: resolveRetrievalModel and servesKind look up the kind asked for (PlanRetrieval(kind)) and not only embeddings. Before this, a plan's embedding model named on /v1/rerank was sent there, and a plan's reranker was never found. - catalog.ServesOf: `voyage-*` is an embedding model (its ids have no "embed"), so Test, detection and a relay serving voyage ids know it. - test.go / gui providers.go: the retrieval-only Test fallback and the editor's "retrieval" count read PlanRetrieval as well. - docs/reference.md: a new "Embeddings and rerank" section with both routes' bodies (OpenAI's for embeddings; the Cohere/Jina/Voyage shape for rerank, top_n or top_k) and the Voyage preset. READMEs and the import docs pages (en, ja, zh) list it. Not served: Voyage's contextualized and multimodal embeddings (their own endpoints). A Voyage 4xx comes back as its raw {"detail": ...} body with its status (errorSaid has no "detail" reader). Tests (no network; a fake built from Voyage's documented request and reply shapes): TestVoyageEmbeddingsAndRerank (bare and provider ids, input_type/output_dimension and top_k/return_documents passed on, usage total_tokens recorded), TestVoyageModelsStayOnTheirRoutes, TestVoyageRefusalSaysWhy, TestVoyagePreset, TestVoyageTestAsksItsRetrievalAPIs, TestServesOf's voyage cases. Run on mote: go test -count=1 -timeout 45m ./internal/provider ./internal/catalog ./internal/gui ./internal/gateway. provider, catalog and gateway ok. gui has one red, TestMainWindowCorners/macOS_26_SDK, which is #3949 (red on macOS 27); this change doesn't touch AppKit. go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok. gofmt -l clean. Broken by hand: - resolveRetrievalModel/servesKind back on PlanEmbeddings: TestVoyageEmbeddingsAndRerank red (rerank-3: 404 "magpie knows no model"), TestVoyageModelsStayOnTheirRoutes red (voyage-4 on /v1/rerank answered 200). - the voyage- prefix out of ServesOf: TestServesOf and TestVoyagePreset red. Not tried: against the real API. No Voyage key was available, so the endpoints, auth and shapes come from Voyage's docs alone. Not tried in the GUI's Add sheet by hand, and not on Windows or Linux beyond vet. |
||
|
|
baf70992f6 |
usage: a call the vendor answered with another model is priced as the model that served it (#5340)
The ledger priced a call at the model asked for and fell back to the
model the reply named (Served) only when the asked-for one had no price
(#1498). That order is right for a relay that sells kimi-k3 as
moonshot-kimi-k3 and bills by the name it sold, but it also priced a
real substitution: claude-opus-5-5 asked, claude-opus-5 served. The
vendor bills for the model that ran. kaimo455's ledger had 836 such
rows, every one at the asked-for rate: $374.06 reported against
$493.28 at the served model's rate. gateway-key cost limits (KeySpent,
NewCoster) and budgets read the same pricer.
Pricer now prices a call the ledger marks swapped at the served model's
price. That covers a price the user set for the served model and every
other layer of BasePriceIn. A price the user set for the model asked for
still wins, 0 included (new provider.UserBasePriceIn is BasePriceIn's
user layer alone). When the served model has no price, the asked-for
one's stands. Renames, vendor aliases, serving names and region
deployments price as before, and rate windows still read each record's
own time. apiPricer, the API price behind a subscription window's whole,
follows the same rule: the served model's API price first, then the
asked-for one's.
Review changes on top of ggbdpq's patch:
- The swap is judged the way the ledger's Swapped column judges it: on
the model id and on the name that went out (SentNameIn over the
user's ModelWires). A model the user sends under the served one's name
was answered as asked, so it keeps its own price. The patch judged the
model id alone, so such a row was priced as swapped while the Requests
page said it wasn't. The pricers' memo keys now include the effort,
because the sent name depends on it.
- apiPricer (window holds) got the same rule. The patch left it on the
old order.
Tests:
- TestLedgerPricesASwappedCallAsTheModelThatServed (patch, plus a
ModelWires case) checks the ledger and the Requests page.
- TestLedgerPricesARenamedModelAsTheOneServed: the sol row (sol asked,
kimi-k3 served, both priced) is a genuine swap, so it now prices at 3,
not 2.
- TestHoldsPriceTheModelTheReplyNamed: claude-opus-4-7 answered by
gpt-5.5 is priced at gpt-5.5's API price. Answered by an unpriced name,
it keeps opus's.
Run on mote at this tree, on origin/main
|
||
|
|
845e324b13 |
liveagent: each model on its own API, and the request format the user picks stays (xiaoxiaofei)
xiaoxiaofei on Discord: "magpie 默认导入的是 message 格式的,要可以自定义请求格式".
magpie wrote one LiveAgent provider, "magpie", type claude_code with
api anthropic-messages, for every model. K-brain asks all of a
provider's models on the provider's one API (routing/client.go builds
the client per provider; PiModel.api is only validated), and LiveAgent's
settings lock an Anthropic provider's API: only an OpenAI provider
(type codex) has a request format to pick (ProviderModalView.tsx,
resolveProviderApi; K-brain settings_provider.go accepts
openai-completions and openai-responses). So the format couldn't be
changed, and a GPT served on Responses was translated from Messages on
every turn.
Now, as dsh's routes do (dshKinds), each model goes on the provider of
the API it is served on natively (catalog.Model.APIs):
- magpie: type codex, Chat Completions, baseUrl the gateway's /v1, for
every model with no Responses or Messages API of its own (groups, Chat
providers' models);
- magpie-responses: type codex, Responses, baseUrl /v1;
- magpie-anthropic: type claude_code, Messages, baseUrl the root (K-brain
appends /v1; for OpenAI it appends only /chat/completions or
/responses, hence /v1 there).
A codex provider is written with api and requestFormat, as LiveAgent's
settings write one; when the user switches it in LiveAgent, a sync keeps
their format (one LiveAgent doesn't offer goes back to magpie's). A
provider left with no model is taken out. A config.json from before (all
on one claude_code "magpie") is moved on the next sync: each model brings
its record (the user's display name) and whether it was turned off, and
a default/compact/task pick of it follows it to its new provider.
Disconnect takes all three out. Docs: reference.md, agent-wiring.md.
Run (mote, through mote-run):
- go test -tags nogui ./internal/agent -run '^TestLiveAgent|Key': all pass,
new TestLiveAgentRequestFormat and TestLiveAgentFormatMove included.
- go test -tags nogui -timeout 45m ./internal/agent: ok (320s).
- GOOS=linux and GOOS=windows go vet ./internal/agent: clean; gofmt -l clean.
- K-brain 507f560 (the version LiveAgent af89ea7 pins), with Go 1.27.0
on mote: config.LoadFile on the config.json magpie writes in
TestLiveAgentRequestFormat loads it, and routing.ClientForProvider
builds *ai.OpenAI at http://127.0.0.1:3425/v1 for magpie,
*ai.Responses at /v1 for magpie-responses and *ai.Anthropic at the
root for magpie-anthropic (a throwaway test, not committed).
Broken by hand (a copy), each turned a test red:
- the user's format not kept -> TestLiveAgentRequestFormat;
- no carried record from another provider of magpie's -> FormatMove;
- picks not following their model -> FormatMove;
- Responses models left on magpie -> both;
- an emptied provider not taken out -> FormatMove;
- turned-off not carried to the new provider -> FormatMove.
Full suite at
|
||
|
|
2f59545d29 |
gateway: a key not given a group listing alone is listed the members it may use (luckymanjc)
luckymanjc on Discord (#general, 11-05): on a second computer, through
Remote magpie, his three Codex accounts offered GPT-6-Luna alone, with
the key his Remote magpie uses held to "Codex 的全部模型" (codex/*),
GPT-6-Luna and the accounts. His screenshot of that key's picker, on the
host, offered GPT-6-Luna alone under Codex too.
Cause: a routing group listing alone (Group.Unlists, "the group alone")
keeps its members out of Catalog(), so out of /v1/models and the key
picker (/api/caller-keys/models), as the group stands in for them there.
Since
|
||
|
|
24d315fa85 |
routing: the request list can be grouped By key, each gateway key's calls under its name
acezan (#help on Discord) asked to see API use on the Routing page the way
it shows each agent's, live and in the history. The list's group bar gets
a third button, By key, after By request and By session. It shows once
Settings has a gateway key (/api/caller-keys). Each head is the key's
current name (else the name the route kept, else its id), with its agents
dim beside it and the usual count, tokens, in progress and cost. Calls with
no key (from this computer, or kept before 75fb76186 named the key) go
under "No gateway key". A row's tooltip names its key too. The choice is
kept in localStorage (magpie.routingGroupBy), and the old
magpie.routingBySession still works. Text added in zh, zh-TW, ja and de.
click-scroll counted two group buttons and now counts three, with By key
hidden when there is no key. purpose-filter clicked .last() for By
session and now picks [data-by="session"].
reference.md and gateway-sessions.md describe By key and Route.CallerKey.
Run (WSL magpie-desktop: mote's disk is full, ld errno=28):
- routing-by-key.test.cjs: 20/20 in chromium and webkit, in en, zh,
zh-TW, ja and de, at 1100 and 420. Red 20/20 with client.js and
i18n.js at the parent (waits for By key).
- 254 Routing-related GUI files at concurrency 4. Every red was rerun
serially, with this change and at origin/main
|
||
|
|
4cb7159f18 |
routing: a ChatGPT account whose usage can't be read is asked, not starved
peterpark8527 on Discord: 11 ChatGPT accounts under Use before expiry,
one never used. An account whose wham/usage reading fails (or names no
window, or is held by "When I ask") stayed not known for good:
Use before expiry counted it a fresh week (FreshPace, ~0.6/h), behind
every known week being spent; Smart put it after every known account.
NoteCodexLimits only updated accounts already read, so its replies'
x-codex-* headers never made it known. Its week, once started by
magpie's own turns or warm-up, lapsed unspent. A simulation of 11
accounts over 4 weeks (Pace, Poisson load 30/60/90%) had it at 141 of
~1200 used at 30% load, losing 3406, while every known account was used.
- provider: a reply that tells an unread account's week makes it known
from that (usedCache.heard), kept over failed readings, until a good
reading tells it; a 5h window alone still makes nothing up.
- gateway: a Codex account not known, weighed against one known, is
Learns, like Claude's: asked first once so its reply tells its week,
and again an hour after its last answer if that told nothing
(codexAnswered, codexLearnAgain). Of accounts none known the order
stands, so no week is started before it is needed.
- docs/reference.md: Smart and Use before expiry say so.
Ruled out (by design or not starving): an unstarted Codex week lasts
until its first request, so last is right for it; ties go by decayed
tokens, not a fixed order; a 5h-only account goes by its 5h pace
(ahead); rests are time-bound with probes.
Run:
- wsl-run go test -count=1 -timeout 45m ./internal/gateway
./internal/routes ./internal/provider ./internal/middleware: provider,
routes, middleware ok; gateway had 3 reds (TestAccountProxy,
TestCodexDrawMovesToNextAccount, TestWeeklyPace's five-hours case):
accounts none known reordered by answers earlier tests left in
codexAnswered. Fixed by the known-peer gate above; then wsl-run
go test -count=1 -timeout 45m ./internal/gateway ./internal/routes:
ok (809s). The none-known guard's u00 line was added after that run
and run alone on Windows (win-run -run TestUnknownCodexAccountIsAsked
./internal/gateway, with the reds above: ok).
- win-run the two new tests on the old code (
|
||
|
|
234903cb23 |
cli: magpie model api sets the API a model is asked on, as the editor's picker does (yew_fence_931206)
A relay with many models behind one key can now have each model's API
set from a script, not only in the provider editor's Names, prices &
levels ("API this model is asked on"):
magpie model api <provider/model>... chat|responses|anthropic|gemini|auto
magpie model api <provider/model>... --reset (auto)
magpie model api <provider/model> what it is asked on
magpie model apis [<provider>] the settings; with a
provider, every model
It saves through provider.SetModelPrefs, the editor's Save, into
settings' modelAPIs, so a running gateway reads it on the next request
and the agents' model lists are told once. Choices are those the editor
offers (modelAPIs in app.js): the APIs the provider has a URL for, when
it has two or more; Vertex AI none. --help anywhere prints the usage. A
flag in place of a model, an unknown API, a model the provider doesn't
list, or an API it has no URL for is refused; several models are all
checked before any is written. A saved setting for a model the vendor
no longer lists can still be reset. Documented in docs/reference.md
("The API a model is asked on") and the gateway-routing page.
Run (mote, via mote-run, at this tree on
|
||
|
|
ed7aeb052f |
plugins: a package that declares magpie.agent is an agent, with a main or without (plugins#737)
miaocell's magpie-agent-deva ships a Bun module as its main beside its moejs agent file (deva.agent.js), because the agent needs a runtime. The market's GitHub list decided the kind by whether a main was there, so it listed the package under Providers, and the Installed row wore a Provider chip and a provider logo though the module serves no provider. Now readTagged gives Kind "agent" to any package that declares magpie.agent; middleware, page and hooks still need no main to be that kind. The file looked for in the repository is still the module Bun loads (its main), or the agent file when there is no main. The Installed row of an agent plugin wears Provider only when its module serves a provider, and its logo is the agent glyph unless it does. The moejs descriptor contract is unchanged. The community registry.json already gives kimi-desktop and reasonix-desktop (both with a main) kind agent; the plugins repo's check now fails an agent package listed as any other kind. Docs: docs/reference.md, docs/subsystems/provider-plugins.md, and site/public/docs plugins.html in en, zh and ja say an agent that needs a runtime keeps its agent file and adds a Bun main, and is listed as an agent either way. Run (on mote, at this head rebased on |
||
|
|
79477604a5 |
providers: a plugin option that says placement "top" sits under the accounts, above Routing (#5269)
mycf_711 (#5269): WorkBuddy Pro's plugin-level "panel" switch was drawn in Plugin options, under the whole model list, so it took a scroll every time. An option in auth.options may now say `placement: "top"`: the provider's editor draws those in a Plugin options block right under the accounts, above Routing, and the rest under the models as before. The note that the plugin reads them goes with the first block. host.js keeps placement only when it is "top" (anything else is left out, so the option goes under the models), and plugin.Option carries it to /api/providers. A plugin that says no placement is drawn exactly as before, and an older magpie ignores the field. Documented in docs/subsystems/provider-plugins.md and docs/reference.md. Run (mote, through mote-run): - new internal/gui/tests/plugin-option-placement.test.cjs: chromium 31/31, webkit 31/31 (1100 and 420 wide, en/zh/zh-TW/ja/de; mixed, top only, none or an unknown placement; the top switch posted on Save). - plugin-options.test.cjs 11/11 and plugin-option-words.test.cjs 21/21, i18n-keys 4/4, each in chromium and webkit. - go test ./internal/plugin ok (TestPluginOptions checks "top" kept and "sidebar" left out); go test -run Budget|Script|Asset ./internal/gui ok. - gofmt -l internal/plugin empty; go vet ./internal/plugin ./internal/gui ./internal/cli, GOOS=linux -tags nogui and GOOS=windows vet of internal/plugin ok. Broken by hand: - app.js put back to its parent: the placement test fails "mixed" and "top" in both engines (blocks under the models), "none" still passes. - host.js's placement line removed: TestPluginOptions fails "second = {... Placement:}". Not tried: a real WorkBuddy Pro plugin (Gitee, private) with the field; the full go test ./... and the whole GUI suite run after the next commit. |
||
|
|
18726b9fb6 |
statusline: a held key is told how to see its line, ?format=json, and /v1/magpie/limit says what holds a key (steven_4422)
steven_4422 (Discord, #feedback): POST /v1/magpie/statusline answered 403
gateway_key_held to a key held to Claude's models, while GET
/v1/magpie/limit told the same key {"limited": false}. They asked for the
line scoped to what the key may use, /limit to agree, and a JSON line for
claude-hud's external usage snapshot.
The scoped view already exists (#2216): the status line goes through
scopeQuotas like the quotas routes, so a held key its owner turns Quotas
on for (Gateway -> Gateway keys, or `magpie gateway-key quotas <id> on`)
is told the accounts it may use of each provider whose every model it may
use, and nothing else. Its 403 never said so. Decision: the switch stays
the gate for every held key, budget, models or accounts alike. What holds
a key says nothing of whether its holder is the owner or a friend (#1981
was a friend's budget key seeing every account's email), and only the
owner knows that, so a model- or account-held key is not told quotas by
default either. The every-model rule of #2216 stays.
- scopeQuotas' refusal (heldQuotasOff) names the switch and what it then
tells. heldRefused, for the routes the switch doesn't open
(concurrency, trace, a card outside the scope, writeCards' told-none),
is unchanged.
- GET /v1/magpie/limit tells a held key heldTo (budget, models,
accounts), models, quotas and, with it on, quotaProviders (the
providers newQuotaScope tells it). No account is named. `limited`
keeps its meaning (the budget) for remote magpies that read it.
- ?format=json on the status line: {"text", "model", "accounts"}, the
cards the line shows in /v1/magpie/quotas?kept=1's shape (windows'
used, resetsAt), through the same scope.
- Docs: reference.md, integrating.md, gateway-routing.md; site docker
and remote pages in en, zh, ja.
Run at this head (
|
||
|
|
cbb09383fb |
plugin: a GitHub-tagged package's card says its own name and summary (#3608, plugins#394)
MYCF711's #3608 (and plugins#394): a repository tagged magpie-plugin outside the community's list showed its repository's name and GitHub's description on its card under Discover → Unofficial, on GitHub, whatever its package.json said of itself. Ported from MYCF711's 1cc337001. Now readTagged keeps package.json's magpie.name (ownName, as main's row already does since |
||
|
|
8a80796805 |
gateway: the native route passes any path of a keyed provider's own API on, at its host
axelburks (Discord #feedback) asked for /v1/magpie/native/<provider>/... to reach the whole of a vendor's API, not only Ark's image and video task paths. Now GET, POST, PUT, PATCH and DELETE of /v1/magpie/native/<provider>/<path> go to the provider's host at /<path> (not under the base's /v1 or /api/v3), with the query and body as they came and the answer streamed back as it comes. Guards: - API-key providers only (nativeKeyed): no subscription, OAuth or plugin account, no remote magpie, no Vertex. 403 otherwise. - The gateway's own guards as every route: lanGuard's Host check, corsGuard (foreign Origin, null, *.localhost without a key), a key beyond loopback, read-only keys refused (PUT/PATCH added to readOnlyRefused), and a key held to models/accounts/limits refused (nativeHeld, as before). - nativeTarget refuses an empty path, "." / ".." segments (encoded too, across %2F), a backslash, a (encoded) leading slash, "://", a scheme-like first segment, and any URL whose host or scheme parsed back isn't the base's. 400, vendor not asked. - The caller's Authorization, x-api-key, api-key, x-goog-api-key, Cookie, ?key=, Origin/Referer/Sec-*/X-Forwarded-*/Cf-*, hop and X-Magpie-* headers are dropped; Sign puts the provider's key in the way it takes one. Set-Cookie, Alt-Svc and HSTS don't come back. - With masking on, a JSON body is masked (fails closed) and restored in the answer; a non-JSON body is a 415. Only a masked request's answer goes through restoring; every other answer streams in 32KB reads, never held whole. - Each request is a Requests row and a usage record (Operation "native"), with tokens when a JSON or SSE answer reports them. - Ark's short paths (nativeArkPath) keep their old code path, under the key's base, unchanged (nativeArk). Docs: gateway-routing.md (table row, native route section), reference.md (path table + paragraph), integrating.md, site integrate.html en and zh. Run (mote, darwin arm64, Go 1.26.8): - go test -count=3 -run 'Native|ReadOnly' ./internal/gateway: ok - go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., gofmt -l: clean - Rebased on origin/main |
||
|
|
083821dc96 |
plugins: a search entry can use the plugin's own sign-in, with its own rests
Asked for by axelburks on Discord. A plugin's search hook entry can name
a provider its own auth hook signs in to, `auth: "<provider id>"`. It then
takes no key. The host picks an account, renews it under `fresh` (the wait
counts within the search's time), runs the hook in `inScope`, and gives it
`ctx.getAuth()`, which returns that account's sign-in. A token the hook saves
with client.auth.set goes to the same account.
The gateway (askSearchSignedIn) asks one account at a time. It takes the
accounts that are on, in the order the provider's model requests take them
(accountsOn, now shared with fallback.go), and puts an account resting from
a search refusal last. A refusal rests only that account's search
(restSearchKey "account <key>"), never its models' rest (restingUntil). Every
attempt gets its own request-log row. An entry without `auth`, or naming a
provider the plugin doesn't sign in to, is a keyed entry as before, with no
getAuth. In Settings → Search, a bound entry shows "Signs in with {name}" in
place of the key field, and the row says whether it is signed in and how
many accounts are on (every language).
Docs: reference.md (with an example), plugin-runtime, plugin-tools and
provider-plugins.
Run on mote at
|
||
|
|
f44fa2ef6a |
sessions: gateway mode lists only the gateway's sessions, never this computer's agents' files
paultian on Discord: magpie web in gateway mode, on a machine with Claude
Code and Codex installed, listed that machine's own sessions beside the
ones other computers sent through it. Owner's call (via the lead): keep
Sessions in gateway mode, scope it.
- sessions.OwnOff (set by the gui to ownSessionsOff): while it holds,
currentReads answers "none", Found and Dirs are empty, the trash lists
and restores/purges only what the gateway kept, and moving Claude
Code's folder is refused. Every route built on Reads follows: the list,
one, transcript, markdown, export, stats, overview, search, manage,
delete, carry, Usage's agent-file calls. Gateway-recorded sessions
(ledger projection, recorded conversations) are not behind the gate.
- ownSessionsOff: magpie web's page, and Settings' gateway mode On, or
Automatic with --gateway or no agents found (looked at once per 30s,
and again on another HOME/PATH). A turn of the answer resets the
sessions' caches and stats; the gateway-mode route does it at once.
- /api/sessions/reads says gateway:true: the page asks nothing, its empty
state names the gateway's sessions (en/zh/zh-TW/ja/de), and Settings ›
Privacy leaves out Agents' session history.
- The gateway-mode subtitle (5 languages), docs/reference.md and
site docs/docker.html (en/zh/ja) say Sessions stays and what it lists
(they said there was no Sessions tab, which was already wrong);
docs/subsystems/gateway-sessions.md has the design.
- Tests: Handler marks the process as magpie web for good, and 13 tests
served magpie web's page, so a later test's sandbox could be in gateway
mode by itself. webPageHandler ends the mark with the test, and
TestWebPageHandlerEveryWhere fails on a direct Handler(webHost{...}).
Ran (mote, at this tree rebased on origin/main):
- TestGatewayModeListsNoOwnSessions: red on the old code, green now.
- gateway-mode-sessions.test.cjs: chromium + webkit, en 900/390, zh,
zh-TW, ja 420, de 390: 36/36; red on the old client.js (every case).
- GUI files the change reaches (gateway-mode*, sessions-*, session-*,
privacy-*, usage-sessions-*, i18n-keys), both engines: 657/657.
- TestCoreScriptBudget ok.
- go test -shuffle=on ./internal/gui ./internal/sessions: sessions ok;
gui ok but TestMainWindowCorners/macOS_26_SDK, red the same on
origin/main
|
||
|
|
c03dee7e3e |
agent: LiveAgent, magpie's models in its model picker (xiaoxiaofei. on Discord)
xiaoxiaofei. asked for LiveAgent (Stack-Cairn/LiveAgent, v2). LiveAgent 2 is a Tauri app that runs its models through K-brain, a Go backend it starts as `k-brain backend -data-dir <root>`; every provider lives in <root>/config.json (JSONC, Pi's provider shape). Root: $LIVEAGENT_HOME, else $K_BRAIN_HOME, else the folder ~/.liveagent/data-dir.json points to, else ~/.liveagent, on every OS (LiveAgent's data_home.rs and kbrain_backend.rs, K-brain's internal/config and internal/storage). Connect adds providers.magpie: type claude_code + api anthropic-messages (what LiveAgent's own settings write for an Anthropic-compatible provider), baseUrl the gateway root (K-brain appends /v1 and posts /messages with X-Api-Key), the key naming LiveAgent, activeModels null, modelOrder in magpie's order, models sorted by id with display name, window, output limit and input [text, image]. K-brain decodes with unknown fields refused, so only its fields are written. A default or compact model still K-brain's endpoint-less demo model1 becomes magpie's first; the user's own pick stays. Through a sync the user's name, the models they turned off, their order, K-brain's metadata and a model's own displayName stay; a new model is on and last; nothing to change writes nothing. A file K-brain wouldn't read as providers (not an object, providers not an object, top-level models, a bare provider) is left alone. Disconnect takes the entry out, puts picks back to K-brain's default, gives a file left with no provider K-brain's demo back (its CLI restores config.json.bak, which could hold magpie's, from a file with none), and removes a file holding only what magpie made. LiveAgent's backend holds the settings and writes them whole on any change, so a change is refused while liveagent or k-brain runs (macOS/Linux; the notice says to quit it first, in every language). Logo: the app's own 64px icon (src-tauri/icons/64x64.png, MIT) in an SVG. Run on mote at this tree: - gofmt -l clean; go vet ./internal/agent ./internal/agentenv for darwin, linux (nogui) and windows - go test -tags nogui ./internal/agent -run 'LiveAgent|GatewayKey|ListsModels' ok; ./internal/agentenv ok; ./internal/gui: only TestCoreScriptBudget red, which is red on its base too (app.js untouched here; #5139) - GUI icon-tile, i18n-keys, agent-notice-lang, gui-zh-tw, gui-ja, gui-de: Chromium 27/27, WebKit 27/27 Broken by hand on mote, each red: the user's activeModels not kept (TestLiveAgentProvider "activeModels after sync [], want [...]"); the demo provider not put back (TestLiveAgentMakesItsFile "emptied file"); the demo default not replaced (TestLiveAgentProvider, TestLiveAgentMakesItsFile). Real use on mote (sandbox HOME and LIVEAGENT_HOME, this magpie on 127.0.0.1:3562, a fake Anthropic upstream on 3561, LiveAgent 2.0.5's bundled k-brain from the release dmg): - k-brain backend's first start wrote config.json as {}; magpie liveagent magpie then wrote providers.magpie and the default pick - `k-brain run "Reply with exactly: pong"` (K-brain's CLI, same config and routing code) answered "pong"; the upstream saw POST /v1/messages from magpie - the backend LiveAgent starts listed magpie's model in /v1/models with it as the default, and its /v1/text/generate answered "pong" through magpie - with k-brain running, connect/disconnect were refused with the notice; after it quit, disconnect removed the file magpie made Not tried: LiveAgent's window itself (its model picker was not opened; the backend's API it reads was); LiveAgent on Linux or Windows; a real vendor reply (fake upstream). |
||
|
|
83bdfe70d2 |
otlp: OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME name the server a trace or metric came from (#5167)
Several magpie servers exporting to one collector or to Langfuse all sent
the same resource, service.name=magpie alone, so nothing said which server
an event came from. Both signals' resource now merges the standard
OTEL_RESOURCE_ATTRIBUTES over that default, and OTEL_SERVICE_NAME over
that (otelResourceAttributes in internal/otlp/otel_resource.go). Nothing
about the machine is looked up; only what the user set is sent. Neither
variable turns export on.
Ported from reyoung's 7ed03b819 (feat/otel-resource-attributes, base
|
||
|
|
90bf96a23d |
search: a plugin can give a web search API (its search hook)
treeman on Discord #help asked for web search to be pluggable so users can
add search vendors. A plugin's `search` hook, {search: {<id>: {name, keysURL?,
keyOptional?, url?, execute({query, count, key, url}, ctx)}}}, adds an API to
Settings > Models > Web search as `<plugin>:<id>`. It is added, keyed, ordered,
switched off and removed like Tavily or Brave. The built-in APIs stay built in.
How: host.js collects the hook's entries (id [a-z0-9-], an execute) into
Loaded.Searches and runs one with the `search` op (timeout from ctx, an error
with a numeric status comes back as a refusal). The host notes them in
plugin-searches.json (internal/plugin/search.go); provider.AllSearchVendors
adds the noted ones of plugins that are on to SearchVendors, so Ready, check,
the CLI and the GUI list see them. askSearchAPI hands a plugin vendor to
askPluginSearch below askSearchAPIKeys, so keys, rest on 401/402/403/429,
order, the masked query and the request-log row are the built-ins' own.
Run (mote, on this tree, whose base
|
||
|
|
df7c94bdf5 |
gateway: inline image descriptions survive a restart (#5121)
The vision description cache (Server.sights) was in memory only, so a restart, update or handover described every image of a long conversation again (62 calls in 2.5 minutes in the report). Completed descriptions of inline images are now appended to vision-cache.jsonl (0600) in the config dir before their waiters are released, and New restores them under the same 2048-entry LRU. URL images stay in memory (their bytes can change); failures are never written. Appends and compaction go through a file lock, a corrupt or truncated line is skipped (and backed up before compaction), and shutdown waits for pending saves within the drain window. Patch by MYCF711, applied clean on main. One change: the Unix permission test now makes the config folder before it pre-creates the file (it failed on a fresh sandbox, where the folder doesn't exist yet). Run (mote, at this tree): go test ./internal/gateway filtered to the vision/sight/cache tests, ok; gofmt -l clean; go vet ./internal/gateway for linux and windows, clean. Broken by hand: saveSight call removed from see(), TestDescriptionSurvivesGatewayRestart red (2 descriptions, want 1), green again with it back. Windows: the same filtered tests on xiaomi-gpu via win-run. Not tried: full go test ./..., go vet ./... for linux (wails cgo doesn't build off-platform on mote), a real process kill or a real handover, a real gateway with a real vision model. Co-authored-by: MYCF711 <323101370+MYCF711@users.noreply.github.com> |
||
|
|
0e1054ce19 |
statusline: the gateway serves Claude Code's status line to another computer (steven_4422)
steven_4422 (Discord) runs magpie in Docker and Claude Code on the host.
The status line square writes the host's settings.json, which the
container can't reach, with a command naming a binary inside the container.
GET or POST /v1/magpie/statusline answers the line `magpie statusline`
prints, as text/plain, so the host needs only curl:
curl -fsS -m 1 -H 'Authorization: Bearer <key>' --data-binary @- http://<host>:3425/v1/magpie/statusline || true
Claude Code's stdin JSON (session_id) adds the model, as /v1/magpie/route
does; ?session= and ?only= work too. The renderer moved to
provider.StatuslineText, shared by the CLI and the endpoint. A caller that
isn't this computer needs a gateway key (lanGuard, unchanged; the handler
also refuses a non-local caller without one). A read-only key is allowed
(GET and POST in readOnlyRoutes) and gets the windows without the model; a
key held to budget, models or accounts sees only its own (scopeQuotas).
corsGuard and origin checks are untouched.
magpie web shows the command in Settings -> About (en, zh, zh-TW, ja, de).
Docs: reference.md, agent-wiring.md, gateway-routing.md, docker pages en/zh/ja.
Run at this head (rebased on
|
||
|
|
d136d0fe98 |
gateway-key: rotating a key can give it a value of the user's own (isaac_bai)
isaac_bai on Discord: a gateway key's value is random, and only rotate changes it, to another random one; they want to set one easy to pass on. Adding a key could take an own value since 6b6113aa; an existing key couldn't. - access: rotate-key takes Change.Secret. Given, it is checked as an added key's own value (ownSecret: 8-256 printable ASCII, no space, not sk-magpie-, no other key's value; its own current value is allowed); empty, magpie makes one as before. The key keeps its id, name, limits, models and accounts, and Named counts a request from this computer with it as that key. - ownSecret now refuses a value that is one of the user's provider keys (a provider's Key or any of its Keys, constant-time), for add-key too: a client sending it would spend that provider directly. - CLI: `magpie gateway-key rotate <id> --key <value|->`; docs/reference.md. - GUI (plugins/gateway/keys.js, outside the core budget): the Rotate key dialog has a hidden "Your own key (optional)" field; Enter rotates, Escape cancels; an own value says "Gateway key changed. Clients that send this key reach magpie now." Strings in zh, zh-TW, ja, de. Tests: TestRotateToOwnValue (bad values refused, old value still works after a refusal, trimmed own value authenticates as the same key, is Named, listed masked; empty makes a new key; add-key refuses a provider key). TestRotatedOwnValueKeepsTheKeysLimit: after rotating to an own value the old one is 401 from another computer, the own one 200 from another computer and from 127.0.0.1, and a 700-token day limit stops the third request from either (429), every record under the key. gateway-key-own-rotate.test.cjs: chromium and webkit, en/zh/zh-TW/ja/de, 1000 and 400px. Run (mote): at the pushed head: TestCoreScriptBudget ok, ./internal/access ok, the own-key/caller-key gateway tests ok. At |
||
|
|
6c201095d8 |
gateway: in Docker, other containers on the host are shown the host's Docker bridge address
jiezhengj (Discord #feedback) runs magpie in Docker on a NAS at 192.168.31.218. The web UI's host address, http://192.168.31.218:3425, works for other devices. Other containers on the NAS couldn't use it, and not the container's own 172.17.0.x either. What works for them is the host's Docker bridge address, http://172.17.0.1:3425. On Linux, host.docker.internal is there only in a container given extra_hosts. magpie showed no such address. - gateway.ContainerHostURL: in a container on a bridge network, the gateway of /proc/net/route's default route (172.17.0.1 on the default bridge, a compose network's own otherwise), on the gateway's port. It is "" outside a container and on the host's network (`network_mode: host`, told by the host's docker0/br-*/veth*/podman* interfaces). In that case ContainerAddrs is false too, since the addresses are the host's own. - The GUI gets it as /api/providers' gateway.containerHost, /api/settings' lanContainerHost and boot's sideGateway.containerHost. - settings.js lanShown is fed by the new gwLAN(g) for Gateway, Connect, the sidebar and the key page. Each case lists: - Opened at the host: the host's address first, then the bridge address, labelled "Other containers on this host". - At localhost: the bridge address alone, with that label, and a line that the host's own is MAGPIE_PUBLIC_URL's. - No default route: as before. The container's own 172.17.0.x is no longer offered beside them. The sidebar line and the key page prefer an address other machines reach. The scheme comes from the URL, not a hard-coded http. Three new strings are in zh, zh-TW, ja and de. - CLI: `magpie web` and the share banner print "other containers on this host <url>". - docs/reference.md and site docs/docker (en, zh, ja): the log example and a new "Other containers on the same host" paragraph. Run on mote, at this change on |
||
|
|
d1cdce1302 |
provider: the group alone keeps subscription models out of agents' lists (shaoyang.)
shaoyang. on Discord (#general, 11-03): with a routing group's Model lists set to the group alone (its card's 成员模型不单独列出), the model list fetched still had every model of the group. Cause: |
||
|
|
5ee5274bd9 |
quotas: a remote magpie's Codex reset is used from its card here (#3850)
prgrmrwy runs magpie on a home server and uses it from work through a remote magpie (and DSH). The remote Codex card said "1 reset", but the reset could only be used from the GUI of the computer that holds the sign-in. What changed: - Gateway: POST /v1/magpie/quotas/codex-reset?user=<email>[&credit=<id>] (Server.codexReset) spends one of that account's resets with provider.SpendCodexReset. That is the Usage page's own code (UseCodexResetCard, then AwaitAllowance), moved out of internal/gui/usage.go so both use it. A reset can't be undone, so the route needs an enabled gateway key with full access, from loopback too. No key gets 401, and that covers every corsGuard exemption that has no key: Origin null, app schemes, *.localhost and a missing Origin. A read-only key gets 403 gateway_key_read_only (readOnlyGuard, which readOnlyRefused now lists, and again in the handler). A held key gets 403 gateway_key_held, even one told quotas. The account must be named (400 otherwise). One ask runs per account at a time (409). When the reset is used, that card is read again. - Remote client: UseRemoteCodexReset (remote_quotas.go) asks the remote with the provider's key. remoteJSON's status mapping is shared through remoteBody. A read-only key there is told as such, and a 404 as a remote too old. With no answer in time it says the reset may have been used, and it never asks again by itself. A remote Codex card now keeps its Resets; a GLM team's (byWindow) and every check-in are still dropped. - GUI: "Use a reset" / "Use one..." show on a remote Codex card (codexResetCard). They open the same in-app confirmation sheet, with a line saying which computer's magpie uses it, and send the card's provider to /api/usage/codex-reset. The remote's errors are put in the user's words. New strings are in all 5 languages. - DSH: no code here. Its provider plugin reads /v1/magpie/quotas/cards and can call the new route with a full key. - resetOutcome (a reset's result in words) moved from app.js into resetask.js, the only place that says it, so the core's scripts stay in TestCoreScriptBudget's 1,533,802 with no raise (1,533,003 after; origin/main |
||
|
|
69167bc299 |
usage: a reply let go under a second after a wait four times longer tells no speed
pluviophile714 on Discord: a gpt-6.1-sol row on Routing read 1,539 tok/s (input 21,617, output 392, first token 8.2 s, total 8.3 s), where another monitor measures ~70. The reply came whole about 255 ms after an 8.2 s wait. Its content was spread over that short window (flow 230 ms), so the HeldShare flow check passed, and so did the 100 ms floor, and 392/0.255 s read as 1,539 tok/s. New rule, usage.HeldWindowMs: a window under 1,000 ms whose start (first token, first text or first reasoning) is more than HeldShare (4) times the window tells no speed. One rule in every place that computes one: - usage.DecodeOf: the Usage page's speed and totals, the CLI, the GUI's model speeds, and the gateway's Speed first pacing (noteTrySpeed); - routing/client.js decodeOf: the Routing row's speed and its story line; - usage/page.js ledDecode, plus a ledNoSpeed_ reason for the dash's tooltip, in en, zh, zh-TW, ja and de. docs/reference.md and docs/subsystems/gateway-sessions.md say so. On the owner's usage.jsonl (read only), 103 of the 106 rows over 600 tok/s were such windows (e.g. 448 tokens in 107 ms after 8.1 s) and are dropped. The 3 that stay have windows of 2 to 5 s. The overall speed goes from 103.8 to 97.9 tok/s. What it costs: a short reply that really streamed after a long wait tells no speed either. The live visible-reasoning fixture (76 tokens over 731 ms after 6.8 s, ~104 tok/s) and #2637's grok record (307 tokens 403 ms after a 4.6 s first token, 531 tok/s) now read "—". Their tests keep their guarantees with the same timings after a short wait, and also check the long-wait case. Tests: - New: internal/usage TestShortWindowAfterLongWaitTellsNoSpeed (the reporter's numbers, a reasoned row from the ledger, the boundary, a second after a long wait, Totals) and internal/gateway TestShortWindowAfterLongWaitNotesNoPace. - GUI: usage-speed-every-row has the reporter's row (dash, and the tooltip in all five languages); routing-burst-speed has it (first token 8.2 s, no tok/s). - Updated to the new rule: TestVisibleReasoningSpeed's decode-minimum and max-speed cases (short wait now), TestCodexTurnMeasured...'s gateway/Claude rows, TestLiveVisibleReasoningFixture and TestUsageIngestTellsSpeed. Run on mote at this tree (rebased on |
||
|
|
bc10a61985 |
agents: Claude Code's status line, the 5h and 7d use, is a switch on its row (steven_4422)
steven_4422 on Discord asked for the 5h and 7d account use in Claude Code. magpie has had `magpie statusline` since #1997 (kensenzhao), but it was found only in docs/reference.md and needed a hand-written settings.json entry naming a `magpie` the app doesn't put on PATH. Claude Code's row now has a "status line" square beside ultracode (the same toggle, now a table, TOGGLES in app.js), and `magpie claude statusline on|off` in the CLI. On writes settings.json's statusLine as {type: command, command: "<this magpie's full path> statusline"}, quoted for a POSIX shell (Git Bash on Windows, forward slashes). The command reads the gateway's kept windows with a 1s timeout and prints nothing when it can't, as before. - A status line of the user's own is never written over: the square isn't offered while one is there, on is refused, and off and Disconnect leave it byte for byte. Ours is a single plain command whose program is magpie/magpie-* and first argument statusline, so a hand-written one from the reference counts and a compound (&&, |, ;, $(...)) is the user's. - An unreadable settings.json is not written over. - Disconnect takes magpie's status line out with the rest. - Quiet: Claude Code reruns a changed statusLine command in its open sessions, so no restart notice. - Not offered for a WSL distro, and a distro's settings.json isn't read for the options (a stopped one would start, #3896). A stopped distro's fields fall back to magpie's models as options, so without a case in wsl.go its square would have listed models (TestWSLClaudeNoStatusLine). Run on mote (go1.26.8, load ~400): - at f33e6d112 (rebased on |
||
|
|
8819beeb0e |
gateway: a display reads routing as it happens at /v1/magpie/route-events (#3387)
joe21_eee (sywyyhykkk on GitHub) wrote this for an ESP32 screen that shows each agent's requests live: started, each try, the first content, fallback, done. Ported from their route-events branch (42e1fa43f) with the changes below. What a display gets (route_events.go): - GET /v1/magpie/route-events/snapshot: cursor, active, routes (every request the trace has that is still going). - GET /v1/magpie/route-events?after=<cursor> (or Last-Event-ID): SSE, one "route" event a change, id = cursor, from a 512-change ring under trace.mu, so a short request is told step by step. 409 snapshot_required for a cursor not this process's or too old, "event: reset" for a reader that fell behind, a heartbeat every 15s, a 10s write deadline. - A route is routeActivity, an allow list: trace id (base 36), time, agent label, the provider of the seat the last try went to (never the seat id, which names an account or a key fingerprint), model, attempt, fallback, phase, status, failed, ms, ttft_ms. No session, account, key, folder, prompt, reply or error text. - firstToken.onFirst tells the first content as it comes (serve and the ChatGPT backend's reads), written to an unexported Try.firstMs so the full trace's TTFT is unchanged. Changed from the branch: - No new key type. The branch added an "sk-magpie-route-" key, its CLI flag and its own Authenticate path through access, identifyCaller and corsGuard. main has read-only keys now (readOnlyGuard), and the feed is answered as /v1/magpie/usage is: this computer, and another machine with an enabled key while shared; a held key is refused (refuseHeld). Both GETs are in readOnlyRoutes, so the display gets `magpie gateway-key add Screen --read-only`. A full key already reads more than this (every call's usage). access, cli, cors.go and lan.go are untouched. - A route the trace drops unfinished (drop: an unrouted request's stand-in once its own route begins; trim past twice traceKeep) is told request_dropped and marked offFeed. The branch kept its own active map that only "done" cleared, so a stand-in stayed going forever. The snapshot is read from t.routes, no second map. - A stream ends when the gateway stops serving (Server.streamsEnding, closed first thing in ListenAndServe's drain). Before, an open stream held srv.Shutdown for its whole drain, 15 minutes on a handover. - Revocation is access.On(KeyID) (identifyCaller swaps the secret out before handlers see it), asked at most once a second when there are changes and at every heartbeat, and remoteKeyed for a remote reader. A rotated key keeps its id, so its open stream goes on until it reconnects (said in the docs). Docs: gateway-routing.md "Route events for a display" and the read-only key's route list; reference.md beside the usage API. Run at the pushed head on mote (Go 1.26.8): - At daaafeb6e (rebased on |
||
|
|
95d0c97bf9 |
routing: "Use before expiry" counts credits that expire before the reset (lcyksp)
lcyksp on Discord: the 「重置前用完」 strategy (pace) ranked a WorkBuddy
account by its monthly 500 credits ("积分 0 / 500 · 已用 0% · 28 天后重置").
WorkBuddy spends check-in credits first because they expire sooner
("70.85 积分 将于 2026/11/3 09:28:52 过期"), and the account was ranked as
if nothing would be lost for 28 days.
What changed:
- provider.Allowance.Pace takes a budget window's soonest expiry into
account (Limit.RunsOut, from QuotaWindow.RunsOutAt, which the
WorkBuddy plugin and others set on the credits window). When that
expiry comes before the window's reset, the window's pace is the
higher of:
- what is left per hour until the reset;
- the share that expires (QuotaWindow.RunsOut, now carried as
Limit.RunsOutLeft) per hour until it expires. When the amount isn't
told, all that is left counts. A share is capped at 100%, and the
hours at no less than one.
The account whose credits are lost soonest per hour goes first.
Expiry at or after the reset, or already past, changes nothing.
Zero-config: nothing new to set.
- The trace says DueBy "expiry" when the expiry set the deadline. The
Routing page's reason then reads "Use before expiry: {who} has the most
credits expiring per hour until they expire — {n} of its allowance
expires in {d}."
- Label: "Weekly pace" / 重置前用完 / 週ペース / Wochentempo becomes
"Use before expiry" / 到期前用完 (zh, zh-TW) / 期限前に使い切る /
Vor Ablauf aufbrauchen. Product call: the strategy's goal was always
"lose nothing at the deadline". A reset and an expiry are both such a
deadline, and "到期" covers both, where 「重置」 names only one. The id
stays pace, so saved groups are unchanged.
- The descriptions (Routing, Settings, group editor), docs/reference.md,
docs/subsystems/gateway-routing.md and the site's start page (en, zh,
ja) say the same.
Go, run on mote at base
|
||
|
|
5f0a84a003 |
agent: Air in JetBrains IDEs gets magpie's Magpie agent in ~/.jetbrains/acp.json (Jumy on Discord)
Jumy asked for the "air-plugin" new in IntelliJ IDEA 2026.3 (Settings ›
AI › Air). magpie's air agent wrote the Air app's acp.json, in
~/Library/Application Support/JetBrains/Air, which the IDE plugin never
reads: the plugin (com.intellij.air, air-plugin-262.8665.521-mac-arm64
from JetBrains Marketplace) loads its custom ACP agents in
AcpConfigurationLoader (intellij.air.backend.acp.runtime) from
user.home/.jetbrains/acp.json on every system, the file AI Assistant's
custom agents use too; AgentServerConfig takes command, args, env,
use_idea_mcp and use_custom_mcp. The standalone app (Air-262.1037.14,
Fleet-based) reads acp.json from its own configs folder
(genericAcpConfigPath), so the two are separate files.
Air's own agents have no base URL: JetBrains AI, the agent's own login,
or an Anthropic, OpenAI, Gemini or OpenRouter key under AI › Air ›
Accounts. So the IDE gets the same route as the app: a new air-ide agent
("Air (JetBrains IDEs)", aliases air-plugin, air-in-ides) writes a
Magpie entry (opencode acp, OPENCODE_CONFIG naming magpie-opencode.json
beside acp.json) and nothing else; the user's agents and
default_mcp_settings stay, and disconnecting takes out that entry and
that file. air and air-ide share airAt. air-ide shows for an IDE config
folder of 2026.2 or later (the plugin is bundled from 2026.3), or with
its entry already in acp.json. Notice in en, zh, zh-TW, ja, de; README,
reference and agent-wiring rows.
Run at this head (rebased on
|
||
|
|
1aca55909f |
gateway keys: a key given a model is not given a routing group of it the user never handed out (kautism)
kautism on Discord: a gateway key held to gemini 3.8 alone was shown, and could use, a routing group the user made of gemini 3.8 alone, though the user never gave the key that group. groupAllowed let a key use any group whose every member it may use (the #882 rule), so the group leaked into /v1/models and every route that asks it. - key_models.go groupAllowed, the one check every route asks (the model lists' entryAllowed, serve on every API, countHeld, embeddings, images, videos, decision groups, a subagent's and masking's route): a group of the user's own is a key's only when the key names it (group/<id> or group/*). A group magpie found (auto/<model>, one model several providers serve; foundGroup) still passes when the key may use every member, as it is that model. A key that names accounts and no model (Linka, access.HeldModels gives it "<provider>/*") still may use a group of those providers' models alone, as it may every such model: access.Identity.AccountModels says so, for an issued key too. - keyGroupFor: a bare name that is both a group of the user's the key may not use and a model it may use is that model for the key (a group the user called "Gemini 3.8", id gemini-3-8, would otherwise have turned the key's bare gemini-3.8 into a 403). serve's grouped and countHeld use it. - Decision models (v0.1.2681) unchanged: a group the key names still asks its own Jev; TestGatewayKeyHeldToAGroupKeepsItsDecider passes. - A group named inside one the key doesn't name no longer makes the outer one the key's (TestGatewayKeyModelsNameAGroup updated); the key names the outer group to use it. - docs/reference.md and gateway-routing.md say so. TestGatewayKeyGivenAModelIsNotGivenItsGroup is the reporter's case: a key given google/gemini-3.8 alone, a group "Only 3.8" and one "Gemini 3.8" of that model alone. Neither is listed in /v1/models nor found at /v1/models/{id}; each is refused on chat completions, messages and count_tokens, by id and by name; the model is served by id and bare; a found group of two providers' gemini-3.8 is still listed and served to a key given both; a key naming group/only-38 is given it. TestGatewayKeyModelsHoldAKey, TestKeyListSeesChangesNextRequest updated from the old rule. Broken by hand: groupAllowed back to the old rule: the new test, TestGatewayKeyModelsHoldAKey and TestGatewayKeyModelsNameAGroup red. The bare-name fallback off: the new test red (chat gemini-3.8 403). The accounts-only exception off: TestGatewayKeyAccountsOnlyHoldTheModels red. Run on mote at this commit (rebased on origin/main |
||
|
|
2b938b170d |
gateway keys: the key editor offers decision models (Jev, Clef) beside the groups
Kautism on Discord: a gateway key held to a few routing groups couldn't use Clef or Jev, and they showed nowhere for it. A decision model is a model: /v1/systemone and the decision list another magpie asks for (DecidersHeader) hold a key to it as to any model, which stays so (the restriction covers both routes). But GET /api/caller-keys/models listed only provider.Catalog, which has no decision models, so the only way to let a held key ask one was All models. - caller_keys.go: the picker's list now has OfferedDeciders, each after its provider's chat models, marked decides. - keys.js: such a model's note says it is a decision model that a routing group asks whatever the key may use, and that picking it lets the key ask it itself; en, zh, zh-TW, ja, de. - A group the key names still asks its own Jev for every turn with no key check (askJev); TestGatewayKeyHeldToAGroupKeepsItsDecider holds that, and that the key is refused Jev at /v1/systemone and not listed it until it names it, then allowed and listed. - docs/reference.md and gateway-routing.md say so. Run on mote at the pre-rebase head; at the pushed head (rebased on |
||
|
|
066ece93bb |
provider: LongCat is a vendor preset, Meituan's LongCat API platform with chat completions, Responses and Anthropic messages (hoobnn on Discord)
LongCat makes its own models (LongCat-2.5, launched 11-02) and serves them
at api.longcat.chat. magpie had LongCat's icon but no preset for it.
The new preset is longcat ("LongCat", KindVendor, icon longcat, catalog
models.dev's longcat). It uses:
- chat completions and Responses at https://api.longcat.chat/openai/v1;
- Anthropic messages at https://api.longcat.chat/anthropic;
- docs at longcat.chat/platform/docs/zh/api-docs, keys at
longcat.chat/platform/api_keys.
The key goes as a Bearer. magpie sends both headers, and the docs ask for
Bearer on both endpoints; x-api-key alone gets "missing_api_key". The model
list is /openai/v1/models. longcat.chat's and longcat.ai's accounts use the
same API host (both sites' api-docs pages name api.longcat.chat).
An entry at those endpoints imports as the preset, for example CC Switch's
Claude Code and Codex entries from LongCat's cc-switch page. OpenCode's
auth.json "longcat" (models.dev's id) maps to the preset too. The README
(en, zh), docs/reference.md and the site's import pages (en, zh, ja, and
import.html, with the icon) list it.
Sources, read 11-02: api-docs, api/models, api/model, api/model-params,
api/chat, api/messages, image-video-understanding, cc-switch, pricing/
longcat-2.5, change-log, faq.
Probed without a key, from this machine: /openai/v1/models and
/anthropic/v1/models answer 401 authentication_error "missing_api_key".
/openai/v1/chat/completions, /openai/v1/responses and
/anthropic/v1/messages with a bad Bearer answer 401 "incorrect api key".
Run at this head (base
|
||
|
|
ad53a23dc8 |
gateway: X-Magpie-Account takes a percent-encoded name (plugins#615)
StockRabbit (magpie-community/plugins#615, Magpie 0.1.2587, Windows): pinning the Fingerprint page to the WorkBuddy account 北冥 failed every sample with "Header 'X-Magpie-Account' has invalid value". A header value is ASCII on the wire and fetch refuses any other, and the gateway matched the header only against the account's user (北冥) or its trace id (workbuddy@北冥/…), so no ASCII form could name that account. pinTo now matches the value as written or percent-decoded (pinnedName: url.PathUnescape, kept only when it decodes to valid UTF-8). The trace's Pinned, the call's error and the 404's "no account %q" name it decoded. gateway.go:2701 is the one place that reads the value; codex_backend.go, codex_relay.go and gateway.go:2523 test only that it is present, so they need nothing. docs/reference.md and the gateway-routing page say how to send such a name. Run at this head (rebased on |
||
|
|
611ce90d15 |
agent: OpenBot, magpie's models in its model picker (jiezhengj)
OpenBot (nightly-labs/openbot, openbot.run, v0.58.0) is a new row on the
Agents page. jiezhengj on Discord asked for it: today they type magpie's
address into OpenBot by hand and add each model one at a time.
OpenBot lists the user's own OpenAI-compatible endpoints from
openbot-custom-providers-v1.json in its userData folder:
~/Library/Application Support/OpenBot, %APPDATA%\OpenBot, or
~/.config/OpenBot. Connecting adds an entry with id "magpie" pointing at
the gateway's /v1 and holding the models picked for OpenBot, with
secret null. OpenBot seals an entry's key in safeStorage, which magpie
doesn't open, so the entry has no key. OpenBot hands it to OpenCode
keyless, and the gateway accepts it as a request from this computer.
What the entry keeps to:
- OpenBot's decoders drop the whole list over one bad entry. So the entry
has at most 64 models, only ids OpenBot accepts as magpie/<id>, and a
context window only inside 1,024 to 100,000,000.
- The user's other entries stay. The name, harness and secret they give
magpie's entry in OpenBot stay too.
- A sync with nothing to change doesn't write.
- A file whose version isn't the number 1, or whose providers isn't a
list, is one OpenBot refuses itself, so magpie leaves it alone.
- Disconnect takes out magpie's entry, and the file too when only the
version and an empty list are left.
OpenBot reads the file at start, so while it runs, a notice says to
restart it. The notice is in every language.
OpenBot is detected by its userData folder, OpenBot.app
(app.openbot.desktop), or OpenBot.exe under %LOCALAPPDATA%\Programs or
%ProgramFiles%. Docs updated: agent-wiring.md, reference.md, and both
READMEs.
Run at the pushed head, on mote:
- gofmt -l: clean.
- go vet -tags nogui for internal/agent and internal/gui, and for ./...
with GOOS=linux and GOOS=windows: ok.
- go test -tags nogui -count=1 -timeout 45m on internal/agent and every
package that imports it (., backup, cli, davsync, gui, library,
profile, stats, tui, uninstall, plugins/...): ok.
- GUI: agent-notice-lang, i18n-keys, header-relang and about-notices in
Chromium and WebKit: 58 of 58 pass.
After rebasing on
|
||
|
|
2503520f82 |
codexcat: each Codex model takes official Codex's own instructions for it (#3759, #4008, #4783)
Every magpie model in Codex's catalog (model_catalog_json) carried
gpt-5.2-codex_prompt.md ("You are Codex, based on GPT-5"), so a magpie
GPT-6 model, the auto group's included, ran on a GPT-5.2-era prompt while
official Codex sends GPT-6's own template. magpie still writes no words of
its own into the prompt and leaves the identity line alone: each entry now
takes the text official Codex sends that model, word for word.
- A model's slug (the id's last segment) is matched as Codex 0.166
matches one (longest prefix of an official slug): first in the entries
the user's ChatGPT account handed this Codex (models_cache.json), whose
base_instructions and model_messages go over as sent; then in Codex
rust-v0.166.0's bundled models.json (instructions_template only, as an
older Codex may not read 0.166's model_messages), embedded as
codex_instructions.json.
- Any other model, and a routing group, takes Codex's prompt for a model
it doesn't know (models-manager/prompt.md, model_info_from_slug), which
replaces codex_prompt.md: that is what official Codex sends it.
- ownEntry with no base_instructions, and internal/provider's
codexInstructions fallback, take the same official text.
- testdata holds Codex's models.json and prompt.md at rust-v0.166.0;
TestBundledIsCodexOwn fails when the embedded copies drift from them.
- GET /v1/codex/models (a remote Codex's model_catalog_url): entries are
now ~21 KB, so Codex before 0.166's 1 MiB cap holds about 48 of them
(was ~125). Codex 0.166 reads the catalog whole (models_endpoint.rs
passes no body limit), and it sends ?client_version=, so the cap now
applies only to a Codex below 0.166 or one that doesn't say
(codexReadsWholeCatalog). docs/reference.md says so.
- docs/subsystems/agent-wiring.md: a "Codex instructions" row. The
Antigravity cloak's comment no longer calls the GPT-5 prompt magpie's.
Run (mote's disk is full, 100% with other sessions' runs, so on WSL
magpie-desktop through wsl-run):
- go test ./internal/codexcat/: ok. go vet -tags nogui ./... and
GOOS=windows go vet ./...: ok. gofmt -l: clean.
- go test -tags nogui -count=1 -timeout 45m codexcat, provider, agent,
gui, gateway (every package that imports codexcat): codexcat, provider,
gui ok. agent: TestGrokInstalled and TestOmpDetectedWithPiDir red, the
same at origin/main
|
||
|
|
ec104b8625 |
gateway: a Codex account can spend its credits before magpie moves to another account (jojonas_xyz on X)
jojonas_xyz on X: "我账号额度用完了自动给我切了别的号…找不到怎么关掉设置…你怎么知道 我不是想用 credits 呢". (Roughly: "my account ran out of quota and magpie switched me to another account by itself; I can't find a setting to turn that off; how do you know I didn't want to use the credits?") Cause. At 90% or 98% of a window, smart routing's tier put the account behind every account that still had room, whether or not it had ChatGPT credits. Codex's own sign-in (NextLogin / SwitchWhenSpent) moved at the spent share in the same way. The account's credits were spent only once every other account was used up, and the switch was a log line. The Use credits switches that existed (on, and "Only after other accounts" from |
||
|
|
9d08993c8b |
routing: Cheapest first prices Ollama Cloud's DeepSeek models at double from 12:00 to 18:00 UTC on weekdays (hayden4608)
hayden4608 on Discord asked that time-of-day routing use the gap between peak and off-peak prices, citing https://ollama.com/pricing. That page (read live on 11-01) gives Off-Peak rows for two models only, deepseek-v4.1-flash ($0.30/$1.20 peak, $0.15/$0.60 off-peak) and deepseek-v4-pro ($1.32/$3.96 peak, $0.66/$1.98), and says off-peak is "outside 12:00 and 18:00 UTC on weekdays and all day on weekends". models.dev's ollama-cloud catalog lists the off-peak prices, so magpie priced Ollama Cloud's peak hours at half. - catalog: a new Peak kind, PeakOllama. Its hours are 12:00 to 18:00 UTC, Monday to Friday, with no holidays. PeakFactor (2) matches the page for both models, cache reads included. - provider: a peakBill for ollama.com (preset/catalog ollama-cloud) that names the two models. Dated tags (deepseek-v4-pro:1017) count as their model; the bare name before ':' is compared without allocating. Every other model there (glm-5.3, gpt-oss...) and every other vendor stays flat. A local Ollama, a relay that names itself ollama-cloud, and an ollama.com.evil host are not matched. - GUI: a model's price tooltip names Ollama's hours for peak "ollama". The Cheapest first and rate-window texts no longer say that only DeepSeek's hours count, in en, zh, zh-TW, ja and de. - docs/reference.md, site docs (en, zh, ja) and the gateway-routing and providers-accounts subsystem pages say the same. Run (on mote through mote-run, at this tree rebased on |
||
|
|
5dfbca6274 |
cli: magpie settings list|get|set|reset, through the window's own save (#4745)
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can be read and set from the terminal. - internal/settingsapi holds the save the handler made: Merge (the carry of keys a page leaves out, moved verbatim from api.go, plus upstream's RouterNote line), the vision/imageGen/searcher checks, settings.Save's own checks, catalog.Touched. POST /api/settings and `magpie settings` both call settingsapi.Apply, so a value is checked and saved one way. It sits outside internal/gui so the nogui build has it. - `magpie settings` (list, the default, with value, default and choices; get; set; reset to settings.Defaults()), --json on list and get. Body sends the whole file with one key changed, so a key the save keeps when absent (noBird, refusalRetries, ...) is set even to off. A flag where a key or value goes, an unknown key (with near matches named) or a refused value writes nothing and exits 1; --help prints usage. - Parity guards: TestKeysAreWhatTheSaveWrites (each Settings field sent changed on its own; what the save takes must equal Keys), TestSettingsCLISetsWhatTheWindowSaves (every key the page's prefsKeep and savePrefs send is a key), TestEveryRouteHasACommandOrIsNamed (each /api route has a command or a reason in notYet, which later stages shrink; 36 have one now). - Item 3 of the stage (per-provider CLI-only fields in the window) is left for stage 2. - The open app's in-process follow-ups (fonts, Dock, tray menu, alerts, language, update re-check) run only from the window's save: #4752. Run (mote, at the pushed head |
||
|
|
994cd4fb68 |
gui: Rex switches to the tab magpie opens, through the app's session.select (#4565, StringKe)
StringKe tried v0.1.2446 on the real Rex app (Rex Beta 0.1.0 (1696)):
the tab opens, but the app keeps showing the tab the user was on. The
new tab shows only in the sidebar, and `open -b` only brings the window
forward. The app's own session.select action, sent to the app client,
does switch to it.
After `rex run` (reused magpie session) or `rex new` (now with --json,
for session_id and initial_windows[0].window_id), openInRex brings Rex
forward and then calls rexSelect. rexSelect reads `rex client list
--json`, takes the client of info.kind "app" whose session_ids hold the
session, else the last app connected, and skips one whose
connection_state is "lost". Then it runs `rex -C <client_id> do
session.select session_id=<id> window_id=<window>`. App actions need
Remote Control on in Rex's settings. With no app, a failed list, a
refused do or no answer within 3s (rexSelectWait), the open still
succeeds, the same way a failed rename is ignored. docs/reference.md's
Rex paragraph says this.
Command shapes come from the real rex CLI, snapshot 0.0.1793420730-
g6d0d9a, on mote with a sandbox HOME and XDG_RUNTIME_DIR: `rex --help`
(-C is a global flag, label or ID), `rex do --help`, `rex client ls
--help`, `rex api describe client.list` (client_id, info.kind
app|cli|agent|other, connection_state connected|lost, session_ids),
`rex new --json` output. With no app connected, `do` without -C exits 3
("no app client is connected"), and -C <unknown> exits 3. A client that
doesn't answer keeps `do` waiting 10s ("did not answer within 10s").
That is why the select runs after open -b and has its own 3s bound.
Tests: TestOpenInRexSelectsTheTab runs a fake rex program (a sh script,
so arguments go through a real exec), with a new session and with
magpie's session reused. It checks that the app attached to the session
is picked over another, that a lost app is never asked, and that no
app, a failing client list, a refused do (exit 1) or a do that never
answers (exec sleep 30, killed at the bound) leave the open a success
within its time. The in-process fakeRex answers client list (no app)
and new --json. TestOpenInRexReal runs these paths against the real rex
server, with no app client.
Ran, through mote-run, on this tree before the rebase onto
|
||
|
|
f2f75ee4ae |
provider: Volcengine Ark's System One API, in beta, as a decider (axelburks on Discord)
Ark answers System One at https://ark.cn-beijing.volces.com/api/v1/systemone (and /api/v3/systemone) only with the beta header ark-beta-systemone-api: true; without it the reply is a bare 404. The new volcengine-decision preset asks it with an Ark API key, and magpie sets the header (DecideHeaders) on Ark's own host only, ark.<region>.volces.com, in both the gateway's /v1/systemone and the provider's Test. Its decision model, doubao-seed-2-1-lite-260915 (ArkDecision), is kept apart from Ark's chat list as Bailian's is (vendorDecision), since no /models names it. Learnt from the real API on 11-01 with the owner's Ark key (read from magpie's config, never printed): only doubao-seed-2-1-lite-260915 answers; doubao-seed-2-1-pro-260628, doubao-seed-2-0-lite-260428 and deepseek-v4-1-flash are refused 400 "does not support the SystemOne API". The Coding and Agent Plans' paths (/api/coding/v3, /api/plan/v3, their v1s) answer an empty 404 even with the header, so it bills as pay as you go. An image in the request was left unread (a red square came back 0.48, input tokens as for no image), so images are off. The tests' replies are the real response bytes. Run: - Real: a magpie built from this tree on mote, in a sandbox HOME: `magpie provider add volcengine-decision <key>` and `provider test` (decide ok, 413 ms), then `magpie serve` on a free port and POST /v1/systemone through it: a real 200 with Ark's choice. - gofmt -l internal/: clean. go vet darwin, linux, windows of internal/provider and internal/gateway: ok. - mote-run go test -count=1 -timeout 45m ./internal/provider/ ./internal/gateway/ ./internal/gui/ ./internal/cli/ at base |
||
|
|
e84870f173 |
plugins: an option's words in the window's language, and a filtered model list says so (plugins#590)
anewuser6937 (Discord, plugins#590) saw one model in WorkBuddy's editor
and took the plugin for broken. They had turned on "Free models only"
themselves, but its label and description read in English in the Chinese
window, and nothing by the models said the list was filtered.
A plugin option (auth.options, magpie's own field; OpenCode's AuthHook is
provider/loader/methods and never reads it) may now give `labels`,
`descriptions` and `confirms`, each keyed by the window's language
("zh", "zh-TW", "ja", "de"), beside the plain strings, as a page's
`titles` do. The host keeps only non-empty strings under language names
of 16 or less, 16 languages at most, each capped as the plain one is
(60/300/300). The editor shows the exact language, then its first part
(zh-TW reads zh), else the plain words, in the row, the hint, and the
confirm dialog and its title. `filtersModels: true` says the plugin's
model list leaves models out while the switch is on; while one is on, as
saved, the Models field says under the chips "Only some models are
listed: the plugin option “…” is on." (zh 只列出部分模型:插件选项「…」已开启。,
zh-TW, ja, de too). An older plugin shows what it showed before, and an
older magpie shows a new plugin's plain words with no note.
WorkBuddy 0.2.10 gives "Free models only" in all four languages with
filtersModels (magpie-community/plugins aec58ae, on npm: `npm view
@magpie-community/opencode-workbuddy-auth@0.2.10 --prefer-online` on mote
says 0.2.10, latest), and the mover's min is raised to it so every moved
user gets it. The CLI's `magpie plugin options` stays English, as the CLI is.
The core scripts would have gone 608 bytes over their budget; three of the
provider editor's comments in app.js are cut down instead, no raise
(1,532,865 of 1,533,105).
Run, on mote (mote-run), at this tree:
- node --test plugin-option-words.test.cjs (new): Chromium and WebKit,
1100 and 420 wide, en/zh/zh-TW/ja/de, switch on and off: each
language's label and description, zh-TW falling back to zh and ja/de to
the plain words for a zh-only option, the note exactly once under the
chips in a .hint inside the editor with no sideways scroll, none while
off, the confirm in the language. With app.js put back: 19 of 21 red
in Chromium (only "en off" passes, both widths).
- With plugin-options.test.cjs and i18n-keys.test.cjs, both engines:
68 pass, 0 fail.
- go test ./internal/plugin ./internal/provider ./internal/cli: ok.
TestPluginOptions with host.js put back: red (empty maps, FiltersModels
false). The real WorkBuddy 0.2.10 index.mjs loaded into this host
(a temporary test, not kept): plugin.Providers lists free_only for
workbuddy and workbuddy-ai with all four languages and filtersModels true.
- go test ./internal/gui: TestCoreScriptBudget ok after the cut. Red,
and red the same at origin/main
|