stateservice

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLIConfigPatch

type CLIConfigPatch struct {
	DefaultModel                *string
	DefaultProvider             *string
	DefaultAltModel             *string
	DefaultAltProvider          *string
	DefaultAutocompleteModel    *string
	DefaultAutocompleteProvider *string
	DefaultMaxTokens            *string
	DefaultThink                *string
	DefaultChain                *string
	HITLPolicyName              *string
}

CLIConfigPatch selects which CLI default keys to write; nil means "do not change".

type CLIConfigSnapshot

type CLIConfigSnapshot struct {
	DefaultModel                string
	DefaultProvider             string
	DefaultAltModel             string
	DefaultAltProvider          string
	DefaultAutocompleteModel    string
	DefaultAutocompleteProvider string
	DefaultMaxTokens            string
	DefaultThink                string
	DefaultChain                string
	HITLPolicyName              string
	ResolvedFrom                map[string]string
	Present                     map[string]bool
}

CLIConfigSnapshot is the resolved KV values after an update.

type RuntimeDefaults added in v0.33.0

type RuntimeDefaults struct {
	ChainRef             string
	FIMChainRef          string
	Model                string
	Provider             string
	AltModel             string
	AltProvider          string
	AutocompleteModel    string
	AutocompleteProvider string
	MaxTokens            string
	Think                string
}

RuntimeDefaults are the model/chain template defaults used when a request does not pass an explicit override.

func ResolveRuntimeDefaults added in v0.33.0

func ResolveRuntimeDefaults(ctx context.Context, service Service, fallback RuntimeDefaults) RuntimeDefaults

ResolveRuntimeDefaults overlays the current CLI config onto startup fallbacks. If state reads fail, callers keep the known-good startup values.

func (RuntimeDefaults) TemplateVars added in v0.33.0

func (d RuntimeDefaults) TemplateVars() map[string]string

func (RuntimeDefaults) Trimmed added in v0.33.0

func (d RuntimeDefaults) Trimmed() RuntimeDefaults

func (RuntimeDefaults) WithCLIConfig added in v0.33.0

func (d RuntimeDefaults) WithCLIConfig(snap CLIConfigSnapshot) RuntimeDefaults

type Service

type Service interface {
	Get(ctx context.Context) ([]statetype.BackendRuntimeState, error)
	// SetupStatus returns readiness from KV defaults, registered backends, and current runtime state.
	SetupStatus(ctx context.Context) (setupcheck.Result, error)
	// Refresh reconciles registered backends/models, then returns the updated setup status.
	Refresh(ctx context.Context) (setupcheck.Result, error)
	// CLIConfig returns the current resolved CLI config without mutating it.
	CLIConfig(ctx context.Context) (CLIConfigSnapshot, error)
	// SetCLIConfig updates CLI default keys in SQLite KV (same as contenox config set / PUT /cli-config).
	// Nil fields in the patch are left unchanged. Empty string fields are written and can clear a resolved setting.
	SetCLIConfig(ctx context.Context, patch CLIConfigPatch) (CLIConfigSnapshot, error)
}

Service exposes runtime backend state plus onboarding/setup evaluation (same inputs as GET /setup-status).

func New

func New(state *runtimestate.State, db libdbexec.DBManager, workspaceID string) Service

New returns a state service backed by runtime state and the same DB used for backends + CLI KV. workspaceID scopes workspace-specific config (default-chain, hitl-policy-name) with global fallback.

func WithActivityTracker

func WithActivityTracker(service Service, tracker libtracker.ActivityTracker) Service

WithActivityTracker wraps a StateService with activity tracking

Jump to

Keyboard shortcuts

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