6b3ee5a03bd32bdf584e793de79c8dabfea463dc
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
db8b791797 |
plugin: tools-, page- and agent- packages take their short name without the prefix
@magpie-community/tools-calc served its tools as tools-calc_eval and its
page under "tools-calc" because ShortName only dropped middleware- and
opencode-. It now drops tools-, page- and agent- too, so the calc example
serves calc_eval/calc_convert/calc_date as its README and the docs say.
`magpie plugin options` / SetOptions find a plugin by its short name or by
its bare package name (plugin.Called), so "agent-aider" keeps working
beside "aider".
Run at
|
||
|
|
e679f1106f |
cli: magpie plugin lists a plugin's tools and its page
The list said a gateway module's hooks, routings and onUsage, but nothing
for a plugin that gives tools (P4b) or a page (P4c), so such a plugin had
nothing under its row. Found in the combined P4 real-use run.
Tools are listed by their names on the plugin tools MCP server
(gateway.ToolNames), a page by its title and what it may read.
Run: TestPluginListSaysToolsAndPage, and internal/cli whole (ok). gofmt
clean; vet darwin, linux -tags nogui and windows = 0. Broken by hand:
without the tools line the test goes red ("aren't listed"), and without
the page line too ("isn't listed"). A `!e.Off` guard on the tools line
didn't change the test, since the host loads no plugin that is off, so
it was dropped.
|
||
|
|
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.
|
||
|
|
9b83fff847 |
cli: magpie plugin login grok installs Grok Build first, as the window's sign-in does, not "install Grok Build first: curl … | bash" in Docker (#2223, evier12345)
The window's plugin sign-in (StartPluginSignIn) installs the vendor CLI a
plugin signs in through when it is missing: Grok Build, with xAI's
installer or, in the Docker image with no curl, as that installer does
(installGrokBuild). The command line's pluginLogin, which `magpie plugin
login` and `magpie accounts add` take for a plugin or a moved
subscription, never did, so every Grok sign-in method in the container
ended in the plugin's "install Grok Build first". The check is now
provider.PluginCLIMissing / InstallPluginCLI, shared by both, and the
command line installs before the method's questions (not for an API key).
The Docker page (en, zh, ja) says Grok's sign-in installs Grok Build into
/config/home/.grok, and that GROK_BIN_DIR takes one put there by hand.
Run at
|
||
|
|
33da86c71a |
provider: removing a plugin sets its providers' model picks in providers.json aside, and adding it again puts them back (#2057, dawn1095)
A plugin's provider leaves a record in providers.json once the user picks its models: its id and nothing of its own (OnlyPicks). Removing the plugin left those records behind. Nothing listed them, `magpie provider rm` couldn't reach them, and a sync or backup asked for a sign-in to them on every run. RemovePlugin now finds the ids the plugin's providers are stored under (PluginID of each provider plugin.Listed gives for its spec), and moves the records with those ids that hold only picks into providers.json's new pluginLeft, under the plugin's package name. Left alone: - any record with an endpoint or a key (the user's own provider, whatever its id); - a built-in's ids (accountIDs) and "magpie"; - an id another installed plugin serves too; - everything, when the plugins' listing isn't known (no cache and no plugin-providers.json): unknown is not "none is the user's". provider.AddPlugin (CLI, GUI, backup restore) puts the set-aside records back, each one whose id has no record now; one the user has given to a provider since stays aside. plugin.Listed is new: the cached listing, or plugin-providers.json. Run: - plugin_left_test.go, four tests with user-owned records beside the plugin's (a user "zap" with an endpoint next to the plugin's zap-plugin, a hand-made "mine", a built-in's picks, another plugin's and a shared id). Each guarantee broken by hand turned its test red: no set-aside, no OnlyPicks check, no other-plugin exclusion, no unknown-listing guard, take-back over the user's record, no take-back. - go test ./... in a sandbox HOME; gofmt -l; go vet darwin, linux (-tags nogui), windows. Not done: records left by plugins removed before this change stay where they are; turning a plugin off (not removing it) sets nothing aside; `magpie provider rm` still can't name such a leftover. The move flow (installPlugin) still adds through plugin.Add, since its own migration owns those records. Not tried with a real plugin removal in the GUI. |
||
|
|
9e76fcdc68 |
plugin, cli, gui: a plugin's "password" question is typed unseen, as an API key is (#1982)
A sign-in method's prompts could only be "text" or "select", so a token a plugin asks for (the Qoder plugin's PAT sign-in, magpie-community/plugins#103) showed on screen as it was typed, in the app and in `magpie plugin login`. What changed: - internal/gui/assets/app.js renderPluginAsk: a prompt of type "password" gets a password field (masked), the same field an "api" method's key gets. A "text" prompt is unchanged. - internal/cli/plugins_cli.go askPrompt: on a terminal a "password" prompt is read with term.ReadPassword (no echo); piped in it is read as a line, as a script answers it, and an empty answer still goes to the plugin's validate, as a text one does. - internal/plugin/providers.go: the Prompt type lists "password". host.js passes the type through untouched, so nothing there changes. The TUI has no plugin sign-in. - Docs: docs/reference.md and site/public/docs (en, zh, ja) plugins.html say what "password" does and that it is magpie's own (OpenCode has text and select). The answer is only sent to /api/plugin-signin/prompt and the sign-in, as a text answer is; nothing logs or shows it. What was run: - TestAskPromptPasswordIsUnseen (internal/cli): with the password branch disabled by hand it fails with `password on a terminal = "typed-in-the-open", <nil>, hidden reads 0; want pt-secret read unseen`; restored it passes. - plugin-password-prompt.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 420 wide, 11/11 each. With app.js put back it fails with expected 'password', actual 'text'. plugin-signin and plugin-signed-out-account 16/16 in both engines; i18n-keys passes in both. - gofmt -l clean; go vet for darwin, GOOS=linux -tags nogui and GOOS=windows on internal/cli, internal/plugin, internal/gui; go test -tags nogui of those three packages in a sandbox HOME: ok. Not tried: a real Qoder PAT through the community plugin (its PR isn't merged), and the CLI on a real Windows console (term.ReadPassword is the same call `magpie plugin login` already uses for an API key). |
||
|
|
3ccbe6bc15 |
plugins: a runtime for built-in plugins, and Plugins › Built-in to switch them (P0)
Lxxyx on X (https://x.com/Lxxyx_/status/2109506752656150974): magpie has too much in it. This is P0 of making magpie's parts plugins, as DeepSeek Harness does: a runtime, plugins.yml, and the first five built-in plugins the user can switch off. - internal/pluginrt: a registry (Register from init), a manifest (API caret range, Requires/Provides, Essential, InUse, Apply, Parts, Defaults) and Reconcile: the plugins no longer wanted, with whatever needs a service they provided, are disposed newest first; the wanted ones are applied once their services are there. A plugin that fails or panics is failed and the rest run. TestPluginsImportOnlyCore keeps the boundary: nothing outside plugins/ imports one, none imports another. - plugins.yml (appdir.Config()): default → preset (essentials | all) → the user's rows → in use. A new install is written Essentials, a magpie that ran here before (settings.RanBefore) All, so existing users keep everything. Writes are locked, whole and keep a .bak; a file that doesn't parse is an error, never empty, and is never written over. - plugins/groups, library, otel, sessions, warmups. In P0 a plugin off is the window's alone: its page, sections and rows (data-feature) leave the window; the gateway, TUI and CLI serve the same, nothing is deleted. One in use stays on. - The window: Plugins › Built-in, the first tab, a switch per plugin; GET/POST /api/plugins/builtin; boot.js says which are off before the first paint. CLI: magpie plugin builtin [on|off <id>], plugin preset, plugin dump [--json]. - docs/subsystems/plugin-runtime.md, gui-shell.md. Run: go test ./internal/pluginrt/ ./internal/settings/ ./internal/gui/; gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./.... GUI: builtins.test.cjs in Chromium and WebKit, 5 languages, 1100/800/420; list-sort, mobile-web, routing-keys-fold, routing-sessions pass. By hand under a sandbox HOME: a new install gets essentials, an existing one all, a broken plugins.yml is refused and kept, dump works. Full suite results after the rebase are in the push notes. |
||
|
|
23e764d0e0 |
cli: magpie's commands move from the root into internal/cli; the root keeps only main.go
The root held 89 .go files (30 commands, 59 tests). They move as they are to internal/cli (package cli), with git mv so history follows them. The only code change is main() becoming cli.Main(version): the root's new main.go keeps `var version` in package main, so -ldflags "-X main.version=…" in the Makefile, the Dockerfile and magpie-releases, and every workflow, work unchanged. go-winres's rsrc_windows_*.syso still land next to package main in the root. Tests that read testdata by a root-relative path now go up one level (../plugin/testdata/fake, ../sessions/testdata). Five subsystem doc links point at internal/cli/. Run: - go build ./..., gofmt -l, go vet on darwin, linux and windows (nogui) - builds with tags production, dev, "production nogui"; windows -H windowsgui; linux CGO_ENABLED=0 - make release-cli TARGETS="darwin/arm64 linux/amd64 windows/amd64 android/arm64" VERSION=9.9.9-tidy: all four built, binary prints "magpie 9.9.9-tidy" - docker build --build-arg VERSION=7.7.7-tidy: container prints "magpie 7.7.7-tidy" - go test ./internal/cli (default and nogui): 152 tests, the same count as the root on main - go test ./...: all packages pass (agent, gateway, library, provider timed out at 10m under other sessions' load and passed rerun alone with -timeout 40m; none of them changed) - the built binary in a sandbox HOME: version, help, ls, providers, claude, and an unknown command's error |