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 ¶
var AllEvents = []Event{PreToolCall, PostToolCall, SessionStart, SessionEnd, TurnEnd}
AllEvents is every hook a manifest may name.
Functions ¶
func IsValidEvent ¶
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 ¶
NewManager builds a manager over the given directories.
func (*Manager) Dispatch ¶
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.
A plugin that fails is still heard out — whatever it managed to print stands on its own. When it left nothing readable behind, PreToolCall refuses the call and every other event carries on without it.
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.