pluginhost

package
v7.2.25 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PluginExtension added in v7.1.69

func PluginExtension(goos string) string

PluginExtension returns the dynamic library file extension used for goos.

func SupportPluginHeaderValue added in v7.1.69

func SupportPluginHeaderValue() string

SupportPluginHeaderValue reports whether the current binary was built with CGO enabled.

func ValidatePluginID

func ValidatePluginID(id string) bool

ValidatePluginID reports whether id can be used as a plugin configuration key.

Types

type AuthModelResult

type AuthModelResult struct {
	Provider string
	Models   []*registry.ModelInfo
	Auth     *coreauth.Auth
	Handled  bool
	Err      error
}

type Host

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

func New

func New() *Host

func NewForTest

func NewForTest(loader pluginLoader) *Host

func (*Host) ApplyConfig

func (h *Host) ApplyConfig(ctx context.Context, cfg *config.Config)

func (*Host) AuthDataToCoreAuth

func (h *Host) AuthDataToCoreAuth(data pluginapi.AuthData, path, fileName string) *coreauth.Auth

func (*Host) AuthProviderIdentifiers

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

func (*Host) BuiltinProviders added in v7.2.8

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

BuiltinProviders returns built-in provider keys that currently have auth registered.

func (*Host) CountPluginExecutor added in v7.2.8

func (h *Host) CountPluginExecutor(ctx context.Context, pluginID string, req coreexecutor.Request, opts coreexecutor.Options) (coreexecutor.Response, error)

CountPluginExecutor executes a count-tokens request with the named plugin executor without changing the requested model.

func (*Host) ExecuteCommandLine

func (h *Host) ExecuteCommandLine(ctx context.Context, program string, args []string, configPath string, flagSet *flag.FlagSet) (int, bool)

ExecuteCommandLine runs all enabled plugins whose command-line flags were provided.

func (*Host) ExecutePluginExecutor added in v7.2.8

func (h *Host) ExecutePluginExecutor(ctx context.Context, pluginID string, req coreexecutor.Request, opts coreexecutor.Options) (coreexecutor.Response, error)

ExecutePluginExecutor executes a request with the named plugin executor without changing the requested model.

func (*Host) ExecutePluginExecutorStream added in v7.2.8

func (h *Host) ExecutePluginExecutorStream(ctx context.Context, pluginID string, req coreexecutor.Request, opts coreexecutor.Options) (*coreexecutor.StreamResult, error)

ExecutePluginExecutorStream executes a streaming request with the named plugin executor without changing the requested model.

func (*Host) HasAuthProvider

func (h *Host) HasAuthProvider(provider string) bool

func (*Host) HasBuiltinProvider added in v7.2.8

func (h *Host) HasBuiltinProvider(provider string) bool

HasBuiltinProvider reports whether a built-in provider currently has at least one registered auth record.

func (*Host) HasExecutorCandidateProvider

func (h *Host) HasExecutorCandidateProvider(provider string) bool

func (*Host) HasModelRouters added in v7.2.8

func (h *Host) HasModelRouters() bool

func (*Host) HasModelRoutersExcept added in v7.2.8

func (h *Host) HasModelRoutersExcept(skipPluginID string) bool

func (*Host) HasRequestInterceptors added in v7.1.62

func (h *Host) HasRequestInterceptors() bool

func (*Host) HasScheduler added in v7.1.57

func (h *Host) HasScheduler() bool

func (*Host) HasStreamInterceptors added in v7.1.55

func (h *Host) HasStreamInterceptors() bool

func (*Host) HasTriggeredCommandLineFlags

func (h *Host) HasTriggeredCommandLineFlags() bool

HasTriggeredCommandLineFlags reports whether any plugin-owned flag was provided.

func (*Host) InterceptRequestAfterAuth added in v7.1.62

func (*Host) InterceptRequestAfterAuthExcept added in v7.1.67

func (h *Host) InterceptRequestAfterAuthExcept(ctx context.Context, req pluginapi.RequestInterceptRequest, skipPluginID string) pluginapi.RequestInterceptResponse

func (*Host) InterceptRequestBeforeAuth added in v7.1.62

func (*Host) InterceptRequestBeforeAuthExcept added in v7.1.67

func (h *Host) InterceptRequestBeforeAuthExcept(ctx context.Context, req pluginapi.RequestInterceptRequest, skipPluginID string) pluginapi.RequestInterceptResponse

func (*Host) InterceptResponse added in v7.1.55

func (*Host) InterceptResponseExcept added in v7.1.67

func (h *Host) InterceptResponseExcept(ctx context.Context, req pluginapi.ResponseInterceptRequest, skipPluginID string) pluginapi.ResponseInterceptResponse

func (*Host) InterceptStreamChunk added in v7.1.55

func (*Host) InterceptStreamChunkExcept added in v7.1.67

func (h *Host) InterceptStreamChunkExcept(ctx context.Context, req pluginapi.StreamChunkInterceptRequest, skipPluginID string) pluginapi.StreamChunkInterceptResponse

func (*Host) ModelsForAuth

func (h *Host) ModelsForAuth(ctx context.Context, auth *coreauth.Auth) AuthModelResult

func (*Host) ModelsForProvider

func (h *Host) ModelsForProvider(provider string) []*registry.ModelInfo

func (*Host) NormalizeRequest

func (h *Host) NormalizeRequest(ctx context.Context, from, to sdktranslator.Format, model string, body []byte, stream bool) []byte

func (*Host) NormalizeResponseAfter

func (h *Host) NormalizeResponseAfter(ctx context.Context, from, to sdktranslator.Format, model string, originalRequestRawJSON, requestRawJSON, body []byte, stream bool) []byte

func (*Host) NormalizeResponseBefore

func (h *Host) NormalizeResponseBefore(ctx context.Context, from, to sdktranslator.Format, model string, originalRequestRawJSON, requestRawJSON, body []byte, stream bool) []byte

func (*Host) ParseAuth

func (h *Host) ParseAuth(ctx context.Context, req pluginapi.AuthParseRequest) (*coreauth.Auth, bool, error)

func (*Host) ParseAuths added in v7.2.23

func (h *Host) ParseAuths(ctx context.Context, req pluginapi.AuthParseRequest) ([]*coreauth.Auth, bool, error)

func (*Host) PickAuth added in v7.1.57

func (*Host) PluginBusy added in v7.2.12

func (h *Host) PluginBusy(id string) bool

PluginBusy reports whether a plugin dynamic library is loaded or being loaded.

func (*Host) PluginExecutorRequestToFormat added in v7.2.8

func (h *Host) PluginExecutorRequestToFormat(pluginID string, req coreexecutor.Request, opts coreexecutor.Options) sdktranslator.Format

PluginExecutorRequestToFormat reports the executor input format selected for a direct plugin executor route.

func (*Host) PluginLoaded added in v7.1.69

func (h *Host) PluginLoaded(id string) bool

PluginLoaded reports whether a plugin dynamic library is still loaded by the host.

func (*Host) PollLogin

func (h *Host) PollLogin(ctx context.Context, provider, state string, metadata ...map[string]any) (pluginapi.AuthLoginPollResponse, bool, error)

func (*Host) RegisterCommandLineFlags

func (h *Host) RegisterCommandLineFlags(ctx context.Context, flagSet *flag.FlagSet)

RegisterCommandLineFlags exposes plugin-declared flags on the provided FlagSet.

func (*Host) RegisterExecutors

func (h *Host) RegisterExecutors(manager executorManager, modelRegistry modelProviderRegistry)

func (*Host) RegisterFrontendAuthProviders

func (h *Host) RegisterFrontendAuthProviders()

func (*Host) RegisterManagementRoutes

func (h *Host) RegisterManagementRoutes(ctx context.Context, reserved map[string]struct{})

RegisterManagementRoutes rebuilds the plugin-owned Management API and resource route tables.

func (*Host) RegisterModels

func (h *Host) RegisterModels(ctx context.Context, modelRegistry modelRegistry)

func (*Host) RegisterUsagePlugins

func (h *Host) RegisterUsagePlugins()

func (*Host) RegisteredPlugins

func (h *Host) RegisteredPlugins() []RegisteredPluginInfo

RegisteredPlugins returns a stable copy of plugin metadata in the current runtime snapshot.

func (*Host) RouteModel added in v7.2.8

func (*Host) RouteModelExcept added in v7.2.8

func (h *Host) RouteModelExcept(ctx context.Context, req pluginapi.ModelRouteRequest, skipPluginID string) (pluginapi.ModelRouteResponse, bool)

func (*Host) ServeManagementHTTP

func (h *Host) ServeManagementHTTP(w http.ResponseWriter, r *http.Request) bool

ServeManagementHTTP dispatches an authenticated Management API request to a plugin route.

func (*Host) ServeResourceHTTP added in v7.1.59

func (h *Host) ServeResourceHTTP(w http.ResponseWriter, r *http.Request) bool

ServeResourceHTTP dispatches an unauthenticated browser-navigable resource request to a plugin route.

func (*Host) SetAuthManager added in v7.2.1

func (h *Host) SetAuthManager(manager *coreauth.Manager)

func (*Host) SetModelExecutor added in v7.1.67

func (h *Host) SetModelExecutor(executor modelExecutor)

func (*Host) ShutdownAll added in v7.1.48

func (h *Host) ShutdownAll()

ShutdownAll removes active plugin capabilities and closes all loaded dynamic libraries.

func (*Host) Snapshot

func (h *Host) Snapshot() *Snapshot

func (*Host) StartLogin

func (h *Host) StartLogin(ctx context.Context, provider string, baseURL string) (pluginapi.AuthLoginStartResponse, bool, error)

func (*Host) TranslateRequest

func (h *Host) TranslateRequest(ctx context.Context, from, to sdktranslator.Format, model string, body []byte, stream bool) ([]byte, bool)

func (*Host) TranslateResponse

func (h *Host) TranslateResponse(ctx context.Context, from, to sdktranslator.Format, model string, originalRequestRawJSON, requestRawJSON, body []byte, stream bool) ([]byte, bool)

func (*Host) UnloadPlugin added in v7.1.70

func (h *Host) UnloadPlugin(id string) bool

UnloadPlugin removes one plugin from the active runtime and closes its dynamic library.

type PluginFileInfo

type PluginFileInfo struct {
	ID   string
	Path string
}

PluginFileInfo describes a plugin binary selected by the host discovery rules.

func DiscoverPluginFiles

func DiscoverPluginFiles(root string) ([]PluginFileInfo, error)

DiscoverPluginFiles returns plugin binaries selected by the current host discovery rules.

type RegisteredPluginInfo

type RegisteredPluginInfo struct {
	ID            string
	Priority      int
	Metadata      pluginapi.Metadata
	SupportsOAuth bool
	Menus         []RegisteredPluginMenu
}

RegisteredPluginInfo describes a plugin that is active in the current runtime snapshot.

type RegisteredPluginMenu

type RegisteredPluginMenu struct {
	Path        string
	Menu        string
	Description string
}

RegisteredPluginMenu describes a plugin-owned resource menu entry.

type Snapshot

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

Jump to

Keyboard shortcuts

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