pluginhost

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCatalogBundledSkillSpecs

func DefaultCatalogBundledSkillSpecs() ([]pkgplugins.BundledSkillSpec, error)

DefaultCatalogBundledSkillSpecs loads the default plugin catalog into a throw-away host and returns all registered bundled skill specs, sorted by skill name then plugin ID.

func NewAuthService

func NewAuthService(store pluginAuthStore) pkgplugins.Auth

func NewScopedStateStore added in v0.38.0

func NewScopedStateStore(store StateStoreBackend, pluginID string) pkgplugins.StateStore

NewScopedStateStore wraps a StateStoreBackend as a pkgplugins.StateStore whose calls are namespaced to the given pluginID. Used by gateway wiring for built-in subsystems (e.g. reflect) that need a state store but don't run inside the plugin runtime.

func NewSkillStoreAdapter

func NewSkillStoreAdapter(s skills.Store) pkgplugins.SkillStore

NewSkillStoreAdapter wraps an internal/skills.Store as a pkgplugins.SkillStore. Exported so that test code and CLI code can construct a typed adapter without depending on the unexported adapter type.

Types

type ChannelPlatform

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

ChannelPlatform is a mutable host extension bag for managed channel runtimes.

func NewChannelRuntimeServices

func NewChannelRuntimeServices() *ChannelPlatform

func (*ChannelPlatform) Handler

func (s *ChannelPlatform) Handler() pkgchannel.Handler

func (*ChannelPlatform) Notifications

func (s *ChannelPlatform) Notifications() pkgplugins.ChannelRegistry

func (*ChannelPlatform) ParentContext

func (s *ChannelPlatform) ParentContext() context.Context

func (*ChannelPlatform) Set

func (s *ChannelPlatform) Set(parent context.Context, handler pkgchannel.Handler, notifications pkgplugins.ChannelRegistry)

type ConfigBackend

type ConfigBackend interface {
	Get(ctx context.Context, pluginID string) (pkgplugins.PluginState, error)
	Set(ctx context.Context, pluginID string, config map[string]any) error
	SetEnabled(ctx context.Context, pluginID string, enabled bool) error
}

ConfigBackend is the host-owned unscoped plugin config backend.

type Host

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

func New

func New(store config.Store, opts ...Option) *Host

func (*Host) AddAdmin

func (h *Host) AddAdmin(reg pkgplugins.AdminSpec)

func (*Host) AddAfterToolResult

func (h *Host) AddAfterToolResult(reg pkgplugins.AfterToolResultSpec)

func (*Host) AddBeforeRun

func (h *Host) AddBeforeRun(reg pkgplugins.BeforeRunSpec)

func (*Host) AddBeforeToolCall

func (h *Host) AddBeforeToolCall(reg pkgplugins.BeforeToolCallSpec)

func (*Host) AddBundledSkill

func (h *Host) AddBundledSkill(spec pkgplugins.BundledSkillSpec)

func (*Host) AddChannel

func (h *Host) AddChannel(reg pkgplugins.ChannelSpec)

func (*Host) AddHook

func (h *Host) AddHook(reg pkgplugins.HookSpec)

func (*Host) AddPromptInventory

func (h *Host) AddPromptInventory(reg pkgplugins.PromptInventorySpec)

func (*Host) AddProvider

func (h *Host) AddProvider(reg pkgplugins.ProviderSpec)

func (*Host) AddRuntime

func (h *Host) AddRuntime(reg pkgplugins.RuntimeSpec)

func (*Host) AddSessionEnv

func (h *Host) AddSessionEnv(spec pkgplugins.SessionEnvSpec)

func (*Host) AddSystemPrompt

func (h *Host) AddSystemPrompt(reg pkgplugins.SystemPromptSpec)

func (*Host) AddTool

func (h *Host) AddTool(reg pkgplugins.ToolSpec)

func (*Host) AfterToolResult

func (*Host) AllBundledSkillSpecs

func (h *Host) AllBundledSkillSpecs() []pkgplugins.BundledSkillSpec

func (*Host) AllSessionEnvSpecs

func (h *Host) AllSessionEnvSpecs() []pkgplugins.SessionEnvSpec

func (*Host) ApplyChannel

func (h *Host) ApplyChannel(ctx context.Context, channel config.Channel) error

func (*Host) ApplyPlugin

func (h *Host) ApplyPlugin(ctx context.Context, pluginID string) error

func (*Host) Auth

func (h *Host) Auth() pkgplugins.Auth

Auth returns the injected auth service, if any.

func (*Host) BeforeRun

func (*Host) BuildEnabledHooks

func (h *Host) BuildEnabledHooks(ctx context.Context, bc pluginhooks.BuildContext) []hooks.HookPlugin

func (*Host) BuildEnabledTools

func (h *Host) BuildEnabledTools(ctx context.Context, bc pkgplugins.ToolBuildContext) []tools.Tool

func (*Host) BuildProvider

func (h *Host) BuildProvider(name string, stateConfig map[string]any) (providers.ProviderAdapter, error)

func (*Host) BuildStreamFunc added in v0.28.0

func (h *Host) BuildStreamFunc(name string, stateConfig map[string]any) (providers.StreamFunc, error)

func (*Host) BundledSkillSpecs

func (h *Host) BundledSkillSpecs(pluginID string) []pkgplugins.BundledSkillSpec

func (*Host) ChannelConfigured

func (h *Host) ChannelConfigured(ctx context.Context, name string) bool

func (*Host) ChannelInstanceConfigured

func (h *Host) ChannelInstanceConfigured(channel config.Channel) bool

func (*Host) ChannelRuntime

func (h *Host) ChannelRuntime() pkgplugins.ChannelPlatform

ChannelRuntime returns the injected channel runtime service extension, if any.

func (*Host) Config

func (h *Host) Config() ConfigBackend

func (*Host) ConfigSchema

func (h *Host) ConfigSchema(pluginID string) map[string]any

func (*Host) DecodeWebhookRunConfig added in v0.60.0

func (h *Host) DecodeWebhookRunConfig(cfg map[string]any) (WebhookRunConfig, error)

DecodeWebhookRunConfig decodes a webhook channel config map into the behaviour-only view consumed by the webhook ingress handler. The plugin owns the decode + default-resolution rules; the transport receives only the resolved values.

func (*Host) DesiredState

func (h *Host) DesiredState(ctx context.Context, pluginID string) (pkgplugins.PluginState, error)

func (*Host) EnabledToolSpecs added in v0.60.0

func (h *Host) EnabledToolSpecs(ctx context.Context) []pkgplugins.ToolSpec

EnabledToolSpecs returns metadata for plugin tools that are visible in the current server state. It does not build tools or touch runtime sandboxes.

func (*Host) HasConfig

func (h *Host) HasConfig(pluginID string) bool

func (*Host) HasRuntime

func (h *Host) HasRuntime(pluginID string) bool

func (*Host) HasStatus

func (h *Host) HasStatus(pluginID string) bool

func (*Host) IsConfigurable added in v0.38.0

func (h *Host) IsConfigurable(pluginID string) bool

IsConfigurable reports whether the plugin has an admin config schema registered. Used by the admin API to reject writes to plugin IDs that no longer exist in code (orphan plugin rows from old installs) or to typo'd IDs, instead of silently accepting them.

func (*Host) ListAdminVisiblePlugins

func (h *Host) ListAdminVisiblePlugins(ctx context.Context) ([]pkgplugins.RegisteredPlugin, error)

func (*Host) ListChannels

func (h *Host) ListChannels(ctx context.Context) ([]config.Channel, error)

func (*Host) ListProviderTypes

func (h *Host) ListProviderTypes() []ProviderType

func (*Host) ListRegisteredPlugins

func (h *Host) ListRegisteredPlugins() []pkgplugins.PluginInfo

func (*Host) LoadCatalog

func (h *Host) LoadCatalog(catalog *pkgplugins.Catalog) error

func (*Host) LoadDefaultCatalog

func (h *Host) LoadDefaultCatalog() error

func (*Host) Logger

func (h *Host) Logger(pluginID string) *slog.Logger

func (*Host) ManagedPlugins

func (h *Host) ManagedPlugins() []string

func (*Host) ManifestPluginPrompts

func (h *Host) ManifestPluginPrompts() []pkgplugins.SystemPromptSection

func (*Host) Notifications

func (h *Host) Notifications() pkgplugins.Notifier

Notifications returns the injected notification service, if any.

func (*Host) PluginsByKind

func (h *Host) PluginsByKind(kind string) []string

func (*Host) PromptTools

func (h *Host) PromptTools(ctx context.Context, pluginID string) ([]pkgplugins.PromptToolInfo, error)

func (*Host) Quiesce added in v0.60.0

func (h *Host) Quiesce(ctx context.Context)

Quiesce halts new ingress on managed runtimes (channel pollers) for a graceful drain while preserving already-accepted operations and notifier senders. The runtime table is left intact so a later Stop can fully tear them down.

func (*Host) RedactConfig

func (h *Host) RedactConfig(pluginID string, raw map[string]any) map[string]any

func (*Host) RegisterManifestPlugins

func (h *Host) RegisterManifestPlugins(m *manifestplugins.Manifest)

RegisterManifestPlugins registers plugins declared in a manifest. For each enabled plugin:

  • New plugins (not already Go-registered) are fully registered with ID, info, and session envs.
  • Existing plugins (already Go-registered) get manifest session envs registered so the manifest is the single source of truth for env injection. Go code should no longer call AddSessionEnv for manifest-declared env vars.

func (*Host) RegisterPluginID

func (h *Host) RegisterPluginID(id string)

func (*Host) Runtime

func (h *Host) Runtime() pkgplugins.RuntimeLookup

func (*Host) Scheduler

func (h *Host) Scheduler() SchedulerBackend

Scheduler returns the injected scheduler backend, if any.

func (*Host) Seal added in v0.60.0

func (h *Host) Seal() error

Seal validates every static registration and capability binding, then marks the host sealed so no further static composition can occur. Missing capability registrations fail here; duplicate static registrations already fail eagerly at registration time (registerUnique). After Seal, LoadCatalog and the Set* capability binders refuse late changes, while the dynamic desired-state surface (ApplyPlugin/ApplyChannel/SetEnabled/RegisterManifestPlugins/Stop) remains available. Seal is one-shot.

func (*Host) SessionEnvSpecs

func (h *Host) SessionEnvSpecs(pluginID string) []pkgplugins.SessionEnvSpec

func (*Host) SessionPluginView

func (h *Host) SessionPluginView(ctx context.Context) (pkgplugins.SessionPluginView, error)

SessionPluginView returns the enabled plugin-owned session env setup used by runner sessions plus the registered/enabled plugin IDs prompt builders may need for visibility-aware output.

func (*Host) SetAuthService

func (h *Host) SetAuthService(service pkgplugins.Auth)

SetAuthService updates the auth service extension after host construction.

func (*Host) SetChannelRuntimeServices

func (h *Host) SetChannelRuntimeServices(services pkgplugins.ChannelPlatform)

SetChannelRuntimeServices updates the channel runtime service extension after host construction.

func (*Host) SetEnabled

func (h *Host) SetEnabled(ctx context.Context, pluginID string, enabled bool) error

func (*Host) SetInfo

func (h *Host) SetInfo(info pkgplugins.PluginInfo)

func (*Host) SetNotificationService

func (h *Host) SetNotificationService(service pkgplugins.Notifier)

SetNotificationService updates the notification service extension after host construction.

func (*Host) SetSchedulerService

func (h *Host) SetSchedulerService(service SchedulerBackend)

SetSchedulerService updates the scheduler backend after host construction.

func (*Host) SetSkillStore

func (h *Host) SetSkillStore(store skills.Store)

SetSkillStore updates the skill store after host construction.

func (*Host) SetStateStore

func (h *Host) SetStateStore(store StateStoreBackend)

SetStateStore updates the plugin state backend after host construction.

func (*Host) SkillStore

func (h *Host) SkillStore() skills.Store

SkillStore returns the injected skill store, if any.

func (*Host) StateStore

func (h *Host) StateStore() StateStoreBackend

StateStore returns the injected plugin state backend, if any.

func (*Host) Status

func (h *Host) Status(ctx context.Context, pluginID string) (any, error)

func (*Host) Stop

func (h *Host) Stop(ctx context.Context) error

func (*Host) SystemPromptSections

func (h *Host) SystemPromptSections(ctx context.Context, build pkgplugins.SystemPromptContext) ([]pkgplugins.SystemPromptSection, error)

func (*Host) ValidateConfig

func (h *Host) ValidateConfig(pluginID string, raw map[string]any) error

func (*Host) ValidateRegistrations

func (h *Host) ValidateRegistrations() error

type Option

type Option func(*Host)

func WithAuthService

func WithAuthService(service pkgplugins.Auth) Option

WithAuthService injects the narrow auth directory available to plugins.

func WithChannelRuntimeServices

func WithChannelRuntimeServices(services pkgplugins.ChannelPlatform) Option

WithChannelRuntimeServices injects the narrow services used by managed channel runtimes.

func WithNotificationService

func WithNotificationService(service pkgplugins.Notifier) Option

WithNotificationService injects the narrow notification service available to plugins.

func WithSchedulerService

func WithSchedulerService(service SchedulerBackend) Option

WithSchedulerService injects the host scheduler backend available to plugins.

func WithSkillStore

func WithSkillStore(store skills.Store) Option

WithSkillStore injects the skill store available to plugins.

func WithStateStore

func WithStateStore(store StateStoreBackend) Option

WithStateStore injects the host plugin state backend available to plugins.

type ProviderType

type ProviderType struct {
	ID         string
	Name       string
	DefaultURL string
}

type RuntimeHost

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

RuntimeHost owns the map of managed runtime instances.

func NewRuntimeHost

func NewRuntimeHost(host *Host) *RuntimeHost

func (*RuntimeHost) ApplyChannel

func (h *RuntimeHost) ApplyChannel(ctx context.Context, channel config.Channel) error

func (*RuntimeHost) ApplyPlugin

func (h *RuntimeHost) ApplyPlugin(ctx context.Context, pluginID string) error

func (*RuntimeHost) Get

func (h *RuntimeHost) Get(_ context.Context, runtimeID string, runtimeName string) (pkgplugins.RuntimeHandle, bool)

Get resolves a managed runtime.

func (*RuntimeHost) Lookup

func (h *RuntimeHost) Lookup(ctx context.Context, runtimeID string, runtimeName string) (pkgplugins.RuntimeHandle, bool)

Lookup is an alias for Get to match the pkgplugins.RuntimeLookup interface.

func (*RuntimeHost) Quiesce added in v0.60.0

func (h *RuntimeHost) Quiesce(ctx context.Context)

Quiesce invokes the optional ingress-quiescer on every managed runtime that implements it, without clearing the runtime table: the subsequent Stop still needs the entries to tear them down fully. This is the drain-phase counterpart to Stop — it halts new ingress while preserving accepted work.

func (*RuntimeHost) Snapshot

func (h *RuntimeHost) Snapshot(ctx context.Context, runtimeID string, runtimeName string) (pkgplugins.RuntimeStatus, error)

func (*RuntimeHost) Stop

func (h *RuntimeHost) Stop(ctx context.Context) error

Stop tears down every managed runtime permanently. It prevents any later Apply, which keeps a graceful drain from admitting new ingress. Entries are removed before Stop is called so no lock is held while runtime teardown runs.

type SchedulerBackend

type SchedulerBackend interface {
	ReconcilePluginJobs(ctx context.Context, pluginID string, jobs []pkgplugins.SchedulerJobSpec) error
	DeletePluginJobs(ctx context.Context, pluginID string) error
	DeletePluginJob(ctx context.Context, pluginID string, key string) error
	ListPluginJobs(ctx context.Context, pluginID string) ([]pkgplugins.SchedulerJob, error)
}

SchedulerBackend is the host-owned unscoped scheduler backend.

type StateStoreBackend

type StateStoreBackend interface {
	Get(ctx context.Context, pluginID string, scope pkgplugins.StateScope, key string) (map[string]any, bool, error)
	Set(ctx context.Context, pluginID string, scope pkgplugins.StateScope, key string, value map[string]any) error
	Delete(ctx context.Context, pluginID string, scope pkgplugins.StateScope, key string) error
}

StateStoreBackend is the host-owned unscoped plugin state backend.

type WebhookRunConfig added in v0.60.0

type WebhookRunConfig struct {
	// DefaultWait selects synchronous (true) vs. fire-and-forget (false) when a
	// request does not set the ?wait query parameter.
	DefaultWait bool
	// Persistent reports whether triggers accumulate into one stable session.
	Persistent bool
	// MaxRunTimeoutSeconds is the effective hard ceiling on the agent run.
	MaxRunTimeoutSeconds int
	// WaitTimeoutSeconds is the effective synchronous-reply wait budget.
	WaitTimeoutSeconds int
}

WebhookRunConfig is the behaviour-only view of a webhook channel's persisted config that the inbound-ingress transport needs. It exposes exactly the knobs the HTTP handler consumes, with the effective (defaulted) timeouts already resolved here, so internal/server never imports the webhook plugin.

Jump to

Keyboard shortcuts

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