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
- func Tools(l *Library, g Gate) []*weft.ToolDef
- type Gate
- type Library
- func (l *Library) Install(name, description, runtime string, schema json.RawMessage, code string, ...) error
- func (l *Library) Invoke(ctx context.Context, name string, timeoutMs int, args json.RawMessage) (string, error)
- func (l *Library) List() string
- func (l *Library) Reserve(names ...string)
- func (l *Library) Scan() ([]string, error)
- func (l *Library) ToolDefs() []*weft.ToolDef
- type Manifest
- type Selftest
Constants ¶
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 ¶
Types ¶
type Gate ¶
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 ¶
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 (*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 ¶
List returns the library as model-visible text: names, descriptions, and which were installed this session.
func (*Library) Reserve ¶
Reserve marks names the library must not shadow (hmm's core and admin tools). Called once at agent build.
func (*Library) Scan ¶
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.
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.