hub

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 4 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 hub holds the types the hub's packages share, so they can be built in parallel.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownTool = errors.New("unknown tool")
	ErrPluginDown  = errors.New("plugin is not running")
)

Functions

This section is empty.

Types

type Audience

type Audience string

Audience says who may see a tool.

const (
	AudienceAssistant Audience = "assistant" // ChatGPT and other assistants
	AudienceAdmin     Audience = "admin"     // the admin UI and the homed CLI only
)

type AuditEntry

type AuditEntry struct {
	At       time.Time
	Caller   Caller
	Tool     string
	Args     json.RawMessage // already redacted
	OK       bool            // false when err != nil or Result.IsError
	Error    string
	Duration time.Duration
}

AuditEntry is one tool call, as stored.

type Auditor

type Auditor interface {
	Record(ctx context.Context, e AuditEntry)
}

Auditor records tool calls; it must not block the call path for long.

type Caller

type Caller struct {
	Person   string // display name, e.g. "Alice"
	PersonID string // the gatekeeper person id; empty for the CLI
	Via      string // "chatgpt", "claude" (the MCP endpoint, by the assistant), "admin" or "cli"
}

Caller says who asked; it goes to the activity log and to the plugin as request _meta (the name and Via only).

type PluginState

type PluginState string

PluginState is the life state of one plugin process.

const (
	PluginStarting PluginState = "starting"
	PluginUp       PluginState = "up"
	PluginFailing  PluginState = "failing"
	PluginStopped  PluginState = "stopped"
)

type PluginStatus

type PluginStatus struct {
	ID        string
	Title     string
	Version   string
	State     PluginState
	LastError string
	Since     time.Time
}

PluginStatus reports one plugin for health checks and the admin.

type Result

type Result struct {
	Text       string          // the plugin's text content, joined with newlines
	Structured json.RawMessage // structuredContent, if any
	IsError    bool            // the tool ran and reported a failure
}

Result is the outcome of a tool that ran.

type Tool

type Tool struct {
	PluginID     string
	Name         string // "<plugin id>_<verb>", unique across the hub
	Title        string
	Description  string
	InputSchema  json.RawMessage // JSON Schema object
	OutputSchema json.RawMessage // optional
	Annotations  json.RawMessage // MCP tool annotations, passed through unchanged; optional
	Audience     Audience
	Inventory    bool          // _meta "homie/role": "inventory"
	Timeout      time.Duration // from _meta "homie/timeout", default 30s, max 300s
	// I18n holds translated texts from _meta "homie/i18n", keyed by language ("ru"). Only the admin UI uses it;
	// assistants always get the English Title and Description. Optional.
	I18n map[string]ToolText
}

Tool is one plugin tool as the hub exposes it.

type ToolHost

type ToolHost interface {
	// Tools returns a snapshot of the tools visible to the audience, sorted by name.
	// AudienceAdmin sees every tool; AudienceAssistant sees only assistant tools.
	Tools(audience Audience) []Tool
	// Call runs a tool. err is non-nil when the call could not be made (ErrUnknownTool, ErrPluginDown,
	// context deadline). A tool that ran and failed returns Result.IsError with a nil err.
	Call(ctx context.Context, caller Caller, name string, args json.RawMessage) (Result, error)
	// Changed returns a channel that is closed at the next change of the tool set.
	Changed() <-chan struct{}
	// Status reports every plugin.
	Status() []PluginStatus
}

ToolHost runs the plugins and calls their tools.

type ToolText

type ToolText struct {
	Title       string
	Description string
	Properties  map[string]string // input property name → label
}

ToolText is a tool's title, description and input labels in one language.

Jump to

Keyboard shortcuts

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