Help us shape the future of Go! Take the 2026 Go Developer Survey

plugins

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package plugins is hmm's tool library: model-written tools live as subprocesses behind a manifest, are mounted as first-class weft tools via weft.RawTool, and — thanks to weft.ToolSource — a plugin installed mid-run is callable by name in the next step. The process boundary is the security, crash, and compatibility boundary.

Index

Constants

View Source
const (
	RuntimeGo     = "go"     // src/main.go, compiled to bin/<name> at install
	RuntimeSh     = "sh"     // src/run.sh
	RuntimePython = "python" // src/run.py
	RuntimeBinary = "binary" // bin/<name> (scanned libraries only — the

)

Runtimes, and where a plugin's entry point lives for each.

Variables

This section is empty.

Functions

func Tools

func Tools(l *Library, g Gate) []*weft.ToolDef

Tools returns the library-admin tools.

Types

type Gate

type Gate struct {
	Yolo    bool
	Confirm func(question string) bool
}

Gate mirrors the tools package's run_command gate: Yolo skips, nil Confirm (non-TTY) refuses with the reason. Confirm receives the full question — including the plugin's code, because that is the payload the user is approving (standing rule: model-written code is confirmation-gated; the gate must see the code).

type Library

type Library struct {
	Dir string
	// contains filtered or unexported fields
}

Library owns plugins/ under HMM_HOME (tests inject a directory). It is safe for concurrent use: ToolSource reads it on the loop goroutine while install_plugin writes from a tool handler.

func New

func New() (*Library, error)

New returns the library at $HMM_HOME/plugins (legacy $BOBINA_HOME), defaulting to ~/.local/share/hmm/plugins — falling back to the pre-rename ~/.local/share/bobina tree when only that exists, so installed plugins keep mounting.

func NewAt

func NewAt(dir string) *Library

NewAt returns a library rooted at dir without scanning.

func (*Library) Install

func (l *Library) Install(name, description, runtime string, schema json.RawMessage, code string, timeoutMs int, st *Selftest) error

Install writes the plugin, builds Go plugins, runs the selftest, and registers on success. A failing selftest removes the directory: the library is left unchanged. The confirmation gate belongs to the caller (the tool handler) — this function is the post-consent act.

func (*Library) Invoke

func (l *Library) Invoke(ctx context.Context, name string, timeoutMs int, args json.RawMessage) (string, error)

Invoke runs the execution contract: args JSON on stdin, stdout verbatim (capped), stderr to the error tail, non-zero exit is an error result carrying that tail, per-plugin timeout kills the process, and HMM_RUN_ID/CALL_ID/STEP correlate the call.

func (*Library) List

func (l *Library) List() string

List returns the library as model-visible text: names, descriptions, and which were installed this session.

func (*Library) Reserve

func (l *Library) Reserve(names ...string)

Reserve marks names the library must not shadow (hmm's core and admin tools). Called once at agent build.

func (*Library) Scan

func (l *Library) Scan() ([]string, error)

Scan loads plugins/<name>/plugin.json, validating manifests; invalid entries are skipped and reported as warnings (one broken plugin must not take down the CLI — including an unreadable manifest, which demotes to a warning like every other skip). Compile-missing Go plugins are built; staging directories left by killed installs are swept once they are old enough that no live install still owns one.

func (*Library) ToolDefs

func (l *Library) ToolDefs() []*weft.ToolDef

ToolDefs returns every registered plugin as a first-class weft tool: its own name, description, and input schema (weft.RawTool). Called by the ToolSource closure on the loop goroutine — cheap and locked.

type Manifest

type Manifest struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Runtime     string          `json:"runtime"`
	InputSchema json.RawMessage `json:"input_schema,omitempty"`
	TimeoutMs   int             `json:"timeout_ms,omitempty"`
	Selftest    *Selftest       `json:"selftest,omitempty"`
}

Manifest is plugin.json. Additive fields are allowed; readers ignore what they do not know.

type Selftest

type Selftest struct {
	Args           json.RawMessage `json:"args,omitempty"`
	ExpectContains string          `json:"expect_contains,omitempty"`
}

Selftest is the proof a plugin must show before entering the library. Args runs through the execution contract; ExpectContains (optional) must appear in stdout. A missing selftest refuses installation — model-written code never enters the library unverified.

Jump to

Keyboard shortcuts

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