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).