agentplug

package
v0.1.4684 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentplug runs the agents plugins add: a module, named by a plugin's package.json magpie.agent, that says where an agent magpie has no wiring of its own keeps its model, and what else to write there for it to use magpie's gateway. internal/agent makes each one an Agent.

A module exports

export const agent = {
  id: "aider", name: "Aider",
  config: "~/.aider.conf.yml", // the file magpie edits
  model: "model",              // the key path of the model in it
  prefix: "openai/",           // what the agent wants before the id
}
export function connect({ gateway, model, models }) {
  return { "openai-api-base": gateway.v1, "openai-api-key": gateway.key }
}

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. connect's input also has decisionModels, magpie's decision models and their routing groups, which models (chat models) leaves out, each with the gateway paths it is asked on (internal/agent's pluggedDecisionModels).

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).

An agent that keeps the model a new session starts on in a file apart from the one connect writes (PiG: the provider and its models in models.json, defaultProvider and defaultModel in settings.json) says so with startup, and model stays out: the row picks the model, written into startup's file with startup's keys beside it, and connect writes the rest into config. A magpie without startup reads the same module as connect only, so a plugin can say it to every magpie.

startup: {
  config: "~/.pig/agent/settings.json",
  model: "defaultModel",
  keys: { defaultProvider: "magpie" },
}

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.

library: {
  instructions: "~/.aider/AGENTS.md",
  mcp: "~/.aider/mcp.json", mcpFormat: "claude",
  skills: "~/.aider/skills",
}

An agent that takes the gateway only from how it is started (agy reads GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL from its environment, and resolves a model only given on its command line) says so with launch, beside model and bin. While it is on one of magpie's models its row gives the command, and magpie puts a function named bin in the user's shells that runs `magpie <id> run`: the agent started with env, each {url}, {v1} and {key} the gateway's, and the model after launch.model's flag (none when the user gives that flag).

launch: {
  env: { GEMINI_API_KEY: "{key}", GOOGLE_GEMINI_BASE_URL: "{url}" },
  model: "--model",
}

merge names keys whose object connect returns only magpie's members of: each member is written on its own beside the user's, and taken out again when magpie steps out (agy's customModelsConfig.customModels). effort: true gives its row a field for how hard magpie's models reason, which the gateway asks its requests for (an agent with no setting of its own for it). wsl: true, for an agent that takes a built-in's place (magpie's agentMovers), has it wired in WSL distros too where the built-in was; aliases are other names it is typed as.

An agent that reads a settings file of magpie's own only when it is so started (agy's --settings) names it as config, the flag that hands it over in launch.args, and its own settings file as base: magpie writes only config, which it removes when magpie steps out, and the user's own model goes in base. connect's input and own's have base, parsed, so connect can carry the user's own entries over (agy takes customModels whole from the --settings file). launch.plain are the arguments that start it as it is (agy's remote-control, which needs its Google sign-in).

config: "~/.gemini/antigravity-cli/magpie-settings.json",
base: "~/.gemini/antigravity-cli/settings.json",
launch: { env: {…}, model: "--model", args: { "--settings": "{config}" }, plain: ["remote-control", "--remote-control"] },

A module may also export own({ config, base, model }), given its config file (and base) as parsed JSON ({} for none) and the model it is on now, returning the agent's own models for its picker, each { value, model, direct }: the value written, the model's name for its picture, and the vendor it goes to without magpie.

Index

Constants

This section is empty.

Variables

View Source
var Formats = map[string]string{
	".json": "json", ".jsonc": "json",
	".yaml": "yaml", ".yml": "yaml",
	".env": "env",
}

Formats are the config files an agent plugin's file may be, by the name its agent.format gives or its extension says.

View Source
var MCPFormats = []string{
	"alma", "antigravity", "claude", "cline", "codex", "commandcode", "copilot",
	"crush", "cursor", "devin", "gemini", "goose", "grok", "hermes", "kimi",
	"omp", "opencode", "zed",
}

MCPFormats are the MCP files an agent plugin's agent may keep, each named for the agent whose file it is written as: "claude" is {"mcpServers": {name: {type, command, args, env, url, headers}}}.

Functions

func Fill

func Fill(v, url, v1, key string) string

Fill is v with {url}, {v1} and {key} as given.

func FormatOf added in v0.1.1668

func FormatOf(config string) string

FormatOf is the format a config file's name says it is in, "" for one it doesn't say.

func Reload

func Reload()

Reload drops the agents loaded, so the next List loads them again.

Types

type Agent

type Agent struct {
	Spec string // the plugin's spec in plugins.json
	File string
	Desc Desc
	// contains filtered or unexported fields
}

Agent is one plugin's agent, compiled.

func Compile

func Compile(spec, file string) (*Agent, error)

Compile compiles the agent module in file, of the plugin spec, and checks what its agent export says.

func List

func List() ([]*Agent, map[string]string)

List is the agents the plugins switched on add, in plugins.json's order, and why any didn't load, by plugin spec. It is loaded again when plugins.json or a module's file changed, which is looked at once a second.

func (*Agent) Connect

func (a *Agent) Connect(in map[string]any) (map[string]any, error)

Connect is what the module's connect returns for in: the keys to write beside the model, by key path. A module without connect writes none.

func (*Agent) HasOwn

func (a *Agent) HasOwn() bool

HasOwn says the module exports own.

func (*Agent) OwnModels

func (a *Agent) OwnModels(config, base any, model string) ([]Own, error)

OwnModels is what the module's own gives for config, the agent's file as parsed JSON, base, its own settings file so (agent.base; nil for none), and model, the one it is on now; none for a module without it.

type Desc

type Desc struct {
	ID     string   `json:"id"`
	Name   string   `json:"name"`
	Config string   `json:"config"`
	Format string   `json:"format"`
	Model  string   `json:"model"`
	Prefix string   `json:"prefix"`
	Bin    string   `json:"bin"`
	Dir    string   `json:"dir"`
	UA     []string `json:"ua"`
	Icon   string   `json:"icon"`
	// Notice is advice shown after a change, as a built-in agent's is
	// (an agent that reads its config at start-up needs a restart)
	Notice string `json:"notice"`
	// Library is where the agent reads the Library's instructions, MCP
	// servers and skills
	Library Places `json:"library"`
	// Startup is the file and key of the model a new session starts on,
	// for an agent that keeps it apart from config; nil for one that
	// keeps it in config (Model) or picks it itself
	Startup *Startup `json:"startup"`
	// Base is the agent's own settings file, for one whose config is a
	// file of magpie's alone (launch.args names it): the user's model is
	// there off magpie, and connect and own are given it as base; magpie
	// never writes it but for the user's own model picked in its row
	Base string `json:"base"`
	// Launch is how the agent is started on magpie, for one that takes the
	// gateway only from its environment and command line; nil for one its
	// config file connects
	Launch *Launch `json:"launch"`
	// Merge are key paths whose object connect returns magpie's members
	// of, each written beside the user's own (json only)
	Merge []string `json:"merge"`
	// Effort gives the agent's row magpie's effort field
	Effort bool `json:"effort"`
	// WSL has the agent in WSL distros too
	WSL bool `json:"wsl"`
	// Aliases are other names the agent is typed as
	Aliases []string `json:"aliases"`
}

Desc is what a module's agent export says.

type Launch

type Launch struct {
	Env   map[string]string `json:"env"`
	Model string            `json:"model"`
	// Args are flags put before the user's arguments, each with its value
	// "{config}", the path of agent.config: agy's --settings, for a config
	// that is magpie's own file the agent reads only when so started
	Args map[string]string `json:"args"`
	// Plain are arguments (a subcommand or a flag, alone or with
	// "=value") with which the agent starts as it is, off magpie: agy's
	// remote-control, which needs its own sign-in
	Plain []string `json:"plain"`
}

Launch is the environment an agent is started with, by variable, each value {key}, {url} or {v1} (the gateway's), or a path under the address, and Model the flag that names its model on the command line ("" for none).

type Own

type Own struct {
	Value  string `json:"value"`
	Model  string `json:"model"`
	Direct string `json:"direct"`
}

Own is one of an agent's own models, as own() gives it.

type Places added in v0.1.1177

type Places struct {
	Instructions string `json:"instructions"`
	MCP          string `json:"mcp"`
	// MCPFormat is how its MCP file lists servers: one of MCPFormats
	MCPFormat string `json:"mcpFormat"`
	Skills    string `json:"skills"`
}

Places are where an agent reads what the Library gives it, each a path as Config is (~ and $VAR expanded); an empty one is a thing it isn't given.

type Startup added in v0.1.3008

type Startup struct {
	Config string         `json:"config"`
	Format string         `json:"format"`
	Model  string         `json:"model"`
	Keys   map[string]any `json:"keys"`
}

Startup is where an agent keeps the model it starts on, apart from the file connect writes: Config and Format as Desc's are, Model the key path of the model in it, and Keys what is written beside it, as it is (PiG's defaultProvider, the provider id its connect writes).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL