pluginhost

package
v7.3.19 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPluginRefreshCompatExecutor added in v7.2.124

func IsPluginRefreshCompatExecutor(executor coreauth.ProviderExecutor) bool

IsPluginRefreshCompatExecutor reports whether executor is a plugin-refresh wrapper.

func NewPluginRefreshCompatExecutor added in v7.2.124

func NewPluginRefreshCompatExecutor(inner coreauth.ProviderExecutor, host *Host, cfg *config.Config) coreauth.ProviderExecutor

NewPluginRefreshCompatExecutor wraps a native provider executor so Refresh is handled by the plugin AuthProvider for the same provider key.

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 UnwrapPluginRefreshCompatExecutor added in v7.2.124

func UnwrapPluginRefreshCompatExecutor(executor coreauth.ProviderExecutor) (coreauth.ProviderExecutor, bool)

UnwrapPluginRefreshCompatExecutor returns the inner native executor when executor is a plugin-refresh wrapper.

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) CompleteRequest added in v7.2.103

func (h *Host) CompleteRequest(ctx context.Context, completion pluginapi.RequestCompletion)

CompleteRequest schedules terminal notifications without blocking response delivery.

func (*Host) CompleteRequestExcept added in v7.2.103

func (h *Host) CompleteRequestExcept(ctx context.Context, completion pluginapi.RequestCompletion, skipPluginID string)

CompleteRequestExcept notifies lifecycle plugins except the plugin that initiated a nested host execution.

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) DescribeQuota added in v7.2.159

func (h *Host) DescribeQuota(ctx context.Context, pluginID string) (pluginapi.QuotaDescribeResponse, bool, error)

DescribeQuota queries a plugin quota provider for metadata.

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) FetchQuota added in v7.2.159

FetchQuota queries quota information for a credential by provider or plugin ID.

func (*Host) FetchQuotaByPlugin added in v7.2.159

func (h *Host) FetchQuotaByPlugin(ctx context.Context, pluginID string, req pluginapi.QuotaFetchRequest) (pluginapi.QuotaFetchResponse, bool, error)

FetchQuotaByPlugin queries quota information for a credential targeting a specific plugin.

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) HasQuotaProvider added in v7.2.159

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

HasQuotaProvider reports whether a quota provider exists for the given provider key.

func (*Host) HasQuotaProviderContext added in v7.2.159

func (h *Host) HasQuotaProviderContext(ctx context.Context, provider string) bool

HasQuotaProviderContext reports whether a quota provider exists with context cancellation support.

func (*Host) HasQuotaProviderForPlugin added in v7.2.159

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

HasQuotaProviderForPlugin reports whether the given plugin ID provides quota capabilities.

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) HasWebSocketResponseObservers added in v7.2.143

func (h *Host) HasWebSocketResponseObservers() bool

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) ObserveWebSocketResponseEvent added in v7.2.143

func (h *Host) ObserveWebSocketResponseEvent(ctx context.Context, event pluginapi.WebSocketResponseEvent)

func (*Host) ObserveWebSocketResponseEventExcept added in v7.2.143

func (h *Host) ObserveWebSocketResponseEventExcept(ctx context.Context, event pluginapi.WebSocketResponseEvent, skipPluginID string)

func (*Host) OwnsExecutor added in v7.2.102

func (h *Host) OwnsExecutor(executor coreauth.ProviderExecutor) bool

OwnsExecutor reports whether executor is an adapter managed by this host.

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) PluginRegistered added in v7.2.32

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

PluginRegistered reports whether a plugin is active in the current runtime snapshot.

func (*Host) PollLogin

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

func (*Host) QuotaProviderIdentifiers added in v7.2.159

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

QuotaProviderIdentifiers returns the list of unique quota provider identifiers.

func (*Host) QuotaProviders added in v7.2.159

func (h *Host) QuotaProviders(ctx context.Context) []RegisteredQuotaProviderInfo

QuotaProviders returns information about all active registered quota providers.

func (*Host) QuotaSupportedProvidersSet added in v7.2.159

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

QuotaSupportedProvidersSet returns a point-in-time set of all provider keys supported by active quota providers. This allows callers (e.g. ListAuthFiles) to discover all quota-capable providers with zero per-credential RPCs.

func (*Host) RefreshAuth added in v7.2.28

func (h *Host) RefreshAuth(ctx context.Context, auth *coreauth.Auth) (refreshed *coreauth.Auth, handled bool, err 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) RegisterPluginForTest added in v7.2.159

func (h *Host) RegisterPluginForTest(id string, plugin pluginapi.Plugin)

RegisterPluginForTest registers a plugin directly on the host for testing.

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) ResetQuota added in v7.2.159

ResetQuota resets quota or usage for a credential if supported.

func (*Host) ResetQuotaByPlugin added in v7.2.159

func (h *Host) ResetQuotaByPlugin(ctx context.Context, pluginID string, req pluginapi.QuotaResetRequest) (pluginapi.QuotaResetResponse, bool, error)

ResetQuotaByPlugin resets quota or usage for a credential targeting a specific plugin.

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) SchedulerWantsAcrossPriorities added in v7.3.7

func (h *Host) SchedulerWantsAcrossPriorities() 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) ShutdownAllContext added in v7.2.96

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

ShutdownAllContext detaches all plugin runtime state without waiting beyond ctx for active plugin calls to complete.

func (*Host) Snapshot

func (h *Host) Snapshot() *Snapshot

func (*Host) StartLogin

func (h *Host) StartLogin(ctx context.Context, provider string, baseURL string, metadata ...map[string]any) (pluginapi.AuthLoginStartResponse, bool, error)

func (*Host) StreamChunkPayloadIncludesHistory added in v7.2.150

func (h *Host) StreamChunkPayloadIncludesHistory() bool

StreamChunkPayloadIncludesHistory reports whether any active stream chunk interceptor still requires HistoryChunks on payload chunks (schema_version < SchemaVersionStreamChunkOmitHistory).

func (*Host) StreamChunkPayloadIncludesRequestBody added in v7.2.129

func (h *Host) StreamChunkPayloadIncludesRequestBody() bool

StreamChunkPayloadIncludesRequestBody reports whether any active stream chunk interceptor still requires OriginalRequest/RequestBody on payload chunks (schema_version < SchemaVersionStreamChunkOmitRequestBody).

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.

func (*Host) UnloadPluginContext added in v7.2.96

func (h *Host) UnloadPluginContext(ctx context.Context, id string) bool

UnloadPluginContext detaches a plugin from the runtime before waiting for its active calls. Physical client cleanup continues after cancellation if needed.

type PluginFileInfo

type PluginFileInfo struct {
	ID      string
	Path    string
	Version string
}

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

func DiscoverPluginFiles

func DiscoverPluginFiles(root string, desiredVersions ...map[string]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
	OAuthProvider string
	SupportsQuota bool
	QuotaProvider string
	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 RegisteredQuotaProviderInfo added in v7.2.159

type RegisteredQuotaProviderInfo struct {
	PluginID           string   `json:"plugin_id"`
	Provider           string   `json:"provider"`
	DisplayName        string   `json:"display_name,omitempty"`
	SupportedProviders []string `json:"supported_providers,omitempty"`
	SupportsReset      bool     `json:"supports_reset"`
}

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