plugin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 14 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 plugin runs external programs at points in the agent's life, so behaviour can be added without rebuilding Antares.

MCP already covers adding tools, and does it better than a bespoke protocol would. What it does not cover is watching and gating what the agent does: refusing a tool call by policy, rewriting a result, logging every turn to something of your own. That is what a hook is for.

A plugin is a directory with a manifest and an executable. The executable is handed one JSON event on stdin and answers with one JSON object on stdout. Any language that can read a pipe can write one.

Index

Constants

This section is empty.

Variables

AllEvents is every hook a manifest may name.

Functions

func IsValidEvent

func IsValidEvent(e Event) bool

IsValidEvent reports whether e names a hook a manifest may declare. Exported so the dashboard can validate a plugin form before writing it to disk.

Types

type Event

type Event string

Event names the moment a plugin is being called for.

const (
	// PreToolCall runs before a tool. The reply may deny it or change its
	// arguments.
	PreToolCall Event = "pre_tool_call"
	// PostToolCall runs after one. The reply may replace the result the model
	// sees.
	PostToolCall Event = "post_tool_call"
	// SessionStart and SessionEnd bracket a conversation.
	SessionStart Event = "session_start"
	SessionEnd   Event = "session_end"
	// TurnEnd runs after each completed turn.
	TurnEnd Event = "turn_end"
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager loads plugins and dispatches events to them.

func NewManager

func NewManager(dirs []string) *Manager

NewManager builds a manager over the given directories.

func (*Manager) Count

func (m *Manager) Count() int

Count is how many loaded without error.

func (*Manager) Dispatch

func (m *Manager) Dispatch(ctx context.Context, p Payload) Reply

Dispatch sends an event to every plugin that asked for it and folds the replies together.

Plugins run in order, each seeing the previous one's changes. A deny from any of them ends it: a refusal is not something a later plugin should be able to quietly undo.

func (*Manager) List

func (m *Manager) List() []Manifest

List reports what is loaded.

func (*Manager) Load

func (m *Manager) Load() error

Load rescans every directory. A plugin that cannot be loaded is kept in the list with its error, so the dashboard can say what is wrong rather than the plugin silently not existing.

func (*Manager) SetEnabled

func (m *Manager) SetEnabled(name string, enabled bool) bool

SetEnabled turns one plugin on or off for this process.

type Manifest

type Manifest struct {
	Name        string `yaml:"name" json:"name"`
	Description string `yaml:"description" json:"description"`
	Version     string `yaml:"version" json:"version"`
	// Command is the executable, relative to the plugin directory unless
	// absolute or on PATH.
	Command string   `yaml:"command" json:"command"`
	Args    []string `yaml:"args" json:"args"`
	// Hooks are the events this plugin wants. An empty list means none, which
	// makes the plugin inert rather than universal.
	Hooks []Event `yaml:"hooks" json:"hooks"`
	// TimeoutMS bounds one call. A plugin that hangs must not hang the agent.
	TimeoutMS int               `yaml:"timeout_ms" json:"timeout_ms"`
	Env       map[string]string `yaml:"env" json:"env"`

	// Filled in at load time.
	Dir     string `yaml:"-" json:"dir"`
	Enabled bool   `yaml:"-" json:"enabled"`
	Error   string `yaml:"-" json:"error,omitempty"`
}

Manifest is a plugin's plugin.yaml.

type Payload

type Payload struct {
	Event     Event  `json:"event"`
	SessionID string `json:"session_id,omitempty"`
	Platform  string `json:"platform,omitempty"`

	// Tool events.
	Tool      string `json:"tool,omitempty"`
	Arguments string `json:"arguments,omitempty"`
	Result    string `json:"result,omitempty"`
	IsError   bool   `json:"is_error,omitempty"`

	// Turn events.
	Turn  int    `json:"turn,omitempty"`
	Reply string `json:"reply,omitempty"`
}

Payload is what a plugin is handed.

type Reply

type Reply struct {
	// Deny refuses a tool call. Reason is shown to the model.
	Deny   bool   `json:"deny,omitempty"`
	Reason string `json:"reason,omitempty"`
	// Arguments replaces the call's arguments when non-empty.
	Arguments string `json:"arguments,omitempty"`
	// Result replaces what the model sees from a finished tool.
	Result string `json:"result,omitempty"`
	// Notice is surfaced in the transcript.
	Notice string `json:"notice,omitempty"`
}

Reply is what a plugin may answer with. Every field is optional; an empty object means "no opinion", which is the common case.

Jump to

Keyboard shortcuts

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