Documentation
¶
Index ¶
- Constants
- func AddModelRegion(entry map[string]any, region string)
- func CatalogCacheKey(accountID string, mode CatalogMode) string
- func CloneModelEntry(model map[string]any) map[string]any
- func CloneModelList(models []map[string]any) []map[string]any
- func DecorateModelsWithContext(ctx context.Context, settings *Settings, models []map[string]any) []map[string]any
- func DefaultContextForModel(model string) int
- func EnsureCheckinDisabledAccounts(ctx context.Context, store SecretStore) (bool, error)
- func EnsureCrossProviderModelPool(ctx context.Context, store SecretStore) (bool, error)
- func EnsureProxyAPIKey(ctx context.Context, store SecretStore, bootstrap string) (string, bool, error)
- func EnsureProxyURL(ctx context.Context, store SecretStore, bootstrap string) (string, error)
- func EnsureRoutingStrategy(ctx context.Context, store SecretStore) (string, error)
- func EnsureWorkBuddyCheckinTime(ctx context.Context, store SecretStore) (string, error)
- func EntryModelRegions(entry map[string]any) []string
- func FilterModelsByAccountAllow(models []map[string]any, identity auth.Identity, pool []AccountModelAllow) []map[string]any
- func FilterModelsForIdentity(identity auth.Identity, models []map[string]any) []map[string]any
- func GenerateAPIKey() (string, error)
- func MergeModelEntryCapabilities(merged, incoming map[string]any)
- func MergeModelEntryPricing(merged, incoming map[string]any)
- func ModelCapabilitiesEntry(model providers.ModelInfo) map[string]any
- func ModelContextKey(model string) string
- func ModelServedByAccounts(entry map[string]any, identity auth.Identity, pool []AccountModelAllow) bool
- func PrefixModelEntries(models []map[string]any) []map[string]any
- func ProviderModelEntry(model providers.ModelInfo, provider string) map[string]any
- type AccountAdminAction
- type AccountAdminResult
- type AccountBundle
- type AccountBundleCredential
- type AccountBundleEntry
- type AccountExport
- type AccountImportInput
- type AccountImportItemError
- type AccountImportResult
- type AccountModelAllow
- type Accounts
- func (a *Accounts) Admin(ctx context.Context, input AccountAdminAction) (AccountAdminResult, error)
- func (a *Accounts) Checkin(ctx context.Context, id string) (accounts.Account, error)
- func (a *Accounts) CheckinAll(ctx context.Context, force, includeDisabled bool) ([]accounts.CheckinAllResult, error)
- func (a *Accounts) CompleteLogin(ctx context.Context, id, callback string) error
- func (a *Accounts) Create(ctx context.Context, input accounts.CreateAccount) (accounts.Account, error)
- func (a *Accounts) Delete(ctx context.Context, id string) error
- func (a *Accounts) Export(ctx context.Context, id string) (AccountExport, error)
- func (a *Accounts) ExportBundle(ctx context.Context) (AccountBundle, error)
- func (a *Accounts) Get(ctx context.Context, id string) (accounts.AccountView, error)
- func (a *Accounts) GetStored(ctx context.Context, id string) (accounts.Account, error)
- func (a *Accounts) Import(ctx context.Context, input AccountImportInput, raw []byte) (accounts.Account, error)
- func (a *Accounts) ImportAll(ctx context.Context, input AccountImportInput, raw []byte) (AccountImportResult, error)
- func (a *Accounts) ImportBundle(ctx context.Context, bundle AccountBundle) (AccountImportResult, error)
- func (a *Accounts) ImportCredentialPayload(ctx context.Context, input accounts.CreateAccount, format string, ...) (accounts.Account, error)
- func (a *Accounts) ImportNative(ctx context.Context, input accounts.ImportAccount) (accounts.Account, error)
- func (a *Accounts) List(ctx context.Context, refresh bool) ([]accounts.AccountView, error)
- func (a *Accounts) ListCheckins(ctx context.Context, id string, limit int) ([]accounts.CheckinRecord, error)
- func (a *Accounts) LoadCredentialPayload(ctx context.Context, id string) (string, []byte, error)
- func (a *Accounts) LoadNativeCredential(ctx context.Context, id string) (accounts.NativeCredential, error)
- func (a *Accounts) LoginPAT(ctx context.Context, id, token string) error
- func (a *Accounts) PollLogin(ctx context.Context, id string) (bool, string, error)
- func (a *Accounts) RefreshAccount(ctx context.Context, id string, forceQuota bool) error
- func (a *Accounts) RefreshAll(ctx context.Context, forceQuota bool) error
- func (a *Accounts) ReloadProxyURL(ctx context.Context, value string) error
- func (a *Accounts) ReplaceProxyAPIKey(ctx context.Context, key string) error
- func (a *Accounts) StartLogin(ctx context.Context, id string) (providers.LoginSession, error)
- func (a *Accounts) Update(ctx context.Context, id string, input accounts.UpdateAccount) (accounts.Account, error)
- type Backup
- type Catalog
- func (c *Catalog) CachedCount(accountID string, mode CatalogMode) int
- func (c *Catalog) Get(refresh bool, accountID string, mode CatalogMode) ([]map[string]any, error)
- func (c *Catalog) ModelContextLength(modelID string) (int, bool)
- func (c *Catalog) ModelContextWindows(modelID string) (dev, max int, ok bool)
- func (c *Catalog) Refresh() (CatalogStatus, error)
- func (c *Catalog) Restore(ctx context.Context)
- func (c *Catalog) RunRefresher(stop <-chan struct{})
- func (c *Catalog) Status() CatalogStatus
- type CatalogAccount
- type CatalogCacheEntry
- type CatalogFetcher
- type CatalogHealth
- type CatalogMode
- type CatalogProviderHealth
- type CatalogSource
- type CatalogStatus
- type CatalogStore
- type KeyRotation
- type Keys
- func (k *Keys) Create(ctx context.Context, input accounts.CreateAPIKey) (accounts.APIKey, error)
- func (k *Keys) Delete(ctx context.Context, id string) error
- func (k *Keys) Get(ctx context.Context, id string) (accounts.APIKey, error)
- func (k *Keys) List(ctx context.Context) ([]accounts.APIKey, error)
- func (k *Keys) SetConsoleSecret(ctx context.Context, secretName, secret string) error
- func (k *Keys) Touch(ctx context.Context, id string) error
- func (k *Keys) Update(ctx context.Context, id string, input accounts.UpdateAPIKey) (accounts.APIKey, error)
- type ModelSetting
- type OperationError
- type ProviderModelSettingPatch
- type Runtime
- type SecretStore
- type Services
- type Settings
- func (s *Settings) BindCatalog(catalog *Catalog)
- func (s *Settings) DefaultContextLength(modelID string) int
- func (s *Settings) GetModelContext(ctx context.Context, modelID string) (int, bool, error)
- func (s *Settings) GetProviderModelSetting(ctx context.Context, provider, modelID string) (accounts.ProviderModelSetting, error)
- func (s *Settings) GetSecret(ctx context.Context, name string) (string, bool, error)
- func (s *Settings) ListModelContexts(ctx context.Context) (map[string]int, error)
- func (s *Settings) MaxContextLength(modelID string) int
- func (s *Settings) ReadModelSetting(ctx context.Context, provider, modelID string) (ModelSetting, error)
- func (s *Settings) SetModelContext(ctx context.Context, modelID string, contextLength int) error
- func (s *Settings) SetProviderModelSetting(ctx context.Context, provider, modelID string, ...) error
- func (s *Settings) SetSecret(ctx context.Context, name, value string) error
- func (s *Settings) SetSecretOrEmpty(ctx context.Context, name, value string) error
- func (s *Settings) UpdateModelSetting(ctx context.Context, provider, modelID string, contextLength *int, ...) (ModelSetting, error)
- func (s *Settings) UpdateProviderModelSetting(ctx context.Context, provider, modelID string, patch ProviderModelSettingPatch) (accounts.ProviderModelSetting, error)
- func (s *Settings) WorkBuddyCheckinTimeDefault(ctx context.Context) string
- type System
- type SystemSettings
- type SystemSettingsPatch
Constants ¶
const ( // AccountBundleFormat identifies a full console account migration file. AccountBundleFormat = "cli2api-accounts" // AccountBundleVersion is bumped when the JSON shape changes incompatibly. AccountBundleVersion = 1 )
const CatalogCacheTTL = 5 * time.Minute
Variables ¶
This section is empty.
Functions ¶
func AddModelRegion ¶
func CatalogCacheKey ¶
func CatalogCacheKey(accountID string, mode CatalogMode) string
func CloneModelEntry ¶ added in v0.7.28
CloneModelEntry copies a catalog entry so rewriting its id never mutates the shared catalog cache.
func DefaultContextForModel ¶
DefaultContextForModel is shared by catalog decoration and settings HTTP.
func EnsureCheckinDisabledAccounts ¶ added in v0.6.13
func EnsureCheckinDisabledAccounts(ctx context.Context, store SecretStore) (bool, error)
func EnsureCrossProviderModelPool ¶
func EnsureCrossProviderModelPool(ctx context.Context, store SecretStore) (bool, error)
func EnsureProxyAPIKey ¶
func EnsureProxyURL ¶
func EnsureRoutingStrategy ¶
func EnsureRoutingStrategy(ctx context.Context, store SecretStore) (string, error)
func EnsureWorkBuddyCheckinTime ¶
func EnsureWorkBuddyCheckinTime(ctx context.Context, store SecretStore) (string, error)
func EntryModelRegions ¶
func FilterModelsByAccountAllow ¶ added in v0.7.34
func FilterModelsByAccountAllow(models []map[string]any, identity auth.Identity, pool []AccountModelAllow) []map[string]any
FilterModelsByAccountAllow drops catalog entries no granted account will serve. See ModelServedByAccounts for the empty-pool and mixed-account rules.
func FilterModelsForIdentity ¶
FilterModelsForIdentity applies grants after loading the shared catalog.
func GenerateAPIKey ¶
func MergeModelEntryCapabilities ¶
MergeModelEntryCapabilities folds a later source entry into the merged one conservatively: numeric fields take the minimum and boolean fields are ANDed.
func MergeModelEntryPricing ¶
MergeModelEntryPricing drops credits/free when source regions disagree.
func ModelCapabilitiesEntry ¶
ModelCapabilitiesEntry is the merge-only capability view of one provider catalog entry. Unlike ProviderModelEntry it always states supports_images (true or false) so MergeModelEntryCapabilities can combine regions; the public entry only carries the field when the provider declares support.
func ModelContextKey ¶
ModelContextKey normalizes a console setting key without treating an empty input as the routing model "auto".
func ModelServedByAccounts ¶ added in v0.7.34
func ModelServedByAccounts(entry map[string]any, identity auth.Identity, pool []AccountModelAllow) bool
ModelServedByAccounts reports whether at least one account the caller can reach will accept this catalog entry. Provider and region grants are applied here too, so a key scoped to one family never keeps another family's name just because that other account left its list unrestricted.
An empty account list keeps the catalog unchanged: tests and a pool that has not reported routing yet must not blank /v1/models. A model stays listed when any granted account can serve it — either because that account is unrestricted, or because the model (or an alias that rewrites to it) is in its enabled set. Region-qualified entries ("workbuddy-cn/…") only consult accounts of that region; a merged entry stays when any of its regions has a serving account.
func PrefixModelEntries ¶ added in v0.7.28
PrefixModelEntries rewrites bare model ids to provider-prefixed ids ("glm-5.2" -> "qoder/glm-5.2"). The gateway accepts bare ids only while the cross-provider pool is on; with it off, RejectsBareModel refuses them, so model lists must match what the gateway accepts or every client that picks a model from the list (console access page, /v1/models consumers) gets a 400. Entries already carrying a prefix, and the pooled qoder view (empty provider, owned_by=qoder), pass through unchanged. Region-qualified entries use the dash form so a specific region stays pinned ("workbuddy-cn/glm-5.3").
Types ¶
type AccountAdminAction ¶
type AccountAdminResult ¶
type AccountAdminResult struct {
Kind string
Session providers.LoginSession
LoginDone bool
LoginStatus string
LoginMsg string
Worker providers.AdminResponse
}
type AccountBundle ¶ added in v0.7.40
type AccountBundle struct {
Format string `json:"format"`
Version int `json:"version"`
ExportedAt string `json:"exported_at"`
Count int `json:"count"`
Accounts []AccountBundleEntry `json:"accounts"`
}
AccountBundle is the full export/import file. Accounts without a stored credential are still exported so their routing settings survive migration.
type AccountBundleCredential ¶ added in v0.7.40
type AccountBundleCredential struct {
Format string `json:"format"`
Credential json.RawMessage `json:"credential,omitempty"`
UserBlob string `json:"user_blob,omitempty"`
MachineID string `json:"machine_id,omitempty"`
}
AccountBundleCredential is the portable credential material for one account. Native Qoder accounts carry user_blob/machine_id; all other providers carry an already-normalized credential payload.
type AccountBundleEntry ¶ added in v0.7.40
type AccountBundleEntry struct {
Name string `json:"name"`
Provider string `json:"provider"`
Region string `json:"region"`
AuthType string `json:"auth_type,omitempty"`
Enabled bool `json:"enabled"`
MaxInFlight int `json:"max_inflight"`
Priority int `json:"priority"`
DropSystemPrompt *bool `json:"drop_system_prompt,omitempty"`
ModelAliases map[string]string `json:"model_aliases,omitempty"`
EnabledModels []string `json:"enabled_models,omitempty"`
ModelsRestricted bool `json:"models_restricted,omitempty"`
AutoCheckin bool `json:"auto_checkin,omitempty"`
CheckinTime string `json:"checkin_time,omitempty"`
WorkBuddyAutoCheckin bool `json:"workbuddy_auto_checkin,omitempty"`
WorkBuddyCheckinTime string `json:"workbuddy_checkin_time,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Credential *AccountBundleCredential `json:"credential,omitempty"`
}
AccountBundleEntry is one account plus its settings and credential.
type AccountExport ¶
type AccountImportInput ¶
type AccountImportInput struct {
Format string `json:"format"`
Name string `json:"name"`
Provider string `json:"provider"`
Region string `json:"region"`
Enabled bool `json:"enabled"`
MaxInFlight int `json:"max_inflight"`
Priority int `json:"priority"`
DropSystemPrompt *bool `json:"drop_system_prompt"`
WorkBuddyAutoCheckin *bool `json:"workbuddy_auto_checkin"`
WorkBuddyCheckinTime string `json:"workbuddy_checkin_time"`
AutoCheckin *bool `json:"auto_checkin"`
CheckinTime string `json:"checkin_time"`
ProxyURL string `json:"proxy_url"`
UserBlob string `json:"user_blob"`
MachineID string `json:"machine_id"`
Credential json.RawMessage `json:"credential"`
}
type AccountImportItemError ¶ added in v0.7.10
type AccountImportItemError struct {
Index int `json:"index"`
Name string `json:"name,omitempty"`
Message string `json:"message"`
}
AccountImportItemError records one failed entry inside a multi-account package.
type AccountImportResult ¶ added in v0.7.10
type AccountImportResult struct {
Object string `json:"object"`
Succeeded int `json:"succeeded"`
Failed int `json:"failed"`
Data []accounts.Account `json:"data"`
Errors []AccountImportItemError `json:"errors,omitempty"`
}
AccountImportResult is the import outcome. Single-credential imports still populate Data with one account; packages may partially succeed.
type AccountModelAllow ¶ added in v0.7.34
type AccountModelAllow struct {
Provider string
Region string
ModelsRestricted bool
EnabledModels []string
// Aliases maps a client-facing canonical name onto the canonical catalog
// model this account rewrites it to. The public list keeps an alias only
// when some granted account both defines it and may serve its target.
Aliases map[string]string
}
AccountModelAllow is one account's contribution to the public model list. A restricted account contributes only EnabledModels; an unrestricted one contributes every model of its provider and region. Enabled IDs are the canonical form stored by NormalizeAccountRouting.
type Accounts ¶
Accounts orchestrates console account operations through Store + Runtime. HTTP handlers keep decoding and error-code mapping.
func NewAccounts ¶
func (*Accounts) Admin ¶
func (a *Accounts) Admin(ctx context.Context, input AccountAdminAction) (AccountAdminResult, error)
func (*Accounts) CheckinAll ¶ added in v0.7.40
func (*Accounts) CompleteLogin ¶
func (*Accounts) ExportBundle ¶ added in v0.7.40
func (a *Accounts) ExportBundle(ctx context.Context) (AccountBundle, error)
ExportBundle builds a portable migration file from every stored account.
func (*Accounts) ImportAll ¶ added in v0.7.10
func (a *Accounts) ImportAll(ctx context.Context, input AccountImportInput, raw []byte) (AccountImportResult, error)
ImportAll imports one credential or every entry in a multi-account package. Failure policy is partial success: valid entries are kept, failures are summarized in Errors instead of rolling back successes.
func (*Accounts) ImportBundle ¶ added in v0.7.40
func (a *Accounts) ImportBundle(ctx context.Context, bundle AccountBundle) (AccountImportResult, error)
ImportBundle restores every account in a migration file. Import is additive: existing accounts and IDs are never touched; new accounts get fresh IDs. Failure policy matches ImportAll: valid entries are kept, failures reported.
func (*Accounts) ImportCredentialPayload ¶
func (a *Accounts) ImportCredentialPayload(ctx context.Context, input accounts.CreateAccount, format string, payload []byte, enable bool) (accounts.Account, error)
ImportCredentialPayload creates a disabled in-process account, writes the provider credential blob, then optionally enables it. Credential write failure deletes the account, matching the previous HTTP handler. A Get after a successful write is best-effort, also matching that handler.
func (*Accounts) ImportNative ¶
func (*Accounts) ListCheckins ¶
func (*Accounts) LoadCredentialPayload ¶
func (*Accounts) LoadNativeCredential ¶
func (*Accounts) LoginPAT ¶ added in v0.6.7
LoginPAT stores a pasted provider-native token for an in-process account whose adapter exposes a PAT credential (for example Command Code's user_… key). The Qoder child runtime keeps its worker login path; only adapters that implement CredentialImporter accept this. The token is wrapped as {"api_key": …} for the importer, then persisted in the provider's own credential format and the account is enabled and started.
func (*Accounts) RefreshAccount ¶
func (*Accounts) RefreshAll ¶
func (*Accounts) ReloadProxyURL ¶
func (*Accounts) ReplaceProxyAPIKey ¶
func (*Accounts) StartLogin ¶
type Backup ¶
type Backup struct {
// contains filtered or unexported fields
}
func NewBackup ¶
func NewBackup(store accounts.AccountStore) *Backup
type Catalog ¶
type Catalog struct {
TTL time.Duration
Interval time.Duration
Fetch CatalogFetcher
Store CatalogStore
Health *CatalogHealth
// contains filtered or unexported fields
}
Catalog is the shared /v1/models and /api/models display cache. It does not own runtime catalogs or proven-model membership.
func NewCatalog ¶
func NewCatalog(fetch CatalogFetcher) *Catalog
func (*Catalog) CachedCount ¶
func (c *Catalog) CachedCount(accountID string, mode CatalogMode) int
func (*Catalog) Get ¶
Get returns the display catalog for one view. A failed fetch never discards a catalog that already served: the last successful list is returned and the failure is reported through Status instead.
func (*Catalog) ModelContextLength ¶ added in v0.6.7
ModelContextLength resolves a model's default context window from the cached (or freshly fetched) merged catalog. It returns ok=false when the model or its window is unknown, so callers fall back to the static default.
func (*Catalog) ModelContextWindows ¶ added in v0.6.7
ModelContextWindows returns a model's default window and its largest selectable window. max is 0 when the model has no larger tier. ok=false when the model or its window is unknown, so callers fall back to the static default.
func (*Catalog) Refresh ¶ added in v0.7.13
func (c *Catalog) Refresh() (CatalogStatus, error)
Refresh forces one full reload and reports the resulting status. The returned error is the fetch error for this attempt; a served catalog is still intact when it is non-nil.
func (*Catalog) Restore ¶ added in v0.7.13
Restore loads the persisted snapshot into the cache without treating it as fresh: the entry keeps its original timestamp, so the next read refreshes it in the background while still serving the last known models.
func (*Catalog) RunRefresher ¶ added in v0.7.13
func (c *Catalog) RunRefresher(stop <-chan struct{})
RunRefresher keeps the merged catalog warm: it refreshes once at start and then every Interval, so a newly announced upstream model reaches clients without waiting for someone to open the model list. A zero or negative interval disables the loop (manual refresh only).
func (*Catalog) Status ¶ added in v0.7.13
func (c *Catalog) Status() CatalogStatus
Status reports the shared catalog's sync state plus each provider's own.
type CatalogAccount ¶
CatalogAccount is a display source snapshot, not a scheduler item.
type CatalogFetcher ¶
type CatalogFetcher func(refresh bool, accountID string, mode CatalogMode) ([]map[string]any, error)
CatalogFetcher loads the raw display catalog. Runtime pool membership and SQLite settings stay outside this cache.
type CatalogHealth ¶ added in v0.7.13
type CatalogHealth struct {
// contains filtered or unexported fields
}
CatalogHealth records per-provider catalog outcomes. Providers discover their own model list, so the merged catalog can be half fresh: recording per provider is what lets the console and /v1/models say which upstream is behind instead of only that "the catalog" failed.
func NewCatalogHealth ¶ added in v0.7.13
func NewCatalogHealth() *CatalogHealth
func (*CatalogHealth) Attempt ¶ added in v0.7.13
func (h *CatalogHealth) Attempt(provider string)
Attempt marks the start of one upstream catalog request.
func (*CatalogHealth) Failure ¶ added in v0.7.13
func (h *CatalogHealth) Failure(provider string, err error)
Failure records a failed catalog request. The previous model count and last success time stay in place so a failure never looks like an empty catalog.
func (*CatalogHealth) Restore ¶ added in v0.7.13
func (h *CatalogHealth) Restore(entries []CatalogProviderHealth)
Restore seeds health from a persisted snapshot. Timestamps are kept verbatim; a provider whose last attempt failed stays stale until the next success.
func (*CatalogHealth) Snapshot ¶ added in v0.7.13
func (h *CatalogHealth) Snapshot() []CatalogProviderHealth
Snapshot returns a stable, provider-sorted copy for display.
func (*CatalogHealth) Success ¶ added in v0.7.13
func (h *CatalogHealth) Success(provider string, models int)
Success records a served catalog and clears the provider's failure state.
type CatalogMode ¶
type CatalogMode int
const ( CatalogModeMerge CatalogMode = iota CatalogModeExpand )
type CatalogProviderHealth ¶ added in v0.7.13
type CatalogProviderHealth struct {
Provider string `json:"provider"`
Models int `json:"models"`
LastAttemptAt string `json:"last_attempt_at,omitempty"`
LastSuccessAt string `json:"last_success_at,omitempty"`
LastError string `json:"last_error,omitempty"`
// Stale is true while the last attempt failed and the model list below
// still describes the last successful sync.
Stale bool `json:"stale"`
}
CatalogProviderHealth is one provider's upstream model-catalog sync state. It is display-only: a failure never removes models from the shared catalog.
type CatalogSource ¶
type CatalogSource struct {
Accounts func() []CatalogAccount
Providers *providers.Registry
WorkerModels func(context.Context, string, bool) ([]map[string]any, error)
Health *CatalogHealth
}
CatalogSource aggregates provider catalogs through injected data sources. Health is optional and records one outcome per provider request.
func (*CatalogSource) Fetch ¶
func (a *CatalogSource) Fetch(refresh bool, accountID string, mode CatalogMode) ([]map[string]any, error)
type CatalogStatus ¶ added in v0.7.13
type CatalogStatus struct {
SyncedAt string `json:"synced_at,omitempty"`
Stale bool `json:"stale"`
Refreshing bool `json:"refreshing"`
LastError string `json:"last_error,omitempty"`
IntervalSeconds int `json:"interval_seconds"`
Providers []CatalogProviderHealth `json:"providers"`
}
CatalogStatus is the whole display catalog's sync state. SyncedAt is the last successful full refresh of the merged view that backs /v1/models.
type CatalogStore ¶ added in v0.7.13
type CatalogStore interface {
GetSecret(ctx context.Context, name string) (string, bool, error)
SetSecret(ctx context.Context, name, value string) error
}
CatalogStore persists the last successful catalog snapshot. internal/store satisfies it; the narrow surface keeps control free of the store package.
type KeyRotation ¶
type KeyRotation struct {
Keys *Keys
Accounts *Accounts
Mu *sync.Mutex
Generate func() (string, error)
Publish func(string)
}
KeyRotation serializes persistence, live authentication publication and worker reload.
type Keys ¶
type Keys struct {
// contains filtered or unexported fields
}
func NewKeys ¶
func NewKeys(store accounts.AccountStore) *Keys
func (*Keys) SetConsoleSecret ¶
type ModelSetting ¶
type OperationError ¶
func (*OperationError) Error ¶
func (e *OperationError) Error() string
func (*OperationError) Unwrap ¶
func (e *OperationError) Unwrap() error
type Runtime ¶
type Runtime interface {
StartAccount(ctx context.Context, account accounts.Account) error
StopAccount(id string) error
RemoveAccount(id string) error
SyncAccount(ctx context.Context, before, after accounts.Account) error
AccountView(ctx context.Context, id string) (accounts.AccountView, error)
Accounts(ctx context.Context) ([]accounts.AccountView, error)
RefreshAccount(ctx context.Context, id string, forceQuota bool) error
RefreshAll(ctx context.Context, forceQuota bool) error
CheckinAccount(ctx context.Context, accountID string) (accounts.Account, error)
CheckinAll(ctx context.Context, force, includeDisabled bool) ([]accounts.CheckinAllResult, error)
ReloadProxyURL(ctx context.Context, value string) error
ReplaceProxyAPIKey(ctx context.Context, key string) error
WorkerAdmin(ctx context.Context, input providers.AdminRequest) (providers.AdminResponse, error)
Store() accounts.AccountStore
}
Runtime is the process lifecycle surface control calls. Persistence and enable/import order live here; Manager only starts, stops, and syncs the pool.
type SecretStore ¶
type Services ¶
type Services struct {
Accounts *Accounts
Keys *Keys
Settings *Settings
Backup *Backup
Catalog *Catalog
}
Services is the console application surface assembled by app.New.
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
func NewSettings ¶
func NewSettings(store accounts.AccountStore) *Settings
func (*Settings) BindCatalog ¶ added in v0.6.7
BindCatalog lets settings resolve per-model context defaults from the display catalog. It is called during process assembly, before the server serves.
func (*Settings) DefaultContextLength ¶ added in v0.6.7
DefaultContextLength is the model's default context window: the upstream value the catalog reported when available, otherwise the static fallback.
func (*Settings) GetModelContext ¶
func (*Settings) GetProviderModelSetting ¶
func (*Settings) ListModelContexts ¶
func (*Settings) MaxContextLength ¶ added in v0.6.7
MaxContextLength is the model's larger selectable window, or 0 when the catalog advertises no larger tier.
func (*Settings) ReadModelSetting ¶
func (*Settings) SetModelContext ¶
func (*Settings) SetProviderModelSetting ¶
func (*Settings) SetSecretOrEmpty ¶
func (*Settings) UpdateModelSetting ¶
func (s *Settings) UpdateModelSetting(ctx context.Context, provider, modelID string, contextLength *int, patch ProviderModelSettingPatch) (ModelSetting, error)
func (*Settings) UpdateProviderModelSetting ¶
func (s *Settings) UpdateProviderModelSetting(ctx context.Context, provider, modelID string, patch ProviderModelSettingPatch) (accounts.ProviderModelSetting, error)
type System ¶
type SystemSettings ¶
type SystemSettings struct {
CrossProviderModelPool bool `json:"cross_provider_model_pool"`
CheckinDisabledAccounts bool `json:"checkin_disabled_accounts"`
RoutingStrategy string `json:"routing_strategy"`
ProxyURL string `json:"proxy_url"`
WorkBuddyCheckinTime string `json:"workbuddy_checkin_time"`
CheckinTimes map[string]string `json:"checkin_times"`
Timezone string `json:"timezone"`
SessionAffinity executor.SessionAffinityStats `json:"session_affinity"`
}
type SystemSettingsPatch ¶
type SystemSettingsPatch struct {
CrossProviderModelPool *bool `json:"cross_provider_model_pool"`
CheckinDisabledAccounts *bool `json:"checkin_disabled_accounts"`
RoutingStrategy *string `json:"routing_strategy"`
ProxyURL *string `json:"proxy_url"`
WorkBuddyCheckinTime *string `json:"workbuddy_checkin_time"`
CheckinTimes map[string]string `json:"checkin_times"`
}