console

package
v0.7.44 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 20 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

This section is empty.

Variables

This section is empty.

Functions

func ParseQueryTime

func ParseQueryTime(raw string, endOfDay bool) *time.Time

func ParseStatsDims added in v0.7.2

func ParseStatsDims(raw string) []string

ParseStatsDims reads ?dim=model,account,provider. Unknown names are dropped; an empty result means "all dimensions" (the overview default).

Types

type Handler

type Handler struct {
	System            *appsvc.System
	KeyRotation       *appsvc.KeyRotation
	Control           *appsvc.Services
	Cfg               *config.Config
	Executor          *executor.ChatExecutor
	Pool              *executor.Pool
	Recorder          *applogs.RequestRecorder
	Ring              *applogs.Ring
	CrossProviderPool *atomic.Bool
	Update            *control.Coordinator

	Chat               http.HandlerFunc
	RequestedAccount   func(*http.Request) string
	FilterModels       func(*http.Request, []map[string]any) []map[string]any
	DecorateModels     func(context.Context, []map[string]any) []map[string]any
	FetchWorkerModels  func(refresh bool) []map[string]any
	FetchDisplayModels func(refresh bool, accountID string, mode appsvc.CatalogMode) ([]map[string]any, error)
	ConsoleKey         func() string
	// Resources returns the latest server+worker process usage snapshot. app
	// wires it to the runtime manager so console stays runtime-free.
	Resources func() *SystemResources
}

Handler is the operator HTTP surface. It decodes requests, calls control/ logs/update services, and maps responses. It must not import store or the runtime manager; catalog fetch, Qoder worker proxy, and live auth rotation are injected by app.

func (*Handler) HandleAPIKeyByID

func (h *Handler) HandleAPIKeyByID(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleAPIKeys

func (h *Handler) HandleAPIKeys(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleAccountBundleExport added in v0.7.40

func (h *Handler) HandleAccountBundleExport(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleAccountBundleImport added in v0.7.40

func (h *Handler) HandleAccountBundleImport(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleAccountByID

func (h *Handler) HandleAccountByID(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleAccountImport

func (h *Handler) HandleAccountImport(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleAccounts

func (h *Handler) HandleAccounts(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleCatalogStatus added in v0.7.13

func (h *Handler) HandleCatalogStatus(w http.ResponseWriter, r *http.Request)

HandleCatalogStatus reports the model-catalog sync state. GET only reads it; POST forces one full reload first and answers with the state that resulted. The body is 200 in both cases — a partial or failed refresh is described by last_error and the per-provider rows, not by the HTTP status.

func (*Handler) HandleChat

func (h *Handler) HandleChat(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleCheckinAll added in v0.7.40

func (h *Handler) HandleCheckinAll(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleConsoleKey

func (h *Handler) HandleConsoleKey(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleLive added in v0.7.2

func (h *Handler) HandleLive(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleLogs

func (h *Handler) HandleLogs(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleModelSetting

func (h *Handler) HandleModelSetting(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleModelsAPI

func (h *Handler) HandleModelsAPI(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleOverview

func (h *Handler) HandleOverview(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleOverviewSummary

func (h *Handler) HandleOverviewSummary(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleProviders

func (h *Handler) HandleProviders(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleSystemResources added in v0.6.14

func (h *Handler) HandleSystemResources(w http.ResponseWriter, r *http.Request)

HandleSystemResources serves GET /api/system/resources. The snapshot itself is produced by the injected Resources func (app wires it to the runtime manager); labels come from the account list so workers show friendly names.

func (*Handler) HandleSystemSettings

func (h *Handler) HandleSystemSettings(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleSystemUpdate

func (h *Handler) HandleSystemUpdate(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleSystemUpdateCancel

func (h *Handler) HandleSystemUpdateCancel(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleSystemUpdateConfirm

func (h *Handler) HandleSystemUpdateConfirm(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleSystemUpdatePrepare

func (h *Handler) HandleSystemUpdatePrepare(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleSystemUpdateRollback

func (h *Handler) HandleSystemUpdateRollback(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleUsage added in v0.7.9

func (h *Handler) HandleUsage(w http.ResponseWriter, r *http.Request)

func (*Handler) StatsCacheSize

func (h *Handler) StatsCacheSize() int

type LiveAccount added in v0.7.2

type LiveAccount struct {
	ID          string `json:"id"`
	InFlight    int    `json:"in_flight"`
	MaxInFlight int    `json:"max_inflight"`
	Enabled     bool   `json:"enabled"`
}

LiveAccount is the per-account slice of the live concurrency snapshot (LiveStrip / sidebar). Kept for backward compatibility.

type LiveCompletion added in v0.7.21

type LiveCompletion struct {
	// RequestID identifies the finished open request so InflightLiveCard can
	// fly that concurrency cell to Done/Failed independently (not whole account).
	RequestID string `json:"request_id,omitempty"`
	AccountID string `json:"account_id"`
	Status    string `json:"status"`
}

LiveSnapshot is the cheap payload behind /api/live, polled every few seconds by the overview live strip and (Stage-3) the inflight card. LiveCompletion is one terminal request finish drained from the request recorder for this /api/live poll (busy→idle Done vs Failed routing).

type LiveJob added in v0.7.22

type LiveJob struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Status    string `json:"status"`
	StartedAt string `json:"started_at,omitempty"`
	// AccountID: dwell fly target on Queue; always set on Occupancy.
	AccountID string `json:"account_id,omitempty"`
}

LiveJob is one selecting (选号) or bound occupancy request for the InflightLiveCard. Status reuses accounts.RequestStatus* — not a new state machine. Queue uses unbound/dwell selecting; Occupancy uses BoundRequests (per-cell model + started_at). Workers still carry Pool InFlight counts.

type LiveRateLimit added in v0.7.21

type LiveRateLimit struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	AccountID   string `json:"account_id"`
	Model       string `json:"model,omitempty"`
	Until       string `json:"until"`
	RemainingMs int64  `json:"remaining_ms"`
}

LiveRateLimit is one active account-wide or model-scoped cooldown window, read from AccountView.DownUntil / ModelCooldowns (already projected from Pool DownUntil / ModelDownUntil). Console never invents a second cooldown state machine here.

type LiveSnapshot added in v0.7.2

type LiveSnapshot struct {
	Time              string                        `json:"time"`
	InFlight          int                           `json:"in_flight"`
	Capacity          int                           `json:"capacity"`
	RPM               int                           `json:"rpm"`
	Accounts          []LiveAccount                 `json:"accounts"`
	Workers           []LiveWorker                  `json:"workers"`
	RateLimits        []LiveRateLimit               `json:"rate_limits"`
	Sticky            executor.SessionAffinityStats `json:"sticky"`
	RecentCompletions []LiveCompletion              `json:"recent_completions,omitempty"`
	// Queue is Prepare→Acquire 选号 (RequestStatusStarted / dwell).
	Queue []LiveJob `json:"queue,omitempty"`
	// Occupancy is bound open requests (one per concurrency cell) with model
	// name and per-request started_at (Bind time) for InflightLiveCard.
	Occupancy []LiveJob `json:"occupancy,omitempty"`
}

type LiveWorker added in v0.7.21

type LiveWorker struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Provider    string `json:"provider"`
	Busy        bool   `json:"busy"`
	InFlight    int    `json:"in_flight"`
	MaxInFlight int    `json:"max_inflight"`
	Enabled     bool   `json:"enabled"`
	RateLimited bool   `json:"rate_limited"`
	// Progress is a legacy occupancy ratio (in_flight/max_inflight). The
	// Overview card no longer treats it as % toward completion — busy slots
	// use an indeterminate shimmer; keep the field for API compat.
	Progress float64 `json:"progress"`
	// StartedAt is RFC3339 wall-clock when the pool slot went busy
	// (InFlight 0→1). Empty when idle. UI shows real elapsed from this.
	StartedAt string `json:"started_at,omitempty"`
	// LastErrorKind is AccountView.LastErrorKind — fallback when a busy→idle
	// transition has no matching recent_completions entry yet.
	LastErrorKind string `json:"last_error_kind,omitempty"`
}

LiveWorker is one account-pool slot projected for the Overview「实时进行中」 card. Stage-1 UI still mocks jobs/depth; Stage-3 swaps workers/rate_limits/ sticky onto this shape without a parallel /api/inflight*.

type SystemProcessResources added in v0.6.14

type SystemProcessResources 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 SystemResources added in v0.6.14

type SystemResources struct {
	SampledAt string                  `json:"sampled_at"`
	Server    SystemProcessResources  `json:"server"`
	Workers   []SystemWorkerResources `json:"workers"`
	TotalRSS  int64                   `json:"total_rss_bytes"`
}

SystemResources is the console-facing view of host process usage. The fields mirror runtime.ResourceSnapshot but the type lives here so console never imports the runtime package.

type SystemWorkerResources added in v0.6.14

type SystemWorkerResources struct {
	AccountID  string  `json:"account_id"`
	Label      string  `json:"label,omitempty"`
	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