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 9d97fd073 + this change and the #2373/#2372/#2374 commits beside it (one tree), -tags nogui -count=1
-timeout 45m: internal/agent, plugin, provider, catalog,
gui, gateway ok. gofmt -l clean; go vet -tags nogui ./... for GOOS
darwin, linux, windows clean.

Full suite: SUITE_LINE
This commit is contained in:
yetone
2026-10-15 23:08:04 +08:00
parent 3d63fc9cb5
commit dbf331211f
7 changed files with 213 additions and 17 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ something else shows up as drift.
| Named omp profiles | omp keeps a profile's settings under `~/.omp/profiles/<name>` (or under `PI_CONFIG_DIR`), each with its own `config.yml` and `models.yml`. Every such profile is an agent of its own — `omp#<name>` on Windows, `omp#<name>@wsl:<distro>` in a distro — so each can be connected, drifted and disconnected on its own. They share omp's model lists (`ListsFor`), and the default `omp` row is the folder `ompDir`/`ompIn` already pick, so an `OMP_PROFILE` that row is already pointed at is not listed twice. A name omp refuses is not a row: `default`, a trailing dot, or a Windows reserved device name (`aux`, `nul`, `com1`, `lpt9.x`, `con.work`), on every platform (`ompProfileOK`). A distro's profile names come from its probe and are kept in `wsl.json`; a stopped distro is never started to list them, its profile rows showing what was last seen (`asleep`). | [`omp.go`](../../internal/agent/omp.go), [`wsl.go`](../../internal/agent/wsl.go) |
| WSL twins | On Windows each running distro is probed once, without starting a stopped one. The `wslKinds` agents found there become agents of their own, `<id>@wsl:<distro>`, edited through `\\wsl.localhost\<distro>`. A kind is found by its folder under the distro's home or by its command there (not one on a Windows drive). Where another tool shares one of them, the kind leaves it out: Gemini CLI is found by its command alone, because Antigravity keeps `~/.gemini` too. Goose is found by its folder alone, because a `goose` command can be pressly's migration tool. Reasonix also needs the version its command gives (`accept`), because the old npm client is named `reasonix` too. The gateway address and key follow the distro's networking: mirrored or NAT (`place`, `keyAt`). `ListsFor` keeps a twin's model picks under the Windows twin's id (#927). | [`wsl.go`](../../internal/agent/wsl.go), [`gatewaykey.go`](../../internal/agent/gatewaykey.go) |
| Settings tuned from use | Usage › Context's "Tuned for you" advises, per agent, the settings that would have spent the fewest tokens on the user's own calls of the range, and puts one in on a click. Package `tune` replays the calls `sessions.Calls` reads from the agents' session files under each candidate value (`Compact`, `CacheTTL`); `tuneOf` picks the agents and models (Claude Code per model, Codex pooled). `TuneRead`, `TuneApply` and `TuneUndo` know where each setting lives: Claude Code's `modelSettings.<model>.autoCompactWindow` (where its `/autocompact` saves), `promptCacheTtl` and `subagentPromptCacheTtl` in `~/.claude/settings.json`; Codex's top-level `model_auto_compact_token_limit`. The advice is weighed by tokens alone: it is labelled "Fewest tokens", and a compaction window it would change says it doesn't measure how well the agent keeps the task after a compaction, and that a lower window compacts more often (#1854, `context-tune.test.cjs`). A compaction row's "Other window…" opens the app menu with every value of the curve, each with its estimated extra tokens over the fewest and about how many compactions it would have made (`Point.compacts`, from the same replay), and puts the one picked in like Use (#1860). An agent whose files time its compactions also has their wait weighed (HirotaNagai on X): Claude Code's `compact_boundary` line says `compactMetadata.durationMs`, which `sessions` puts on the first call after it, and Codex compacts by a call of its own (the record a `compacted` line names, in rollouts since 2026-09), whose time is the compaction's (`Call.Compact`; an older rollout's compaction has no call and stays untimed). With 3 or more timed for a model (`minTimed`), `Facts.took` is their median seconds, each window says its wait (`Point.wait`, its compactions × `took`), and the row says what a compaction took, the wait at the advice against the window now, and the cheaper window the advice passed over for waiting longer (`Compaction.cheapest`, `wait_cheapest`) when it saves 3% or more; the advice is labelled "Tokens + wait", its caveat says tokens and waiting only, and the picker says each window's wait with "Fewest tokens" on the cheapest (`context-tune.test.cjs`). An agent or model with fewer timed reads and is advised as before. | [`internal/tune`](../../internal/tune/tune.go), [`tune.go`](../../internal/agent/tune.go), [`internal/gui/tune.go`](../../internal/gui/tune.go) |
| Agents a plugin adds | A plugin's `magpie.agent` module (or a `*.agent.js` file) says where an agent magpie has no setup of its own keeps its model (`config`, `format`, `model`, `prefix`), and its `connect` returns the other keys to write. `agentplug` compiles each in moejs (via `jsmod`, as gateway middleware is), reloads it when plugins.json or the file changes, and keeps why one didn't load. `plugged` makes each an `Agent` with `Plugin` set, listed after magpie's own; an id one of magpie's own agents has is refused (`PluginErrors`). | [`agentplug.go`](../../internal/agentplug/agentplug.go), [`plugged.go`](../../internal/agent/plugged.go) |
| Agents a plugin adds | A plugin's `magpie.agent` module (or a `*.agent.js` file) says where an agent magpie has no setup of its own keeps its model (`config`, `format`, `model`, `prefix`), and its `connect` returns the other keys to write. One with no `model` is connect only (#2374): its one field is `provider`, magpie or nothing, as an app whose one setting is magpie as its provider; `connect` is called without a model, must return keys, and is called again on a catalog change (`Sync`); `ListsModels` is set, so its list is the models picked for it. `agentplug` compiles each in moejs (via `jsmod`, as gateway middleware is), reloads it when plugins.json or the file changes, and keeps why one didn't load. `plugged` makes each an `Agent` with `Plugin` set, listed after magpie's own; an id one of magpie's own agents has is refused (`PluginErrors`). | [`agentplug.go`](../../internal/agentplug/agentplug.go), [`plugged.go`](../../internal/agent/plugged.go) |
| Environment-only agents | Agents that read the gateway only from the environment get a `Launch` command. Cursor Private Inference instead gets user-level variables (`cursorLocalOn`, `KeepCursorLocalEnv`), and magpie writes none of Cursor's own files. It is found by its product.json in the apps folders, in the folder Windows' list of installed programs names (`cursorLocalInstalls`, any folder picked in its installer), or as its Linux AppImage (`Cursor_Private_Inference-…AppImage`) in the folders downloads are kept in (#1254). Its effort field is kept in magpie (`provider.AgentEffort`) and asked by the gateway, its levels those of the models it lists (`cursorLocalEfforts`, #1003). | [`cursorlocal.go`](../../internal/agent/cursorlocal.go) |
| Claude Science | Its daemon (`claude-science`) reads the API's address only from its environment's `ANTHROPIC_BASE_URL` and has no setting for it. Connect restarts the daemon with that variable set to the gateway (`scienceOn`: `stop`, then `serve --detached --no-browser` on the port `status` said it was on) and notes the daemon in `claude-science.json` (url, pid, port); Disconnect restarts it without the variable, one in magpie's own environment taken out too. No variable is set for the user and no file of the app's is written. Setting it again while magpie's daemon runs on this gateway does nothing (`Pick` sets the field after `connect`). `KeepClaudeScience` starts it again on the gateway, on its port, when it isn't running (a restart of the computer), each minute while magpie serves; it never stops one running. `Check` reads the daemon's `operon.lock`, not `status` (seconds for a 130 MB Bun program), and calls a daemon with another pid drift: the app's window, opened while none ran, starts its own without the variable. It is found in the Mac app's bundle (`Claude Science.app/Contents/Resources/bin`), `%LOCALAPPDATA%\Programs\ClaudeScience` on Windows, `~/.local/bin`, else on PATH. The app still needs its own Claude sign-in; the gateway never passes it on (see gateway-routing). | [`claudescience.go`](../../internal/agent/claudescience.go), [`science.go`](../../internal/gateway/science.go) |
+49 -8
View File
@@ -258,7 +258,11 @@ func plugged(home string, p *agentplug.Agent) *Agent {
forget(key)
return nil
}
// wire writes ref and connect's keys, stashing what each key had
// only: the agent picks its model itself among those connect writes
// (#2374), so magpie writes no model, and the switch is its one field
only := d.Model == ""
// wire writes ref and connect's keys, stashing what each key had; a
// connect-only agent's ref is ""
wire := func(ref string) error {
var model map[string]any
var models []map[string]any
@@ -276,17 +280,28 @@ func plugged(home string, p *agentplug.Agent) *Agent {
model = map[string]any{"id": ref, "name": ref, "context": 0, "output": 0, "images": false, "efforts": []string{}}
}
gk := agentKeyAt(id, at.gw())
out, err := p.Connect(map[string]any{
in := map[string]any{
"gateway": map[string]any{"url": at.gw(), "v1": at.v1(), "key": gk},
"model": model,
"models": models,
"agent": map[string]any{"id": id, "config": f.path},
})
}
if !only {
in["model"] = model
}
out, err := p.Connect(in)
if err != nil {
return fmt.Errorf("%s: %w", plugin.Name(p.Spec), err)
}
delete(out, d.Model)
kvs := []edit.KV{{Path: d.Model, Value: d.Prefix + ref}}
var kvs []edit.KV
if only {
// nothing written would read as connected all the same
if len(out) == 0 {
return fmt.Errorf("%s: connect returned no keys to write", plugin.Name(p.Spec))
}
} else {
delete(out, d.Model)
kvs = append(kvs, edit.KV{Path: d.Model, Value: d.Prefix + ref})
}
mark, strs := "", map[string]string{}
for _, k := range sortedKeys(out) {
kvs = append(kvs, edit.KV{Path: k, Value: out[k]})
@@ -356,7 +371,7 @@ func plugged(home string, p *agentplug.Agent) *Agent {
if !ok {
return ""
}
if v, _ := f.get(d.Model); v != d.Prefix+st.Ref {
if v, _ := f.get(d.Model); !only && v != d.Prefix+st.Ref {
return ""
}
var kvs []string
@@ -365,6 +380,7 @@ func plugged(home string, p *agentplug.Agent) *Agent {
}
return wiringOff(d.Name, f.path, f.get, kvs...)
},
ListsModels: only,
Fields: []Field{{
Key: "model", Label: "model",
Get: get,
@@ -389,7 +405,7 @@ func plugged(home string, p *agentplug.Agent) *Agent {
// the catalog changed: what connect writes for the model may too
Sync: func() error {
if st, ok := onMagpie(); ok {
if v, _ := f.get(d.Model); v == d.Prefix+st.Ref {
if v, _ := f.get(d.Model); only || v == d.Prefix+st.Ref {
return wire(st.Ref)
}
}
@@ -402,6 +418,31 @@ func plugged(home string, p *agentplug.Agent) *Agent {
return nil
},
}
if only {
// magpie as its provider, on or off: the models are the agent's
// to pick, in the list connect writes
a.Fields = []Field{{
Key: "provider", Label: "provider",
Get: func() string {
if _, ok := onMagpie(); ok {
return magpieID
}
return ""
},
Set: func(v string) error {
if v == magpieID {
return wire("")
}
if st, ok := onMagpie(); ok {
return restore(st)
}
return nil
},
Options: func(map[string]string) []Option {
return []Option{{Value: magpieID, Label: "magpie", Icon: "magpie"}}
},
}}
}
if d.Dir != "" {
a.Dir = pluggedPath(home, d.Dir)
}
+146
View File
@@ -0,0 +1,146 @@
package agent
import (
"encoding/json"
"os"
"path/filepath"
"slices"
"strings"
"testing"
"github.com/yetone/magpie/internal/gateway"
"github.com/yetone/magpie/internal/provider"
)
// An agent plugin with no model key is connect only (#2374, a Raycast
// plugin): its row is magpie as its provider, on or off, with no model to
// pick, connect is called without a model and writes the gateway and the
// model list, the list follows the catalog, and switching it off puts back
// what the user had.
func TestPluggedConnectOnly(t *testing.T) {
home := pluggedHome(t, `
export const agent = { id: "raycast", name: "Raycast", config: "~/.raycast/providers.json" };
export function connect({ gateway, model, models }) {
return {
"providers.magpie.base": gateway.v1,
"providers.magpie.key": gateway.key,
"providers.magpie.models": models.map((m) => m.id),
"providers.magpie.given": typeof model,
};
}`)
path := filepath.Join(home, ".raycast", "providers.json")
os.MkdirAll(filepath.Dir(path), 0o755)
os.WriteFile(path, []byte(`{"theme":"dark","providers":{"magpie":{"key":"mine"}}}`), 0o644)
read := func() (map[string]any, map[string]any) {
t.Helper()
var c map[string]any
b, _ := os.ReadFile(path)
if err := json.Unmarshal(b, &c); err != nil {
t.Fatalf("%v: %s", err, b)
}
ps, _ := c["providers"].(map[string]any)
m, _ := ps["magpie"].(map[string]any)
return c, m
}
a, err := Find("raycast")
if err != nil {
t.Fatal(err)
}
if len(a.Fields) != 1 || a.Fields[0].Key != "provider" || !a.ListsModels {
t.Fatalf("fields %+v, lists models %v", a.Fields, a.ListsModels)
}
f := a.Field("provider")
if opts := f.Options(nil); len(opts) != 1 || opts[0].Value != magpieID {
t.Fatalf("a model is offered to pick: %+v", opts)
}
if f.Get() != "" || a.Wired() {
t.Fatal("connected before it was")
}
how, err := a.ConnectHow()
if err != nil {
t.Fatal(err)
}
c, m := read()
if how.How != "magpie" || m["base"] != gateway.URL()+"/v1" || m["key"] != gateway.TokenFor("raycast") || m["given"] != "undefined" || c["theme"] != "dark" {
t.Fatalf("connected %+v: %v", how, c)
}
if _, ok := c["model"]; ok {
t.Fatalf("a model was written: %v", c)
}
ids := func() []string {
_, m := read()
var out []string
for _, v := range m["models"].([]any) {
out = append(out, v.(string))
}
return out
}
if !slices.Contains(ids(), "deepseek/pro") || !slices.Contains(ids(), "deepseek/flash") {
t.Fatalf("models: %v", ids())
}
if f.Get() != magpieID || !a.Wired() || a.Check() != "" {
t.Fatalf("get %q, wired %v, check %q", f.Get(), a.Wired(), a.Check())
}
// the catalog changed: the list it wrote follows
if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro", "flash", "max"}}); err != nil {
t.Fatal(err)
}
if err := a.Sync(); err != nil {
t.Fatal(err)
}
if !slices.Contains(ids(), "deepseek/max") {
t.Fatalf("the list didn't follow the catalog: %v", ids())
}
// the key moved by hand: Check says so
b, _ := os.ReadFile(path)
os.WriteFile(path, []byte(strings.Replace(string(b), gateway.URL(), "http://elsewhere", 1)), 0o644)
if a.Check() == "" {
t.Fatal("Check missed the base moved")
}
// off: what the user had is back, and what wasn't there is gone
if err := f.Set(""); err != nil {
t.Fatal(err)
}
c, m = read()
if m["key"] != "mine" || m["base"] != nil || m["models"] != nil || c["theme"] != "dark" || a.Wired() || f.Get() != "" {
t.Fatalf("off: %v", c)
}
}
// A connect-only module needs a connect, and one that writes something:
// with neither a model key nor keys of connect's, the row would say
// connected while nothing in the agent's file was magpie's.
func TestPluggedConnectOnlyWritesSomething(t *testing.T) {
pluggedHome(t,
`export const agent = { id: "bare", config: "~/.bare.json" };`,
`export const agent = { id: "empty", config: "~/.empty.json" };
export function connect() { return {}; }`,
)
errs := PluginErrors()
if len(errs) != 1 {
t.Fatalf("errors: %v", errs)
}
for _, e := range errs {
if !strings.Contains(e, "agent.model names no key") || !strings.Contains(e, "connect") {
t.Fatalf("error: %q", e)
}
}
a, err := Find("empty")
if err != nil {
t.Fatal(err)
}
if _, err := a.ConnectHow(); err == nil || !strings.Contains(err.Error(), "no keys") {
t.Fatalf("connect: %v", err)
}
if a.Wired() {
t.Fatal("connected with nothing written")
}
if _, err := os.Stat(a.Path); err == nil {
t.Fatal("written though connect returned nothing")
}
}
+11 -2
View File
@@ -18,6 +18,11 @@
// and it runs in moejs in magpie's own process, as gateway middleware
// does: there is no Node here, so a package it imports is bundled into it.
//
// An agent whose model is picked in the agent itself (Raycast's own
// picker, among the models connect writes) leaves model out: it is connect
// only, a switch on the Agents page as an app whose one setting is magpie
// as its provider is, and connect is called without a model (#2374).
//
// The agent export may also say where its agent reads what magpie's
// Library gives (internal/library): an instructions file, an MCP file in
// one of MCPFormats, and a skills folder; each is optional.
@@ -258,6 +263,11 @@ func Compile(spec, file string) (*Agent, error) {
}
}
}
// connect only: with no model key, connect's keys are all magpie
// writes, so a module with neither would write nothing
if a.Desc.Model == "" && !a.has {
return nil, errors.New("agent.model names no key, and there is no connect to write the gateway: say one or both")
}
return a, nil
}
@@ -268,9 +278,8 @@ func (d *Desc) check() error {
return fmt.Errorf("agent.id %q: lower-case letters, digits, '.', '_' and '-' only", d.ID)
case strings.TrimSpace(d.Config) == "":
return errors.New("agent.config names no file")
case strings.TrimSpace(d.Model) == "":
return errors.New("agent.model names no key")
}
d.Model = strings.TrimSpace(d.Model)
if d.Name == "" {
d.Name = d.ID
}
+2 -2
View File
@@ -768,7 +768,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to
<tr><td><code>name</code></td><td>ページでの表示名。省略すると id。</td></tr>
<tr><td><code>config</code></td><td>magpie が編集するファイル。<code>~</code> と <code>$VAR</code> は展開されます。なければ作成します。</td></tr>
<tr><td><code>format</code></td><td>ファイル名から分からないときの <code>json</code>、<code>yaml</code>、<code>env</code>(<code>.json</code>/<code>.jsonc</code>、<code>.yaml</code>/<code>.yml</code>、<code>.env</code>)。TOML はまだ対応していません。</td></tr>
<tr><td><code>model</code></td><td>ファイル内のモデルのキー。JSON と YAML ではドット区切りのパス(<code>llm.model</code>)。</td></tr>
<tr><td><code>model</code></td><td>ファイル内のモデルのキー。JSON と YAML ではドット区切りのパス(<code>llm.model</code>)。モデルをエージェント自身で、<code>connect</code> が書くモデルの中から選ぶ場合(Raycast など)は省略します。その行は接続スイッチだけになってモデルの選択欄は出ず、<code>connect</code>(このプラグインには必須)は <code>model</code> なしで呼ばれます。</td></tr>
<tr><td><code>prefix</code></td><td>magpie のモデル id の前に書くもの。LiteLLM 経由で OpenAI 互換エンドポイントを使うエージェントなら <code>openai/</code>。id 自体はゲートウェイが受け付ける <code>&lt;プロバイダー&gt;/&lt;モデル&gt;</code> です。</td></tr>
<tr><td><code>bin</code>、<code>dir</code></td><td>エージェントがインストール済みかを示す <code>PATH</code> 上のコマンドとフォルダー。</td></tr>
<tr><td><code>ua</code></td><td>キーなしで来たリクエストを使用量で名付けるための、エージェントの User-Agent に含まれる語。</td></tr>
@@ -777,7 +777,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to
<tr><td><code>library</code></td><td><span class="ui">ライブラリ</span>が渡すものをエージェントがどこで読むか:<code>instructions</code>(毎回の会話の前に読む Markdown ファイル)、<code>mcp</code>(MCP サーバーのファイル)とその書き方を表す <code>mcpFormat</code>(どのエージェントのファイルと同じ形か:<code>alma</code>, <code>antigravity</code>, <code>claude</code>, <code>cline</code>, <code>codex</code>, <code>commandcode</code>, <code>copilot</code>, <code>crush</code>, <code>cursor</code>, <code>devin</code>, <code>gemini</code>, <code>goose</code>, <code>grok</code>, <code>hermes</code>, <code>kimi</code>, <code>omp</code>, <code>opencode</code>, <code>zed</code>。<code>claude</code> は <code>{"mcpServers": {…}}</code>)、<code>skills</code>(<code>SKILL.md</code> のフォルダを置くフォルダ)。どれも省略でき、<code>~</code> と <code>$VAR</code> は展開されます:<code>library: { instructions: "~/.toy/AGENTS.md", mcp: "~/.toy/mcp.json", mcpFormat: "claude", skills: "~/.toy/skills" }</code>。書かなければライブラリからは何も渡されず、渡そうとするとプラグインが書くべきキーを示して断られます。</td></tr>
</table></div>
<h3>connect</h3>
<p><code>connect(input)</code> はモデルの横に書き込む他のキーを、キーのパスと値で返します。<code>async</code> でも構いません。受け取るのは <code>gateway</code>(<code>url</code>、<code>/v1</code> で終わる URL の <code>v1</code>、エージェント専用のキー <code>key</code>。リクエストはその id で数えられます)、<code>model</code>(<code>id</code>、<code>name</code>、<code>context</code>、<code>output</code>、<code>images</code>、<code>efforts</code>)、<code>models</code>(magpie がエージェントに出すすべてのモデル、同じ形)、<code>agent</code>(<code>id</code>、<code>config</code>)です。<code>connect</code> がないプラグインはモデルだけを書きます。</p>
<p><code>connect(input)</code> はモデルの横に書き込む他のキーを、キーのパスと値で返します。<code>async</code> でも構いません。受け取るのは <code>gateway</code>(<code>url</code>、<code>/v1</code> で終わる URL の <code>v1</code>、エージェント専用のキー <code>key</code>。リクエストはその id で数えられます)、<code>model</code>(<code>id</code>、<code>name</code>、<code>context</code>、<code>output</code>、<code>images</code>、<code>efforts</code>)、<code>models</code>(magpie がエージェントに出すすべてのモデル、同じ形)、<code>agent</code>(<code>id</code>、<code>config</code>)です。<code>connect</code> がないプラグインはモデルだけを書きます。magpie のモデルが変わると <code>connect</code> がもう一度呼ばれるので、書いたモデル一覧は最新のまま保たれます。</p>
<h3>magpie がすること</h3>
<ul>
<li><b>書き込み。</b>各キーをその場で書き換え、ユーザーのコメントや他のキーは残します。最初に書く前に、各キーの元の値を型ごと(数値は数値のまま)取っておきます。</li>
+2 -2
View File
@@ -768,7 +768,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to
<tr><td><code>name</code></td><td>What the page calls it. The id when left out.</td></tr>
<tr><td><code>config</code></td><td>The file magpie edits. <code>~</code> and <code>$VAR</code> are expanded. It is made when it isn’t there.</td></tr>
<tr><td><code>format</code></td><td><code>json</code>, <code>yaml</code> or <code>env</code>, when the file’s name doesn’t say it (<code>.json</code>/<code>.jsonc</code>, <code>.yaml</code>/<code>.yml</code>, <code>.env</code>). TOML isn’t supported yet.</td></tr>
<tr><td><code>model</code></td><td>The key of the model in the file, as a dotted path for JSON and YAML (<code>llm.model</code>).</td></tr>
<tr><td><code>model</code></td><td>The key of the model in the file, as a dotted path for JSON and YAML (<code>llm.model</code>). Leave it out for an agent whose model is picked in the agent itself, among the models <code>connect</code> writes (Raycast): the row is then a switch with no model picker, and <code>connect</code>, which such a plugin must have, is called without <code>model</code>.</td></tr>
<tr><td><code>prefix</code></td><td>Written before magpie’s model id: <code>openai/</code> for an agent that reaches OpenAI-compatible endpoints through LiteLLM. The id itself is <code>&lt;provider&gt;/&lt;model&gt;</code>, as the gateway takes it.</td></tr>
<tr><td><code>bin</code>, <code>dir</code></td><td>The command on <code>PATH</code> and the folder that say the agent is installed.</td></tr>
<tr><td><code>ua</code></td><td>Words of the agent’s User-Agent, to name its requests in Usage when they come without its key.</td></tr>
@@ -777,7 +777,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to
<tr><td><code>library</code></td><td>Where the agent reads what the <span class="ui">Library</span> gives: <code>instructions</code> (a Markdown file it reads before every conversation), <code>mcp</code> (its MCP servers file) with <code>mcpFormat</code>, the agent whose file it is shaped like (<code>alma</code>, <code>antigravity</code>, <code>claude</code>, <code>cline</code>, <code>codex</code>, <code>commandcode</code>, <code>copilot</code>, <code>crush</code>, <code>cursor</code>, <code>devin</code>, <code>gemini</code>, <code>goose</code>, <code>grok</code>, <code>hermes</code>, <code>kimi</code>, <code>omp</code>, <code>opencode</code>, <code>zed</code>; <code>claude</code> is <code>{"mcpServers": {…}}</code>), and <code>skills</code> (a folder of <code>SKILL.md</code> folders). Each is optional, with <code>~</code> and <code>$VAR</code> expanded: <code>library: { instructions: "~/.toy/AGENTS.md", mcp: "~/.toy/mcp.json", mcpFormat: "claude", skills: "~/.toy/skills" }</code>. Without it the agent is given nothing from the Library, and giving it an item is refused, naming the key its plugin would set.</td></tr>
</table></div>
<h3>connect</h3>
<p><code>connect(input)</code> returns the other keys to write beside the model, by key path, each with its value; it may be <code>async</code>. It is given <code>gateway</code> (<code>url</code>, <code>v1</code> — the URL ending in <code>/v1</code> — and <code>key</code>, the agent’s own key, which counts its requests under its id), <code>model</code> (<code>id</code>, <code>name</code>, <code>context</code>, <code>output</code>, <code>images</code>, <code>efforts</code>), <code>models</code> (every model magpie offers the agent, the same way) and <code>agent</code> (<code>id</code>, <code>config</code>). A plugin without <code>connect</code> writes only the model.</p>
<p><code>connect(input)</code> returns the other keys to write beside the model, by key path, each with its value; it may be <code>async</code>. It is given <code>gateway</code> (<code>url</code>, <code>v1</code> — the URL ending in <code>/v1</code> — and <code>key</code>, the agent’s own key, which counts its requests under its id), <code>model</code> (<code>id</code>, <code>name</code>, <code>context</code>, <code>output</code>, <code>images</code>, <code>efforts</code>), <code>models</code> (every model magpie offers the agent, the same way) and <code>agent</code> (<code>id</code>, <code>config</code>). A plugin without <code>connect</code> writes only the model. It is called again when magpie’s models change, so a list it writes stays current.</p>
<h3>What magpie does with it</h3>
<ul>
<li><b>Writing.</b> Each key is set in place, the user’s comments and other keys kept. Before the first write, what each key held is kept aside, typed (a number stays a number).</li>
+2 -2
View File
@@ -768,7 +768,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to
<tr><td><code>name</code></td><td>页面上显示的名字。不写就用 id。</td></tr>
<tr><td><code>config</code></td><td>magpie 修改的文件。会展开 <code>~</code> 和 <code>$VAR</code>。文件不存在时会新建。</td></tr>
<tr><td><code>format</code></td><td><code>json</code>、<code>yaml</code> 或 <code>env</code>,文件名看不出格式时才需要写(<code>.json</code>/<code>.jsonc</code>、<code>.yaml</code>/<code>.yml</code>、<code>.env</code>)。暂不支持 TOML。</td></tr>
<tr><td><code>model</code></td><td>文件里模型的键,JSON 和 YAML 用点分路径(<code>llm.model</code>)。</td></tr>
<tr><td><code>model</code></td><td>文件里模型的键,JSON 和 YAML 用点分路径(<code>llm.model</code>)。模型在 Agent 自己里面选(从 <code>connect</code> 写入的模型里挑,比如 Raycast)时不写它:这一行就只有连接开关、没有模型选择器,而 <code>connect</code>(这种插件必须有)调用时不带 <code>model</code>。</td></tr>
<tr><td><code>prefix</code></td><td>写在 magpie 模型 id 前面的内容:通过 LiteLLM 访问 OpenAI 兼容接口的 Agent 用 <code>openai/</code>。id 本身是网关接受的 <code>&lt;供应商&gt;/&lt;模型&gt;</code>。</td></tr>
<tr><td><code>bin</code>、<code>dir</code></td><td><code>PATH</code> 上的命令和配置目录,用来判断 Agent 是否已安装。</td></tr>
<tr><td><code>ua</code></td><td>Agent 的 User-Agent 里的词,请求没带它的 key 时,用来在用量里认出它。</td></tr>
@@ -777,7 +777,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to
<tr><td><code>library</code></td><td>Agent 从哪里读<span class="ui">资源库</span>给它的东西:<code>instructions</code>(每次对话前读的 Markdown 文件)、<code>mcp</code>(它的 MCP 服务器文件)和 <code>mcpFormat</code>(这个文件的写法跟哪个 Agent 的一样:<code>alma</code>, <code>antigravity</code>, <code>claude</code>, <code>cline</code>, <code>codex</code>, <code>commandcode</code>, <code>copilot</code>, <code>crush</code>, <code>cursor</code>, <code>devin</code>, <code>gemini</code>, <code>goose</code>, <code>grok</code>, <code>hermes</code>, <code>kimi</code>, <code>omp</code>, <code>opencode</code>, <code>zed</code>;<code>claude</code> 即 <code>{"mcpServers": {…}}</code>),以及 <code>skills</code>(放 <code>SKILL.md</code> 文件夹的目录)。每项都可省略,<code>~</code> 和 <code>$VAR</code> 会展开:<code>library: { instructions: "~/.toy/AGENTS.md", mcp: "~/.toy/mcp.json", mcpFormat: "claude", skills: "~/.toy/skills" }</code>。不写的话,资源库不会给它任何东西,给它某一项时会被拒绝,并说明插件该写哪个键。</td></tr>
</table></div>
<h3>connect</h3>
<p><code>connect(input)</code> 返回要在模型旁边一起写入的其他键,按键路径给出各自的值;可以是 <code>async</code>。它拿到 <code>gateway</code>(<code>url</code>、<code>v1</code>——以 <code>/v1</code> 结尾的地址——和 <code>key</code>,即这个 Agent 自己的 key,请求会按它的 id 计入用量)、<code>model</code>(<code>id</code>、<code>name</code>、<code>context</code>、<code>output</code>、<code>images</code>、<code>efforts</code>)、<code>models</code>(magpie 给这个 Agent 的所有模型,格式相同)和 <code>agent</code>(<code>id</code>、<code>config</code>)。没有 <code>connect</code> 的插件只写模型。</p>
<p><code>connect(input)</code> 返回要在模型旁边一起写入的其他键,按键路径给出各自的值;可以是 <code>async</code>。它拿到 <code>gateway</code>(<code>url</code>、<code>v1</code>——以 <code>/v1</code> 结尾的地址——和 <code>key</code>,即这个 Agent 自己的 key,请求会按它的 id 计入用量)、<code>model</code>(<code>id</code>、<code>name</code>、<code>context</code>、<code>output</code>、<code>images</code>、<code>efforts</code>)、<code>models</code>(magpie 给这个 Agent 的所有模型,格式相同)和 <code>agent</code>(<code>id</code>、<code>config</code>)。没有 <code>connect</code> 的插件只写模型。magpie 的模型有变化时会再调用一次 <code>connect</code>,它写的模型列表因此保持最新。</p>
<h3>magpie 怎么用它</h3>
<ul>
<li><b>写入。</b>每个键原地修改,用户的注释和其他键都保留。第一次写之前,每个键原来的值会按原类型存起来(数字仍是数字)。</li>