4794de398ea8337d223a91e207181c56fcf4ad76
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
79099d6adb |
provider, gui, tui: Ollama, LM Studio and oMLX take an address, so a server on another port or computer is the preset's provider (#1165)
The three On this machine presets were pinned to localhost and their default port: one started on another port, or on another computer on the LAN, had to be rebuilt as a custom provider or typed URL by URL in the CLI. They now take an Address (scheme, host and port), and each of their URLs keeps its own path there (provider.AtAddress, AddressOf; no scheme means http, only http/https, port 1-65535, a pasted path is dropped, anything else refused with nothing changed). - GUI: the add and edit editors have a Server address section under the key, folded unless the saved address isn't the preset's, opened and focused on a refused one. The Endpoints, Test and Refresh follow what is typed; URLs are sent only when the address changed, so ones set apart (an import, the CLI) are left alone. zh, zh-TW, ja, de. - TUI: adding a local preset asks for its address before the key (Enter keeps the default), and w edits it. - CLI: the usage shows provider add ollama url=... anthropic=.... - LM Studio's and oMLX's notes say "port N by default". timonwong's PR head e63cf18e, merged onto main, which had given oMLX a decision API (#1641) since: presets.go keeps main's oMLX Decide; app.js keeps both the Vertex block and the address one; the docs row and -run list take both. Run: see the next commit. |
||
|
|
6794cccd53 |
cli: models and visible find a WSL agent by its id, in any case (#271)
`magpie models --agent` and `magpie visible <agent>` turned the typed name
into an agent through usage's AgentOf, which knows the built-in agents
only, so a WSL agent's id (claude@wsl:Ubuntu) was "no agent". Both now
use agent.Find, as every other agent command does, and visible keeps its
key lowered, as VisibleTo looks it up.
Landed from #271 (AnxForever), merged onto main by hand. The test moved
from the repo root into internal/cli, where the code it tests lives, with
one more case added: TestWSLAgentByIDInModelsAndVisible.
Run (merged onto
|
||
|
|
248a68598c |
gateway, provider, gui, cli: a key+URL provider may be sent the agent's own User-Agent in place of magpie's (#1851)
Every forward went with User-Agent magpie/<version>. A coding plan that serves only the agents it names (pi, OpenCode, Claude Code…) knows them by their User-Agent, so it turned magpie away. What changed - provider: PassUserAgent (passUserAgent in providers.json), off by default. PassesUserAgent takes it only for a key+URL provider: never a signed-in account, a plugin's, or a vendor whose own client magpie goes as (OwnClient: OpenCode, Cline, Kilo, another magpie). A copy keeps it. - gateway: userAgentFor in forwardOnce (chat, Anthropic, Responses, Gemini, count_tokens) sends the inbound User-Agent unchanged where the provider passes it on. It sends magpie's where it doesn't, where the agent sent none, and on magpie's own requests (magpiesOwn: magpie/…, magpie-router/vision/search, the image tool's "<client> magpie-image/1", which is built from MCP clientInfo, not a User-Agent). magpie never invents another client's. The claude-cli/Codex header copies, the OpenCode/Cline/Kilo overrides and account signing run after it as before, and the user's header.User-Agent is put on at signing, so it wins. - gateway: embeddings, images and videos (retrieveFrom, sendWith, remoteVideoContent) now stamp the same for a key+URL provider through stampUA, from the caller's User-Agent kept on the request ctx (caller.ua, withCaller). Before, they went with Go's default (Go-http-client/1.1). Account and remote-magpie paths are untouched. - cli: `magpie provider set <id> user-agent=agent|magpie`, refused for a signed-in account; `magpie provider <id>` shows it. - gui: the provider editor's User-Agent row, "Send the agent's own User-Agent", with an explanation, for a provider with a key only (the JSON says ownClient for presets and providers); en/zh/zh-TW/ja/de. The TUI only adds presets, so it has no field for this. - docs: reference.md (provider set) and subsystems/gateway-routing.md. What was run - gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows. - go test -count=1 ./internal/gateway ./internal/provider ./internal/cli ./internal/gui: all ok (sandbox HOME, private GOCACHE). - TestUserAgentPassedOn covers 7 routes (messages, count_tokens, chat, responses, gemini, embeddings, images) x off / on / on with no UA / on with magpie-router/1 / on with the image tool's UA / the user's header with it on and off. TestUserAgentAccountUntouched: a Factory account with passUserAgent in providers.json is still asked as factory-cli/. Also TestUserAgentClaudeCodeAsBefore, TestUserAgentFor, TestPassesUserAgent, TestAddCopyPassUserAgent, TestProviderUserAgentPair. - Broken by hand, each went red: forwardOnce back to magpie's UA (5 routes red); stampUA removed from embeddings/draw (both red, seen as Go-http-client/1.1); PassesUserAgent ignoring accounts/OwnClient; magpiesOwn dropped (the internal UAs leaked on all 7 routes); the GUI row shown for OpenCode and Save not posting it. - provider-user-agent.test.cjs: 60/60 in chromium and webkit, en, zh, zh-TW, ja, de, at 900 and 440 wide. The provider/editor/add/i18n GUI tests in chromium: 244/244. Not run - Not tried against a real coding plan that checks User-Agent, nor with a real agent through a live gateway. Videos have no test of their own (they go through sendWith, which the images test covers). - The GUI suite was not run in full; the Windows box was not used. |
||
|
|
10d60b1899 |
provider: a provider saved with Select none serves no models, unlisted or not (#1818)
Select none saved `models: []`, which omitempty wrote as no models key at
all, so the provider read back as "no picks" and served the first 24 of
the vendor's list on /v1/models, in auto groups and on the card, while
the editor said none would be served.
What changed:
- Provider.NoModels (json noModels) records the choice; ServesNone() is
NoModels with no picks. A file with no models key still serves the
vendor's list as before.
- Exposed() is empty for it, so the catalog, /v1/models and auto groups
leave it out; resolveIn refuses an explicit pid/model to it; listedBy
and Deciders skip it (a decide-only provider is still a decider).
- SetModels and normalize clear NoModels once there are picks.
- GUI: the editor sends noModels on Save, an edit that omits it keeps it,
the card's exposed count is 0, the hint says nothing is served; with
unlisted the dashed chips explain they are only for groups. Strings in
en, zh, zh-TW, ja, de.
- CLI: `magpie provider models <id> none`.
- docs/subsystems/providers-accounts.md describes it.
Decision (owner delegated): Select none means none, whether or not
unlisted is on; unlisted keeps meaning "hide from the list, still
usable by groups that name it".
Run:
- go test ./internal/provider ./internal/gui ./internal/cli -count=1
(green; second pass ran too) with private GOCACHE and sandbox HOME.
- Broke Exposed's ServesNone check: TestSelectNoneServesNone red
("exposed 24"); broke resolveIn's: red ("watched/m0 resolved"); broke
the GUI keep line: TestProviderSaveSelectNone red ("exposed 24").
- GUI tests chromium + webkit, 5 languages: provider-none-picked 20/20,
provider-draft-picks 10/10 (red with noneChosen broken), plus 12
related model/group/editor tests green.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows clean for the
three packages.
Not run: the gateway package; Codex native model narrowing is unchanged.
searcher-pick.test.cjs fails 3 webkit cases (hover timeout) identically
on the unmodified base
|
||
|
|
af7d97fa2f |
gateway: a Responses provider set codex=as-sent gets Codex's requests as Codex sent them, for a relay that checks they are Codex's own (#1758)
A relay that checks a request is Codex's own answered magpie 400 "Codex 客户端请求特征无效" (10014). magpie fits every Codex request for a Responses backend that isn't OpenAI's: Responses Lite's additional_tools item is lifted into tools (#350), the tool search goes as a function, and OpenAI-only fields such as stream_options.reasoning_summary_delivery are left out. The reporter found that the relay takes the request when additional_tools is left as an input item, and that the lifted shape is what it refuses. The lifting stays the default, because backends that aren't OpenAI's refuse additional_tools or silently drop it (#350). A provider can now opt out: `magpie provider set <id> codex=as-sent` (`codexAsSent` in providers.json; `codex=default` turns it back off). With it on, a request from Codex (fromCodex: Codex's User-Agent or originator) goes as Codex sent it, with only its model name swapped. Codex's own headers go with it as before. A subscription account is never sent this way, and the GUI's provider save keeps the setting. What was run: - TestCodexAsSent: by default the request is still fitted; with codexAsSent the upstream gets exactly what Codex sent, with model m1, X-Codex-Turn-Metadata and the Responses Lite header. It fails on the old gateway.go and passes now. TestAdditionalTools and the gateway's Codex tests pass. Not verified: not tried against the reporter's relay. Their check was made by hand outside magpie, so which other fields that relay looks at is not known. There is no GUI control for the setting (CLI or providers.json only). |
||
|
|
ff930886a2 |
gateway: keys all out of their allowance are answered from their rests with a Retry-After, not asked again on every request, and a key listed twice is asked once (#1772)
A fleet on four Ollama Cloud keys, every one out of its weekly allowance:
each new request asked every key again (the first twice) and answered
429 with no Retry-After, so an agent that waits as told asked again at
once, and the vendor saw four refused requests a turn.
What changed:
- The first key twice: the reporter's providers.json named the first key
in "keys" as well as "key". KeysOn now lists a key once.
- When every key left for a request rests out of its allowance (a 429 or
402 that failure() calls quota or credit, keys only), the request is
answered from the rest without asking: the vendor's own words, "not
asked again before HH:MM", and Retry-After until the first of them is
back (quotaHeld, soonestBack). Accounts are left out, so autoReset
can still spend a reset for them; a 403 or 400 worded as quota is
asked as before.
- The last key out of its allowance now rests as the ones before it do
(before, the last one left was never rested), and a 429 the vendor gave
no Retry-After for gets the soonest rest's end as one.
- A provider can set how long its keys rest when the vendor says nothing
of when the allowance is back: quotaRest (minutes) in providers.json,
or `magpie provider quota-rest <id> 7d`; default stays 15 minutes, at
most 8 days. A time the vendor names (resets_at, Retry-After, a
window) still wins. A GUI save keeps it.
What was run:
- TestAllRestingAnswersFromRest, TestFirstKeyListedTwiceAskedOnce and
TestOwnQuotaRest fail on the old code (no Retry-After, keys re-asked;
"dead-1 dead-1 dead-2 ok-3", the reporter's log); they pass now, with
TestQuotaHeldOnlyForKeysOutOfAllowance, TestDeadChainWalksEachOnce and
TestRestMinutes. The mock answers with the reporter's literal 429 body.
- go test -tags nogui ./internal/provider ./internal/gui pass. A gateway
package run at load ~60 hit its 20m timeout mid-suite with only
TestMaxRPM* red; those pass 8/8 alone here and on origin/main
|
||
|
|
94aa153973 |
tui, provider, serve: a signed-in account's models are fetched at start, so Routing offers Cursor's whole list without m (#1789, reyoung)
The terminal and `magpie serve` never called provider.FetchNew, which the window calls at start: a signed-in Cursor account's list exists only at Cursor, so the TUI's Routing pickers (and a headless gateway's /v1/models) offered the fallback cursor/auto alone until the list was fetched by hand with m on the Providers page. - tui: Init fetches the new lists (fetchModelsCmd, alongside the catalog sync). A model picker open when they arrive (Routing members, the classifier, a provider's models, an agent's model field) is filled in place through its relist, keeping its filter and the model under the cursor. A list left missing (no network) is asked for again a minute later (modelsRetry). Built on reyoung's branch and test. - serve: FetchNew at start, again each minute while a list is missing. - provider: FetchNew reports whether a list is missing, and waits for a CLI asked who is signed in for the first time (awaitIdentities), then lists the accounts again. With the real Cursor account in a fresh sandbox, `cursor-agent about` answered after a look's 3s firstAsk, so FetchNew saw no Cursor account and `magpie serve` still listed 1 model with the TUI fix alone. The window's startBackend gets the same wait. - docs: providers-accounts.md says who fetches the lists and when. Run: - internal/tui TestTUIFetchesSubscriptionModels (6 views) and TestTUIAsksAgainForAMissingList, -race x3; red with the Init fetch, the relist, the cursor restore or the retry tick each removed by hand. A first `about` slowed to 12s injected: passes (the test re-asks). - internal/provider TestFetchNewWaitsForASlowSignIn: red without awaitIdentities (no provider "cursor"); TestFetchNewAccount covers the missing result. - Real Cursor account, sandbox HOME with a keychain holding only Cursor's two items: TUI on main showed cursor/auto only in Routing; the fix shows the full list and "24 models" on Providers. `magpie serve`: main 1 Cursor model at /v1/models, the fix 24 within 5s. - gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows), go test ./... in a sandbox HOME. Not tried: Linux and Windows real Cursor CLIs (the fake CLI tests skip on Windows); Devin's CLI identity goes through the same wait but wasn't tried with a real account. |
||
|
|
23e764d0e0 |
cli: magpie's commands move from the root into internal/cli; the root keeps only main.go
The root held 89 .go files (30 commands, 59 tests). They move as they are to internal/cli (package cli), with git mv so history follows them. The only code change is main() becoming cli.Main(version): the root's new main.go keeps `var version` in package main, so -ldflags "-X main.version=…" in the Makefile, the Dockerfile and magpie-releases, and every workflow, work unchanged. go-winres's rsrc_windows_*.syso still land next to package main in the root. Tests that read testdata by a root-relative path now go up one level (../plugin/testdata/fake, ../sessions/testdata). Five subsystem doc links point at internal/cli/. Run: - go build ./..., gofmt -l, go vet on darwin, linux and windows (nogui) - builds with tags production, dev, "production nogui"; windows -H windowsgui; linux CGO_ENABLED=0 - make release-cli TARGETS="darwin/arm64 linux/amd64 windows/amd64 android/arm64" VERSION=9.9.9-tidy: all four built, binary prints "magpie 9.9.9-tidy" - docker build --build-arg VERSION=7.7.7-tidy: container prints "magpie 7.7.7-tidy" - go test ./internal/cli (default and nogui): 152 tests, the same count as the root on main - go test ./...: all packages pass (agent, gateway, library, provider timed out at 10m under other sessions' load and passed rerun alone with -timeout 40m; none of them changed) - the built binary in a sandbox HOME: version, help, ls, providers, claude, and an unknown command's error |