runtime

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	KindAuth                    = accounts.KindAuth
	KindUnavailable             = accounts.KindUnavailable
	DefaultWorkBuddyCheckinTime = accounts.DefaultWorkBuddyCheckinTime
)

Variables

View Source
var ErrAccountNotFound = accounts.ErrAccountNotFound

Functions

func CheckedInLocalDay

func CheckedInLocalDay(at, status string, now time.Time) bool

func NormalizeWeight

func NormalizeWeight(priority int) int

func NormalizeWorkBuddyCheckinTime

func NormalizeWorkBuddyCheckinTime(value string) (string, error)

func PersistRetryBackoff

func PersistRetryBackoff() time.Duration

func QoderRuntimeSpec

func QoderRuntimeSpec(cfg ManagerConfig, account Account, home string) (cliPath, site, configDir, configEnv string, err error)

func StarterEnv

func StarterEnv(config ManagerConfig, account Account, home string, port int) ([]string, error)

Types

type APIKeyConfigurableStarter

type APIKeyConfigurableStarter interface {
	SetProxyAPIKey(string)
}

APIKeyConfigurableStarter is the sibling of ProxyConfigurableStarter for the manager's proxy API key.

type Account

type Account = accounts.Account

type AccountStore

type AccountStore = accounts.AccountStore

type AccountView

type AccountView = accounts.AccountView

type CheckinRecord

type CheckinRecord = accounts.CheckinRecord

type Classified

type Classified = executor.Classified

type CooldownRow

type CooldownRow = accounts.CooldownRow

type CreateAccount

type CreateAccount = accounts.CreateAccount

type ExecStarter

type ExecStarter struct {

	// Config is initial configuration; after first use access it through methods.
	Config ManagerConfig
	// contains filtered or unexported fields
}

func NewExecStarter

func NewExecStarter(config ManagerConfig) *ExecStarter

func (*ExecStarter) ConfigSnapshot

func (s *ExecStarter) ConfigSnapshot() ManagerConfig

func (*ExecStarter) SetProxyAPIKey

func (s *ExecStarter) SetProxyAPIKey(value string)

func (*ExecStarter) SetProxyURL

func (s *ExecStarter) SetProxyURL(value string)

func (*ExecStarter) Start

func (s *ExecStarter) Start(ctx context.Context, account Account, home string, port int) (ManagedProcess, error)

type ImportAccount

type ImportAccount = accounts.ImportAccount

type Item

type Item = executor.Item

type ManagedProcess

type ManagedProcess interface {
	URL() string
	Done() <-chan error
	Stop() error
	// PID returns the OS process ID, or 0 when the process is not running or the
	// starter does not spawn an external process.
	PID() int
}

type Manager

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

func NewManager

func NewManager(config ManagerConfig, store AccountStore, starter ProcessStarter) *Manager

func (*Manager) AccountURL

func (m *Manager) AccountURL(id string) (string, bool)

func (*Manager) AccountView

func (m *Manager) AccountView(ctx context.Context, id string) (AccountView, error)

RefreshAccount re-probes one account's health, quota, and model catalog. forceQuota bypasses the worker's own quota cache, matching the console's "Refresh credits" button. It refreshes only the requested account, so a

func (*Manager) Accounts

func (m *Manager) Accounts(ctx context.Context) ([]AccountView, error)

func (*Manager) CheckinAccount

func (manager *Manager) CheckinAccount(ctx context.Context, accountID string) (Account, error)

func (*Manager) CheckinOptedIn

func (manager *Manager) CheckinOptedIn(ctx context.Context)

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, input CreateAccount) (Account, error)

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, id string) error

func (*Manager) EnsureModelCatalogs

func (m *Manager) EnsureModelCatalogs(ctx context.Context, force bool)

EnsureModelCatalogs refreshes per-account catalogs that are missing or older than the worker TTL. Failures leave the previous snapshot in place and never flip readiness or cooldown.

Refreshes run concurrently in the background with a bounded semaphore so the first chat request is never blocked by N serial 15-second timeouts when multiple accounts are offline. The caller returns immediately; a nil Models slice means unknown (fail open) until the background refresh completes and subsequent requests use the fresh catalog.

func (*Manager) Flush

func (m *Manager) Flush()

Flush waits for all cooldown writes queued so far to be persisted. The marker fires only once the dirty set has drained to empty, so every account's newest state enqueued before this call is persisted before Flush returns.

func (*Manager) Import

func (m *Manager) Import(ctx context.Context, input ImportAccount) (Account, error)

func (*Manager) KeepaliveWorkBuddy

func (manager *Manager) KeepaliveWorkBuddy(ctx context.Context, onlyOptIn bool)

func (*Manager) Pool

func (m *Manager) Pool() *Pool

func (*Manager) ProxyAPIKey

func (m *Manager) ProxyAPIKey() string

func (*Manager) RefreshAccount

func (m *Manager) RefreshAccount(ctx context.Context, id string, forceQuota bool) error

func (*Manager) RefreshAll

func (m *Manager) RefreshAll(ctx context.Context, forceQuota bool) error

AccountView returns the same projection the accounts list builds, for one

func (*Manager) ReloadProxyURL

func (m *Manager) ReloadProxyURL(ctx context.Context, value string) error

func (*Manager) RemoveAccount

func (m *Manager) RemoveAccount(id string) error

func (*Manager) ReplaceProxyAPIKey

func (m *Manager) ReplaceProxyAPIKey(ctx context.Context, key string) error

func (*Manager) Resources added in v0.6.14

func (m *Manager) Resources() ResourceSnapshot

Resources returns the most recent resource snapshot. The maintenance loop refreshes it on every tick; if it has never run (tests, minimal embedding) a sample is taken synchronously.

func (*Manager) RunMaintenanceLoop added in v0.6.1

func (manager *Manager) RunMaintenanceLoop(stop <-chan struct{})

func (*Manager) SetProviders

func (m *Manager) SetProviders(registry *providers.Registry)

SetProviders wires optional in-process account probers (WorkBuddy, etc.).

func (*Manager) SetWorkBuddy

func (m *Manager) SetWorkBuddy(ops WorkBuddyMaintainer)

SetWorkBuddy wires Phase N check-in / keepalive without a second scheduler package.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

func (*Manager) StartAccount

func (m *Manager) StartAccount(ctx context.Context, account Account) error

func (*Manager) StopAccount

func (m *Manager) StopAccount(id string) error

func (*Manager) Store

func (m *Manager) Store() AccountStore

func (*Manager) SyncAccount

func (m *Manager) SyncAccount(ctx context.Context, before, after Account) error

func (*Manager) SyncCredential

func (m *Manager) SyncCredential(ctx context.Context, id, authType string) error

func (*Manager) TestCheckinOptedIn

func (m *Manager) TestCheckinOptedIn(ctx context.Context, now time.Time, scheduledTime string, retryDue bool)

func (*Manager) TestPersistDirtyLen

func (m *Manager) TestPersistDirtyLen() int

func (*Manager) TestPersistSnapshot

func (m *Manager) TestPersistSnapshot(id string) (item Item, version uint64, ok bool)

func (*Manager) TestProcess

func (m *Manager) TestProcess(id string) ManagedProcess

func (*Manager) TestProcessCount

func (m *Manager) TestProcessCount() int

func (*Manager) TestRecoverPending added in v0.7.1

func (m *Manager) TestRecoverPending(id string) bool

TestRecoverPending reports whether a failure is queued behind an active recovery.

func (*Manager) TestRecovering

func (m *Manager) TestRecovering(id string) bool

func (*Manager) TestRestartDelay

func (m *Manager) TestRestartDelay(level int) time.Duration

func (*Manager) TestRestoreCooldowns

func (m *Manager) TestRestoreCooldowns(ctx context.Context)

func (*Manager) TestSetRecoverUnwindHook added in v0.7.1

func (m *Manager) TestSetRecoverUnwindHook(hook func(id string))

TestSetRecoverUnwindHook installs a hook run when a recovery goroutine starts unwinding, before it clears the recovering guard. Tests only.

func (*Manager) TestStartAccount

func (m *Manager) TestStartAccount(ctx context.Context, account Account) error

func (*Manager) Update

func (m *Manager) Update(ctx context.Context, id string, input UpdateAccount) error

func (*Manager) WorkerAdmin

func (m *Manager) WorkerAdmin(ctx context.Context, input providers.AdminRequest) (providers.AdminResponse, error)

WorkerAdmin coordinates worker readiness and authoritative credential sync. HTTP status/body are opaque worker protocol results, not public handlers.

func (*Manager) WorkerPIDs added in v0.6.14

func (m *Manager) WorkerPIDs() map[string]int

WorkerPIDs maps account ID -> OS PID for managed child processes. In-process providers never appear here. Safe for concurrent use.

type ManagerConfig

type ManagerConfig struct {
	DataDir         string
	BasePort        int
	NodeBinary      string
	DaemonPath      string
	QoderCLIPath    string
	QoderCNCLIPath  string
	TemplatePath    string
	ProxyAPIKey     string
	ProxyURL        string
	MaxLogWriters   io.Writer
	RestartDelay    time.Duration
	RestartMaxDelay time.Duration
}

type NativeCredential

type NativeCredential = accounts.NativeCredential

type Pool

type Pool = executor.Pool

func NewPool

func NewPool(urls, ids []string) *Pool

type PoolStateStore

type PoolStateStore = accounts.PoolStateStore

type ProcessResources added in v0.6.14

type ProcessResources struct {
	PID        int     `json:"pid"`
	RSSBytes   int64   `json:"rss_bytes"`
	HeapBytes  int64   `json:"heap_bytes,omitempty"`
	Goroutines int     `json:"goroutines,omitempty"`
	CPUPercent float64 `json:"cpu_percent"`
}

type ProcessStarter

type ProcessStarter interface {
	Start(context.Context, Account, string, int) (ManagedProcess, error)
}

type ProxyConfigurableStarter

type ProxyConfigurableStarter interface {
	SetProxyURL(string)
}

ProxyConfigurableStarter lets the manager push the global outbound proxy to a starter that can apply it to newly spawned workers. Kept optional so test starters need not implement it.

type QuotaRefreshError added in v0.6.20

type QuotaRefreshError struct{ Err error }

QuotaRefreshError reports an upstream quota refresh failure without implying that the account itself is unhealthy or unavailable.

func (*QuotaRefreshError) Error added in v0.6.20

func (e *QuotaRefreshError) Error() string

func (*QuotaRefreshError) Unwrap added in v0.6.20

func (e *QuotaRefreshError) Unwrap() error

type QuotaSnapshot

type QuotaSnapshot = accounts.QuotaSnapshot

type ResourceSnapshot added in v0.6.14

type ResourceSnapshot struct {
	SampledAt time.Time         `json:"sampled_at"`
	Server    ProcessResources  `json:"server"`
	Workers   []WorkerResources `json:"workers"`
}

ResourceSnapshot is a point-in-time view of host process usage for the server and each managed worker process. CPU percent follows the ps/top convention: 100 == one core fully busy.

type UpdateAccount

type UpdateAccount = accounts.UpdateAccount

type WorkBuddyMaintainer

type WorkBuddyMaintainer interface {
	DailyCheckin(ctx context.Context, accountID string) (string, error)
	Keepalive(ctx context.Context, accountID string) error
}

WorkBuddyMaintainer is the Phase N ops surface. Implemented by workbuddy.Client; kept narrow so accounts does not grow a generic check-in capability on AccountProber.

type WorkerResources added in v0.6.14

type WorkerResources struct {
	AccountID  string  `json:"account_id"`
	PID        int     `json:"pid"`
	RSSBytes   int64   `json:"rss_bytes"`
	CPUPercent float64 `json:"cpu_percent"`
}

Jump to

Keyboard shortcuts

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