ac4af582301a4e8a29245dbba767eba31334ddf9
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c8eb7b3877 |
search: a search API's keys are a list, each switched off, moved and removed on its own
Web search took one key per API in one field (辰林鸭~ on Discord: only one
Tavily key). Settings › Models › Web search now lists an API's keys under
it as a provider's accounts are: each masked on its own row with a tick
(off / on), Show, Copy and Remove; several pasted at once (commas,
semicolons, lines), the reply saying how many were new and how many it
had; the order changed by dragging or Alt+↑/↓. A resting key says why and
until when on its row ("asked last until 14:05: rate limited"), from the
gateway's rest (SearchKeyRest, SearchQuota.Ref); rotation on 401/403,
402/432/433 and 429 (#1477) is unchanged.
provider.SearchAPI keeps Key as the keys on, comma-joined, so the gateway
and an older magpie never ask one switched off; keyList is written only
while a key is off. A Key that differs from the list (an older magpie, a
sync) wins, its keys on in its order, the list's off keys after. The last
key on can't be switched off or removed. The GUI names a key by
SearchKeyRef (a hash): POST /api/settings/search-keys (add, ref+on,
ref+remove, arrange) and /api/settings/search-key with ref. Saving an API
with no key keeps its keys, off ones too. Backup and WebDAV sync carry
the off keys, or leave them out with the rest. `magpie search` says
"+N off". docs/subsystems/gateway-routing.md has "The keys as a list".
Run (mote, at this tree, base
|
||
|
|
ce8b67de37 |
gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called page.goto with no timeout of its own, so Playwright held the first load of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a busy box (a whole-suite run at load 130-160) that load took longer and goto timed out. The same pattern is in 988 GUI test files (1174 pages): every one of them now also sets setDefaultNavigationTimeout(60000) on the same page, right after its default, so goto, reload and waitForURL wait on the load itself with room, while clicks and waits keep their short bar. group-from-model-add's own 20s navigation bar is raised to the same minute. claude-switch-only also gives its first provider row (drawn from the page's first reads) a minute before clicking it. nav-timeout.test.cjs (no browser) reads every GUI test file and names each page given a default under a minute without a navigation timeout of at least a minute, so a new file can't bring the pattern back. What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from other sessions): - node --check on every file in internal/gui/tests: all parse. - nav-timeout.test.cjs against origin/main's test files: red (names the 1174 pages); against this tree: its only reds were my own probe copies of the old files, since removed. - By hand: claude-switch-only with app.js served 7s late (a busy box's first load), --test-name-pattern "1100 en": origin/main's file 4 of 4 red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green. - claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420: 32 of 32. group-from-model-add, usage-access-key-card and i18n-keys: green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red on a 5s waitForFunction at line 115 (a wait after load, not the navigation), at load ~230. Not tried: the whole GUI suite (about 1000 files; the change is one mechanical line per page), Windows or mote (mote's browsers, #4125). |
||
|
|
402577c15a |
gateway: image generation is an MCP server on the gateway, /mcp/magpie/image
JonahFu on X runs magpie in Docker in gateway mode, so he has no Library and
no stdio Magpie Image server, while image recognition is an HTTP MCP server
on the gateway (/mcp/magpie/vision). Now image generation is one too, with
the stdio server's tools: generate_image, generate_video and
generation_result, drawing with Settings › Images › Image generation.
- image_mcp.go: served by serveMCP, so it is guarded as the vision server
is (local or a shared magpie's caller, a refused Origin 403, POST only,
the key's limit reserved per call). A drawing is s.images run in-process
on a clone of the request (caller and key kept), so routing, key models,
usage and the timeout setting are draw.go's own. It runs as a job (15
min at most); the tool answers within 20s or gives an id that
generation_result waits on. Images come back as MCP image content (5 MB
each at most) and at /mcp/magpie/image/files/<name>, kept in memory an
hour, 256 MB at most, readable only by the key that made them. Videos
go through videosCreate/videosGet in-process and are given as
/v1/videos/<id>/content. Image generation Off is a tool error naming
where to turn it on, before the arguments are read.
- Input images go through the vision server's reader, now mcpImageSrc
(vision_mcp.go), so a file path is read only for a local caller.
- The tool schemas live in the gateway (ImageToolProps, VideoToolProps,
ResultToolProps); internal/imagemcp takes them and adds only its path
argument. Its tools/list JSON was compared byte for byte with the old one.
- Settings › Models: #imageMcpRow under #visionMcpRow with the address and
a copy button; the gateway-mode Image generation sub now points at it.
en, zh, zh-TW, ja, de.
The two rows are drawn by one helper (mcpRow), which took the vision
row's own code, so the row costs 462 bytes of app.js.
- core_budget_test: appScriptBudget 1,321,336 -> 1,321,424 and
coreScriptBudget 1,528,525 -> 1,528,972, the exact sizes with the row,
with no room added (10-25). Nothing moved out: the row is Settings'
own, which the core draws.
- search-api.test.cjs: the new row pushed the search row partly below the
1400px window at 420px, where scrollIntoViewIfNeeded leaves it, and
magpie puts back a scroll the reader didn't make, so the test's
coordinate clicks missed. It now brings the whole row on screen with
the wheel and checks it is still there a second later. Red with the new
row before this, green after; green on origin/main's GUI either way.
- oneport_test knows ImageMCPPath and ImageMCPFiles (ClientPath covers
them).
Run (worktree at this commit, on origin/main
|
||
|
|
197849ad4d |
gateway: image generation's timeout is a setting, 1 to 60 minutes
neighbads on X: a slow image endpoint needed more than the fixed 5 minutes. Settings > Images > Image generation timeout (imageTimeout in settings.json, 5 when unset, 1 to 60 accepted, anything else a 400) now gives every drawing that long, on each route it takes: - drawTimeout() reads the setting; drawWithin marks the context as a drawing and sets its deadline. Error texts say the time it was given (givenTo), ModelScope's task polling too. - A marked drawing goes through a vendor transport with no ResponseHeaderTimeout (drawsApart), since an images API sends its headers only once it has drawn; everything else keeps the 10-minute upstreamHeaderWait, so a 30-minute setting isn't cut at 10. - An image answered as a link is downloaded within the same time (imageLongest, never under ImageLongest). - Videos keep 5 minutes per call (videoTimeout): a video is made between its calls, so the setting isn't theirs. - magpie mcp image waits on a call up to callLongest (2h1m, past the 60-minute bound twice over), since it may not read the settings (WSL); ToolTimeout, which agent configs carry, is unchanged. - The plugin path: Bun 1.4.2's fetch has no 5-minute cap (tried against a server answering after 330s), so nothing changes there. - api.go keeps the saved value when a page doesn't send imageTimeout; prefsKeep carries it on every other Settings save. GUI: a segmented row under Image generation (5, 10, 15, 30, 60 min; a value set by hand gets its own segment), in en, zh, zh-TW, ja and de. Three GUI tests clicked controls the new row pushed under the window's foot or past the viewport; they now wheel to them with reader.cjs's reach (disabled-models, search-api, refusal-retries-setting). searcher-pick checks the help has no title before reach's pointer passes over it (the app's mouseover sets one on cut-short text). Run, at |
||
|
|
8f9bc3fccf |
gui tests: the 37 other Settings tests act on rows once the page has drawn its last read of the settings, as the masking-rules tests do since #1653 (#1659)
Opening Settings reads the settings twice: the page's own read (showView), then the window's load() once the state is in. Each read redraws every row. A test that found a row after the first draw, and then called scrollIntoViewIfNeeded or boundingBox on it, failed when the second read landed in between. The errors were "Element is not attached", or a null box. #1653 fixed the three masking-rules tests and listed these 37 in #1659. Each of the 37 now calls watchSettingsReads(page) before every page.goto, and settingsDrawn(page) right after it. Right after goto is exact for ?view=settings: at boot, show(view) asks for showView's read before load() runs. load() sets load.done in the same run that then asks for its own read, so settingsDrawn's "load.done and every read asked for drawn" holds only once the second read is drawn. For a test opened on another page that clicks into Settings later, load is done by then, the click makes the only read, and the wait passes at once. watchSettingsReads now watches a page once, however many times it is opened, since some of these tests open one page several times. The page is unchanged. Reproduced with a generic injection (scratchpad inject1659.cjs, loaded with NODE_OPTIONS=--require). A route added at each goto holds the page's second GET /api/settings. It lets the read go just as the test calls scrollIntoViewIfNeeded or boundingBox, or waits on the page with waitForFunction (which settingsDrawn is), with a 4s timer as a backstop. This is #1653's injection, made generic. Before, injected, both engines, all languages: - 5 files red with the issue's error: - github-token: null box. - member-model-setting, searcher-pick, search-first and update-wait: "Element is not attached to the DOM". - 4 files red on a check of a row drawn from the first read: model-suffix-own, otel, readable-focus and warm-at-times. - 28 green. After, injected: 36 of the 37 files green, every held read let go by settingsDrawn's wait. otel stays red in WebKit at 360px. It is red the same way with no injection, on origin/main's own copy of the test. That cause is separate (the narrow nav laid out after setViewportSize returns) and has its own commit next. Plain (no injection), both engines, all 37 files: 460 cases passed and 2 failed, both otel's WebKit 360px check above. The 8 files red under injection before, injected again after, 5 rounds: 390 of 390 cases passed. |
||
|
|
cfa280a6c2 |
provider, gateway, gui: You.com can be added as a search API, with no key for its free search or with a key (#1626, brainsparker)
A model's web search, when no provider can search, goes to the search APIs the user added; each of them needed a key except a SearXNG of the user's own. You.com answers with no key too, so it is one a user can add in one step. - provider: SearchVendor has KeyOptional (You.com, SearXNG); Ready and check let a vendor that has it go with no key. You.com is listed between Firecrawl and SearXNG, its keys at you.com/platform. - gateway: with no key, GET https://api.you.com/v1/agents/search?query= &count=6 (YouFreeSearch); with a key, POST https://ydc-index.io/v1/search {"query","count"} with X-API-Key, as its API reference says; with a base URL of the user's own and no key, GET <url>/v1/agents/search. Both replies are read from results.web then results.news: the snippets, else the description, and page_age. You.com's errors are a code beside a message, so the message is what the user is told (a 402 "prepaid credit balance has been depleted" is a refused key, the next key or API is asked). Its requests carry the User-Agent tag You.com asked for, "youdotcom-integration/yetone-magpie", after magpie's own. - gui: Settings › Web search lets You.com be added with the key empty, its placeholder saying so (zh, zh-TW, ja, de). - cli: magpie search add you [<key>]; the help lists it. New network addresses: api.you.com (keyless) and ydc-index.io (keyed), asked only when the user adds You.com, with the search query only. Checked against the real service on 10-11: a keyless GET to api.you.com/v1/agents/search answered 200 (testdata/you/free_search.json is that reply, cut to 3 hits), and a real run through askSearchAPIKeys returned 6 pages. ydc-index.io/v1/search answered 402 with no key (testdata/you/keyed_402.json, real bytes) and 403 to a made-up key. The keyless endpoint isn't in the API reference; You.com's own docs pages for third-party tools describe it (free, 100 a day per address, no account), as LiteLLM, ragflow and AnythingLLM use it. you.com/terms bars automated use of its website and apps, not the API. The keyed request shape is from its API reference only: no key with credit was tried. Run: go test -tags nogui . ./internal/gui/ ./internal/provider/ ./internal/backup/ green; ./internal/gateway/ green but TestTurnDoneSaidAtTheTurnsEnd (#1629, fixed in its own commit); search-api.test.cjs in Chromium and WebKit, en/zh, 980/420px green; gui-ja, gui-de and i18n-keys green; gofmt -l; go vet -tags nogui for linux, windows and darwin. The tests make no network request (a stub RoundTripper). Without the change, TestYouSearch, TestYouKeyOutOfCredit, TestYouNeedsNoKey and TestSearchCLIYouWithoutKey fail, and with the GUI's keyOptional check taken out search-api.test.cjs fails in all four Chromium runs (Add sends nothing). |
||
|
|
1c0eab7c84 |
gui, gateway: every search API takes a base URL of the user's own, under its key in Settings (#1580, xzhlksh)
The reporter has endpoints that answer as Tavily, Exa and others do, at
addresses that aren't the vendors', and Settings only took a key. The
saved SearchAPI already had a url, and the CLI's url= set it, but the
Settings row showed the field only for SearXNG and sent "" for the rest.
- Settings › Models › Web search: the add row has a base URL field on a
line of its own under the key, for every API, with the vendor's own
address as its placeholder (searchVendorJSON.base). Picking an API
already added fills in its saved URL, so Add with a new key alone keeps
it; Add with no key typed changes only the URL, the key kept (the key
placeholder says so). Strings in zh, zh-TW, ja, de.
- provider: check() also refuses a URL with a ?query or #fragment, since
the vendor's path goes after it.
- gateway: the key goes only to the URL set. Go drops Authorization on a
redirect to another host but keeps Brave's X-Subscription-Token and
Exa's x-api-key, so a search API's redirect to another host is not
followed; the error names where it was sent. The request still goes
through the gateway's client and so magpie's proxy settings.
- CLI: `magpie search add <api> <key>` keeps the url set before; `url=`
with nothing after it puts the vendor's own back (was: a new key alone
dropped the url).
- docs/subsystems/gateway-routing.md: "A search API's base URL";
gui-shell.md: the field.
- search-api.test.cjs: Settings is drawn twice (/api/state, then
/api/settings), so scrolling to the add row can hit a detached node
(WebKit, 1 in ~6 runs here); it retries the scroll.
magpie ships and lists no third-party search endpoint; the URL is only
the user's.
Tests (sandbox HOME, pinned caches):
- TestSearchAPIAtItsOwnBaseURL: an httptest fake at <fake>/relay/<vendor>/
gets tavily POST /relay/tavily/search with Bearer, exa POST
/relay/exa/search with x-api-key, brave GET
/relay/brave/res/v1/web/search with X-Subscription-Token, firecrawl
POST /relay/firecrawl/v2/search with Bearer. Passes on the old gateway
too: the backend already honoured a url.
- TestSearchKeyStaysAtItsBaseURL: with search_api.go put back, FAIL
"a key reached another host: exa-secret / brave-secret".
- TestSearchCLI: with search_cli.go put back, FAIL "a new key took the
base URL away"; with provider/search_api.go put back, FAIL
"url=https://x.example.com/?k=1 taken".
- TestSearchAPIBaseURLFromSettings: POST /api/settings/search-api saves,
keeps the key, refuses ftp/no-scheme/query URLs, lists vendor bases.
- search-api.test.cjs in Chromium and WebKit, en and zh, 980px and
420px: 8/8; with the old app.js, FAIL "Tavily takes a base URL"
(false !== true). WebKit 980px 10 runs in a row green after the retry.
search-first, search-mcp, searcher-pick, i18n-keys, gui-ja, gui-de,
gui-zh-tw, click-scroll with it: 45/45 in each engine.
- Screenshots at 980/420 in both engines checked by eye.
- go test -tags nogui -timeout 40m ./... on
|
||
|
|
1e0829b125 |
gui, gateway, settings: the Usage page's agent rows show their cache hit rate, and web search can go to the search APIs first (#925, xiaozhu1337; #928, hypooo)
#925: an agent's row said "9.0M cached" but not what share of its prompt that was. Each row of the Agent (and Model, Account, Key) lists now adds "hit rate N%", counted as the Cache read tile counts it: cache read over input + cache read + cache write; a row with no cache read shows none. usage-hit-rate.test.cjs is new and fails without the change. #928: with both a provider that searches and a search API set up, Settings › Web search has "Search first with": Model search (as before, the default) or Search APIs. Saved as settings.searchFirst ("api", or empty for the model first); with the APIs first, webSearch asks them before the Kimi/Google own search and the searcher's model, which search only when every API fails. The Search APIs row says they are asked first. The row is shown only when both sides are set up. TestSearchAPIsFirst and search-first.test.cjs are new and fail without the change. Test fixes on main: gui-ja/gui-de failed on ja/de strings with a second {agent} (the "is signed in to {user} now" warning) and on <name> written <名前>/<Name> in the docker-forward warning; quota-curve.test.cjs opened /blank, which its harness served as a 404 with no body, and Chromium refused to open it (ERR_HTTP_RESPONSE_CODE_FAILURE) — a harness bug, now served as an empty page; search-api.test.cjs waited for #status text that Brave's refusal had already set, so on Chromium it read the posts before the copy arrived. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass; the GUI tests above pass on Chromium and WebKit with Playwright 1.63. |
||
|
|
47eb27296f |
settings: a search API's saved key can be shown, hidden and copied in its row, as a provider's can (OnurBen on Discord: the Providers page shows a key, Settings → Models → Search APIs only listed Firecrawl/Tavily/Exa keys masked, so copying one meant going back to the vendor's site)
Each saved search API with a key gets Show and Copy next to Remove. Show asks the new POST /api/settings/search-key for the key (served on loopback, as provider/key is) and puts it in the row's line in place of the masked one, selectable; Hide puts the masked one back. Copy copies the key without showing it. The settings still list keys masked. search-api.test.cjs checks Show/Hide/Copy (fails on the old app.js) and TestSearchKeyShown the endpoint. GUI: search-api, searcher-pick, click-scroll pass on WebKit; go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. |
||
|
|
10da2936da | gui: Settings is a page per part, under a tab each, the part kept in the address (#471: Settings is one long scroll of some 45 rows in 9 sections) — the page now opens with a tab list in the warm-ups' look (role=tablist, a tab each with aria-controls/aria-labelledby): General (appearance, language, text size, the icons, model names, login, Dock, session terminal), Usage (the menu bar's usage, refresh, logos, what usage shows, currency, number units, the two alerts, then the warm-up and check-in tabs), Network and sharing (proxy, local network), Models (images, web search), Privacy, Observability, Sync and backup, About; the part picked shows its rows alone. Every row, its id and what it saves are as they were; the duplicate heading of a one-section part and the Preferences heading are gone. The part is kept as ?view=settings&tab=<part> (dropped on any other view), so a reload or a link lands there, and remembered (magpie.settingsTab) for Settings opened again without one, as the tray's window/main?view=settings; an unknown one falls back to it. A part whose rows are all hidden on this system has no tab, and one picked falls back to the first shown. The arrows, Home and End move along the tabs, one in the Tab order; a click on a tab moves nothing on the page, the tabs staying where they were; a pill drawn while its part was hidden has its thumb put under its pick when shown (the warm-ups' fix, now shared). The tabs wrap to a line more when they don't fit (English in the 560x420 window, at 110 and 125%, a phone), no left-border stripe. The click hold also holds a click not yet held before taking the next (keys pressed within a frame on a tab list whose part shrank to the window: the second click was taken at the clamped top and the page stayed there). New strings General and Network and sharing are in i18n.js (常规, 网络与共享). Tests that reach a row now open or click its part: api-key-theme, currency, gateway-caller-keys, gateway-connect-keys, lan-docker, number-units, otel, redact-rule-row, s3-sync, search-api, settings-groups, sync-other-kind, tray-inuse, tray-logos, tray-usages, update-check, update-hide, usage-alert, webdav-settings-refresh, whats-new; those needing a scrolled page wheel a shorter window or in smaller steps, as a part is shorter than the whole page was. settings-sections.test.cjs (Chromium, WebKit, en, zh) fails without the change (10 of 10). go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestAccountProxy as on main); settings-sections, settings-groups, click-scroll, old-webkit, text-size and every settings test listed above pass. | ||
|
|
f654bec468 | gateway: a model's web search goes to a search API of the user's own when no provider can search (#419 by HwFee: let me set up Tavily, Brave or SearXNG with my key rather than lose the search tool) — with no provider that searches by itself and no provider magpie could search with, the gateway took the client's web search tool away. Tavily, Brave Search, Exa, Firecrawl and SearXNG (an address of one's own, a key only if it asks for one) can now be set up, in an order: the injected web_search tool is then offered, and a search goes to the searcher's model as before, or, with none or when it fails, to each search API in turn, called directly with no model, its results handed back as the same hits and text the searcher path gives, so clients see the same web_search_tool_result blocks. The order is provider searches itself, searcher provider, search APIs, strip. They are kept in providers.json (0600) like provider keys; a backup carries them, their keys only when it carries keys, and one restored without keys keeps the key here; sync does the same, and a backup or sync from a magpie before them leaves the ones here alone. magpie search lists them, magpie search add <api> [key] [url=…] adds or updates one, magpie search rm <api> removes one; Settings has a Web search section (联网搜索) to add and remove them. Prompts, identity lines and headers to model providers are unchanged. TestWebSearchBySearchAPI, TestNoSearchAPINoTool, TestBackupSearchAPIs, TestSyncSearchAPIs and search-api.test.cjs fail without the change; TestSearchAPIsEachAsked checks each vendor against a fake, TestSearchCLI the command. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; search-api, provider-search, click-scroll, old-webkit pass. |