diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.md index 1bf4464f5..380abd72f 100644 --- a/docs/subsystems/agent-wiring.md +++ b/docs/subsystems/agent-wiring.md @@ -23,7 +23,7 @@ something else shows up as drift. | Named omp profiles | omp keeps a profile's settings under `~/.omp/profiles/` (or under `PI_CONFIG_DIR`), each with its own `config.yml` and `models.yml`. Every such profile is an agent of its own — `omp#` on Windows, `omp#@wsl:` 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, `@wsl:`, edited through `\\wsl.localhost\`. 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..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) | diff --git a/internal/agent/plugged.go b/internal/agent/plugged.go index 633f9aade..b5223ac31 100644 --- a/internal/agent/plugged.go +++ b/internal/agent/plugged.go @@ -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) } diff --git a/internal/agent/plugged_connect_only_test.go b/internal/agent/plugged_connect_only_test.go new file mode 100644 index 000000000..d9ed650e9 --- /dev/null +++ b/internal/agent/plugged_connect_only_test.go @@ -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") + } +} diff --git a/internal/agentplug/agentplug.go b/internal/agentplug/agentplug.go index 9ab85046d..c15bfe2ff 100644 --- a/internal/agentplug/agentplug.go +++ b/internal/agentplug/agentplug.go @@ -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 } diff --git a/site/public/docs/ja/plugins.html b/site/public/docs/ja/plugins.html index e056bcc61..62eb910dd 100644 --- a/site/public/docs/ja/plugins.html +++ b/site/public/docs/ja/plugins.html @@ -768,7 +768,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to nameページでの表示名。省略すると id。 configmagpie が編集するファイル。~ と $VAR は展開されます。なければ作成します。 formatファイル名から分からないときの json、yaml、env(.json/.jsonc、.yaml/.yml、.env)。TOML はまだ対応していません。 - modelファイル内のモデルのキー。JSON と YAML ではドット区切りのパス(llm.model)。 + modelファイル内のモデルのキー。JSON と YAML ではドット区切りのパス(llm.model)。モデルをエージェント自身で、connect が書くモデルの中から選ぶ場合(Raycast など)は省略します。その行は接続スイッチだけになってモデルの選択欄は出ず、connect(このプラグインには必須)は model なしで呼ばれます。 prefixmagpie のモデル id の前に書くもの。LiteLLM 経由で OpenAI 互換エンドポイントを使うエージェントなら openai/。id 自体はゲートウェイが受け付ける <プロバイダー>/<モデル> です。 bin、dirエージェントがインストール済みかを示す PATH 上のコマンドとフォルダー。 uaキーなしで来たリクエストを使用量で名付けるための、エージェントの User-Agent に含まれる語。 @@ -777,7 +777,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to libraryライブラリが渡すものをエージェントがどこで読むか:instructions(毎回の会話の前に読む Markdown ファイル)、mcp(MCP サーバーのファイル)とその書き方を表す mcpFormat(どのエージェントのファイルと同じ形か:alma, antigravity, claude, cline, codex, commandcode, copilot, crush, cursor, devin, gemini, goose, grok, hermes, kimi, omp, opencode, zed。claude は {"mcpServers": {…}})、skills(SKILL.md のフォルダを置くフォルダ)。どれも省略でき、~ と $VAR は展開されます:library: { instructions: "~/.toy/AGENTS.md", mcp: "~/.toy/mcp.json", mcpFormat: "claude", skills: "~/.toy/skills" }。書かなければライブラリからは何も渡されず、渡そうとするとプラグインが書くべきキーを示して断られます。

connect

-

connect(input) はモデルの横に書き込む他のキーを、キーのパスと値で返します。async でも構いません。受け取るのは gateway(url、/v1 で終わる URL の v1、エージェント専用のキー key。リクエストはその id で数えられます)、model(id、name、context、output、images、efforts)、models(magpie がエージェントに出すすべてのモデル、同じ形)、agent(id、config)です。connect がないプラグインはモデルだけを書きます。

+

connect(input) はモデルの横に書き込む他のキーを、キーのパスと値で返します。async でも構いません。受け取るのは gateway(url、/v1 で終わる URL の v1、エージェント専用のキー key。リクエストはその id で数えられます)、model(id、name、context、output、images、efforts)、models(magpie がエージェントに出すすべてのモデル、同じ形)、agent(id、config)です。connect がないプラグインはモデルだけを書きます。magpie のモデルが変わると connect がもう一度呼ばれるので、書いたモデル一覧は最新のまま保たれます。

magpie がすること

  • 書き込み。各キーをその場で書き換え、ユーザーのコメントや他のキーは残します。最初に書く前に、各キーの元の値を型ごと(数値は数値のまま)取っておきます。
  • diff --git a/site/public/docs/plugins.html b/site/public/docs/plugins.html index b9caa74d1..c3d98eb16 100644 --- a/site/public/docs/plugins.html +++ b/site/public/docs/plugins.html @@ -768,7 +768,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to nameWhat the page calls it. The id when left out. configThe file magpie edits. ~ and $VAR are expanded. It is made when it isn’t there. formatjson, yaml or env, when the file’s name doesn’t say it (.json/.jsonc, .yaml/.yml, .env). TOML isn’t supported yet. - modelThe key of the model in the file, as a dotted path for JSON and YAML (llm.model). + modelThe key of the model in the file, as a dotted path for JSON and YAML (llm.model). Leave it out for an agent whose model is picked in the agent itself, among the models connect writes (Raycast): the row is then a switch with no model picker, and connect, which such a plugin must have, is called without model. prefixWritten before magpie’s model id: openai/ for an agent that reaches OpenAI-compatible endpoints through LiteLLM. The id itself is <provider>/<model>, as the gateway takes it. bin, dirThe command on PATH and the folder that say the agent is installed. uaWords of the agent’s User-Agent, to name its requests in Usage when they come without its key. @@ -777,7 +777,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to libraryWhere the agent reads what the Library gives: instructions (a Markdown file it reads before every conversation), mcp (its MCP servers file) with mcpFormat, the agent whose file it is shaped like (alma, antigravity, claude, cline, codex, commandcode, copilot, crush, cursor, devin, gemini, goose, grok, hermes, kimi, omp, opencode, zed; claude is {"mcpServers": {…}}), and skills (a folder of SKILL.md folders). Each is optional, with ~ and $VAR expanded: library: { instructions: "~/.toy/AGENTS.md", mcp: "~/.toy/mcp.json", mcpFormat: "claude", skills: "~/.toy/skills" }. Without it the agent is given nothing from the Library, and giving it an item is refused, naming the key its plugin would set.

    connect

    -

    connect(input) returns the other keys to write beside the model, by key path, each with its value; it may be async. It is given gateway (url, v1 — the URL ending in /v1 — and key, the agent’s own key, which counts its requests under its id), model (id, name, context, output, images, efforts), models (every model magpie offers the agent, the same way) and agent (id, config). A plugin without connect writes only the model.

    +

    connect(input) returns the other keys to write beside the model, by key path, each with its value; it may be async. It is given gateway (url, v1 — the URL ending in /v1 — and key, the agent’s own key, which counts its requests under its id), model (id, name, context, output, images, efforts), models (every model magpie offers the agent, the same way) and agent (id, config). A plugin without connect writes only the model. It is called again when magpie’s models change, so a list it writes stays current.

    What magpie does with it

    • Writing. 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).
    • diff --git a/site/public/docs/zh/plugins.html b/site/public/docs/zh/plugins.html index 061a8e8b1..dfdf0d0e2 100644 --- a/site/public/docs/zh/plugins.html +++ b/site/public/docs/zh/plugins.html @@ -768,7 +768,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to name页面上显示的名字。不写就用 id。 configmagpie 修改的文件。会展开 ~ 和 $VAR。文件不存在时会新建。 formatjson、yaml 或 env,文件名看不出格式时才需要写(.json/.jsonc、.yaml/.yml、.env)。暂不支持 TOML。 - model文件里模型的键,JSON 和 YAML 用点分路径(llm.model)。 + model文件里模型的键,JSON 和 YAML 用点分路径(llm.model)。模型在 Agent 自己里面选(从 connect 写入的模型里挑,比如 Raycast)时不写它:这一行就只有连接开关、没有模型选择器,而 connect(这种插件必须有)调用时不带 model。 prefix写在 magpie 模型 id 前面的内容:通过 LiteLLM 访问 OpenAI 兼容接口的 Agent 用 openai/。id 本身是网关接受的 <供应商>/<模型>。 bin、dirPATH 上的命令和配置目录,用来判断 Agent 是否已安装。 uaAgent 的 User-Agent 里的词,请求没带它的 key 时,用来在用量里认出它。 @@ -777,7 +777,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to libraryAgent 从哪里读资源库给它的东西:instructions(每次对话前读的 Markdown 文件)、mcp(它的 MCP 服务器文件)和 mcpFormat(这个文件的写法跟哪个 Agent 的一样:alma, antigravity, claude, cline, codex, commandcode, copilot, crush, cursor, devin, gemini, goose, grok, hermes, kimi, omp, opencode, zed;claude 即 {"mcpServers": {…}}),以及 skills(放 SKILL.md 文件夹的目录)。每项都可省略,~ 和 $VAR 会展开:library: { instructions: "~/.toy/AGENTS.md", mcp: "~/.toy/mcp.json", mcpFormat: "claude", skills: "~/.toy/skills" }。不写的话,资源库不会给它任何东西,给它某一项时会被拒绝,并说明插件该写哪个键。

      connect

      -

      connect(input) 返回要在模型旁边一起写入的其他键,按键路径给出各自的值;可以是 async。它拿到 gateway(url、v1——以 /v1 结尾的地址——和 key,即这个 Agent 自己的 key,请求会按它的 id 计入用量)、model(id、name、context、output、images、efforts)、models(magpie 给这个 Agent 的所有模型,格式相同)和 agent(id、config)。没有 connect 的插件只写模型。

      +

      connect(input) 返回要在模型旁边一起写入的其他键,按键路径给出各自的值;可以是 async。它拿到 gateway(url、v1——以 /v1 结尾的地址——和 key,即这个 Agent 自己的 key,请求会按它的 id 计入用量)、model(id、name、context、output、images、efforts)、models(magpie 给这个 Agent 的所有模型,格式相同)和 agent(id、config)。没有 connect 的插件只写模型。magpie 的模型有变化时会再调用一次 connect,它写的模型列表因此保持最新。

      magpie 怎么用它

      • 写入。每个键原地修改,用户的注释和其他键都保留。第一次写之前,每个键原来的值会按原类型存起来(数字仍是数字)。