pluginhost

package
v8.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPluginRefreshCompatExecutor

func IsPluginRefreshCompatExecutor(executor coreauth.ProviderExecutor) bool

IsPluginRefreshCompatExecutor reports whether executor is a plugin-refresh wrapper.

func NewPluginRefreshCompatExecutor

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

func PluginExtension(goos string) string

PluginExtension returns the dynamic library file extension used for goos.

func SupportPluginHeaderValue

func SupportPluginHeaderValue() string

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

func UnwrapPluginRefreshCompatExecutor

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

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

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

func (*Host) CompleteRequest

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

CompleteRequest schedules terminal notifications without blocking response delivery.

func (*Host) CompleteRequestExcept

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

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

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

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

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

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

func (*Host) FetchQuotaByPlugin

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

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

func (h *Host) HasModelRouters() bool

func (*Host) HasModelRoutersExcept

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

func (*Host) HasQuotaProvider

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

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

func (*Host) HasQuotaProviderContext

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

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

func (*Host) HasQuotaProviderForPlugin

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

HasQuotaProviderForPlugin reports whether the given plugin ID provides quota capabilities.

func (*Host) HasRequestInterceptors

func (h *Host) HasRequestInterceptors() bool

func (*Host) HasScheduler

func (h *Host) HasScheduler() bool

func (*Host) HasStreamInterceptors

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

func (h *Host) HasWebSocketResponseObservers() bool

func (*Host) InterceptRequestAfterAuthExcept

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

func (*Host) InterceptRequestBeforeAuthExcept

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

func (*Host) InterceptResponseExcept

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

func (*Host) InterceptStreamChunkExcept

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

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

func (*Host) ObserveWebSocketResponseEventExcept

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

func (*Host) OwnsExecutor

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

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

func (*Host) PluginBusy

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

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

func (*Host) PluginExecutorRequestToFormat

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

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

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

func (*Host) PluginRegistered

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

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

QuotaProviderIdentifiers returns the list of unique quota provider identifiers.

func (*Host) QuotaProviders

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

QuotaProviders returns information about all active registered quota providers.

func (*Host) QuotaSupportedProvidersSet

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

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

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

ResetQuota resets quota or usage for a credential if supported.

func (*Host) ResetQuotaByPlugin

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

func (*Host) RouteModelExcept

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

func (*Host) SchedulerWantsAcrossPriorities

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

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

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

func (*Host) SetModelExecutor

func (h *Host) SetModelExecutor(executor modelExecutor)

func (*Host) ShutdownAll

func (h *Host) ShutdownAll()

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

func (*Host) ShutdownAllContext

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

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

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

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

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

func (*Host) UnloadPluginContext

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

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