onboarding

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package onboarding provides helpers that detect whether the user needs first-run configuration before the agent can make API calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NeedsOnboarding

func NeedsOnboarding(cfg config.Config) (bool, error)

NeedsOnboarding reports whether the active provider has no resolvable API key or the base URL is empty — both are required to make any call.

Resolution order for the key:

  1. cfg.API.Key (legacy / direct field populated by Load or CLI flag)
  2. cfg.Providers[cfg.Active.Provider] via config.ResolveSecret

The second return value is non-nil only for unexpected I/O errors (e.g. bad secrets-file permissions, TOML parse failure). A missing key is not an error: it is expressed as (true, nil). Callers should surface a non-nil error as a diagnostic rather than treating it as "needs onboarding".

func PersistConfig

func PersistConfig(r OnboardingResult) error

PersistConfig writes:

  • model + base_url to ~/.deepseek/config.toml (user config layer)
  • DEEPSEEK_API_KEY = apiKey to config.SecretsPath() at mode 0600

func Run

func Run(ctx context.Context, cfg config.Config, args []string, in io.Reader, out io.Writer, hc *http.Client) error

Run is the entry point for `dsc init`. In interactive mode it prompts on stdin/stdout; in --non-interactive it reads from env / existing config and errors loudly if anything is missing. hc is the HTTP client used for key validation (nil = http.DefaultClient).

func ValidateKey

func ValidateKey(ctx context.Context, baseURL, apiKey string, hc *http.Client) error

ValidateKey sends a minimal single-token chat-completions request to baseURL using the provided apiKey. hc is injected so tests can supply httptest clients. Returns nil on HTTP 200, a descriptive error otherwise.

Types

type OnboardingResult

type OnboardingResult struct {
	APIKey  string
	BaseURL string
	Model   string
}

OnboardingResult holds the values the user confirmed during init.

Jump to

Keyboard shortcuts

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