ac4af582301a4e8a29245dbba767eba31334ddf9
90
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
623e797fde |
plugin pages: read a day's usage and share a picture they drew
A plugin's page can now read one day's usage and share an image it
drew. This is for the day card (JungleyYeh on X asked for a "daily AI
statement"); the card itself is an optional community plugin,
@magpie-community/page-day-card.
- A page that asks for the "usage:day" read gets that day as
magpie.read("usage:day", {date, tz}): totals, each agent and its
models, the streak and the average active day (usageapi/day.go,
gui/pageday.go). The Plugins page names the read before it is granted.
- magpie.image.copy(png) and magpie.image.save(png, name) share a PNG
of at most 16 MB. In the window they go through
POST /api/plugin-pages/image (pageimage.go): copy puts the picture on
the clipboard (clipimage.go: osascript PNGf on macOS, PowerShell
PNG + Bitmap on Windows, wl-copy or xclip on Linux), and save writes
it to Downloads under a name made safe. In magpie web, the browser
saves or copies the picture itself.
- The window's side, pageshare.js, is imported the first time a page
shares a picture. The core grows by its one call only, paid for by
comments cut, so the budget is not raised.
Tests:
- New: TestDayOf, TestPluginPageReadsADay, TestPluginPageSharesAPicture,
TestPageImageName and TestClipImageCommand. plugin-page.test.cjs
covers the bridge, both engines and a refused SVG.
What was run (mote):
- gofmt, plus go vet on darwin, linux and windows: clean.
- Full go test ./... at the pre-rebase base: 369 packages ok, 3 FAILs.
- TestEveryRouteHasACommandOrIsNamed and TestCoreScriptBudget were
this change's own reds. The new route now has a parity entry, and
the share code moved into lazy pageshare.js with no raise.
- TestGatewayModeStatsNameTheGatewaySessions is #5690, the red in the
first hour of the day (it ran at 00:32).
- GUI suite (affected and plugin files, both engines): 1160 of 1179
passed. Every red is filed and none touches this change:
- i18n-keys "a plugin's words are its own": #5332, #5426, #5482.
- page-width-steady: #5013.
- plugin-card-update in WebKit: #3079.
- plugin-move-unserved "Try again": #4410.
- At this head, after the rebase on
|
||
|
|
136178803b |
gui: Escape closes a plugin's details dialog on Discover (#3779)
On Plugins › Discover, Escape left a plugin's details dialog open and only showed Install's focus ring. detail() opened #modal without setting confirmAsk, unlike every other dialog that borrows #modal outside Providers, so Escape reached only the Providers page's handler, which closes nothing there. detail() now sets confirmAsk and its Close goes through closeConfirmAsk. show() clears confirmAsk when leaving a page closes the modal: the dialog's Sign in goes to Providers through show(), and a leftover confirmAsk would take the next Escape there. This is sevtdy's patch from the issue. Side effect: cfgblocked.js steps back to the dialog under a Repair only when confirmAsk is unset, so a Repair opened over the plugin details no longer goes back to them, the same as over the other confirmAsk dialogs. New test: plugin-detail-escape.test.cjs (en, zh): Escape closes the details twice, Close still closes them, and after Install, then Sign in, then Providers, Escape closes the add sheet. Run (mote, via suite.lock): - plugin-detail-escape.test.cjs: chromium 3/3, webkit 3/3 Broken by hand: - plugins.js and app.js at the base: red in both engines (the first Escape leaves the dialog open) - only show()'s clear taken out: red in both engines (after Sign in, Escape on Providers leaves the add sheet open) Wider GUI run (every plugin*, modal-*, i18n-keys, update-wait and the files testing Escape on #modal: 114 files, both engines): running at push time; any red gets its own issue. Not tried: the real app (Wails webview) by hand. Reported-by: sevtdy <16433683+sevtdy@users.noreply.github.com> Co-authored-by: sevtdy <16433683+sevtdy@users.noreply.github.com> |
||
|
|
a5c97cd83a |
plugins: a tool plugin's Hide from agents sits with Switch off and Remove
The button was on the tools line, pushed right with margin-left: auto, so in a two-line row (x: "Tools for agents: x_search, x_read") it sat a line below Switch off and Remove, which the row centres. It is now one of the row's buttons (toolsFlip), before Options, Switch off and Remove, as a text button like them. Run (mote): plugin-tools 22/22, both engines, en/zh/zh-TW/ja/de, 980 and 420; its new check that every row button shares one centre line fails on the old plugins.js/css (red in every language). plugin*.test.cjs, i18n-keys, old-webkit, library-mcp-tool*: 1134 pass, 6 red: plugin-move-unserved's "Try again" x4 is red on unchanged |
||
|
|
784113472d |
gui: motion answers sooner: strong ease-out, folds and popovers under 300ms, no scale(0)
The owner asked for every animation to follow Emil Kowalski's "make your app feel faster" rules (x.com/emilkowalski/status/2118687605776597482): ease-out for anything the user starts, a strong curve over the stock one, and UI motion under ~300ms. Spinners, attention flashes, decorative loops and the chart intros are left as they were. - New token --ease-out: cubic-bezier(.23, 1, .32, 1); --morph-ease is now the strong ease-in-out (.77, 0, .175, 1). - Agents' fold, and the panel's edge that moves with it (UNROLL/ROLLUP): .62s/.42s -> .34s/.26s on --ease-out; its rows .56s with a 48ms stagger -> .32s with 24ms. - An agent row's details (ROW_OPEN/ROW_CLOSE, .ag-open, .ag-body): .48s/.40s -> .32s/.26s. The curve stays the gentle-start spring the comment chose so the panel's edge keeps up; only the time is shorter. - Hover reveal of a row's menu: up to .52s -> .28s. Chevrons .3-.5s -> .22-.32s. - Popovers: pop-in .42s -> .24s; pop-out was .22s on an ease-in curve, now .15s ease-out. - The new-dot started from scale(0); it starts at scale(.5), opacity 0. - Sheets, sidebar sub-lists, modals (.57s -> .44s open, .38s -> .30s close), Context tiles and fades, plugin cards: 460-620ms -> 240-400ms. - Theme crossfade .35s -> .25s; copied/new-account pops .36-.5s -> .26-.3s. Run on the Linux VM (magpie-desktop, WSL), both engines, every language: - Whole GUI suite at this change: 21559 pass, 431 fail of 21990. The run overlapped another session's suite (15-minute load 39). #5559 has 478 of 21666 red on this VM at main. - 17 files that touch the changed motion (model-chip-steady, page-width-steady, zero-priced-free, segs-press-redraw, rest-try-now, provider-fetch-again, codex-predictions, side-toggle, tray-cell-click, menu-input-scroll, agent-details-ready, agent-expand-steady, held-animations, group-morph, header-centre, inner-scroll-contain, recovered-file), concurrency 2, at the parent |
||
|
|
922cc0ccf8 |
library: a plugin's tools hidden from every agent from its Plugins row
chengming0v0 (Discord) keeps a plugin for its providers but doesn't want
the MCP server it brings (minimax_query_video_generation and the rest)
shown to agents, and doesn't want to remove the plugin.
Before: a plugin that gives tools is a Library server of its own
(plugin_tools.go), switched per agent with the row's chips in Library ›
MCP, which held through updates and off/on. Nothing on the Plugins page
said so: its line read "Tools for every agent" whatever the Library had,
and an app at the router's address (/mcp/magpie/hub, agent "") was given
every server, ticked for any agent or none, so taking every chip off
still left the tools there.
Now:
- The plugin's tools line says "Tools for agents" or "Tools, hidden from
agents", with Hide from agents / Give to agents beside the copy button
(plugins.js, toolsServer in /api/plugins from library.PluginServers).
- PluginServerOn (servers/plugin-on {name, on}) sets Server.Hidden and
keeps the agents it had in Paused. Hidden, no agent is given it and
hubServers leaves it out for the router's address too. Give to agents
gives the kept agents back; with none kept, the router's agents
(hubAgents), or else every shown agent that can take it.
- It holds through a plugin update, the plugin off and on, an edit in the
Library editor (SaveServer keeps it) and an agent's "every server"
(serversAgents with no names skips a hidden one). Ticking an agent for
it in Library › MCP shows it again (save clears Hidden).
- Library › MCP tags the server "Plugin", its tooltip pointing at Plugins.
- /mcp/magpie/tools (every plugin's tools, wired by hand) is unchanged.
- Docs: plugin-tools.md, mcp-router.md, site docs plugins (en, zh, ja).
- The core script budget is not raised: two plugins.js comments cut, the
button's tooltips and status lines left out.
Run on mote at this tree (before the site docs, html only):
- go build ./..., go vet ./internal/library ./internal/gui, GOOS=windows
go vet of both, GOOS=linux go vet ./internal/library: ok.
- go test -count=1 ./internal/library/: ok (187s).
- go test -count=1 ./internal/gui/ -run 'Plugin|Library|Budget|Script':
ok (TestCoreScriptBudget 1,533,514 of 1,533,802).
- node --test plugin-tools.test.cjs (new: the line's words, Hide and Give
posting {name, on}, the button inside its row at 980 and 420, all five
languages, Chromium and WebKit): ok; builtins, every library-mcp-* and
mcp-* file: ok.
- i18n-keys "a plugin's words are its own": red, the same three words on
origin/main
|
||
|
|
116f23c784 |
plugins: an agent plugin whose agent isn't on this computer says so, not "Adds Kimi to Agents" (zzZ)
zzZ (innerscw) on Discord: Kimi no longer shows in Agents, even with the
plugin installed. Nothing in magpie regressed. Kimi Code CLI (built-in
`kimi`, ~/.kimi-code) is found on main: installed with Kimi's own
install.sh in a sandbox HOME on mote, it is listed. The plugin is
@magpie-community/agent-kimi-desktop. Its agent's folder,
~/.config/magpie-kimi, is made by its adapter only once Kimi desktop's
Work runtime has written its config.json (bootstrap() in adapter.mjs).
Until then Detected() is false, so Agents lists no row for it. All the
while, the Plugins page said "Adds Kimi to Agents".
/api/plugins's agent now has missing, looks (where magpie looks, ~ for
home) and notice (the plugin's own notice) when the agent isn't found.
The row's line says "Kimi isn't in Agents: magpie doesn't find it in
~/.config/magpie-kimi", followed by the plugin's notice ("请先打开 Kimi…").
It wraps, in muted colour, since it is not a failure. In zh, zh-TW, ja
and de as well. A found agent's row is unchanged, as are fixtures with
no `missing`.
Run on mote (mote-run):
- go test ./internal/gui -run 'TestPluginAgent|TestCoreScriptBudget|I18n|Words': ok.
- node --test plugin-agent, i18n-keys, i18n-en-no-cjk: 30 pass, Chromium
and WebKit, en/zh/zh-TW/ja/de, at 980 and 420.
- go test ./internal/gui ./internal/agent -count=1 -timeout 45m:
internal/agent ok; internal/gui red only in TestMainWindowCorners
(macOS 27, #3949).
- node --test every *plugin*.test.cjs: 1126 of 1130 pass. The 4 reds are
plugin-move-unserved's "Try again takes the models unticked", red the
same on origin/main
|
||
|
|
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 |
||
|
|
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 |
||
|
|
2a19043afc |
library: a skill's files are read as Markdown and edited in the page (refeccd)
refeccd on Discord kept skills in ~/.agents/skills, handed them over to
magpie ("let magpie manage"), and then had nowhere to edit them: the
Library's skill view showed SKILL.md as raw text with no way to change
it. There never was an edit path; this adds one.
- GET /api/library/skill takes `file` and answers library.ReadSkillFile:
the file (SKILL.md by default), its text, the skill's folder and its
text files (UTF-8, no NUL, up to 1 MB each, 200 listed, SKILL.md first;
links, hidden folders and what installing writes left out).
- POST /api/library/skills/save {name, file, text, was} is
library.SaveSkillFile, through change(): it writes only a regular
file already in the skill's library folder (no .., no absolute path,
no link, no folder that is a link out of the skill, nothing under
node_modules/.venv/…), refuses when the file no longer holds `was`
(the text the page opened), keeps CRLF line ends, and writes with
edit.WriteAtomic. The sync after it reaches every agent: a linked
one reads the library's folder, a copy is made again. A copy edited in
an agent before the save is older, so takeEdits sets it aside in the
backups. A GitHub skill saved here reads as Changed here, so an update
asks first.
- The page (viewSkill in plugins/library/client.js) draws a Markdown
file with the Plugins page's own renderer (plugins.js exports it as
window.mdRender, 27 bytes of core script) and its front matter as
rows; other files as text. Edit swaps in a text box; Save or ⌘S/Ctrl+S
sends it; Cancel asks when there are changes. Other files are the
app's menu under the name (no native select). New code is in the
library plugin, so the core script budget is not raised.
- SkillText is gone (its only caller was the route). One new string, in
all five languages. docs/subsystems/library.md says all this.
Run on mote at the change rebased on
|
||
|
|
277c911658 |
plugins: a plugin's Sign in asks which subscription, and Qoder CN is Qoder 中国版 in Chinese
小武 on Discord: "Qoder 只支持国际版 请添加 Qoder中国版", then "有Qoder CN 没有添加账号的入口". The Qoder plugin serves four subscriptions (qoder, qoder-cn, qwenwork, qwenwork-enterprise), but the Plugins page's Sign in on its card and on its Installed row always took the first one not signed in, qoder.com. Qoder CN was never offered there. In the Add sheet it was called "Qoder CN" in every language, so a search for 中国版 found nothing. - plugins.js: with more than one subscription not signed in, Sign in opens the app's menu (openProtoMenu), headed "Sign in to which subscription" and listing each one by its Add-sheet name (subName). With one, it signs in to it directly, as before. The Installed row says "Sign in to another…" when more than one is left. The pm-sub lines and tips use the same names. - app.js: the qoder-cn SUBS entry's name goes through t(). openProtoMenu passes the click event to a single-choice choose, so the sign-in it starts has a fresh trusted event. - i18n.js: Qoder 中国版 (qoder.cn) / Qoder 中國版 (qoder.cn) / Qoder 中国版 / Qoder CN, plus the menu's heading and "Sign in to another…", in zh, zh-TW, ja and de. - The core scripts' budget is unchanged. The ~800 bytes added are paid for by cutting two of plugins.js's GitHub-section comments (1,533,657 <= 1,533,802). The registry's Qoder summary was updated to name Qoder 中国版 in magpie-community/plugins 2595d48. No plugin code changed, so there is no new npm version and no mover min raise. Run at 3b3d32724 (this commit plus the next commit's market.json), rebased on origin/main |
||
|
|
e65bc84731 |
plugins: a git plugin updated past the commit the look found waits no more (#4802)
matrix0487 (Discord, #4802): github:faithleysath/magpie-oh-my-aihub, unpinned. The look at 14:38:55 wrote {version: fdaa691, latest: 3b411a5}; the repository moved on to ba898e7 twenty seconds later, and Update installed ba898e7. The dot, "Update all (1)" and the row's New commits stayed until the next hourly look, and every Update after said only "is up to date". Cause (checked against the source, as the reporter traced it): - PendingUpdates kept a git entry until the commit installed was the recorded latest (GitBehind is installed != head, not "behind"), so a commit newer than latest kept it forever. The npm branch compares versions in order and was right. - Upgrade, Update and add never touched plugin-updates.json; only the next CheckUpdates/CheckNow rewrote it. - The page kept /api/plugins/git's old head (3b411a5) in its heads map, and merge() put it over the plugins' own fresher head after the update, so the row's New commits and Update all stayed even with the file right. Changes: - waitsNoMore (shared by PendingUpdates and the new settleWaiting): a git entry also waits no more once the commit installed is not the one the look saw installed (Version). - settleWaiting rewrites plugin-updates.json without what waits no more, after add (every install, npm Upgrade, Update's pinned path), a git Upgrade, Update (Update all) and InstallMissing. Checked time is kept. - reinstall's #2954 "left it at X" error now needs the commit to have stayed: a moved install that can't ask the repository again (rate limit, offline) isn't reported as stuck on the look's older head. - plugins.js: an action on a plugin (Update all: on every one) drops the page's cached head for it, so the plugins' own head is drawn; a git Update whose commit moved says "{name} updated to {commit}" (zh, zh-TW, ja, de), and the Up to date chip's tooltip prefers the row's head over the check's. Siblings: npm (version order already right; now also rewritten on file), a commit pin (dropped once at the pin: test case), Update all (same flow as Upgrade: test case), the toast (above). CheckNow/CheckUpdates rewrite the file as before. Tests (reporter's literal fdaa691 / 3b411a5 / ba898e7): - TestGitWaitingGoneOnceUpdatedPastTheLook: installed ba898e7, 3b411a5, another commit, still fdaa691 (waits), and a pinned spec. - TestSettleWaitingRewritesTheRecord: git + npm entries gone from the file. - TestGitUpdatePastTheLookWaitsNoMore: fake bun + fake GitHub; look, push, then Upgrade / Update / Upgrade with GitHub down after; nothing waits on file or in PendingUpdates, and the update isn't an error. - plugin-git.test.cjs: the repository moves on after Check for updates; Update installs ba898e7, no New commits, no Update all, toast names it. Run at the pushed head (rebased on |
||
|
|
276c806db2 |
plugins: a plugin's own requests are counted; a provider plugin's options get the editor (plugins#592)
zelong77 asked for two things once Devin 0.1.30's cache keep-alive
worked: its pings were invisible in magpie, and the interval and ping
count could only be edited in plugins.json. The owner decided pings are
shown as counted usage and the two numbers are edited in the GUI.
- host.js gives plugins input.magpie.usage(provider, call) and
input.magpie.account(provider). usage validates the call (kind
[a-z0-9_-]{1,40}, a model id, whole-number tokens from 0, status at
most 999, error clipped to 500) and sends an unasked "usage" event;
host.go hands it to plugin.OnUsage in the background.
- internal/usage/plugin_calls.go writes each one as a row of agent
magpie on the plugin's provider (provider.PluginID) and account
(provider.PluginAccountUser), with its kind. It is counted, priced
and in every total, not a probe. Kind cache_keepalive is in the
purpose catalog as "Cache keep-alive" (five languages), so the
request log names and filters it. The ping itself still goes straight
to Devin, never through the gateway, which would break the cache.
- /api/plugins reads every plugin's package options example, not only a
middleware's or request hook's, and the Installed row offers the same
Options JSON editor for a provider or agent plugin that suggests or
has options (not while it is off). Clear's confirm no longer calls
them a middleware's options.
- The Devin mover's min is 0.1.31, which reports each ping and gives
its two settings' defaults (285 s, 6) to the editor. npm has 0.1.31
(published 10:03Z); the plugins publish run is red only for
think-tags' known E404 (plugins#180).
- docs: provider-plugins.md (the API, the options editor),
gateway-sessions.md (the counted row beside probes).
Run at this tree (rebased on origin/main
|
||
|
|
a6217e83d3 |
plugins: a plugin npm said nothing of offers Install, not Coming soon (zhudabao8433 on Discord)
zhudabao8433 on Discord (#general, 11-01): PowerContext (@magpie-community/gateway-powercontext) could be installed yesterday and today reads 即将上线 again. Cause: PowerContext was never pulled. It is in registry.json since plugins 1e4c8a2 (10-29) and on the dist branch (0.2.0, every dist commit since), and not on npm (E404), so magpie learns its version from the dist branch's ~1.7MB index.json. Coming soon is drawn whenever a listing has an npm answer with no version, and three paths gave one without anything confirming the package is missing: - builds before v0.1.2413 kept a dist read cut off at npmEach (6s) as "not on npm" in plugin-npm.json (ferock, |
||
|
|
f85a221c96 |
plugins: a plugin installed twice says "another copy" once, not its own name per provider (plugins#565)
ferock (plugins#565) installed the CodeArts / OfficeAce plugin from two
specs. Each copy serves codearts and officeace, so each card got one
clash line per provider, built from the other copy's shownName, which
is the card's own name. In zh it read "CodeArts / OfficeAce 也登录 CodeArts;
由这个插件提供" and then again for OfficeAce.
clashLine is now given groups (clashGroups): a row's clashes grouped by
side (served here or by the other plugin) and by which specs they clash
with, with the provider names joined. When every other spec's name is
this row's own name, the line says another copy of this plugin ({spec})
does it. Otherwise several names use new plural keys, and one name uses
the old key. All four new keys are in zh, zh-TW, ja and de. The
existing zh and zh-TW singular line now reads "{other} 也能登录 {name},
现由这个插件提供" in place of the clipped "也登录 …;由这个插件提供".
Run on mote, at this tree rebased on origin/main
|
||
|
|
d8cf4f74f9 |
plugins: a plugin's package.json names its row with magpie.name (#4558, MYCF711)
A plugin installed from git whose package.json says
"magpie": { "name": "华为云 HUAWEI" } read as its dependency key
(magpie-officeace) on Settings → Plugins. Bun takes no non-ASCII key, so
a package outside the community's list had no way to show a readable
name. magpie.name was never read at all: #3608's route (MYCF711's branch
1cc33700) didn't reach main, so no release has it, git or npm.
plugin.InstalledName reads magpie.name from the installed package's own
package.json, beside magpie.icon (installedOwn, one parse for both): one
line of at most 80 bytes, no control or format characters (a bidi
override would show it as another name), else nothing. /api/plugins gives
each row it as ownName, and plugins.js's shownName takes it after the
community list's name and before the git package or the spec, so a
listed package is still named by the list. The row's page, the "is up to
date" status and every message that names the row (options, prefer, Update
all) go through shownName; a page plugin's sidebar tab takes it when the
page names no title (windowParts). It is never used to resolve a name and
never shown with the community badge. Not changed: the CLI's plugin list
(the dependency key, as the reporter expects), Discover's cards for
uninstalled GitHub/npm packages, and magpie.summary. Documented in
docs/reference.md and site/public/docs (en, zh, ja).
Run:
- mote: go test -timeout 45m ./internal/plugin/ ./internal/gui/ — plugin
ok; gui red only in TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
the AppKit window tests killed at their deadline (TestPanelCloseHidesIt,
TestPluginPageLoadsItsFilesInTheWindow, TestMainWindowCorners, …;
#4125, #2645). The first three run the same red on origin/main
|
||
|
|
e647a1fd54 |
plugins: an npm registry of the user's own is used for installs and lookups (timwangdev on X)
timwangdev asked on X for plugins to take a custom npm registry. Zero-config
first: Registry() (internal/plugin/registry.go) takes, in order, the one set
in magpie (settings npmRegistry: `magpie plugin registry <url>|default`, or
Plugins › Discover's new npm registry row), BUN_CONFIG_REGISTRY /
NPM_CONFIG_REGISTRY / npm_config_registry in magpie's environment, then the
login shell's (cached probe only, proc.LoginEnvKnown, never waits on a
shell), install.registry in the plugins folder's or the user's .bunfig.toml,
registry= in the plugins folder's or ~/.npmrc, then the 国内镜像 switch's
npmmirror, then npm's own. The switch no longer puts npmmirror over a
registry the user named: before, bun was handed BUN_CONFIG_REGISTRY=npmmirror
whenever it was on, over the user's .npmrc. bun is told the registry only
where it wouldn't find it itself (magpie's setting, the shell's, the
switch's). magpie's own npm questions (latest version for the market,
Update and the hourly check, README, search) go to the same registry, a
package's @scope:registry= to that scope's, with the .npmrc's
//host/path/:_authToken (${VAR} expanded, longest prefix) sent to that host
alone, dropped on a redirect to another host, never logged or shown.
Download counts stay npm's. Only http(s) with a host, no userinfo, query
or fragment is taken; anything else is refused and not saved, and a bad
value hand-written into settings.json is passed over. /api/plugins says
which registry is in use and where it came from.
The GUI row is in registry.js, imported when Discover draws it, so the
core script budget isn't raised (plugins.js is 292 bytes smaller than
before, one long comment there condensed).
Left out: bunfig [install.scopes] for magpie's own lookups (bun reads them
for installs), .npmrc _auth and username/password, NPM_CONFIG_USERCONFIG
and npm's global npmrc, and internal/agent/cliupdate.go's agent CLI update
lookups, which still ask npm's own.
Run (mote and wsl-run). First at this change on
|
||
|
|
40af660275 |
gui: failed calls told through statusErr, statusTErr and settingsErr (#3685)
origin/main |
||
|
|
dc0ec94d89 |
plugins: a repository's package.json name no longer hides npm's package (#3685)
A search left out npm's card of any package a tagged repository's package.json names, as if npm's package were that repository's. It is only when npm has the package from that repository, and then the repository's card is installed by npm's name (ghListing's spec). Otherwise npm's package of that name, if npm has one, is another plugin, which a search never showed. Now a search leaves out npm's card only of a listing's package, or of a tagged repository's that npm has from that repository, whose card installs by npm's name. npm's package of a name another repository's package.json gives stays, and its Install asks before it takes an installed repository's place (the first commit). Not changed: the GitHub section drops a tagged repository whose package.json names a listing's package (`listed`), the same rule the other way. Showing those would put repositories named like community plugins beside them, and that's the owner's call (#3929). Both sets are built from every listing and tagged repository, not from what the query left, as before. An npm card installs by the bare name, which resolve takes for a community plugin's where one is called by it (#3928). plugins.js grows 153 bytes, the core's scripts to 1,530,343 of 1,530,449: 2,028 bytes for the three commits, in the 2,134 the room makes. What was run (tree a5364df0, on origin/main |
||
|
|
7ea9056ae3 |
plugins: a GitHub card reads Installed only for the repository installed (#3685)
entryOf took a tagged repository's card for an installed git plugin of the package the repository's package.json names, so a second repository naming that package read Installed too. EchoChan314 (#3685) had github:mu-zi-lee/magpie-our-free-model installed, and Gyarados4157's repository of the same package showed a second Installed card, though nothing of it was on disk. Now a repository's card reads Installed only when the plugin installed is that repository, by whichever spec names it: GitHub's shorthand, its page, a git URL over https, ssh with a user, scp's colon or a port, ssh.github.com and git://, owner/repo, in any case and with a ref. ghRepo read only the shorthand, its page and owner/repo before. The other repository's card reads Install, and its Install asks first (the commit before), naming the spec installed. One case turns from Installed to Install: a repository renamed or moved on GitHub, installed by its old name. The page can't tell that from another repository of the same package without asking GitHub, and the latter is #3685, so it asks before a reinstall. And a card found by another spec than its own (its page, a git URL) shows no Sign in, as the page's URL didn't before: actionFor reads the sign-ins by the card's spec (#3930). plugins.js grows 41 bytes, the core's scripts to 1,530,190 of 1,530,449. What was run (tree c3898368, on origin/main |
||
|
|
5e8ddf5003 |
plugins: Install asks before it replaces a plugin of the same package (#3685)
plugins/ holds one package of a name, so plugin.Add installs another
source of an installed plugin's package in its place: the old one is
removed, its options and Off carry over, and the sign-ins saved for the
providers it served stay with those providers (plugin-auth.json keeps
them by provider id) for whichever code serves them next. The Plugins
page did that with no word: a listing's card over a git install of its
package, a tagged repository's card over npm's package of the name its
package.json gives, and the field's Install ("Have one in mind?") over
either. EchoChan314 (#3685) had github:mu-zi-lee/magpie-our-free-model
installed, and worried that a click on the card of Gyarados4157's
repository, of the same package, would switch the source quietly. Once
that card reads Install, as it should, its Install would do just that,
sign-ins included.
Now Install asks first when it would take another source's place, and
names both by their source, a git spec or npm:<name> (resolve's word for
npm's own package). For #3685's two repositories it asks "Replace
github:mu-zi-lee/magpie-our-free-model with
github:Gyarados4157/magpie-our-free-model?" (in the field; the card asks
the same once the next commit has it read Install), and says only one of
them can be installed, that the old one is removed and its options and
sign-ins pass to the new one, and, when the old one is off, that the new
one is installed off too. Cancel installs nothing. The same repository
by another spec, npm's package at another version, and a package nothing
installed has, install at once as before.
The field asks the same for a repository the page has read, npm:<name>
and a scoped name. A bare name, which resolve may take for a community
plugin's, and a repository the page hasn't read are known only once
installed, so they install at once as before; #3927 has them, with
`magpie plugin add` and a backup's or a sync's plugins, which replace
the same way.
Not covered: npm's cards still send the bare name, so where it is also a
name a community plugin goes by, the dialog names npm:<name> while the
community package is what gets installed (#3928).
The strings are in zh, zh-TW, ja and de. plugins.js grows 1,834 bytes,
the core's scripts to 1,530,149 of 1,530,449, in the room the commit
before makes.
What was run (tree 7ca08da4, on origin/main
|
||
|
|
dfc08e8824 |
gui: one NO_SCROLL for 90 focus calls, one statusErr for 68 failed calls (#3685)
Room for #3685, which did not fit the core script budget. The budget is not raised; two repeated forms move into one name each. - NO_SCROLL: `{ preventScroll: true }` was written out at 90 focus calls (89 in app.js, 1 in plugins.js). It is one const at the top of app.js now. - statusErr(e): `status(e.message, "err")` was written out for 68 failed calls (app.js 61, plugins.js 3, context.js 4), 15 of them as a `e => status(e.message, "err")` callback that now passes statusErr. renderSync is left alone: `status` is a local string there (#4066). Saves 2,016 bytes: core 1,536,751 of 1,537,034 and app.js 1,312,975 of 1,315,316 with #3685 on top. quota-refresh-order.test.cjs evals parts of app.js in a vm and gets both names as stubs. The idea is Coffemon's (JoeyWu-tech) e7af88774, which no longer applied to main; it was redone on the current tree. Landed by yetone in a batch of Coffemon's patches from the issues. What was run, go1.26.8, on origin/main |
||
|
|
ef7f55fe98 |
plugin: Discover lists a repository of gateway hooks alone, as a request hook (#3821)
MengXiangxi (#3821): a GitHub repository tagged magpie-plugin whose package.json has magpie.hooks and no main, exports or index.js, a gateway request hook alone that installs and runs, never showed in the Plugins page's "Unofficial, on GitHub". readTagged read the magpie block's middleware, agent and page but not hooks, so such a package was taken for a provider: the file #1327's check looks for in the repository was its entry as Bun resolves it, index.js, which it hasn't, and the 404 left it out without a word. An inert index.js, as the reporter tried, lists it, as a provider. readTagged reads magpie.hooks. A package with hooks, no main or exports, and none of middleware, agent or page is of kind "hooks", and the file #1327's check looks for is its hooks file, so one whose hooks file isn't committed (a dist built only to publish) is still left out, as a middleware's is. The Plugins page picks "hooks" out with middleware, as both run in the gateway (kindOf), and its chip says Request hook, as an installed one's row does, through the word kindChip takes since the previous commit. docs/subsystems/gateway-request-hooks.md says so. Not changed: a raw 404 that GitHub's cache answers just after a push is still kept for that push in this process (the reporter's second point, #4067). plugins.js grows 51 bytes for it. With the previous commit the core's scripts are 24 bytes under main's, 1,527,948 of 1,528,076. What was run (tree 79884772, on origin/main |
||
|
|
7a1bfaf2f0 |
plugins: kindChip says the word it is given, so a request hook's chip is one call (#3821)
The Installed tab's row of a gateway request hook made its chip as middleware's and then wrote "Request hook" over the chip's word, in five lines. kindChip now takes a word to say in place of its kind's, and the row asks for its chip in one line. Behaviour is unchanged: the same chip, class, glyph and tooltip, its word translated as before. This makes room under TestCoreScriptBudget for the next commit without raising the budget: the core's scripts go from 1,527,972 to 1,527,897 of 1,528,076. plugin-gateway.test.cjs, which opens such a row, now checks its chip says Request hook in each of its five languages; nothing checked it. What was run (tree 0b0ba0c9, on origin/main |
||
|
|
1027db4081 |
plugins: a README read once shows at once when its page opens again
The owner (10-30): closing a plugin's page and opening it again played
the loading bird over a README already read, and memory for them must
stay bounded, and a README changed since must not stay old.
detail() keeps each page read in a Map, the last 20 opened only: a new
read goes to the end and the oldest is dropped past 20. Opening a page
that is there draws its README and date at once, with no loader and no
bird, and reads the page again behind it; a README that changed takes
the old one's place, and a failed read keeps the one shown. A page never
read still loads under the bird, waiting for its three landings.
The core's scripts grow 677 bytes; coreScriptBudget is raised to the
exact size, 1,537,034, with no room added.
Run (mote, at
|
||
|
|
56bc3d515a |
plugins: a plugin's README waits for its bird to land on three lines
The owner (10-30): opening a plugin's page, the README came so fast that the bird dropped in and flew straight off, the same flash the skeleton bird had ( |
||
|
|
f463a8aaf7 |
gui: Settings has Loading bird, which keeps magpie's bird off skeletons and stops looking for them
Yayoi_no_yume on X, agreed by GymlinZhu: they run magpie on a 1-core,
1GB server and asked for a way to turn the loading bird off. The owner
wanted the bird, so it stays on by default. Settings -> General now has
"Loading bird" (Off / On), below Reduce motion.
- settings.json keeps noBird (omitted when the bird is on), and boot.js
passes it. A POST that leaves it out keeps it, as with the other prefs.
theme.js sets data-bird="off" on <html> before the first paint, and
applyPrefs changes it.
- skelBird (app.js): with the bird off, nothing looks for skeletons at
all. No 250ms interval and no observer run. Turning it off mid-hop ends
the hops, and the bird flies off.
- With the bird on, the look is driven by events. Before, the 250ms
setInterval ran forever, scanning the DOM for .skeleton whether or not
one existed. Now a MutationObserver watches for an added node that is or
holds a skeleton, the 250ms look runs only while one is in the page,
and the look stops itself once none are left.
- The README's bird (plugins.js bounceLoader): with the bird off, the four
lines stand straight with no bird, and the box goes when the README
comes.
- Strings are in en, zh, zh-TW, ja and de. App.js is 1,294,016 bytes, under
its budget, which is not raised.
Tests:
- skeleton-bird.test.cjs adds three tests:
- with no skeleton left, the look stops, and a skeleton added later
starts it again;
- with the setting saved off, no bird, no dip and no look ever starts
(setInterval is wrapped to count the look);
- the Settings row shows On by default; Off posts noBird:true, stops a
running look, and a skeleton added after that starts none; On posts
false and the look starts again.
- plugin-readme-bird.test.cjs: with the setting off, the lines stay
straight, no .sk-bird is drawn, and the box goes at once.
- settings-general: #birdSegs is in the list of bare rows.
- TestSettingsNoBird: off by default, kept by a POST that leaves it out,
cleared by false, in settings.json and boot.js.
Run at this head (rebased on
|
||
|
|
e8e9245ecf |
agents: Install another agent says Plugins has more agents, and opens them
The owner, on the Agents page: 因为我们支持Agent插件了,这里是不是也应该 显示插件中有更多? Install another agent listed only the agents magpie has an install command for; the agents a plugin adds were nowhere on that page. - GET /api/plugins/agents names the suggested agent plugins (the market's kind "agent") not installed here. One installed but turned off, or pinned to a version, counts as installed: Plugins turns it on. - Install another agent counts them in its header and ends with one row, "More in Plugins" with their names, as the Providers add sheet does for subscriptions. The row opens Plugins › Discover scrolled to its Agents, only while the click is fresh (scrollOnPurpose), on the section drawn last, since npm's answers draw it again. - The list is fetched beside the install commands, not before them, so a slow market never holds the commands back. With no install command left, the section shows the plugins' row alone and no install note. - Budgets: app.js 1,311,681 and the core 1,530,449 (+1,430 / +2,408 over main), the Agents page and Plugins page are the core's own, no room added. Run at this tree, rebased on |
||
|
|
766356cd3f |
plugins: a row's "Serves" chip names the providers the plugin registers (#3902)
The chip named only built-ins moved onto a plugin (provider.MovedOnto), so a plugin magpie never shipped as a built-in, like magpie-magicrew-auth signing in to letsmagic.cn and magicrew.ai, said nothing about what it carries. /api/plugins now sends `serves`: the names of the providers the plugin registers (plugin.Cached, which the row's provider names already come from), once each, leaving out the moved ones (a moved built-in's id is the plugin's provider id; the page names it as the built-in). It is sent when the plugin has a moved built-in or registers two or more providers: a lone provider is the row's title already. No package.json field. The "in place of the built-in" tooltip stays on a chip that names a moved built-in only. plugins.js is 27 bytes smaller; no budget touched. Analysis and the proposal by MYCF711 (mycf_711 on Discord) in #3902. Run: - go test ./internal/gui -count=1: ok (107s) - TestPluginServesItsProviders red with servesBeside returning nil (three cases), green restored - plugin-release.test.cjs (chromium + webkit, en + zh): 6/6; with origin/main's plugins.js 0/6 - plugin-*.test.cjs plugins-*.test.cjs i18n-keys.test.cjs: 661/664. The 3 reds are on main too: i18n-keys "a plugin's words are its own" (#3897) and plugin-card-update webkit en under load (#3079; 2 of 5 red on origin/main's plugins.js too, load ~65) - gofmt -l, go vet, GOOS=windows go vet, GOOS=linux go vet -tags nogui on internal/gui: clean Not tried: a real install of magpie-magicrew-auth in the window. |
||
|
|
ed5cc959a7 |
gui: every slow page's skeletons get magpie's bird hopping bar to bar
The owner, after the Plugins page's README bird ( |
||
|
|
689cf41423 |
plugins: a row's picture is asked for as it nears the screen (#909, #1956, #2459)
Each SVG an <img> draws is a document of its own in the webview (its
own Page, style engine and DOM, ~0.6 MB), kept while the window is
open. Opening Plugins drew 122 pictures at once, 57 of them SVGs, so
the renderer took 58 documents more, most for rows far below the fold.
icon() takes a lazy flag that sets loading="lazy" on the <img> it makes
for a stored picture or a -color/PNG icon; Plugins' rows and cards pass
it, the plugin's own page header (big) does not. Menus and other pages
keep loading at once, so nothing that opens on screen waits a frame.
Measured in Chromium against a dev backend with a copy of the real
library and its stored icons, every page visited then on Settings
(memory-infra dump of the renderer, then ps RSS):
- documents: 81 -> 37
- malloc 90.3 -> 81.7 MB, blink_gc 41.7 -> 39.7, partition_alloc
25.4 -> 20.5, image cache 5.3 -> 1.3
- renderer RSS 256-289 -> 243 MiB
Scrolled to the bottom of Discover, all 122 pictures load in Chromium
and WebKit (screenshot checked); before scrolling, 52 and 18.
Run at this head:
- go test ./internal/gui -count=1 -timeout 45m: ok 125s
- GUI: tests/plugin*.test.cjs, models-add-and-icons, mono-icon-redraw,
routing-log-icons, tray-logos, i18n-keys: 691 of 693 pass; the one
red is webkit en of plugin-card-update, waiting 5s for the Update
button under load 10 (#3079, filed on main
|
||
|
|
385ce789e4 |
gui: a page plugin's sidebar tab comes and goes as it is installed or switched
The owner: after installing a page plugin, its tab took a long while to show
in the sidebar. The Plugins page's actions (Install, Switch on/off, Remove,
the market card's Switch on, Move) re-read the plugin list and providers in
refresh(), but only the Plugins page's own load told the sidebar to read
/api/plugin-pages again, so the tab came when that page was next opened or
the language changed. The backend was never slow: POST /api/plugins/{op} and
GET /api/plugin-pages both answer synchronously.
refresh() now calls loadPluginPages first, without waiting on the providers'
answer, which can be slow.
Core script budget raised by 174 bytes to 1,542,418, measured at origin/main
|
||
|
|
722483c089 |
plugins: a plugin's README loads under magpie's bird bouncing down its lines
The owner found the plugin page's pulsing skeleton bars boring and picked concept F (Trampoline) from the design round. While the README loads, the skeleton's four lines are strings. magpie's bird drops onto the first, bounces down them, and each string bends under its feet and wobbles after it as a damped spring. A string it has landed on turns faintly to the accent colour. From the last string it is thrown off the top and drops in again. When the README comes, the strings fade and the bird flies off up-right while the dialog grows to the README on its spring, as before. With reduced motion the strings are drawn straight and the bird sits on the first one. How it fits the dialog: - The leaving box goes into #modal, beside the dialog, not inside it. Anywhere in the dialog (a scroller), an absolutely positioned box made WebKit lay the fields out 8px short until it was removed, so the dialog's last frame jumped 8px and modal-centred-late's "centred in every frame" went red at 820px in WebKit. Tried in the README and in the dialog first; both were red. - Its marks are data-* attributes, not classes, so holdModal's MutationObserver (class/hidden/open) doesn't run on every hop. It is removed 200ms after the 570ms height spring would end. - The README fades in alone (n, not the readme box), so the bird isn't faded with it. - Only the README skeleton changes; the small .skeleton bars elsewhere are as they were. Core budget: 1,537,016 -> 1,542,244, the bytes plugins.js grew, with no room added. Run at |
||
|
|
54b198c5c1 |
gui: a plugin's page grows to its README on a spring, not in one jump
A plugin's page (Plugins › Discover) opens with a skeleton for its README, and when the README came in the dialog took its new height in one frame. Now detail()'s fill() measures the dialog, puts the README in, re-centres it (holdModal), and animates height and top together from the old box to the new on SPRING, the curve the dialog opened on (570ms, 1.5% over), clipped while it grows; the README fades in over it. Height and top move on one curve, so the dialog keeps the middle in every frame. The same for the error note when npm or GitHub doesn't answer. Reduced motion: no animation, as before. Budget: the core 1,530,050 -> 1,530,631, the 581 bytes of fill(), the Plugins page's own, no room added. Run at this head (rebased on |
||
|
|
894ec96036 |
plugins: "More in Plugins" opens Discover, not the tab visited last (outloudvi on Discord)
On Providers, 「插件里还有更多」 / "More in Plugins" opened whichever
Plugins tab was visited last (Built-in, Installed). pluginQuery("")
returned early when the query was already empty, before it set the
tab to Discover. The early return is gone, so an empty query also
switches to Discover; a non-empty one already did.
plugins-more-discover.test.cjs visits Built-in, then Installed, in en
and zh, goes back to Providers and clicks the add sheet's More in
Plugins tile, expecting Discover with its cards and no Built-in list;
then the "look for a plugin" link with a search, expecting Discover
with that search.
Run:
- plugins-more-discover.test.cjs, chromium and webkit: 3 of 3 green.
- 61 GUI files the change can reach (plugin-*, plugins-*, builtins,
deprecat*, add-sheet*, provider-search*, i18n-keys, nav-sub-unroll,
mobile-web, market-have, sidebar-tab-top), both engines: 412 pass,
1 fail each: builtins.test.cjs's sidebar list lacks the masking
tab, red the same with the old plugins.js (#3498).
- go test ./internal/gui/ -count=1 (budgets included): ok but
TestMainWindowCorners/macOS_15_SDK killed at load ~200 (#1936,
#2645); alone it passes.
- At the rebased head (
|
||
|
|
63c0c354af |
gui: Discover is quieter: one unofficial mark, one button style, a reason in your language
Kiko03O1 on X asked for a better-looking Plugins › Discover page
("ui 设计能不能好看点"). Five things on it said one thing twice or said
it raw:
- A GitHub card had an "Unofficial" chip. A GitHub card is only ever
drawn in the 非官方插件 · GitHub section, so the chip repeated the
section's head on every card. It is gone from the card; the plugin's
page keeps its full warning.
- Sign in on a card and on an Installed row is tinted like Install,
not filled. It stays filled only in the plugin's sheet, so each level
of action has one look.
- The GitHub line said Go's English in the middle of a zh page ("no
answer in 8s"). internal/plugin's GitHub read now wraps its timeout in
ErrNoAnswer; /api/plugins/github passes `why`: "slow" for that or any
timeout, "limited" for GitHub's rate limit (ghtoken.Limited), and the page says "GitHub 响应超时" (zh, zh-TW, ja, de); the raw
error is the line's hover. The line is smaller and muted, and Retry
takes the accent colour.
- The second filter row's All had a count. It always equalled
Installed + Not installed and the first row's picked count, so
"全部 · N" showed twice side by side. It has no count now.
- Found on the way, same page: the filter box's placeholder was cut off
in en at 1280/1100/980 and in de at every width but 420. It fits at
every width now; the filter bar wraps where it did.
Looked at and left alone: the 8px inset on the borderless Signed in,
and the monospace version numbers.
plugins.js nets -25 bytes (the Unofficial chip's code went), so the
core script budget is unchanged: TestCoreScriptBudget passes at the
pushed head with no raise.
What was run, at this change on origin/main
|
||
|
|
fb101b0d57 |
plugins: a GitHub list that couldn't be read says why with Try again, instead of the section vanishing (till on Discord)
till (Windows, v0.1.1293, Belarus network) saw no "Unofficial plugins ·
GitHub" section in Plugins › Discover; a magpie in Japan shows it. On
v0.1.1293 the section shows its loading skeleton and then disappears
whenever GitHub can't be read: plugin.TaggedRepos returned the last list
(or nothing) with no error when the topic search failed, and an empty
list with no error when the search answered but every package.json read
from raw.githubusercontent.com failed or timed out. /api/plugins/github
answered 200 {repos:[]}, and the page showed ghFailed only on an HTTP
error, never in a search, and never once a list had been had.
Now:
- TaggedRepos returns the error with what it has. A failed search keeps
the last list and says why (held a minute, like before); repositories
the search found but that couldn't be read come back as a
*TaggedMissing with their count and the last read error.
- /api/plugins/github sends error and missing beside repos; ?again asks
GitHub again at once when the last answer had an error.
- The page shows the reason and Try again: in place of the section when
nothing could be read (in Discover and in a search), and as a line over
the cards when some were read or an older list is kept. Try again keeps
the cards while it asks. zh, zh-TW, ja and de strings added.
No Windows-only cause was found in the code: the fetch goes through the
same netproxy on every OS (a PAC-only system proxy isn't read anywhere).
The likely cause is the network reaching api.github.com or
raw.githubusercontent.com, or the unauthenticated search limit; the page
now names which.
Run (worktree on
|
||
|
|
33dbdcc529 |
plugins: Sign in on Installed takes the reader down to the plugin's sign-in
Sign in on Plugins › Installed (or a plugin card) opens the Providers add
sheet with the plugin's sign-in drawn at the sheet's foot, under every
tile. With many plugins the sheet is taller than the window and the reader
was left at its top, the sign-in out of sight: the click seemed to do
nothing (the owner, on magpie-intelligence-check).
The click now passes its event, so pluginSignIn scrolls the sign-in into
the middle of the view on purpose. In WebKit that alone didn't hold: the
list show() loads redraws the sheet after the scroll, WebKit pulls the view
to 0 while it is drawn, and inside the purpose window that 0 was taken as
the reader's, then backToReader returned there. arrived(v) ends the
purpose window once the scroll is done and keeps where it left the view as
where the reader is, so the redraw is put back to the sign-in.
Run:
- plugin-signin-scrolls.test.cjs (new; 24 signed-in plugins and one
signed out, 900x560, Chromium and WebKit, en and zh): 6/6 pass. On
origin/main 0/6 ("the page went down to the sign-in"); with the scroll
but without arrived(), Chromium passes and WebKit fails 2/2.
- GUI: plugin*, *scroll*, *signin*, builtins: 1033 pass, 0 fail.
- go test -tags nogui ./internal/gui: ok (script budget, guard tests).
No Go changes.
|
||
|
|
d783df46cb |
plugin: a plugin's page adds items to a provider's and an agent's row menu (P6)
package.json's magpie.actions: [{id, menu, title, titles}] puts items in
the row menus magpie draws, after its own: a provider row's (right-click)
and an agent row's (its handle, or right-click). Picking one opens the
plugin's page and posts it {event: "action", data: {id, provider|agent:
{id, name}}}, nothing else of the row; the bridge's magpie.onAction(fn)
gets it, and an action picked before fn was given waits for it.
- plugin.Window reads them (page.go): menu one of ActionMenus (provider,
agent; a session's menu is left out, its title is user content), id
^[a-z0-9][a-z0-9-]{0,39}$, an id given twice is the first's, 8 at most,
none for a plugin with no page.
- /api/plugin-pages carries them on the page; a missing title is the
page's, in each language (pluginpage.go).
- pluginpages.js: magpie.actions(menu, context) gives the row menu's
items; openRowMenu draws a plugin's name as written (literal), not
through t().
- The Plugins page says which menus a plugin adds to (actionsLine),
translated in zh, zh-TW, ja and de.
- Docs: plugin-runtime.md's P6 section and verification; the site's
plugin docs (en, zh, ja) gain "Items in magpie's menus".
- The core's budget (TestCoreScriptBudget) is not raised (#2710): with
P6 the core came to 1,447,648 bytes, 648 over. pluginpages.js's header
now says P5's and P6's part in one paragraph and points to
plugin-runtime.md, which says it in full, and plugins.js's panels and
actions lines share whereLine: 1,446,845, 155 under.
Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
built-ins-on commit since dropped for main's own
|
||
|
|
8e44c2f351 |
gui: the dot on Plugins says what it is, and leads to the plugins with an update
The owner, on the sidebar's dot beside Plugins: no one can tell what it means, and once they click it, they should see which plugins need updating. It meant "a plugin update is waiting", said only in a hover title, and Plugins opened on whatever tab was last open. - Sidebar: under Plugins, Installed reads "1 update" / "N updates" in the dot's colour in place of its count, with a title saying where to update. - Opening Plugins while an update waits lands on Installed. - Installed names the plugins with a newer version in a bar above the list, with Update all beside them (moved there from the footer). Each row still shows its own "vX out" and Update. - Strings in zh, zh-TW, ja and de; the docs (en, zh, ja) say the same. Run: - plugin-updates.test.cjs: chromium and webkit, en zh zh-TW ja de, at 1024 (sidebar) and 600 (tab bar), 22 ok. Also ok in both engines: plugin-git, plugin-update-button, plugin-check-updates, plugin-card-update, plugin-prerelease, nav-sub-unroll, sidebar, builtins, i18n-keys. go test ./internal/gui/ -run 'TestCoreScriptBudget' ok. - Broken by hand, each red: no sidebar label (the 1024 cases), no jump to Installed, no bar (every case). - Looked at in WebKit screenshots, zh at 1024 and de at 600. Full run, with the rest of its series: this series (P5, the Plugins dot, the probe test, P6, and a built-ins-on commit since dropped for main's own |
||
|
|
b9f790d37b |
plugins: panels in magpie's pages, a page that replaces a built-in one, titles in the window's language, and a look that matches
P5 of the plugin runtime (docs/subsystems/plugin-runtime.md):
- Panels (magpie.panels): a plugin draws a frame into a slot of a
built-in page (a provider's editor, Settings, Usage); magpie.context
says where it is, and the frame is as tall as what it draws.
- A page can replace a built-in one (magpie.page.replaces); show() opens
it in that page's place, and the sidebar row goes to it.
- page.titles and a panel's titles name it in the window's language
({"zh": …}); a malformed map is dropped, the title kept
(TestWindowTitles).
- main's #2501 already names wails:// in the policy of a page in the
desktop window (through ownWindow), which is why the usage page drew as
bare HTML from v0.1.1259. TestPluginPageLoadsItsFilesInTheWindow loads
a page through ownWindow in a real WKWebView, which Playwright on http
can't; the subsystem page says how.
- The bridge adds magpie's look for what a page leaves unstyled, every
rule in :where() so any rule of the page's wins, and the theme's
colours as --magpie-* variables.
One commit: the panels, the replacing pages and the titles share hunks
in page.go, pluginpage.go, pluginpages.js and the docs, and couldn't be
split cleanly.
Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
built-ins-on commit since dropped for main's own
|
||
|
|
17557132cb |
gui: in a narrow window the title bar's tools show their icons, then the title gives way; nothing lies over it (#2625, linusxiong)
Beside the sidebar, Library's, Plugins' and Settings' heads sit in the
title bar after the breadcrumb, between --tools-l (the crumb's right +
16) and the window's buttons, laid out flex-end. When the tools needed
more than that room they ran on to the left, over the crumb: at about
650pt with the sidebar, Library -> MCP servers had 「发现」 over
「MCP 服务器」's last character. The crumb never gave way to them.
app.js tools() now shares the room out, laying out and reading each
step in its one frame, the next only if the tools still run over:
1. the crumb whole (its natural width from its parts, the last one's
scrollWidth) and the tools with their words;
2. body.tools-tight: Library's Discover / Library folder / Backups and
Plugins' "Mirrors in China" show their icon (or switch) alone. Each
keeps its name as aria-label (a hidden span leaves the accessible
name) and its tooltip as before (the folder's path, the backups'
note and path, Discover's and the mirrors' sentences);
3. --crumb-max: the crumb drops its leading parts ("Work /"), a part
and its slash at a time, and last cuts the page's name at its end.
In the side-nav head the Library buttons and the mirror switch are
flex: none and Plugins' search keeps 120px, so what doesn't fit shows
as running over rather than shrinking out of sight. The views'
MutationObserver also asks tools() again, as a tab's own tools change
(Discover only on MCP servers and Skills) without the crumb resizing.
title-bar-tools.test.cjs (new): every Library tab, Plugins' three and
Settings, sidebar picked, window mode, at 560 (the window's least),
650, 760, 900, 1024 and 1280px, in zh, zh-TW, ja, de and en, Chromium
and WebKit. No tool lies over the shown title or another tool or out
of the bar, no label is cut, an icon-only tool has aria-label and
title, only leading crumb parts go and the page's name shows, whole
from 650px. Against the old assets (MAGPIE_GUI_ASSETS) it fails in all
five languages at 560px Library Instructions ("a tool lies over the
title"); with the change Chromium 5/5 and WebKit 5/5. Looked at
screenshots of zh Library MCP servers and Plugins Discover at 560, 650
and 760px.
docs/subsystems/gui-shell.md says how the title bar gives way.
Run with both #2623's and #2625's changes, on
|
||
|
|
7d7dba31ae |
provider: removing or turning off a moved subscription's plugin moves nothing back
The built-ins are being retired (the owner, 10-16: 陆续把内置Provider下线掉),
so the last way back to one is gone. MoveBack, moveBack and releasePlugin
are removed, with the Left flag they set.
- SetPluginOff only turns the plugin off. A moved subscription stays
moved, off with it.
- RemovePlugin records the moved ids as the new state "removed". The
record keeps its accounts, which plugin.Remove leaves in the plugin's
auth store. Nothing moves or installs it by itself: MoveRetiring
skips it and keepMovedCurrent reads only "plugin".
- HandOver turns a removed record whose plugin is installed and current
back into "plugin", record and all. So does Adopt (the editor's Move).
- MoveRetiring moves an old "back" record again, whatever Left said.
- Plugins page, rm/off confirms: "{names} stops working until the plugin
is installed again. Its accounts are kept." / "... while the plugin
is off." The status after removing no longer says it is back on the
built-in.
- Strings: five old strings dropped ("Moving back…" among them), three
new ones in zh, zh-TW, ja and de.
- `magpie plugins rm`/`off` say the same in their output.
- Docs: provider-plugins.md (the states table, the Move-back paragraph)
and AGENTS.md.
Tests:
- TestNoWayBack is new. It covers a "back" record moved again, the
plugin turned off (still moved, accounts kept), removed (removed, not
reinstalled by keepMovedCurrent or MoveRetiring), installed again
(HandOver), and removed again then Adopt.
- TestReleasePlugin and TestMoveBackKeepsLapse asserted the way back
and are deleted.
- TestMove, TestHandOver, TestMoveTidiesItsPlugin and
TestAdoptBeforeSigningIn no longer call MoveBack. TestKeepMovedCurrent
uses the removed state.
- plugin-release.test.cjs checks the new asks and that the status names
no built-in.
Run:
- Broken by hand:
- With HEAD's migrate.go, TestNoWayBack is red at "turning the plugin
off moved it back".
- With HandOver's removed branch disabled, it is red at "installed
again: map[], moved false".
- go test -tags nogui ./internal/provider -run
'TestMove|TestNoWayBack|TestHandOver|TestKeepMovedCurrent|TestAdopt|TestInstallPlugin|TestWorkBuddyCheckin|Plugin|Migrat':
ok.
- GUI (NODE_PATH playwright, --test-concurrency=1): plugin-release,
plugin-move and i18n-keys, chromium and webkit: 17/17.
- gofmt -l clean; GOOS=linux and windows go vet of provider, gui and cli.
- Full suite: go test -tags nogui ./... -count=1 -timeout 90m at this commit rebased on
|
||
|
|
1d6f461a99 |
plugins: the Unofficial, on GitHub section shows while GitHub hasn't answered, looking, with cards still to come
On a slow line the section wasn't drawn until /api/plugins/github
answered, so Discover read as having no unofficial plugins (yetone:
当还没加载完的时候,压根就不显示,会让那些网慢的用户以为没有非官方插件).
While it waits, the section stands in its place before the field: its
head and hint, a quiet "Looking on GitHub" with three breathing dots
(role=status, aria-busy on the section), and three card-shaped ghosts
(logo, name, author, button, two lines, two chips) a soft light passes
over, each card a beat after the last. When GitHub answers, its cards
come in where the ghosts were with a short staggered fade-up. A search
while it waits shows the same. When the ask fails (and nothing was
loaded before) the section says "Couldn't ask GitHub: <error>" with Try
again, instead of disappearing. prefers-reduced-motion stops all of it.
Strings in zh, zh-TW, ja and de.
Run:
- new internal/gui/tests/plugin-github-wait.test.cjs: 18/18 on this tree
(Chromium and WebKit; en, zh, ja, de; 980 and 440 wide; held, search
while held, let go, 502 then Try again, no scroll on the click).
With MAGPIE_WAIT_ASSETS at origin/main's assets: 9/9 red (Chromium).
Screenshots of each state looked at.
- GUI files around it (plugin-*, i18n-*, builtins, nav-sub*,
click-scroll, old-webkit, mobile-web): 602/620 under load. The reds,
rerun one file at a time here and on origin/main
|
||
|
|
9b04c4e20f |
plugin: async gateway request hooks, run in Bun before routing and after the reply (#2118)
A package's magpie.hooks entry (or a *.hooks.{js,mjs,ts,mts} file) exports
`async onRequest(body, ctx)` and an optional `onResponse(reply, ctx)`. They
run in the Bun plugin host, so a hook can await I/O, for example a context
service like PowerContext, which the sync moejs middleware can't. The
gateway still makes one model request per client request. A hook adds
context to the body; it doesn't register tools or run a loop, so magpie
doesn't become an agent runtime.
Ported from Tsukikage7/magpie#1. Changes from the fork:
- The entry name is magpie.hooks / *.hooks.*. The fork's magpie.gateway /
*.gateway.mjs is already the middleware's alias, so a hook importing
node:fs was also loaded as moejs middleware and failed there.
TestGatewayHookNamesApartFromMiddleware fails if the two sets overlap.
- onRequest is rolled back, and counts as failed with no onResponse, when
it throws, times out, returns non-JSON, or changes tools, tool_choice,
function_call, functions, toolConfig, model or stream.
- onResponse gets the client-facing reply, merged through the gateway's own
stream decoder, collector and renderer (no second merger).
- Codex's native passthrough (/backend-api/codex) runs the hooks too,
without the sync middleware.
- The run ends with the request handler, not the client connection. Codex
hangs up on response.completed, and the reply it got is still captured
as a success. TestGatewayHookSeesReplyAfterClientHangsUp is red on the
old `r.Context().Err()` check and green with -count=3.
- ctx.origin is host-derived (local / gateway-key / remote). Headers, keys
and peer addresses never reach the hook.
- Plugins page: a hook package shows a "Request hook" chip, a diagnostics
line (outcome code, calls, avg ms, bytes, failures; no content), and
Options. Strings are in en, zh, zh-TW, ja and de.
Docs: docs/subsystems/gateway-request-hooks.md (new), provider-plugins.md,
gateway-middleware.md, and site docs plugins.html in en, zh and ja.
Real use, sandbox HOME on 127.0.0.1:3486 with the owner's real Codex Pro
sign-in. The probe hook adds a codename note and logs both callbacks:
- /v1/responses, /v1/messages, Gemini generateContent: stream and
non-stream. onRequest's note reached the model (the answer had the
codename), and onResponse got success=true and the whole reply.
- /v1/chat/completions: with the probe also changing `model`, the change
was rolled back (the reply came from the asked model) and no onResponse
ran. Without that change, earlier: stream and non-stream success.
- The real Codex CLI 0.162.1 `codex exec` through openai_base_url ->
/backend-api/codex: the hook saw origin=local, agent=codex and the
query; the answer had the codename; onResponse success=true (before the
hang-up fix it never ran: the context was already cancelled).
- `magpie plugin list` shows only "async gateway hook onRequest" for the
hook package, no failed middleware.
Tests (base origin/main
|
||
|
|
b6533893a7 |
plugins: Discover lists tools and page plugins, and the intro links to the plugin docs
Every kind of plugin magpie runs now has its place on the Plugins page, so
someone looking to extend magpie finds what exists and how to write one:
- Discover has "Tools for agents" (market kind "tools") and "Pages" (kind
"page") sections beside Subscriptions, Gateway middleware and Agents,
each card with its own chip (a new Tools chip, the Page chip). Before,
both kinds fell under Subscriptions as Providers.
- A GitHub repository tagged magpie-plugin whose package.json has
magpie.page.file is a Page, and that file must be committed, as a
provider's entry must (TaggedRepos).
- An installed plugin that only gives tools wears the Tools chip.
- The intro says what a plugin can be (provider, gateway middleware,
routing strategy, tools, an agent, a page) and its "Write a plugin" link
opens usemagpie.ai/docs/plugins in the window's language (zh and zh-TW
to zh/, ja to ja/), outside the window.
- The docs' Publishing section lists the "tools", "page" and "agent"
registry kinds and the community package names for each, in en, zh, ja.
Run at the reviewed head (on origin/main
|
||
|
|
dfdb6f8a35 |
gui: a plugin that takes a deprecated built-in's place says "Replaces built-in"
molvqingtai on Discord: the Plugins card's "Also built in" chip read as "magpie has this anyway", so why install a plugin. A new user can't add a deprecated built-in at all: the Add sheet leaves one with no account out (unusedSub). And installing the plugin moves the built-in's accounts to it (provider.HandOver: at once with none, from the hourly KeepRetiringMoved with some). The chip now says "Replaces built-in". Its tooltip, and the note on the plugin's page, say that magpie's own sign-in to this subscription is deprecated, that the plugin takes its place, and that accounts signed in there move to it. This is in en, zh, zh-TW, ja and de. Run: - plugin-market.test.cjs: asserts the Zed card's chip text and tooltip in en and zh, in Chromium and WebKit. Red on the old strings. - plugin-move, plugin-movable-review, plugin-move-unserved and deprecation-notice: 37/38 in one concurrent run. The red was plugin-move WebKit en, a scroll measure in the editor, which doesn't draw this chip. It passed 3/3 alone and 8 at once, and is filed as #2431. Full suite: not run for this commit alone; run on the batch before push. |
||
|
|
acb0d4ba0a |
gui: Plugins' "Unofficial, on GitHub" picks out what's installed beside its kinds, and the two narrow it together (#2381)
The owner: 插件发现这里加一个未安装. MiFaZhan's patch (#2381, fork commit 295eb0e9): beside the kinds, a second segmented control, All · Installed · Not installed, each with how many there are. Each strip counts what the other, the section's field and the page's search leave, so picking Middleware turns the installed strip's counts into the middleware's alone; Show all clears it with the kind and the field. Which repositories are installed is asked once each (entryOf, the same call the cards' "have" comes from). "Installed or not" and "Not installed" in zh, zh-TW, ja and de; Installed reuses its key. Changed from the patch, on review: - The strip shows only while the list has both installed and not installed repositories, as one kind alone gets no kinds strip: with nothing from GitHub installed, Not installed was All again and Installed always 0. - A pick the strip can no longer show is dropped, rather than narrowing the grid out of sight: Installed picked, then the page's search left only repositories not installed, hid the strip and kept an empty grid. - The test checks the page's own .pm-card.have against the two the fixture installs (it had compared a package-name rule of its own), and adds: nothing installed has no strip, and the strip going takes its pick with it. Its 420px run is the commit before. Run (at this commit): - plugin-github-filter.test.cjs, en/zh/zh-TW/ja/de at 1100/980/420 plus "nothing installed": chromium 17/17, webkit 17/17. - Broken by hand, each red in both engines: the pick kept when the strip goes (16 red), the strip always shown (17), Show all leaving the pick (16), the kinds' counts ignoring the installed pick (16), the installed strip's counts ignoring the kind (16). - plugin-github.test.cjs 9/9, i18n-keys.test.cjs 3/3, go test -tags nogui -run 'TestCoreScriptBudget|TestBuiltinsTranslated' ./internal/gui ok. No Go file changed; git diff --check clean. Not tried: the real app window; the patch's threshold (no bar at six tagged repositories or fewer) is kept as it was. Full suite: SUITE_LINE Co-authored-by: MiFaZhan <MiFaZhan10@gmail.com> |
||
|
|
3f913b3de6 |
plugins: a JS gateway plugin serves routings (strategies) and watches usage rows (onUsage); plugins/middleware is "JS gateway plugins" (P4)
A plugin's gateway module (magpie.middleware, or its alias magpie.gateway,
or a *.gateway.js file) may now export, besides onRequest/onEvent/onResponse:
- strategies: {name: (pool, seats, options) => order}. Each is a routing
"<short name>/<name>", registered with routes.Register while the plugin is
on and loaded and removed when it goes off or reloads. Seats are
routes.Seat in camelCase JSON. 20ms each; it fails open: a throw, a timeout
or a result that isn't an order of the seats means the listed order. The
failure is counted and logged, rate-limited. A file's name is made into a
routing-safe prefix.
- onUsage(row, options): gets an allow-listed usage row (no bodies, prompts,
error text, sessions or request ids). The rows come from a bounded queue
(1024) with one worker, off the request path; a full queue drops the row
and counts it, and a request never waits. 250ms each.
plugins/middleware is renamed "JS gateway plugins", with a new Sub
(en/zh/zh-TW/ja/de). It registers usage.Observe(middleware.Points()). Off,
no JS hook, strategy or onUsage runs. InUse is unchanged.
providers.json keeps a routing of the form <plugin>/<name> as saved
(provider.PluginRouting) in provider and group Save, whether or not a
plugin serves it now. Before this, `group set g routing=pick/last`
stored nothing.
GUI: the settings state carries jsRoutings. Provider and group routing
pickers offer the served ones, marked data-feature=middleware. A saved
routing that no plugin serves now shows as it is, with a hint. The
Plugins page's line shows routings, how often they were asked, onUsage
rows and dropped rows. The CLI accepts `group set <id> routing=<plugin>/<name>`.
`magpie plugin` lists a module's routings and onUsage; a strategy-only
module had printed nothing after "gateway middleware".
Docs: docs/subsystems/gateway-middleware.md (Routings and usage rows,
limits, verification) and plugin-runtime.md (P4: community plugins at
every point). site/public/docs plugins.html in en, zh and ja has an
example: internal/middleware/testdata/spread.gateway.js, which
TestDocsExample runs.
What was run (worktree on 4df1ba0c6, -p 2):
- gofmt -l: clean. go vet on internal/{middleware,cli,gui,plugin,provider}
and plugins/...: darwin, GOOS=linux -tags nogui, GOOS=windows; all
clean, run after the last Go change.
- go test, after the last Go change: internal/middleware ok,
plugins/middleware ok, internal/provider ok (210s), internal/cli ok
(203s). Earlier in the work: internal/plugin ok (385s), internal/pluginrt
ok, internal/gui (Go) ok (320s), and plugins/... ok. The first
plugins/... run printed a bare FAIL line that `tail` cut off before its
cause showed. The rerun was all ok; the cause is unknown.
- GUI, both engines (routing-*, group-*, builtins, i18n-keys, gui-de/ja/zh-tw,
plugin-middleware): 1220 tests, 1204 pass, 16 fail.
- routing-manual (4): mine. A group's own "manual" was offered a second
time as a routing no plugin serves. Fixed in client.js withJS. The
coordinator is rerunning routing-manual, keys-fold, group-fold,
intent-entry and routing-js alone in both engines, so that rerun is
not recorded here.
- routing-model-rest: red alone too, and red on untouched 4df1ba0c6
(3/20). It is #2115; I commented there with the webkit cases.
- group-member-weight webkit de 420 is #2387.
- group-from-model-add webkit zh: it passes alone 2 of 2. Under load it
waits a fixed 2s for the save post. Filed as #2388.
- routing-keys-fold (webkit zh/ja/de), routing-group-fold (goto timeout)
and routing-intent-entry (browser launch timeout 180s) are load
timeouts. The coordinator is rerunning them alone.
- routing-js.test.cjs (new) passed in chromium en and zh, before the full run.
Broken by hand, each test went red, then restored:
- the permutation check: TestStrategyFailsOpen;
- the queue's non-blocking send: TestOnUsageNeverBlocks ("Ledger waited
2.04s");
- the allow-list: TestUsageRowAllowList;
- unregister on off: TestStrategiesServedWhileOn and
TestStrategiesStopWithServe;
- the CLI pattern: TestParseRoutingStays;
- Observe in plugins/middleware: TestOnServesStrategies;
- PluginRouting in provider.go and in group.go: TestPluginRoutingKept;
- the prefix sanitizing: TestRoutingFromFileName;
- the CLI list line: TestPluginListSaysMiddleware;
- the GUI's data-feature mark and its unserved-saved entry: routing-js.
Real use: a sandbox HOME, the gateway served on 127.0.0.1:3682 by a
-tags nogui build, a fake vendor on 3681, and providers fa (key ka) and
fb (key kb) in group g. pick.gateway.js has strategy last (reverse) and an
onUsage that logs.
- `group set g routing=pick/last` stored it.
- A request to group/g reached the vendor with Bearer kb, and the
"usage-row fb m in=5 keys=17" line was logged.
- `plugin off pick.gateway.js`: Bearer ka (listed order), no onUsage,
routing still pick/last.
- `plugin on`: Bearer kb and onUsage again.
- `plugin builtin off middleware` says "in use and stays on", as InUse
should.
- Not tried: the GUI against that gateway, or a real vendor account.
|
||
|
|
64b0f3a201 |
plugins: a community plugin's own page in magpie's window, shut in a sandboxed frame (P4)
A plugin's package.json may declare magpie.page {title, file, icon} and
magpie.permissions.reads. While the plugin is on, its page gets a tab in a
"Plugins" group after the built-in pages, drawn in an iframe sandboxed to
allow-scripts only (an opaque origin: no cookie, no storage, no parent).
Its files come from /_magpie/plugin/<token>/ (HMAC of the spec with a
per-process secret) under a CSP with connect-src 'none' and
frame-ancestors 'self'; a path that leaves the page's folder, a symlink
out, or an off plugin's token is refused. The window's postMessage bridge
answers only that frame (event.source checked) with theme and language,
the plugin's own options.get/set (throttled), and the reads it declared;
any other read is refused in the window and again by the server, and no
read carries a secret. /api refuses Origin: null and frame/iframe
fetch-dest requests (noFramedAPI), so the frame never reaches the GUI's
API even with the cookie. A page that throws or never says hello shows
the kernel's broken-page state with Try again. The Plugins page shows the
page and what it reads before the plugin is turned on.
Docs: gui-shell.md, plugin-runtime.md (P4 section), site docs en/zh/ja
with an example plugin; i18n zh, zh-TW, ja, de; fixture in
internal/gui/testdata/page-plugin.
Run (worktree at base 4df1ba0c6, -p 2, one package at a time):
- go test -count=1 -timeout 45m: internal/gui ok, internal/plugin ok,
internal/pluginrt ok, plugins/... (budget groups middleware otel redact
rotation search) ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
- Playwright (chromium + webkit, 5 languages, narrow widths): plugin-page 4/4,
plugin-kernel 4/4, builtins 4/4, i18n-keys, gui-de, gui-ja, gui-zh-tw 3/3,
plugin-middleware 24/24, plugin-own-icon 22/22, plugin-options 22/22,
plugin-local 8/8, plugin-agent 22/22, click-scroll 22/22.
Broken by hand, each went red: CSP without connect-src; apiFramed always
false; the server's read check removed; the noFramedAPI wrap removed from
api.go (red through the real Handler); inside() letting every path
through; CORP same-origin re-added; in JS the client read check removed,
the ev.source check removed, and allow-same-origin added to the sandbox.
Without the Array.isArray guard on /api/plugin-pages, plugin-kernel,
builtins and plugin-middleware/own-icon/options went red (their mocks
answer a non-list) - that was found by the run, then fixed.
Real use: built magpie, `magpie web` on 127.0.0.1:3472 (gateway 3471) in a
sandbox HOME with the example plugin added. curl: the page file loads
with the CSP and no cookie, traversal and a bad token are 404, /api with
Origin: null or Sec-Fetch-Dest: iframe is 403 even with the cookie, an
undeclared read 403, a declared one 200. Chromium and WebKit at 1100 and
420: the page draws its declared read, the probe's fetch/absolute
fetch/top access/undeclared read are all refused, an <img> of /api is
refused, no page errors. Real use found that a
Cross-Origin-Resource-Policy: same-origin header blocked the frame's own
files (its origin is opaque); it is gone and a test guards it.
Not tried: the desktop (Wails) window. Market cards of plugins not yet
installed don't show a page's reads. The Playwright suite mirrors the
CSP in a mock route rather than the Go server (the Go tests and real use
cover the server).
|
||
|
|
6ac7032b4b |
plugins: a community plugin's tools reach every agent through magpie's MCP server /mcp/magpie/tools (P4 tool point)
A plugin's OpenCode `tool` hook ({tool: {name: tool({description, args,
execute})}}) used to reach no agent. Now the plugin host collects each
loaded plugin's tools, turns their zod args (v3/v4 shape or object; a
raw JSON Schema is kept) into JSON Schema, and runs one on a `tool`
call: arguments checked against the tool's own zod first (defaults
filled, a wrong one named), execute raced against ToolTimeout (55s,
ctx.abort fires), the answer as text.
The gateway serves them as an MCP server at /mcp/magpie/tools
(tools_mcp.go, guarded by serveMCP as the search one, 4 MiB body):
tools/list names each <plugin short name>_<tool>, at most 64 chars,
a shared name numbered _2; tools/call holds the call to the calling
key's limit through reserveFor and runs it with the calling agent.
The built-in plugin `tools` ("Plugin tools", Essential) serves
gwtool.PluginTools; off, nothing is listed, a call says the plugin is
off and the host isn't asked. InUse counts plugins that are on and
gave tools, from plugin-tools.json, which the host writes after each
load (whole, only on change), so it never starts Bun; the gateway's
KeepFresh watches that note too. Tool answers go to the calling
agent only, so masking doesn't apply (said in the docs).
The Plugins page lists an on plugin's tools by their MCP names, with
descriptions on hover and a button copying the server's address; a
plugin of tools alone has no Provider chip and isn't said to sign in
to nothing. Not done: a Library featured opt-in entry; wiring is the
copied address.
Docs: docs/subsystems/plugin-tools.md (new), plugin-runtime.md's new
"P4: community plugins at every point" section with the tool row, the
README index, usemagpie.ai/docs/plugins#tools in en, zh, ja with an
example. Strings in zh, zh-TW, ja, de. Example plugin:
internal/plugin/testdata/tools.
Run at this commit's tree (base 4df1ba0c6), each package alone, -p 2:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
over internal/plugin, gwtool, gateway, plugins/..., gui, pluginrt: ok
- go test ./internal/plugin -run Tool; ./plugins/...; ./internal/pluginrt;
./internal/gui -run 'Builtin|Plugins'; ./internal/gateway -timeout 45m
-run 'ToolsMCP|ServingGates|OwnMCPRejects|SearchOnAndOff|KeyLimitsOnAndOff':
all ok
- GUI, Chromium and WebKit: every plugin-*.test.cjs, i18n-keys,
builtins: 461/461 pass; plugin-tools.test.cjs (new) covers en, zh,
zh-TW, ja, de at 980 and 420 px
Broken by hand, each red, then restored:
- tools/list ignoring the gwtool gate -> TestToolsMCPOff
- tools/call ignoring the gate -> TestToolsMCPOff
- reserveFor removed -> TestToolsMCPHeldToKeyLimit (tool ran)
- collision suffix dropped -> TestToolsMCPServesPluginTools
- ToolsOn ignoring Off -> TestPluginTools
- host arg check removed -> TestPluginTools
- host timeout race not listening -> TestPluginTools (answered at
5.3s by Go's backstop; the test now bounds it at 4s, and the first
try at this break was a syntax error that proved nothing)
- GUI listing an off plugin's tools -> plugin-tools.test.cjs
Real use: a built magpie in a sandbox HOME (MAGPIE_ADDR 127.0.0.1:3491,
real Bun), the example plugin added with `magpie plugin add`. curl over
MCP: initialize, tools/list (4 tools, schemas), shout "HI HI (for
curl)", a missing argument as isError naming it, add {"sum":6.5}, fail
"it broke", a foreign Origin 403; plugin-tools.json written. Claude
Code (sandbox CLAUDE_CONFIG_DIR) `claude mcp add --transport http` +
`mcp list`: Connected. Not tried: a model calling a tool through a
real agent turn (no model in the sandbox). Binary and HOME removed.
|