ac4af582301a4e8a29245dbba767eba31334ddf9
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1fd02d33ce |
agentplug: an agent plugin can pick the model its agent starts on in a second file (str_, PiG)
str_ on Discord (#help, v0.1.3005): PiG's row on the Agents page only
switched the model list on, where Pi's picks the model it starts on.
PiG, like Pi, keeps its providers in ~/.pig/agent/models.json and the
model a session starts on in settings.json (defaultProvider,
defaultModel; PiG's docs/site/docs/settings.md, startup_model.go). An
agent plugin could name a model key only in the one file connect
writes, so agent-pig 0.1.0 had to be connect-only.
An agent's descriptor can now say `startup: {config, format, model,
keys}`: the other file, the key that holds the model (the id without
magpie's prefix) and keys written beside it. With it the row gets a
model field as a built-in's does. Picking one of magpie's writes
connect's keys into config and the model and keys into startup.config,
each key kept aside as before; a model of magpie's picked in the agent
itself still reads as magpie's; a model of the user's own picked there
while magpie's provider is listed counts as connected (Beside), not
drift, and is kept on disconnect. Sync rewrites the list and leaves the
startup model where it is. Off, or `magpie <id> default` with the plugin
gone (RestoreGone), puts both files back. startup without connect, beside
agent.model, in config's own file, or naming the model key among keys
is refused. An older magpie ignores the field, so agent-pig 0.1.1
(plugins repo) stays connect-only there. Every other agent plugin
already names its model in its own config; pig is the only
connect-only one.
Run (mote):
- go test -count=1 ./internal/agentplug/: ok
- go test -count=1 -run 'TestPlugged|TestPlugin|TestRestoreGone|TestAgent'
./internal/agent/: ok
- go vet, GOOS=linux and GOOS=windows go vet of both packages; gofmt -l
clean
- the four TestPluggedStartup* tests on the old code: red (the row had
a provider field and only listed models)
- real PiG 0.5.3 (darwin-arm64 release, SHA256SUMS checked) in a sandbox
HOME, models.json written by agent-pig 0.1.1's own connect and
settings.json as startup writes it, against a fake OpenAI server:
`pig -p` sent model deepseek/flash with the gateway key. With an
enabledModels scope that leaves it out, PiG started on the scope's
first model (said in the plugin's README).
Broken by hand: no startRestore in Unwire (TestPluggedStartupModel and
OwnPickKept red); no Beside (OwnPickKept red, "wired false").
Not tried: the GUI and the TUI with the real row (app.js unchanged; the
row is the model field every built-in has), Windows and Linux runs of
PiG, a real magpie gateway in front of PiG, a real vendor model.
|
||
|
|
60520ddb3b |
moejs: v0.1.0-alpha.11, at its new module path github.com/MoeForge/moejs
Gateway middleware and agent plugins run on moejs. alpha.11 moves the
module to github.com/MoeForge/moejs; every other API change since
alpha.4 is an addition. What magpie gets: faster calls, loops, property
lookups and JSON.parse, allocation-free await, a bytecode verifier, a
correct default.pgo, and Intl / toLocaleString in plugin code.
Checked against both tags' source: every name magpie uses (NewRuntime,
Options, Compile, Link, Hook, Value, Arg, Undefined, NativeFunc,
Referrer, the Promise results, Exception) has the same signature, and
Options' defaults (shared frozen builtins, no timers) are unchanged.
fetch, Streams, URL, node:fs and node:buffer live in the separate
webapi and node packages, installed only on request; magpie installs
neither, so a plugin still reaches no network or file.
Intl's CLDR, Unicode, ICU and V8 material is compiled into every build,
and moejs asks a program that includes it to carry sections 1 to 4 of
its notices. THIRD_PARTY_NOTICES holds them verbatim. Release archives
ship no LICENSE today either; that is not changed here.
Doc and site links (docs/, site/public/docs/{,zh/,ja/}plugins.html)
point at the new repo.
Run on mote at this tree: gofmt; go build -trimpath -s -w (60,670,658
bytes on origin/main
|
||
|
|
d10cdf7969 |
agentplug: a late timeout no longer fails every connect after it (#3727)
An agent module loads and connects under limit, whose timer interrupts the module once its second has passed. When the timer fired just as the call returned, Stop didn't wait for its func, which could still be on its way to Interrupt when limit read fired. The interrupt then landed on an idle runtime, and moejs keeps one that lands while nothing runs for the next call, whatever it is (its Interrupt doc). That call's own limit never fired, so nothing cleared it: the agent's every connect after failed with "connect: interrupted: took too long" until magpie loaded the module again. A module that takes about its second, on a busy machine, is the case. limit now waits for the timer's func when Stop says it has begun, then clears the interrupt it gave. A call the timer ran out on reads took too long when it failed, as before, and keeps what it returned when it finished; before, which of the two it got depended on the same race. afterFunc stands in for time.AfterFunc, so a test can hold the timer's func. internal/middleware's timer func can run late the same way; there it stops only the next call, not every one after: #3742. What was run (tree 0199ae4d, on origin/main |
||
|
|
3ec3cb704b |
plugin: turning an agent plugin off or removing it puts the agent's config back first (#3810)
An agent a plugin adds is known only while the plugin is on. Turning the plugin off or removing it (CLI `magpie plugin off/rm`, or the Plugins page) left the agent's config on magpie, and `magpie <agent> default` then said `unknown agent`, with nothing to put it back. - provider.SetPluginOff (off) and provider.RemovePlugin first call provider.PluginAgentGoing, set by internal/agent to UnwirePlugin: the agent is disconnected as `magpie <agent> default` does (Disconnect), while the plugin still loads. A plugin off already is read from its module as it is; one whose module is gone puts back each file whose stash names its spec. If that fails, the plugin is left as it was and the error says why. - The stash now records the plugin's spec and the file's format, so `magpie <id> default` for the agent of a plugin deleted on disk puts the file back from the stash alone (agent.RestoreGone; an older stash's format comes from its file's name, agentplug.FormatOf). A file that no longer holds magpie's gateway key is the user's and is left alone; one that can't be read is unknown: nothing is written, the stash is kept. With the plugin only switched off, `default` says the agent is off magpie already instead of "unknown agent". - Turning the plugin back on (or installing it again) does not rewire the agent by itself: its config stays as the user had it. Connecting it (its switch on the Agents page) puts back the model it was on, through Disconnect's `.reconnect`. The CLI says so when it turns off or removes a plugin whose agent was on magpie. Run (this change on origin/main |
||
|
|
dbf331211f |
agents: an agent plugin with no model key is connect only, a switch with no model picker (#2374, rocona)
A Raycast plugin wants magpie to write the gateway, the agent's key and
the model list, and leave the model to Raycast's own picker. agent.model
was required ("agent.model names no key"), and the row always had a
model picker whose pick Raycast never read.
An agent export without model is now connect only:
- its one field is provider, magpie or nothing, as an app whose one
setting is magpie as its provider (ZCode); ListsModels is set, so the
row has the model list button and no model picker; no new UI control
and no new strings
- connect is called without model and only its keys are written; the
stash, the restore on Disconnect, the agent's own key and Check work
as before; Sync calls connect again on a catalog change
- such a module must export connect (else it doesn't load, saying why),
and connect must return keys (else the connect errs and nothing is
written), so the row never says connected with nothing written
An export with model behaves as before. Docs: the plugins page (en, zh,
ja) and docs/subsystems/agent-wiring.md.
Tests (internal/agent/plugged_connect_only_test.go):
- TestPluggedConnectOnly: one provider field, menu, connect without a
model, no model key written, the user's key and theme kept, list
follows a catalog change, Check sees a base moved by hand, off puts
everything back.
- TestPluggedConnectOnlyWritesSomething: no connect is a load error;
connect returning {} errs and writes nothing.
Broken by hand (only forced false and model passed): both FAIL.
The /api/state row for such an agent was dumped through gui.state() in
a temporary test: key provider, one magpie option, menu true, the same
shape as ZCode's. zcode-models, plugin-agent and agent-connect GUI tests
pass in Chromium and WebKit (46/46; every language, 1100/980 and 420).
Run at origin/main
|
||
|
|
c3bbf16022 |
agentplug: an agent plugin's keys are written in the order it gave them (#1890)
What: connect's result is taken from the module as JSON text (moejs AppendJSON keeps JS insertion order) instead of rt.ToGo, which made a Go map at every level. An object or array connect returns reaches the writer as a json.RawMessage, so edit.SetJSON writes it in the plugin's order; strings, numbers, booleans and null are their Go values as before (the gateway-key mark still matches a string). edit.SetYAML now takes a json.RawMessage too, as a block-style node in the text's order (it would have written the bytes as a list of ints), and the env format writes it compact as before. Why: Kilo's agent plugin (magpie-community/plugins#90) returns each model's effort variants weakest first, low, medium, high, the order Kilo lists them in. Go maps marshal sorted, so Kilo showed high, low, medium. magpie's own OpenCode wiring already keeps order (openCodeVariants). The key paths connect returns are still applied in sorted order: each is a separate edit, and the user's file around them is untouched. Siblings: rt.ToGo's other caller (middleware's string lists) writes no file; the Library's MCP block for a plugin agent is built by magpie, not returned by the plugin. Run: - TestPluggedKeepsPluginOrder (Kilo-shaped connect, a kilo.jsonc with a comment, a theme, $schema, a provider of the user's own with keys zeta, alpha and a trailing key) and TestPluggedKeepsPluginOrderYAMLAndEnv. With agentplug.go put back: FAIL, variants written high, low, medium and provider keys sorted. With yaml.go put back: FAIL, the object written as a list of byte values. Both pass with the change. - gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., the three builds: OK. - go test -tags nogui -timeout 40m ./... under a scratch HOME: all ok. (A first run with the default 10m timeout timed out in internal/gateway while four other sessions' suites ran on this box and the disk was full; the gateway package took 973s under that load and passed.) - Real use, sandbox HOME: this build, `magpie plugin add` of packages/kilo at plugins PR #90 head b67360cb7, a provider whose fake-chat has efforts stored high, low, medium; `magpie kilo magpie/fakeup/fake-chat` wrote variants low, medium, high with the user's comment, $schema, theme and own provider in place, and @kilocode/cli 7.8.8 `kilo models magpie --verbose` lists them low, medium, high. `magpie kilo default` put the file back; the only difference is Kilo's own one-time permission migration. |
||
|
|
26816de2f9 |
library, agentplug: an agent a plugin adds is given the Library's instructions, MCP servers and skills where its agent.library says (AlmarionAI on X)
Agent plugins wired models and keys only: library.targetOf had no case
for them, so the Library's instructions, MCP servers and skills never
reached an agent a plugin adds, while the announcement said the
Library carries over.
An agent export can now say
library: { instructions, mcp, mcpFormat, skills }
each a path (~ and $VAR expanded, as config is). mcpFormat names the
agent whose MCP file it is shaped like (agentplug.MCPFormats: claude,
codex, gemini, opencode, cursor, zed, ... 18 of the library's
mcpFormats). A format outside the list, or an mcp without one, keeps
the plugin from loading. library.pluginTarget makes such an agent a
Target, so it is written as any agent is: magpie's marker block in the
instructions file, servers merged beside the user's own (their fields
kept), skills linked or copied, Applied recording only magpie's part,
backups kept. Takes refuses a place the plugin doesn't name, and says
which agent.library key would give it.
Docs: docs/subsystems/library.md and agent-wiring.md; plugins.html
(en, zh, ja) gets the library field and what magpie does with it.
Run:
- internal/library/agent_plugin_test.go: TestPluginAgentGetsTheLibrary,
TestPluginAgentWithoutAPlaceIsRefused, TestPluginAgentMCPFormat,
TestPluginMCPFormatsAreWritten. With targetOf's plugin case and the
check() validation taken out by hand, the first three go red.
- e2e: a nogui build in a scratchpad HOME (env -i, no live configs),
`magpie plugin add` of a throwaway toy agent plugin; `library
instructions set/agents`, `library mcp add/rm` wrote and took back
only magpie's block and server, the user's "mine" server, its "note"
field and other keys kept, backups made; with mcp dropped from the
plugin, `library mcp add ... agents=toy` is refused naming
agent.library.mcp.
- go test -tags nogui ./... (one unrelated FIFO flake in internal/agent,
fixed in the commit before), gofmt -l clean, go vet for GOOS=linux
and GOOS=windows clean. No GUI code changed.
|
||
|
|
cb406c8425 |
plugins: a plugin can add an agent magpie has no setup of its own for
Plugins could be subscription providers or gateway middleware. Now a third
kind: an agent plugin, so a user whose agent magpie doesn't ship can still
put it on magpie.
- internal/agentplug: a plugin's magpie.agent module (or a *.agent.js file)
exports agent = {id, name, config, format?, model, prefix?, bin?, dir?,
ua?, icon?, notice?} and an optional connect({gateway, model, models,
agent}) returning the other keys to write. Compiled in moejs, reloaded
when plugins.json or the file changes; why one didn't load is kept.
- internal/jsmod: module compiling (imports kept inside the plugin), moved
out of middleware so both share it.
- internal/agent/plugged.go: each becomes an Agent (Plugin set) after
magpie's own. JSON, YAML and env files are edited key by key, comments
kept; what each key held is stashed typed under plugin:<id>:<path>, and
its own model or Disconnect puts every key back. A built-in id is
refused; a connect that throws writes nothing. Key magpie-<id>; usage
names it by key or ua (usage.PluginAgents).
- GUI Plugins page: an Agent kind chip and glyph, a Discover "Agents"
section (market kind "agent"), and an installed row line "Adds X to
Agents" or why it didn't load. zh, zh-TW, ja, de strings.
- Docs: site Plugins page (en, zh, ja) "Agent plugins", reference.md,
agent-wiring.md, gateway-middleware.md.
Run:
- go test ./... (all ok); gofmt -l clean; GOOS=linux go vet -tags nogui
./... and GOOS=windows go vet ./... clean.
- TestPluggedYAML, TestPluggedJSONUnwire, TestPluggedRefused.
- GUI: plugin-agent.test.cjs 22/22 (en, zh, zh-TW, ja, de; 980 and 420;
chromium and webkit); all plugin-*.test.cjs, i18n-keys,
deprecated-subscriptions, filter-ime: 315 pass, 0 fail.
- Real use, in a sandbox HOME: an Aider plugin (~/.aider.conf.yml, prefix
openai/, connect writes openai-api-base/key) installed in a dev build;
picking DeepSeek V4.1 Flash on the Agents page wired the file keeping the
user's comment and keys; real aider 0.86.2 `--message` answered through
magpie from the real DeepSeek account; usage.jsonl recorded agent aider,
provider deepseek, 200; Disconnect restored the file byte for byte.
|