Commit Graph
7 Commits
Author SHA1 Message Date
yetone d1f8d8aae7 agent: Cherry Studio adds magpie through its providers link (plugins#865)
Cherry Studio (CherryHQ) shows on the Agents page, and with
`magpie cherrystudio`, on macOS, Windows and Linux. Its row is the link
its main process takes, cherrystudio://providers/api-keys?v=1&data=, with
the gateway at <gw>/v1 as an OpenAI-compatible provider named magpie and
the named key agentKeyAt("cherrystudio"). Cherry Studio asks the user to
confirm it. magpie writes nothing into its store. "Added" is read
untouched from its 2.x database (Data/cherrystudio.sqlite, user_provider),
in the default userData and every one boot-config.json moved it to. A
database or boot-config that can't be read, or a 1.x userData (Local
Storage, no database), is unknown. The data is standard base64, because
Cherry Studio swaps raw + and / before parsing and back after. /api/open
lets that link through. aionui's database status is generalized into
dbStatus{has} so both apps share it. Icon: Cherry Studio's own logo, not
cherryin-color (a different product).

Run (mote, at this change on origin/main c66cdbea9; then rebased on
0f04dca6e and run again: vet of agent/gui/cli, Windows vet of agent/gui,
and the Cherry, AionUi, gateway-key and import-link tests, ok):
- gofmt -l clean; go vet ./internal/agent ./internal/gui ./internal/cli;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...
- go test -tags nogui -count=1 ./internal/agent ./internal/gui
  ./internal/cli: agent and cli ok; gui ok but TestCoreScriptBudget, red the
  same on a clean c66cdbea9 (#4526, 1533856 > 1533802)
- node --test import-row.test.cjs i18n-keys.test.cjs: import-row 20/20,
  chromium and webkit, en/zh/zh-TW/ja/de, and 420px wide; i18n-keys red
  only on "a plugin's words are its own", the same on clean c66cdbea9
  (#5332, #5426, #5482). No new strings.
- TestCherryStudioLinkParsedAs2_1_10 runs the link through 2.1.10's own
  parser (copied into testdata) and the renderer's zod checks, with
  gateways whose base64 spells + and /.
- Real try on mote (macOS 27.2, arm64): released Cherry Studio 2.1.10 in a
  sandbox HOME and --user-data-dir, with a sandbox magpie of this tree on
  127.0.0.1:3561 and a fake upstream. `magpie cherrystudio add` opened the
  dialog with base URL http://127.0.0.1:3561/v1 and the key
  magpie-cherrystudio. Add saved it, turned off as every Cherry provider
  is. `magpie cherrystudio` then said added, read while the app ran (WAL).
  Sync models listed fake/fake-1 from the gateway, and adding it turned
  the provider on. A chat got the fake upstream's reply, and magpie usage
  counted it as Cherry Studio's. A link sent while the first-run welcome
  page was up showed no dialog; after "set up later" it did.

Broken by hand, each red, then restored:
- URL-safe base64: TestCherryStudioLinkParsedAs2_1_10 (baseUrl decoded as
  /x~>/v1 and /xy\x7f?/v1)
- no closing quote/slash on the address match: TestCherryStudioHas
  (another port's provider counted)
- the /api/open prefix dropped: TestCherryStudioImportRow
- Cherry Studio dropped from /api/open's app case:
  TestImportLinkNothingOpens

Not tried: a real run on Windows or Linux (detection is unit tests
only); Cherry Studio 1.x, which reads as unknown; a real vendor upstream
(the try used a fake). Full suite not run at push.

Reported-by: mysterysqwq
2026-11-08 19:09:21 +08:00
yetone 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).
2026-10-31 02:09:18 +08:00
yetone 628ac36fc9 agents: Add magpie says when nothing here opens the app's import link (sungt)
sungt (Discord #feedback, Windows, magpie 0.1.1976, Cindy 0.1.119, Cindy
open): on the Agents page Cindy's 添加 magpie "spins, no response".

What magpie got wrong: Cindy, AionUi and Lody take magpie only through
their import link, which magpie hands to rundll32 / open / xdg-open and
never waits on. A link nothing opens did nothing, the button never awaited
/api/open nor caught its error, and `magpie cindy add` printed "opened"
whatever happened.

- agent.OpenAppLink asks the system, without opening anything, whether
  something opens the link's scheme: Windows' HKCR\<scheme> (what
  Electron's setAsDefaultProtocolClient writes) and then the user's
  UrlAssociations UserChoice; macOS Launch Services (cgo builds); Linux
  `xdg-mime query default`. Only "none", or a registered program whose
  full path is gone, refuses the link (NoLinkHandlerError); anything
  unknown hands it over as before.
- /api/open (Cindy, AionUi, Lody after OpenLody) answers
  code no_link_handler with app, exe and said, an i18n.js key from
  linkSaid that api() puts through t() as it does bunSaid's.
- The import button now waits for /api/open and shows the result: "Sent
  to {name}: confirm adding magpie there", or the reason in the
  reader's language.
- The CLI's add returns the same error.

This is not verified as sungt's cause. Cindy was open, and Cindy
registers cindy:// at every start, so the check most likely passes on
their machine. If so, the spinner is Cindy's own import dialog
(previewProviderImport / fetching magpie's /v1/models). Cindy 0.1.119
wasn't available here. We still need Cindy's log around "received deep
link" from sungt.

Run (worktree at origin/main 536a98316, mote unless said):
- go test -tags nogui -count=1 ./internal/agent ./internal/gui
  ./internal/cli: agent ok, cli ok. gui is red only on
  TestCoreScriptBudget, #4133, which is red on origin/main
  (1531446 > 1530861, from a4e929212's context.js). This change adds 85
  bytes to app.js (1311673, under app.js's own 1311735) and makes the
  total 1531531. No budget was raised.
- node --test, chromium and webkit, every language: import-row,
  i18n-keys, plugin-bun-unstartable, agent-connect-no-models and
  agent-connect-all-hidden (api()'s error paths). Result: 84 pass, 0 fail.
- Windows (win-run): TestCommandProgram, TestOpenAppLinkSaysNothingOpensIt,
  TestSystemLinkHandlerNoSuchScheme (real registry lookup) and
  TestFolderVarsAreListed all pass. Earlier in this work:
  - rundll32 handed magpie's 719-char Cindy link byte for byte to a
    registered handler;
  - a temporary HKCU scheme was read as found, then as gone once its exe
    was deleted, and the key was removed afterwards.
- Linux (wsl-run, magpie-desktop, real xdg-mime): the same applink tests
  pass.
- macOS (mote): Launch Services finds https and mailto, and finds no
  handler for cindy, lody, aionui or a random scheme.
- gofmt -l is clean. go vet passes for GOOS=linux -tags nogui, for
  GOOS=windows, and with CGO_ENABLED=0 for internal/agent.

Red on the old code, each wiring reverted by hand:
- providers.go: TestImportLinkNothingOpens is red (204, link handed over).
- cli main.go: TestImportAddSaysNothingOpensIt is red (nil error, link
  handed to the browser).
- importButton: import-row is red (status "" where the Sent/err line was
  wanted).

Not tried:
- Cindy 0.1.119, or any real Cindy, on Windows.
- A real app whose registered exe was deleted.
- The full go test ./... and the whole GUI suite. mote was running
  another session's full suites, and there is one suite per machine.
2026-10-29 09:24:31 +08:00
yetone 4b1994ad31 agent: AionUi, added through its add-provider link
seven7032 on Discord asked how to connect AionUi to magpie. AionUi
keeps its providers in its own SQLite database
(<userData>/aionui/aionui-backend.db, WAL mode), each key encrypted, so
there is no config file for magpie to write. The one supported way in
is its deeplink. AionUi 2.2.2's main process parses it
(parseDeepLinkUrl), and its renderer opens Settings -> Model with the
add form filled in, which the user confirms:

  aionui://add-provider?api_key=magpie-aionui&base_url=<gw>/v1&name=magpie&platform=custom

The AionUi row works the way Cindy's and Lody's do:
- Add magpie opens that link. /api/open allows the aionui://add-provider?
  prefix only. `magpie aionui add` opens it from the CLI.
- The key is agentKeyAt("aionui"), so it becomes the LAN key while
  sharing is on (added to TestPinnedGatewayKeyForEveryWriter).
- "custom" is AionUi's OpenAI-compatible platform. Its base URLs end in
  /v1, as its own OpenAI preset's does.
- Added reads providers.base_url for the gateway's address without
  touching the database (sessions.OpenUntouched, from the previous
  commit). A database that can't be read is unknown, never "not added".
  The last read is kept while the database and its log keep their size
  and time, for 15s at most, so the Agents poll doesn't copy a running
  AionUi's database every time.
- It is detected by userData/aionui (os.UserConfigDir()/AionUi on every
  OS).
- As with Cindy and Lody, the TUI leaves the row out (nothing to pick).

Tests:
- TestAionUiLink: the link's exact bytes.
- TestAionUiLinkParsedAs2_2_2: runs the link through
  testdata/aionui/deeplink-2.2.2.js, which is parseDeepLinkUrl copied
  byte for byte from 2.2.2's app.asar (out/main/index.js 50995-51021)
  plus the renderer's add-provider mapping and the form prefill. The
  result is action add-provider, route /settings/model, and the form gets
  platform custom, the /v1 base URL and the key.
- TestAionUiHas: a fixture database built from 2.2.2's real providers
  schema (taken from the database 2.2.2 made at first start). It covers
  none, another gateway, a row present only in the log of a running app,
  and a closed app, and checks that AionUi's folder is unchanged each
  time.
- TestAionUiUnreadableIsUnknown, TestAionUiStatusRereadsOnChange,
  TestAionUiDetect, TestAionUiImportRow (GUI: the row, unknown status,
  and /api/open refusing other aionui:// links).
- import-row.test.cjs gains the AionUi row (icon, known status in each
  language, the click opens the exact link, and it fits at 420px), in
  chromium and webkit across en, zh, zh-TW, ja and de. The same file
  now waits for the rows to settle before its alignment check: under
  load 105 one run caught Cindy's button mid-resize at 193.4px beside
  the picker's 194.4px. The old file passed 3/3 alone, so it is a
  timing assumption, not a layout bug.

Run at 18041fc5b (this change on origin/main 714ab8e8b):
- go test ./... -timeout 45m, through the suite lock: every package ok
  except internal/proc's TestNoCommandBypassesProc, red on
  internal/tui/keep.go:102 from 75e78a5a0 on main (#3567, which has a
  fix on skygunner's fork).
- gofmt -l clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet of agent, gui, cli and sessions clean.
- import-row.test.cjs: 20/20 in chromium and webkit.
- The whole GUI suite (make test-ui, 882 files) was still running at
  push, so it is not recorded here.
Rebased onto cbbf3163c, which changes GUI assets and api.go. At the
pushed head: go vet of the four packages is clean; go test
./internal/gui ok; the AionUi, Cindy and pinned-key agent tests are ok.
import-row.test.cjs at load ~210: one run had 19/20, and that run's
output wasn't kept, so I can't name the failing case. The next three
runs were 20/20.

Tried: magpie built at this commit with -tags nogui under a sandbox
HOME. `magpie aionui` printed "magpie aionui add  to add magpie" with
AionUi's folder and no database. With a copy of the real 2.2.2 database
holding one row at the gateway's /v1, it printed "magpie added".

Broken by hand:
- Dropping the aionui prefix from /api/open: TestAionUiImportRow red
  ("AionUi's link was not handed to the desktop").
- The reader put back to a plain mode=ro open: TestAionUiHas red
  ("AionUi's folder changed: aionui-backend.db ->
  aionui-backend.db,aionui-backend.db-shm,aionui-backend.db-wal").
Both were restored and are green.

Not tried: the add form, the saved row and gateway traffic. The
released AionUi 2.2.2 desktop app asks for an aionui.com sign-in before
any page, Settings included. That sign-in was not faked, and no
aionui.com account was available, so the link has never been opened in
a signed-in AionUi end to end. Also not tried: what AionUi saves for
platform custom when it is confirmed, AionUi's User-Agent (so none is
matched), and the aionui:// handler on Linux and Windows (Electron's
setAsDefaultProtocolClient, unverified there).
2026-10-25 16:49:29 +08:00
yetone 2e2c890304 agent: Lody is detected by what Lody makes, its link only on loopback is guarded, and its row is tested in every language
Review of Leon Zhao's Lody import (the two commits before this):

- Detection: a bare ~/.lody or ~/.lody-oss another tool made counted as
  Lody. Now the home folder counts only with an entry Lody makes there
  (workspace-catalog.json, loro-repo, agent-binaries, code-collab-v2, all
  in the owner's real ~/.lody). A Lody.app counts only with an ai.lody.
  bundle id (the real /Applications/Lody.app is ai.lody.desktop, and
  registers the lody scheme) or a plist that isn't XML. Electron's data
  folder under os.UserConfigDir (Application Support / %APPDATA% /
  ~/.config, "Lody", "Lody OSS", "Lody Nightly") still counts as before.
  A never-opened install on Windows or Linux has no folder and isn't
  shown; said in agent-wiring.md.
- Security: TestLodyLinkCarriesNoSecret turns LAN sharing on and checks
  the link holds magpie-lody and never the LAN key, every endpoint is
  loopback http, and MAGPIE_ADDR pinned beyond loopback gives no link at
  all (0.0.0.0, 127.0.0.1 and [::1] still give one).
- `magpie lody add` with no link (a LAN-pinned gateway) said it opened
  Lody and opened ""; it now says why and opens nothing.
- Added *bool: every consumer re-read. The CLI and TUI use agent.Agent's
  func (nil-safe), the GUI reads a.added == null, and Cindy's false is now
  sent as "added":false. TestLodyImportHandoff also checks Cindy's row
  says false and Lody's leaves added out; the handoff test's ~/.lody
  holds a catalog file now and checks it is left byte for byte.
- The hint "Opens {name} to add magpie as a provider — confirm it there"
  was already translated in zh, zh-TW, ja and de (the import button's
  tooltip). import-row now runs in all five languages, asserts Lody's
  exact translated line and that no added/not-added wording shows, and
  checks both import rows fit a 420px window with no sideways scroll
  (waiting for the header's segments to settle after the resize, which
  overflow for ~300ms in WebKit en on main too).

Run (on origin/main 4a6bf80f4 + Leon's two; after rebasing onto
dcf292cc8, a routing-only CSS change, import-row, agent-layout,
group-editor-align and i18n-keys were run again in both engines, 47/47,
with the Lody/Cindy/Import Go tests in agent and gui, ok):
- go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME
  (scratchpad dir, XDG_* there too, Go caches pinned): 64 packages ok,
  exit 0 (agent 607s, gateway 674s, gui 130s, provider 219s).
- gofmt -l .: clean. go vet: darwin ./..., GOOS=linux -tags nogui ./...,
  GOOS=windows ./...: clean.
- GUI, playwright 1.62.0, Chromium and WebKit: import-row 20/20 (5
  languages x added/not x 2 engines, 960/700/420px); i18n-keys, gui-de,
  gui-ja, gui-zh-tw, agent-layout, agent-connect, plugin-agent,
  agent-cli-missing, agent-connected-unfolded, agent-bulk-visibility,
  agents-hidden-last: 116/116.

Broken by hand, each went red, then restored:
- a bare ~/.lody counting again: TestLodyDetectionAndRegistration;
- any Lody.app counting: TestLodyBundle (com.example.lody, ai.lodyx.);
- the loopback switch removed: TestLodyLinkCarriesNoSecret (LAN-pinned
  addresses got a link);
- the key taken from agentKeyAt at a LAN address: the LAN key showed in
  the link, red;
- Cindy's false left out of state(): TestLodyImportHandoff;
- app.js's unknown-status branch taken out: import-row red in every
  language; the de translation removed: import-row de red.

Not tried: Lody opening the link for real (Leon ran Lody's parser), and
Windows or Linux Lody installs.
2026-10-15 21:21:42 +08:00
Leon Zhao c6bd4e9707 agent: let Lody confirm local provider imports
Offer Lody a versioned import link for Claude, Codex, Pi, DSH,
Kimi Code, Grok and Bub. Export only loopback endpoints and the public
magpie-lody token. Leave Lody data untouched and show a confirmation hint
when the app exposes no public import-status reader.

Verified: go test -tags nogui ./... in a temporary HOME with pinned Go
caches; native, Linux nogui and Windows vet/build; gofmt and diff checks;
17 Chromium/WebKit import-row and locale checks. The actual Lody parser
accepted all seven targets with IPv4, localhost, IPv6 and canonical ports.

Negative controls: removing registration fails
TestLodyDetectionAndRegistration with "Lody missing from Agents";
removing URL handoff fails TestLodyImportHandoff with
"Lody import was not handed to the desktop". Restored tests pass.

Desktop launch and Linux/Windows runtime behavior were not exercised.

Cherry-picked onto main (4a6bf80f4) from Leeeon233/magpie
feat/lody-integration (ab6c6dd27): README lists resolved with Lody after
Cindy beside main's new agents; /api/open keeps main's OpenURL error path
(#2043) and takes lody:// beside cindy://; the test's fake Windows
returns OpenURL's error as main's interface now does.
2026-10-15 21:18:41 +08:00
yetone e05e3886f9 gui: Cindy's row on the Agents page is laid out as the others (owner: Cindy 这个排版好奇怪啊,跟别的格格不入啊) — an app magpie is added to by a link of its own had no 「接入」 kind, so its row was drawn the old way: no line under the name, and its Add magpie button spanning both picker columns, wider than every other row's model picker and out of line with it. It is now kind "link": a line under the name says Not added · Cindy asks to add magpie when its link opens, or Added · magpie is a provider in Cindy (green dot), and its button stands where the others' model picker does, 196px and lined up with it, the switch's room kept beside it empty. zh, ja, de strings. import-row.test.cjs (Chromium and WebKit, en and zh, added or not): the line, the button lined up with Crush's picker at 960 and 700px, a click opens the link; it fails on the old code (no line). agent-layout, agent-start-pick, agent-disconnect, agy-launch, desktop-model-menu, gui-ja, gui-de and click-scroll pass on WebKit; go vet and go test -tags nogui ./internal/gui/ pass. 2026-10-05 02:30:00 +08:00