agentplug

package
v0.1.1164 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 13 Imported by: 0

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.

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.

Functions

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.

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"`
}

Desc is what a module's agent export says.

Jump to

Keyboard shortcuts

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