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 ¶
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:
- cfg.API.Key (legacy / direct field populated by Load or CLI flag)
- 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 ¶
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 ¶
OnboardingResult holds the values the user confirmed during init.