Documentation
¶
Index ¶
- Constants
- func CacheDir() string
- func ConfigDir() string
- func Cover() string
- func EntryIsProfile(fields map[string]any) bool
- func ExperimentalApp() bool
- func GlobalConfigPath() string
- func GlobalConfigTakesProfiles() error
- func HelpHidden() bool
- func LastCalendarID() int64
- func NonInteractiveEnv() bool
- func NormalizeAccountID(accountID string) (string, error)
- func Origin(baseURL string) (string, error)
- func ProfileNameIsPathSafe(name string) bool
- func RegisterProfile(name string, p ProfileConfig) (isDefault bool, err error)
- func SaveCover(preset string) error
- func SaveHelpHidden(hidden bool) error
- func SaveLastCalendarID(id int64) error
- func ScrubLegacyCredentials() error
- func SetDefaultProfile(name string) error
- func StateDir() string
- func UnregisterProfile(name string) error
- func ValidProfileName(name string) bool
- func ValidateBaseURL(base string) error
- type Config
- func (c *Config) ActiveEndpoint() string
- func (c *Config) ApplyProfile(name string, source Source) error
- func (c *Config) CheckProfileServer(by, value string) error
- func (c *Config) LocalConfig() *LocalConfig
- func (c *Config) ProfileInGlobalConfig(name string) bool
- func (c *Config) ProfileNames() []string
- func (c *Config) SaveAccountID(accountID string) error
- func (c *Config) SaveBaseURL(baseURL string) error
- func (c *Config) SaveOnboarded(onboarded bool) error
- func (c *Config) SetFromFlag(key, value string) error
- func (c *Config) SourceOf(key string) Source
- func (c *Config) TrustLocalConfig() error
- func (c *Config) UntrustLocalConfig() error
- func (c *Config) UntrustedLocalConfig() *LocalConfig
- func (c *Config) Warnings() []string
- type LocalConfig
- type OldConfig
- type ProfileConfig
- type Source
- type TrustedLocalConfig
Constants ¶
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.
const (
AllAccounts = "all"
)
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.
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 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
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
NormalizeAccountID reads a linked mail account ID, or "all".
func Origin ¶ added in v1.11.0
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
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
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
SaveHelpHidden stores whether the TUI's shortcut help is hidden, leaving every other setting alone.
func SaveLastCalendarID ¶ added in v0.2.0
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
SetDefaultProfile names the profile used when nothing else chooses one.
func UnregisterProfile ¶ added in v1.14.0
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
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
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 ¶
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
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
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
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
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
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
ProfileNames lists the configured profiles, sorted.
func (*Config) SaveAccountID ¶
SaveAccountID stores the default linked-account filter for the effective server without replacing settings for any other server.
func (*Config) SaveBaseURL ¶
SaveBaseURL stores the global server URL while preserving account defaults for every server.
func (*Config) SaveOnboarded ¶ added in v0.2.0
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 (*Config) TrustLocalConfig ¶
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 ¶
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.
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.
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 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
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.