Documentation
¶
Index ¶
- Variables
- func ApplyServiceEnvFile() ([]string, error)
- func CaptureAPIKeysFromEnv() []string
- func GenerateServiceEnvFile() error
- func IsSecretEnvName(key string) bool
- func LoadServiceEnvFile() (map[string]string, error)
- func MatchesAPIKeyPattern(key string) bool
- func ServiceEnvPath() (string, error)
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 ApplyServiceEnvFile ¶ added in v0.29.2
ApplyServiceEnvFile sets the variables from service.env in the current process. A service-managed daemon calls it at startup: launchd has no EnvironmentFile equivalent, so this is how captured keys reach the daemon on macOS without being written into the plist. Variables already present in the environment win (on Linux systemd has already applied the same file, so this changes nothing there). It returns the names it set — never values — and its errors carry no values either.
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 IsSecretEnvName ¶ added in v0.29.2
IsSecretEnvName reports whether a variable name looks like a credential (`*_API_KEY`, `*_TOKEN`, `*_SECRET`, ...). Unlike MatchesAPIKeyPattern it ignores the non-secret SPROUT_PROVIDER-style settings service.env also carries.
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.