{"modulePath":"github.com/enowdev/antares","version":"v0.8.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package plugin\n\nPackage plugin runs external programs at points in the agent's life, so behaviour can be added without rebuilding Antares.\n\nMCP 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.\n\nA 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.\n\n## Variables\n\n```go\nvar AllEvents = []Event{PreToolCall, PostToolCall, SessionStart, SessionEnd, TurnEnd}\n```\nAllEvents is every hook a manifest may name.\n\n## Functions\n\n```go\nfunc IsValidEvent(e Event) bool\n```\nIsValidEvent reports whether e names a hook a manifest may declare. Exported so the dashboard can validate a plugin form before writing it to disk.\n\n## Types\n\n```go\ntype Event string\n```\nEvent names the moment a plugin is being called for.\n\n```go\nconst (\n\t// PreToolCall runs before a tool. The reply may deny it or change its\n\t// arguments.\n\tPreToolCall Event = \"pre_tool_call\"\n\t// PostToolCall runs after one. The reply may replace the result the model\n\t// sees.\n\tPostToolCall Event = \"post_tool_call\"\n\t// SessionStart and SessionEnd bracket a conversation.\n\tSessionStart Event = \"session_start\"\n\tSessionEnd   Event = \"session_end\"\n\t// TurnEnd runs after each completed turn.\n\tTurnEnd Event = \"turn_end\"\n)\n```\n\n```go\ntype Manager struct {\n\t// contains filtered or unexported fields\n}\n```\nManager loads plugins and dispatches events to them.\n\n```go\nfunc NewManager(dirs []string) *Manager\n```\nNewManager builds a manager over the given directories.\n\n```go\nfunc (m *Manager) Count() int\n```\nCount is how many loaded without error.\n\n```go\nfunc (m *Manager) Dispatch(ctx context.Context, p Payload) Reply\n```\nDispatch sends an event to every plugin that asked for it and folds the replies together.\n\nPlugins 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.\n\nA 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.\n\n```go\nfunc (m *Manager) List() []Manifest\n```\nList reports what is loaded.\n\n```go\nfunc (m *Manager) Load() error\n```\nLoad 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.\n\n```go\nfunc (m *Manager) SetEnabled(name string, enabled bool) bool\n```\nSetEnabled turns one plugin on or off for this process.\n\n```go\ntype Manifest struct {\n\tName        string `yaml:\"name\" json:\"name\"`\n\tDescription string `yaml:\"description\" json:\"description\"`\n\tVersion     string `yaml:\"version\" json:\"version\"`\n\t// Command is the executable, relative to the plugin directory unless\n\t// absolute or on PATH.\n\tCommand string   `yaml:\"command\" json:\"command\"`\n\tArgs    []string `yaml:\"args\" json:\"args\"`\n\t// Hooks are the events this plugin wants. An empty list means none, which\n\t// makes the plugin inert rather than universal.\n\tHooks []Event `yaml:\"hooks\" json:\"hooks\"`\n\t// TimeoutMS bounds one call. A plugin that hangs must not hang the agent.\n\tTimeoutMS int               `yaml:\"timeout_ms\" json:\"timeout_ms\"`\n\tEnv       map[string]string `yaml:\"env\" json:\"env\"`\n\n\t// Filled in at load time.\n\tDir     string `yaml:\"-\" json:\"dir\"`\n\tEnabled bool   `yaml:\"-\" json:\"enabled\"`\n\tError   string `yaml:\"-\" json:\"error,omitempty\"`\n}\n```\nManifest is a plugin's plugin.yaml.\n\n```go\ntype Payload struct {\n\tEvent     Event  `json:\"event\"`\n\tSessionID string `json:\"session_id,omitempty\"`\n\tPlatform  string `json:\"platform,omitempty\"`\n\n\t// Tool events.\n\tTool      string `json:\"tool,omitempty\"`\n\tArguments string `json:\"arguments,omitempty\"`\n\tResult    string `json:\"result,omitempty\"`\n\tIsError   bool   `json:\"is_error,omitempty\"`\n\n\t// Turn events.\n\tTurn  int    `json:\"turn,omitempty\"`\n\tReply string `json:\"reply,omitempty\"`\n}\n```\nPayload is what a plugin is handed.\n\n```go\ntype Reply struct {\n\t// Deny refuses a tool call. Reason is shown to the model.\n\tDeny   bool   `json:\"deny,omitempty\"`\n\tReason string `json:\"reason,omitempty\"`\n\t// Arguments replaces the call's arguments when non-empty.\n\tArguments string `json:\"arguments,omitempty\"`\n\t// Result replaces what the model sees from a finished tool.\n\tResult string `json:\"result,omitempty\"`\n\t// Notice is surfaced in the transcript.\n\tNotice string `json:\"notice,omitempty\"`\n}\n```\nReply is what a plugin may answer with. Every field is optional; an empty object means \"no opinion\", which is the common case.\n\n","path":"github.com/enowdev/antares/internal/plugin","name":"plugin","synopsis":"Package plugin runs external programs at points in the agent's life, so behaviour can be added without rebuilding Antares.","isRedistributable":true}
