home

package
v1.0.63 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRefreshPayload

func BuildRefreshPayload(updated *coreauth.Auth) ([]byte, error)

BuildRefreshPayload builds a build refresh payload.

func SanitizeAuthForDownstream

func SanitizeAuthForDownstream(auth *coreauth.Auth) *coreauth.Auth

SanitizeAuthForDownstream removes refresh-capable credentials from the auth payload before it is returned to downstream CPA nodes.

Types

type ClusterAdapter

type ClusterAdapter interface {
	Enabled() bool
	LoadAuthIndex(ctx context.Context) error
	ListMinimalAuths() []*coreauth.Auth
	GetFullAuth(ctx context.Context, uuid string) (*coreauth.Auth, error)
	LoadConfigYAML(ctx context.Context) ([]byte, error)
}

type ConcurrencyAdmissionRequest added in v1.0.63

type ConcurrencyAdmissionRequest struct {
	CredentialID    string
	Model           string
	Fingerprint     string
	ConnectedAt     time.Time
	Controlled      bool
	ProtocolVersion int
}

ConcurrencyAdmissionRequest identifies a dispatch request for atomic admission.

type ConcurrencyAdmissionResult added in v1.0.63

type ConcurrencyAdmissionResult struct {
	Accounted    bool
	CredentialID string
	Model        string
}

ConcurrencyAdmissionResult describes the credential and model admitted by the limiter.

type ConcurrencyAdmitter added in v1.0.63

type ConcurrencyAdmitter interface {
	AdmitCredentialConcurrency(context.Context, ConcurrencyAdmissionRequest) (ConcurrencyAdmissionResult, error)
}

ConcurrencyAdmitter atomically reserves a credential concurrency slot.

type ConcurrencyAdmitterFunc added in v1.0.63

ConcurrencyAdmitterFunc adapts a function to ConcurrencyAdmitter.

func (ConcurrencyAdmitterFunc) AdmitCredentialConcurrency added in v1.0.63

type DispatchConcurrencyContext added in v1.0.63

type DispatchConcurrencyContext struct {
	Fingerprint     string
	ConnectedAt     time.Time
	Controlled      bool
	ProtocolVersion int
	PrepareResponse DispatchResponsePreparer
}

DispatchConcurrencyContext carries the RESP connection identity required for admission.

type DispatchResponsePreparer added in v1.0.63

type DispatchResponsePreparer func(*DispatchResult) (unaccounted []byte, accounted []byte, err error)

DispatchResponsePreparer prebuilds both dispatch response variants before admission.

type DispatchResult

type DispatchResult struct {
	Model         string
	AccessToken   string
	BaseURL       string
	APIKey        string
	ForceMapping  bool
	OriginalAlias string

	AuthID   string
	Provider string

	Auth                  *coreauth.Auth
	Concurrency           ConcurrencyAdmissionResult
	UnaccountedReply      []byte
	AccountedReply        []byte
	AdmissionFenceFailure error
}

type KVGetResult added in v1.0.44

type KVGetResult struct {
	Value []byte
	Found bool
}

type ModelInfo

type ModelInfo = registry.ModelInfo

type PluginPlatform added in v1.0.44

type PluginPlatform struct {
	GOOS   string `json:"goos"`
	GOARCH string `json:"goarch"`
}

func CurrentPluginPlatform added in v1.0.44

func CurrentPluginPlatform() PluginPlatform

CurrentPluginPlatform reports the platform used by Home plugin discovery.

type Runtime

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

func NewRuntime

func NewRuntime(cfg *config.Config) (*Runtime, error)

NewRuntime creates a new runtime.

func (*Runtime) AddToken

func (r *Runtime) AddToken(ctx context.Context, rawJSON string) (string, error)

AddToken stores a credential JSON blob into the auth directory and schedules it for use. It returns the created (or existing) auth file name under auth-dir.

func (*Runtime) ApplyConfigFromCluster

func (r *Runtime) ApplyConfigFromCluster(ctx context.Context, cfg *config.Config) error

ApplyConfigFromCluster updates apply config from cluster.

func (*Runtime) Authenticate

func (r *Runtime) Authenticate(ctx context.Context, headers http.Header) (*access.Result, *access.AuthError)

Authenticate validates request credentials and returns the access result.

func (*Runtime) AuthenticateHTTPRequest added in v1.0.44

func (r *Runtime) AuthenticateHTTPRequest(ctx context.Context, req *http.Request) (*access.Result, *access.AuthError)

AuthenticateHTTPRequest validates request credentials from a complete HTTP request.

func (*Runtime) BuildPluginSyncPlan added in v1.0.63

func (r *Runtime) BuildPluginSyncPlan(ctx context.Context, request pluginstore.PluginSyncRequest) (pluginstore.PluginSyncResponse, error)

func (*Runtime) Config

func (r *Runtime) Config() *config.Config

Config handles a config.

func (*Runtime) ConfigPath

func (r *Runtime) ConfigPath() string

ConfigPath handles a config path.

func (*Runtime) CoreManager

func (r *Runtime) CoreManager() *coreauth.Manager

CoreManager handles a core manager.

func (*Runtime) DispatchForAPIKey added in v1.0.44

func (r *Runtime) DispatchForAPIKey(ctx context.Context, reqModel string, headers http.Header, apiKey string) (*DispatchResult, error)

DispatchForAPIKey processes dispatch with API-key channel restrictions.

func (*Runtime) DispatchForAPIKeyWithConcurrency added in v1.0.63

func (r *Runtime) DispatchForAPIKeyWithConcurrency(ctx context.Context, reqModel string, headers http.Header, apiKey string, concurrencyCtx DispatchConcurrencyContext) (*DispatchResult, error)

DispatchForAPIKeyWithConcurrency performs dispatch and atomic admission for a RESP request.

func (*Runtime) HasPluginAuthProvider added in v1.0.63

func (r *Runtime) HasPluginAuthProvider(provider string) bool

HasPluginAuthProvider reports whether a Home-loaded plugin owns provider login.

func (*Runtime) HasScheduler added in v1.0.44

func (r *Runtime) HasScheduler() bool

HasScheduler reports whether a Home-loaded plugin supplies auth scheduling.

func (*Runtime) KVDel added in v1.0.44

func (r *Runtime) KVDel(ctx context.Context, keys []string) (int64, error)

KVDel deletes active KV values from the cluster store.

func (*Runtime) KVExpire added in v1.0.44

func (r *Runtime) KVExpire(ctx context.Context, key string, ttl time.Duration) (bool, error)

KVExpire updates a KV value TTL in the cluster store.

func (*Runtime) KVGet added in v1.0.44

func (r *Runtime) KVGet(ctx context.Context, key string) ([]byte, bool, error)

KVGet returns an active KV value from the cluster store.

func (*Runtime) KVIncrBy added in v1.0.44

func (r *Runtime) KVIncrBy(ctx context.Context, key string, delta int64) (int64, error)

KVIncrBy increments a KV integer in the cluster store.

func (*Runtime) KVMGet added in v1.0.44

func (r *Runtime) KVMGet(ctx context.Context, keys []string) ([]KVGetResult, error)

KVMGet returns KV values in request order from the cluster store.

func (*Runtime) KVMSet added in v1.0.44

func (r *Runtime) KVMSet(ctx context.Context, pairs map[string][]byte) error

KVMSet atomically writes KV values to the cluster store.

func (*Runtime) KVSet added in v1.0.44

func (r *Runtime) KVSet(ctx context.Context, key string, value []byte, ttl time.Duration, mode string) (bool, error)

KVSet writes a KV value to the cluster store.

func (*Runtime) KVTTL added in v1.0.44

func (r *Runtime) KVTTL(ctx context.Context, key string) (int64, error)

KVTTL returns a Redis-compatible KV TTL from the cluster store.

func (*Runtime) ListPendingPluginTasks added in v1.0.44

func (r *Runtime) ListPendingPluginTasks(ctx context.Context, nodeType string, nodeID string) ([]node.PluginTask, error)

ListPendingPluginTasks returns pending plugin tasks for a node.

func (*Runtime) ParseAuth added in v1.0.44

func (r *Runtime) ParseAuth(ctx context.Context, req pluginapi.AuthParseRequest) (*homeauth.Auth, bool, error)

ParseAuth lets Home auth synthesis use provider plugins.

func (*Runtime) ParseAuths added in v1.0.44

func (r *Runtime) ParseAuths(ctx context.Context, req pluginapi.AuthParseRequest) ([]*homeauth.Auth, bool, error)

ParseAuths lets Home auth synthesis use provider plugins that expand one file into multiple auths.

func (*Runtime) PersistAppLogPayload added in v1.0.44

func (r *Runtime) PersistAppLogPayload(ctx context.Context, clientIP string, payload string) (bool, error)

PersistAppLogPayload stores a CPA app log payload in the runtime database.

func (*Runtime) PersistClusterUsagePayload

func (r *Runtime) PersistClusterUsagePayload(ctx context.Context, payload string) (bool, error)

PersistClusterUsagePayload stores persist cluster usage payload.

func (*Runtime) PickAuth added in v1.0.44

PickAuth lets Home dispatch use scheduler plugins.

func (*Runtime) PluginLoginAuths added in v1.0.63

func (r *Runtime) PluginLoginAuths(resp pluginapi.AuthLoginPollResponse) ([]*homeauth.Auth, error)

PluginLoginAuths converts auth records returned by a successful plugin login.

func (*Runtime) PluginSyncNodeActive added in v1.0.63

func (r *Runtime) PluginSyncNodeActive(ctx context.Context, nodeID string, fingerprint string) (bool, error)

func (*Runtime) PollPluginLogin added in v1.0.63

func (r *Runtime) PollPluginLogin(ctx context.Context, provider, state string, metadata map[string]any) (pluginapi.AuthLoginPollResponse, bool, error)

PollPluginLogin polls an OAuth flow through a Home-loaded auth provider plugin.

func (*Runtime) PublishConfigYAML

func (r *Runtime) PublishConfigYAML(payload []byte)

PublishConfigYAML handles a publish config yaml.

func (*Runtime) ReadConfigYAMLContext

func (r *Runtime) ReadConfigYAMLContext(ctx context.Context) ([]byte, error)

ReadConfigYAMLContext loads read config yaml context.

func (*Runtime) RecordUsagePayload

func (r *Runtime) RecordUsagePayload(ctx context.Context, payload string)

RecordUsagePayload applies downstream usage status to the scheduler auth state.

func (*Runtime) RefreshAuth added in v1.0.44

func (r *Runtime) RefreshAuth(ctx context.Context, auth *homeauth.Auth) (*homeauth.Auth, bool, error)

RefreshAuth lets Home refresh provider plugin credentials.

func (*Runtime) RefreshClusterAuthIndex

func (r *Runtime) RefreshClusterAuthIndex(ctx context.Context, uuid string) error

RefreshClusterAuthIndex refreshes refresh cluster auth index.

func (*Runtime) RefreshNow

func (r *Runtime) RefreshNow(ctx context.Context, authIndex string) ([]byte, error)

RefreshNow refreshes refresh now.

func (*Runtime) RefreshNowLocal

func (r *Runtime) RefreshNowLocal(ctx context.Context, authIndex string) ([]byte, error)

RefreshNowLocal refreshes refresh now local.

func (*Runtime) RegisteredPlugins added in v1.0.63

func (r *Runtime) RegisteredPlugins() []sdkpluginhost.RegisteredPluginInfo

RegisteredPlugins returns Home-loaded plugin metadata for management clients.

func (*Runtime) ReloadAuths

func (r *Runtime) ReloadAuths(ctx context.Context) error

ReloadAuths handles a reload auths.

func (*Runtime) ReplacePluginStatus added in v1.0.44

func (r *Runtime) ReplacePluginStatus(ctx context.Context, nodeType string, status node.PluginTaskStatus) error

ReplacePluginStatus stores the latest plugin status report in the cluster store.

func (*Runtime) SetClusterAdapter

func (r *Runtime) SetClusterAdapter(adapter ClusterAdapter)

SetClusterAdapter sets a cluster adapter.

func (*Runtime) SetClusterRefreshHandler

func (r *Runtime) SetClusterRefreshHandler(handler func(context.Context, string) ([]byte, error))

SetClusterRefreshHandler sets a cluster refresh handler.

func (*Runtime) SetConcurrencyAdmitter added in v1.0.63

func (r *Runtime) SetConcurrencyAdmitter(admitter ConcurrencyAdmitter)

SetConcurrencyAdmitter sets the admission backend used for concurrency-aware dispatch.

func (*Runtime) SetPluginStoreAuthResolver added in v1.0.63

func (r *Runtime) SetPluginStoreAuthResolver(resolver func(context.Context) ([]pluginstore.ResolvedAuthConfig, error))

func (*Runtime) SetPluginSyncConfigLoader added in v1.0.63

func (r *Runtime) SetPluginSyncConfigLoader(loader func(context.Context) (*config.Config, error))

func (*Runtime) SetPluginSyncNodeActive added in v1.0.63

func (r *Runtime) SetPluginSyncNodeActive(check func(context.Context, string, string) (bool, error))

func (*Runtime) Start

func (r *Runtime) Start(ctx context.Context, configPath string) error

Start starts the process.

func (*Runtime) StartAutoRefresh

func (r *Runtime) StartAutoRefresh(ctx context.Context)

StartAutoRefresh starts an auto refresh.

func (*Runtime) StartPluginLogin added in v1.0.63

func (r *Runtime) StartPluginLogin(ctx context.Context, provider, baseURL string) (pluginapi.AuthLoginStartResponse, bool, error)

StartPluginLogin starts an OAuth flow through a Home-loaded auth provider plugin.

func (*Runtime) Stop

func (r *Runtime) Stop()

Stop stops the process.

func (*Runtime) StopAutoRefresh

func (r *Runtime) StopAutoRefresh()

StopAutoRefresh stops an auto refresh.

func (*Runtime) SubscribeConfigYAML

func (r *Runtime) SubscribeConfigYAML(subscriber func(payload []byte) error) (unsubscribe func())

SubscribeConfigYAML handles a subscribe config yaml.

func (*Runtime) UpdateAuthInMemory

func (r *Runtime) UpdateAuthInMemory(ctx context.Context, auth *coreauth.Auth) (*coreauth.Auth, error)

UpdateAuthInMemory updates an auth in memory.

Jump to

Keyboard shortcuts

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