config

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	EndpointServer = "server"
	EndpointApp    = "app"
)

The endpoints a profile names: HEY's server, or the HEY app on this computer, reached through the door it opens while "Let Agents Use HEY" is on.

View Source
const (
	AllAccounts = "all"
)
View Source
const DefaultMCPClientID = "vd96nBiRFXz1AjTXbADAtkrg"

DefaultMCPClientID is the client id of "HEY MCP (local)", the OAuth row `hey mcp` signs in as (haystack#9041), pinned by haystack's first-party client registry (haystack#9215, Oauth::Client::Mcp) to this one id in every HEY environment, as the CLI's own id is. HEY_MCP_CLIENT_ID or a configured id (MCPClientID) overrides it.

View Source
const ExperimentalEnv = "HEY_EXPERIMENTAL"

ExperimentalEnv turns on what is not ready to be anyone's default. Its value is a comma-separated list; "app" lets a profile's endpoint be the HEY app.

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() string

func ConfigDir

func ConfigDir() string

func Cover added in v0.2.0

func Cover() string

Cover is the art over the Imbox's Previously Seen, or "" for none.

It is stored here rather than read from HEY on purpose. The web app keeps a cover per box in its own table, but no client reads that: the iOS and Android apps each keep their own choice in device preferences, with their own set of presets, and never ask the server. This is the same decision, and it is the reason a cover set here does not show up on the web.

func EntryIsProfile added in v1.14.0

func EntryIsProfile(fields map[string]any) bool

EntryIsProfile reports whether a config file's entry names a profile, as parseProfiles reads it: one with a base_url, or one the app answers, which needs none.

func ExperimentalApp added in v1.14.0

func ExperimentalApp() bool

ExperimentalApp reports whether HEY_EXPERIMENTAL lists "app". Without it a profile whose endpoint is the app is refused, and nothing about the app shows in help.

func GlobalConfigPath added in v1.14.0

func GlobalConfigPath() string

GlobalConfigPath is the global config file hey reads, for a message naming it.

func GlobalConfigTakesProfiles added in v1.14.0

func GlobalConfigTakesProfiles() error

GlobalConfigTakesProfiles reports whether the global config file can take a profile entry, without writing anything: the refusal the writers make, made before a step that cannot be taken back (a sign-in, a credential's removal).

func HelpHidden added in v0.2.0

func HelpHidden() bool

HelpHidden reports whether the TUI's shortcut help is hidden.

func LastCalendarID added in v0.2.0

func LastCalendarID() int64

LastCalendarID is the calendar the last event was filed on, so the next new event opens on the same one. Somebody who keeps a work calendar and a personal one is nearly always adding to whichever they added to last, and the first in the list is a poor guess about which that is.

It lives here rather than on HEY for the reason Cover does: HEY serves no such preference, and making one up on the server for one client to read would be worse than remembering it locally.

func NonInteractiveEnv added in v0.2.0

func NonInteractiveEnv() bool

NonInteractiveEnv reports whether HEY_NONINTERACTIVE is set to a truthy value. When true, the CLI must not show interactive prompts regardless of TTY detection. This is an escape hatch for agents and harnesses that run the CLI under an allocated PTY (where stdio looks like a terminal) and want to avoid a prompt wedging the session — without forcing a machine output format the way --agent does.

func NormalizeAccountID added in v1.14.0

func NormalizeAccountID(accountID string) (string, error)

NormalizeAccountID reads a linked mail account ID, or "all".

func Origin added in v1.11.0

func Origin(baseURL string) (string, error)

Origin is baseURL's canonical origin (scheme and host lowercased, default port dropped), so one HEY has one spelling wherever it keys state.

func ProfileNameIsPathSafe added in v1.14.0

func ProfileNameIsPathSafe(name string) bool

ProfileNameIsPathSafe reports whether a profile name stays one directory below the directory it is joined to. A name from a config file was never validated, so it becomes a path component only when it is a single one.

func RegisterProfile added in v1.14.0

func RegisterProfile(name string, p ProfileConfig) (isDefault bool, err error)

RegisterProfile adds a profile to the global config file. The first profile registered becomes the default; isDefault reports whether this one did.

func SaveCover added in v0.2.0

func SaveCover(preset string) error

SaveCover stores the Imbox's cover, leaving every other setting alone. An empty preset drops the key rather than writing a blank one.

func SaveHelpHidden added in v0.2.0

func SaveHelpHidden(hidden bool) error

SaveHelpHidden stores whether the TUI's shortcut help is hidden, leaving every other setting alone.

func SaveLastCalendarID added in v0.2.0

func SaveLastCalendarID(id int64) error

SaveLastCalendarID stores it, leaving every other setting alone.

func ScrubLegacyCredentials added in v0.2.0

func ScrubLegacyCredentials() error

ScrubLegacyCredentials removes migrated embedded credentials from the global config file. Call only after the credential store confirmed the save.

func SetDefaultProfile added in v1.14.0

func SetDefaultProfile(name string) error

SetDefaultProfile names the profile used when nothing else chooses one.

func StateDir

func StateDir() string

func UnregisterProfile added in v1.14.0

func UnregisterProfile(name string) error

UnregisterProfile removes a profile from the global config file, and default_profile when it named this one. Credentials are the caller's to remove.

func ValidProfileName added in v1.14.0

func ValidProfileName(name string) bool

ValidProfileName reports whether name may name a new profile: letters, numbers, hyphens and underscores, as it becomes part of a credential key and a cache path.

func ValidateBaseURL added in v1.14.0

func ValidateBaseURL(base string) error

ValidateBaseURL refuses a server URL hey would not send a credential to.

Types

type Config

type Config struct {
	BaseURL   string `json:"base_url"`
	AccountID string `json:"account_id,omitempty"`
	Onboarded bool   `json:"onboarded,omitempty"`

	// OAuthIssuerURL and OAuthTokenURL move sign-in off BaseURL: the issuer authorizes
	// it in the browser, the token endpoint exchanges, refreshes and revokes it. Empty
	// is BaseURL. Only a profile or the environment sets them, never a repository's
	// top-level keys, since they decide where a code and a refresh token are sent.
	OAuthIssuerURL string `json:"oauth_issuer_url,omitempty"`
	OAuthTokenURL  string `json:"oauth_token_url,omitempty"`

	// Profiles, DefaultProfile and ActiveProfile are profiles.go's: the profiles the
	// global config and a trusted repository config name, the one chosen when nothing
	// else chooses, and the one this invocation runs as ("" for none).
	Profiles       map[string]*ProfileConfig `json:"-"`
	DefaultProfile string                    `json:"-"`
	ActiveProfile  string                    `json:"-"`
	// contains filtered or unexported fields
}

func Defaults added in v0.2.0

func Defaults() *Config

Defaults is the configuration before any file or environment is consulted: the fallback for commands that must run even when the global file is broken.

func Load

func Load() (*Config, error)

Load reads the effective configuration: defaults, the global file, a repository-local .hey/config.json found from the working directory, then the environment.

func LoadGlobal added in v0.2.0

func LoadGlobal() (*Config, error)

LoadGlobal reads the configuration without any repository-local file. It is for commands that run from an arbitrary working directory on the user's behalf — a desktop bar poller, say — where a checkout's config must neither redirect them nor trip the local-config trust gate.

func (*Config) ActiveEndpoint added in v1.14.0

func (c *Config) ActiveEndpoint() string

ActiveEndpoint is the endpoint this invocation answers from: EndpointApp only for an active profile that names the app, which ApplyProfile has already refused unless ExperimentalApp.

func (*Config) ApplyProfile added in v1.14.0

func (c *Config) ApplyProfile(name string, source Source) error

ApplyProfile makes name the active profile: its server and account replace the files' values, and HEY_BASE_URL and HEY_ACCOUNT_ID still win over it, as basecamp-cli re-applies its environment after the profile. Flags are the caller's to apply after. A repository's base_url is the files' and so loses to the profile's; its account_id stays only where the profile names none.

A profile that names no account does not take the top-level account defaults, which belong to the top-level sign-in: a second account's profile on the same server would otherwise inherit the first one's mail account.

func (*Config) CheckProfileServer added in v1.14.0

func (c *Config) CheckProfileServer(by, value string) error

CheckProfileServer refuses a server override, named by, that is not the active profile's own server. hey config set base_url is no override: it sets the top-level URL, which no profile's credential uses.

func (*Config) LocalConfig

func (c *Config) LocalConfig() *LocalConfig

LocalConfig returns the discovered local configuration and its trust status.

func (*Config) ProfileInGlobalConfig added in v1.14.0

func (c *Config) ProfileInGlobalConfig(name string) bool

ProfileInGlobalConfig reports whether the global config file defines name, as opposed to a trusted repository config alone.

func (*Config) ProfileNames added in v1.14.0

func (c *Config) ProfileNames() []string

ProfileNames lists the configured profiles, sorted.

func (*Config) SaveAccountID

func (c *Config) SaveAccountID(accountID string) error

SaveAccountID stores the default linked-account filter for the effective server without replacing settings for any other server.

func (*Config) SaveBaseURL

func (c *Config) SaveBaseURL(baseURL string) error

SaveBaseURL stores the global server URL while preserving account defaults for every server.

func (*Config) SaveOnboarded added in v0.2.0

func (c *Config) SaveOnboarded(onboarded bool) error

SaveOnboarded stores the onboarding flag in the global config so later logged-out runs of bare `hey` skip the full first-run wizard.

func (*Config) SetFromFlag

func (c *Config) SetFromFlag(key, value string) error

func (*Config) SourceOf

func (c *Config) SourceOf(key string) Source

func (*Config) TrustLocalConfig

func (c *Config) TrustLocalConfig() error

TrustLocalConfig trusts the current security-sensitive values in the discovered local configuration. A later change produces a different digest and requires trust again.

func (*Config) UntrustLocalConfig

func (c *Config) UntrustLocalConfig() error

UntrustLocalConfig removes trust for the discovered local configuration.

func (*Config) UntrustedLocalConfig

func (c *Config) UntrustedLocalConfig() *LocalConfig

UntrustedLocalConfig returns the local configuration when one of its values is effective for this invocation and the user has not trusted its current contents.

func (*Config) Warnings added in v1.14.0

func (c *Config) Warnings() []string

Warnings are what loading the configuration had to say: keys it ignored, and why.

type LocalConfig

type LocalConfig struct {
	Path         string `json:"path"`
	BaseURL      string `json:"base_url,omitempty"`
	AccountID    string `json:"account_id,omitempty"`
	ServerOrigin string `json:"server_origin"`
	Digest       string `json:"digest"`
	Trusted      bool   `json:"trusted"`

	// Profiles and DefaultProfile are the profile keys it sets, which trust approves
	// with the rest; ProfileNames lists the profiles by name for a person to review.
	Profiles       map[string]any `json:"-"`
	ProfileNames   []string       `json:"profiles,omitempty"`
	DefaultProfile string         `json:"default_profile,omitempty"`
}

LocalConfig describes the security-sensitive settings supplied by the nearest repository-local .hey/config.json file.

type OldConfig

type OldConfig struct {
	BaseURL       string `json:"base_url"`
	AccessToken   string `json:"access_token,omitempty"`
	RefreshToken  string `json:"refresh_token,omitempty"`
	TokenExpiry   int64  `json:"token_expiry,omitempty"`
	SessionCookie string `json:"session_cookie,omitempty"`
}

OldConfig represents the legacy config format with embedded credentials. Used only for migration.

func LoadOld

func LoadOld() (*OldConfig, error)

LoadOld reads the config file as the old format (with embedded credentials). Used only during migration.

type ProfileConfig added in v1.14.0

type ProfileConfig struct {
	BaseURL        string `json:"base_url"`
	AccountID      string `json:"account_id,omitempty"`
	OAuthIssuerURL string `json:"oauth_issuer_url,omitempty"`
	OAuthTokenURL  string `json:"oauth_token_url,omitempty"`
	// Endpoint is EndpointApp for a profile answered by the HEY app on this computer,
	// and "" (the server) otherwise. Only an experimental build honours it (ExperimentalApp).
	Endpoint string `json:"endpoint,omitempty"`
}

ProfileConfig is one named profile.

func (ProfileConfig) TokenServer added in v1.14.0

func (p ProfileConfig) TokenServer() string

TokenServer is where the profile's sign-in is exchanged, refreshed and revoked.

type Source

type Source string
const (
	SourceDefault Source = "default"
	SourceGlobal  Source = "global"
	SourceLocal   Source = "local"
	SourceEnv     Source = "env"
	SourceFlag    Source = "flag"
)
const SourceProfile Source = "profile"

SourceProfile is a value the active profile set.

const SourcePrompt Source = "prompt"

SourcePrompt is a profile chosen at the terminal's picker.

func MCPClientID added in v1.11.0

func MCPClientID(baseURL string) (string, Source, error)

MCPClientID resolves the local MCP client id for the HEY at baseURL, and where it came from: HEY_MCP_CLIENT_ID, then the global config's "mcp_client_ids" entry for that origin, then DefaultMCPClientID. It is read from the global config only, never a repository's .hey/config.json, so a checkout can't point hey mcp's sign-in at another client.

type TrustedLocalConfig

type TrustedLocalConfig struct {
	Path         string `json:"path"`
	ServerOrigin string `json:"server_origin"`
	BaseURL      string `json:"base_url,omitempty"`
	AccountID    string `json:"account_id,omitempty"`
	Digest       string `json:"digest"`
}

TrustedLocalConfig identifies a repository-local configuration trusted by this user.

func TrustedLocalConfigs

func TrustedLocalConfigs() ([]TrustedLocalConfig, error)

TrustedLocalConfigs returns the local configurations trusted in user-level config.

Jump to

Keyboard shortcuts

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