plugins

package
v0.107.42 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlacementSidePane = "sidePane"
	PlacementSettings = "settings"
	// MaxPanels bounds the panels one plugin may declare.
	MaxPanels = 8
	// DefaultUIRoot is UI.Root when the manifest leaves it empty.
	DefaultUIRoot = "ui"
)

Variables

This section is empty.

Functions

func CleanRelativePath added in v0.107.42

func CleanRelativePath(p string) bool

CleanRelativePath reports whether p is a slash-separated relative path whose segments are all ordinary names: no empty, "." or ".." segments, no dot files, backslashes, colons or control characters. Such a path can only name something below the directory it is resolved against.

func Dirs

func Dirs(project string) []string

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func New

func New(project string) (*Manager, error)

func (*Manager) Get added in v0.107.42

func (m *Manager) Get(name string) (Plugin, bool)

Get returns the loaded plugin called name.

func (*Manager) Hook

func (m *Manager) Hook(ctx context.Context, event string, payload any, policy *sandbox.Policy) error

func (*Manager) Install

func (m *Manager) Install(src string) error

func (*Manager) Invoke

func (m *Manager) Invoke(ctx context.Context, name string, args json.RawMessage, policy *sandbox.Policy) (string, error)

func (*Manager) List

func (m *Manager) List() []Plugin

func (*Manager) Platform

func (m *Manager) Platform() string

func (*Manager) Project added in v0.107.42

func (m *Manager) Project() string

Project is the workspace whose plugins this manager loads; empty when it loads user plugins only.

func (*Manager) PromptBlock

func (m *Manager) PromptBlock() string

func (*Manager) Reload

func (m *Manager) Reload() error

Reload rescans the plugin directories and rereads the saved enabled state.

func (*Manager) Remove

func (m *Manager) Remove(name string) error

func (*Manager) RunHook

func (m *Manager) RunHook(ctx context.Context, event hooks.Event) error

func (*Manager) SetEnabled

func (m *Manager) SetEnabled(name string, enabled bool) error

SetEnabled saves name's enabled state on top of the state saved meanwhile by other managers or processes.

func (*Manager) Source added in v0.107.42

func (m *Manager) Source(p Plugin) string

Source reports where p was found: "workspace" for the project's plugin directory, "user" for the user's.

func (*Manager) Tools

func (m *Manager) Tools() []Tool

type Manifest

type Manifest struct {
	Name        string            `json:"name"`
	Version     string            `json:"version,omitempty"`
	Description string            `json:"description,omitempty"`
	Prompt      string            `json:"prompt,omitempty"`
	Command     []string          `json:"command,omitempty"`
	Tools       []Tool            `json:"tools,omitempty"`
	Hooks       map[string]string `json:"hooks,omitempty"`
	Enabled     *bool             `json:"enabled,omitempty"`
	// UI declares static web panels a graphical client may show. They are
	// plain files under the plugin directory, served read-only and rendered in
	// a sandboxed frame; nothing in them runs in K-brain itself.
	UI *UI `json:"ui,omitempty"`
}

func (Manifest) UIRoot added in v0.107.42

func (m Manifest) UIRoot() string

UIRoot is the plugin's UI directory relative to its directory.

type Panel added in v0.107.42

type Panel struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	// Entry is the panel's HTML page, relative to Root.
	Entry string `json:"entry"`
	// Placement says where a client shows the panel: PlacementSidePane or
	// PlacementSettings.
	Placement string `json:"placement"`
}

Panel is one UI panel.

type Plugin

type Plugin struct {
	Manifest
	Dir     string
	Enabled bool
	Err     error
}

func Load

func Load(dir string) (Plugin, error)

type Tool

type Tool struct {
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	InputSchema json.RawMessage `json:"inputSchema,omitempty"`
}

type UI added in v0.107.42

type UI struct {
	// Root is the directory, relative to the plugin directory, that holds
	// every file a panel may load; "ui" when empty. Nothing outside it is
	// served.
	Root   string  `json:"root,omitempty"`
	Panels []Panel `json:"panels"`
}

UI is the "ui" section of plugin.json.

Jump to

Keyboard shortcuts

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