Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var APIEnvKeyPatterns = []string{
"_API_KEY",
"_TOKEN",
"_SECRET",
"_ACCESS_KEY",
"_SECRET_KEY",
}
APIEnvKeyPatterns defines the suffixes and prefixes for API keys and related credentials.
var APIEnvKeyPrefixes = []string{
"SPROUT_PROVIDER",
"SPROUT_SUBAGENT_PROVIDER",
"SPROUT_SUBAGENT_MODEL",
}
APIEnvKeyPrefixes defines specific prefixes to capture.
var ForceConfirm bool
ForceConfirm skips confirmation prompts when true (set by -y flag).
var ServiceCmd = &cobra.Command{
Use: "service",
Short: "Manage the sprout daemon service",
Long: `Manage the sprout daemon as a system service.
Integration with systemd (Linux) or launchd (macOS) allows the sprout
web UI to start automatically on boot and run persistently in the background.`,
}
ServiceCmd is the root command for service management.
Functions ¶
func CaptureAPIKeysFromEnv ¶
func CaptureAPIKeysFromEnv() []string
captureAPIKeysFromEnv filters the current environment for API keys and related credentials. It returns a slice of "KEY=value" strings for matching environment variables.
func GenerateServiceEnvFile ¶
func GenerateServiceEnvFile() error
GenerateServiceEnvFile captures API keys from the current environment and writes them to the state directory's service.env with restricted permissions (0600).
Takes no homeDir: the destination comes from envutil.StateDir(). See ServiceEnvPath for why.
func LoadServiceEnvFile ¶
LoadServiceEnvFile reads the state directory's service.env and returns a map of key-value pairs. If the file doesn't exist or is empty, returns an empty map.
Takes no homeDir: the source comes from envutil.StateDir(). See ServiceEnvPath for why.
func MatchesAPIKeyPattern ¶
matchesAPIKeyPattern returns true if the environment variable name appears to be an API key.
func ServiceEnvPath ¶
ServiceEnvPath returns the path to the service.env file in the state dir.
It deliberately takes no homeDir argument. The state root is resolved by envutil.StateDir() ($SPROUT_STATE_DIR → $XDG_STATE_HOME/sprout → $HOME/.local/state/sprout), so it is not necessarily under any particular home directory. The previous signature accepted a homeDir that was silently ignored whenever StateDir() succeeded — callers that passed an isolated directory (notably tests) still read and wrote the real user's file, which caused live API keys to be loaded into test output. Redirect via $SPROUT_STATE_DIR instead.
Types ¶
This section is empty.