service

package
v0.17.18 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIEnvKeyPatterns = []string{
	"_API_KEY",
	"_TOKEN",
	"_SECRET",
	"_ACCESS_KEY",
	"_SECRET_KEY",
}

APIEnvKeyPatterns defines the suffixes and prefixes for API keys and related credentials.

View Source
var APIEnvKeyPrefixes = []string{
	"SPROUT_PROVIDER",
	"SPROUT_SUBAGENT_PROVIDER",
	"SPROUT_SUBAGENT_MODEL",
}

APIEnvKeyPrefixes defines specific prefixes to capture.

View Source
var ForceConfirm bool

ForceConfirm skips confirmation prompts when true (set by -y flag).

View Source
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

func LoadServiceEnvFile() (map[string]string, error)

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

func MatchesAPIKeyPattern(key string) bool

matchesAPIKeyPattern returns true if the environment variable name appears to be an API key.

func ServiceEnvPath

func ServiceEnvPath() (string, error)

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.

Jump to

Keyboard shortcuts

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