Documentation
¶
Overview ¶
Package setup provides config generation for the day-1 onboarding wizard. It builds config.GenieConfig from wizard answers and encodes it with the TOML library so CLI-generated config is compatible with config.LoadGenieConfig. The web Config Builder is at https://stackgenhq.github.io/genie/config-builder.html.
Package setup: detect checks for existing AI API keys in the environment so the wizard can pre-select a provider and optionally skip the "paste key" step.
Package setup: tools_spec loads optional-tool definitions from embedded JSON and applies collected answers to config.GenieConfig so the setup wizard can offer dynamic, data-driven forms for email, web search, calendar, etc.
Index ¶
- Constants
- func ApplyToolAnswers(cfg *config.GenieConfig, answers map[string]map[string]string)
- func BuildGenieConfig(in WizardInputs, securitySecrets map[string]string, ...) config.GenieConfig
- func ConfigPathFromCollected(c *Collected, configPathDefault string) (string, error)
- func DefaultModelForProvider(provider string) string
- func DetectAIKeyProvider() string
- func EncodeTOML(w io.Writer, cfg config.GenieConfig) error
- func SecretNameForProvider(provider string) string
- func ValidateConfigPath(s string) error
- func WriteConfigFile(path string, in WizardInputs, toolAnswers map[string]map[string]string, ...) error
- type Collected
- type OptionSpec
- type QuestionSpec
- type ToolSpec
- type WizardInputs
Constants ¶
const ( ChoiceYes = "yes" ChoiceNo = "no" )
Choice values for yes/no setup questions.
const ( EnvOpenAIKey = "OPENAI_API_KEY" EnvGoogleKey = "GOOGLE_API_KEY" EnvAnthropicKey = "ANTHROPIC_API_KEY" )
Env var names used by Genie for each provider (must match SecretNameForProvider).
const DefaultPlatform = "agui"
Default platform when user does not pick one.
const DefaultSkillsRoots = "./skills"
Default skills roots path offered in the wizard.
Variables ¶
This section is empty.
Functions ¶
func ApplyToolAnswers ¶
func ApplyToolAnswers(cfg *config.GenieConfig, answers map[string]map[string]string)
ApplyToolAnswers applies collected tool answers to cfg. Only tools present in answers are configured; others are left as zero values. Call this after building the base GenieConfig so optional tools are merged in.
func BuildGenieConfig ¶
func BuildGenieConfig(in WizardInputs, securitySecrets map[string]string, toolAnswers map[string]map[string]string) config.GenieConfig
BuildGenieConfig builds a config.GenieConfig from wizard inputs. When securitySecrets is non-nil, the config uses [security.secrets] with filevar URLs and token is "${name}"; otherwise when ModelProviderTokenLiteral is set the token is literal, or "${ENV_VAR}" when using env. Optional toolAnswers (from the tools step) are applied via ApplyToolAnswers when non-nil.
func ConfigPathFromCollected ¶
ConfigPathFromCollected returns the absolute config path from collected or default.
func DefaultModelForProvider ¶
DefaultModelForProvider returns a default model name for the given provider.
func DetectAIKeyProvider ¶
func DetectAIKeyProvider() string
DetectAIKeyProvider returns the first provider that has a non-empty API key in the environment: "openai", "gemini", "anthropic", or "" if none set. Use this before the model step to pre-select the provider and allow "leave blank to use existing key".
func EncodeTOML ¶
func EncodeTOML(w io.Writer, cfg config.GenieConfig) error
EncodeTOML encodes cfg to TOML and writes it to w using the same library (github.com/BurntSushi/toml) and structs as config.LoadGenieConfig.
func SecretNameForProvider ¶
SecretNameForProvider returns the conventional env/secret name for the provider. Uses keyring account constants so keyring and config stay in sync.
func ValidateConfigPath ¶
ValidateConfigPath returns an error if s is empty or not a valid path. Used when the user passes --config to genie setup.
func WriteConfigFile ¶
func WriteConfigFile(path string, in WizardInputs, toolAnswers map[string]map[string]string, vectorMemoryOverride *vector.Config) error
WriteConfigFile builds config from inputs and writes it to path. Every secret collected (pasted or from env) is stored in the system keyring and [security.secrets] is set to keyring:// URLs so the secret provider resolves them via keyringvar at runtime. The config file never contains raw secrets. Optional toolAnswers from the tools step are merged when non-nil. If vectorMemoryOverride is non-nil, it is used as the [vector_memory] config (e.g. when setup detects a local Ollama for embeddings).
Types ¶
type Collected ¶
type Collected struct {
ConfigPath string
SkillsRoots string
ModelProvider string
ModelName string // optional; when set (e.g. user picked Ollama model) used for that provider
AgentName string
APIKey string
Platform string
// Messenger tokens / env (platform-specific)
TelegramToken string
TelegramTokenEnv string
SlackAppTokenEnv string
SlackBotTokenEnv string
DiscordBotTokenEnv string
TeamsAppIDEnv string
TeamsAppPassEnv string
GoogleChatCreds string
// Google and data sources
ManageGoogleServices string // ChoiceYes or ChoiceNo
// Learn is ChoiceYes when the user wants Genie to gather data (Gmail, Calendar) and learn from it (sync + knowledge graph after first sync).
Learn string
DataSourcesKeywords string
// AGUI (built-in web): when true, the web chat is secured with a password (stored in keyring per agent during setup).
AGUIPasswordProtected bool
}
Collected holds all answers from the setup wizard. The CLI populates it step-by-step; ApplyCollectedToInputs and ConfigPathFromCollected consume it to build WizardInputs and resolve the config path.
type OptionSpec ¶
OptionSpec is one option in a select question.
type QuestionSpec ¶
type QuestionSpec struct {
Key string `json:"key"`
Label string `json:"label"`
Description string `json:"description"`
Type string `json:"type"` // "input", "password", "select", "number"
Options []OptionSpec `json:"options,omitempty"`
Default string `json:"default,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Optional bool `json:"optional,omitempty"`
}
QuestionSpec describes a single question in a tool's form.
type ToolSpec ¶
type ToolSpec struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Questions []QuestionSpec `json:"questions"`
}
ToolSpec describes one optional tool and its setup questions. It is loaded from tools.json so devs can add tools without changing wizard code.
func LoadSetupTools ¶
LoadSetupTools returns the list of optional tools and their questions from embedded tools.json. Add or edit tools there to change the wizard without changing Go code.
type WizardInputs ¶
type WizardInputs struct {
// AgentName is the user-chosen name for the agent (personality and default audit path).
AgentName string
// Messenger
Platform string // "", "slack", "telegram", "teams", "googlechat", "whatsapp", "discord"
TelegramTokenEnv string // env var name when token not in keyring
TelegramTokenLiteral string // pasted token stored in keyring when set
SlackAppTokenEnv string
SlackBotTokenEnv string
DiscordBotTokenEnv string
TeamsAppIDEnv string
TeamsAppPassEnv string
TeamsListenAddr string
GoogleChatCreds string
// Model provider (first provider)
ModelProvider string // "openai", "gemini", "anthropic"
ModelName string // default model for that provider
ModelProviderTokenEnv string // env var name when not pasting key
ModelProviderTokenLiteral string // pasted API key (stored in config when set)
// Skills
SkillsRoots []string
// ManageGoogleServices is true when the user chose to connect Google (Calendar, Contacts, Gmail) during setup.
ManageGoogleServices bool
// Learn is true when the user wants Genie to gather data (Gmail, Calendar) and learn from it: sync runs in the background and a knowledge graph is built after the first sync.
Learn bool
// DataSourceKeywords are up to MaxSearchKeywords terms (e.g. project names, customers) that Genie should look for when indexing; only items matching any keyword are embedded. From setup wizard or config.
DataSourceKeywords []string
// AGUIPasswordProtected is true when the user chose to secure the built-in web chat with a password (stored in keyring per agent).
AGUIPasswordProtected bool
}
WizardInputs holds the raw answers from the setup wizard (env var names, platform choice, paths). It is not a duplicate of config structs; it is only the form data used to build config.GenieConfig.
func ApplyCollectedToInputs ¶
func ApplyCollectedToInputs(c *Collected, detectedProvider string) WizardInputs
ApplyCollectedToInputs maps collected setup answers to WizardInputs for writing config. When APIKey is empty and detectedProvider is set, the config uses the env var placeholder for that provider.
func DefaultWizardInputs ¶
func DefaultWizardInputs() WizardInputs
DefaultWizardInputs returns inputs with the same defaults as the web Config Builder.