setupcheck

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package setupcheck evaluates local runtime readiness (defaults, backends) for the CLI.

Index

Constants

View Source
const (
	CategoryDefaults     = "defaults"
	CategoryRegistration = "registration"
	CategoryHealth       = "health"
)
View Source
const DefaultOllamaSuggestModel = "qwen2.5:7b"

DefaultOllamaSuggestModel is the model name we suggest for local Ollama when no chat models are present yet.

Variables

This section is empty.

Functions

func ProbeLocalOllamaAPI

func ProbeLocalOllamaAPI(ctx context.Context) (baseURL string, ok bool)

ProbeLocalOllamaAPI returns (baseURL, true) if GET {base}/api/tags responds with HTTP 200.

func ResolveMaxOutputTokens added in v0.29.0

func ResolveMaxOutputTokens(states []statetype.BackendRuntimeState, provider, model string) int

ResolveMaxOutputTokens returns the known output-token ceiling for the active provider/model from already-synced runtime state. It returns 0 when unknown.

func StatesFromMap

StatesFromMap flattens runtime state snapshots for Evaluate / GatherInput.

Types

type BackendCheck

type BackendCheck struct {
	ID              string   `json:"id"`
	Name            string   `json:"name"`
	Type            string   `json:"type"`
	BaseURL         string   `json:"baseUrl"`
	Status          string   `json:"status"`
	Reachable       bool     `json:"reachable"`
	DefaultProvider bool     `json:"defaultProvider"`
	ModelCount      int      `json:"modelCount"`
	ChatModelCount  int      `json:"chatModelCount"`
	ChatModels      []string `json:"chatModels,omitempty"`
	Error           string   `json:"error,omitempty"`
	Hint            string   `json:"hint,omitempty"`
}

BackendCheck reports the runtime status of one registered backend.

type Input

type Input struct {
	DefaultModel       string
	DefaultProvider    string
	DefaultAltModel    string
	DefaultAltProvider string
	DefaultChain       string
	HITLPolicyName     string
	States             []statetype.BackendRuntimeState
	// RegisteredBackendCount, if non-nil, overrides len(RegisteredBackends) / len(States)
	// for BackendCount. CLI doctor sets this from ListBackends when runtime state sync is unavailable.
	RegisteredBackendCount *int
	RegisteredBackends     []runtimetypes.Backend
	// ResolvedFrom records where workspace-scoped keys came from: "workspace" or "global".
	// Keys are camelCase JSON names: "defaultChain", "hitlPolicyName".
	ResolvedFrom map[string]string
}

Input is everything needed to compute readiness; callers gather from DB + runtime state.

func GatherInput

func GatherInput(ctx context.Context, db libdbexec.DBManager, states []statetype.BackendRuntimeState, workspaceID string) (Input, error)

GatherInput builds Input from SQLite KV defaults, registered backend count, and a runtime state snapshot. workspaceID scopes workspace-scoped keys (default-chain, hitl-policy-name) with global fallback.

type Issue

type Issue struct {
	Code       string `json:"code"`
	Severity   string `json:"severity"`
	Category   string `json:"category,omitempty"`
	Message    string `json:"message"`
	FixPath    string `json:"fixPath,omitempty"`
	CLICommand string `json:"cliCommand,omitempty"`
}

Issue describes one setup problem and how to fix it.

type Result

type Result struct {
	DefaultModel           string            `json:"defaultModel"`
	DefaultProvider        string            `json:"defaultProvider"`
	DefaultMaxOutputTokens int               `json:"defaultMaxOutputTokens,omitempty"`
	DefaultChain           string            `json:"defaultChain"`
	HITLPolicyName         string            `json:"hitlPolicyName"`
	BackendCount           int               `json:"backendCount"`
	ReachableBackendCount  int               `json:"reachableBackendCount"`
	Issues                 []Issue           `json:"issues"`
	BackendChecks          []BackendCheck    `json:"backendChecks,omitempty"`
	ResolvedFrom           map[string]string `json:"resolvedFrom,omitempty"`
}

Result is returned by GET /setup-status and contenox doctor.

func EnrichResultWithOllamaProbe

func EnrichResultWithOllamaProbe(ctx context.Context, r Result) Result

EnrichResultWithOllamaProbe probes the local Ollama HTTP API (OLLAMA_HOST or default) and augments registration-related issues when /api/tags is reachable but no Ollama backend is ready yet.

func Evaluate

func Evaluate(in Input) Result

Evaluate returns readiness from gathered input (no I/O).

func (Result) BlockingIssues

func (r Result) BlockingIssues() []Issue

BlockingIssues returns the issues that make the runtime not ready, in the order Evaluate produced them. It performs no I/O.

func (Result) Ready

func (r Result) Ready() bool

Ready reports whether the runtime has a usable default model and provider with a reachable backend. It reads the already-computed Result — no I/O, and never a model completion — and is the shared readiness predicate for doctor, chat/run preflight, and the setup wizard.

func (Result) Summary

func (r Result) Summary() string

Summary renders a concise, human-readable readiness report for a chat/terminal surface (e.g. the ACP /doctor command). It reads the already-computed Result — no I/O and no model completion.

Jump to

Keyboard shortcuts

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