Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileEnv = "LANGSMITH_CONFIG_FILE"
	DefaultAPIURL = "https://api.smith.langchain.com"
)

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the LangSmith CLI config path.

func MaskSecret

func MaskSecret(value string) string

MaskSecret returns a redacted value suitable for CLI output.

Types

type Config

type Config struct {
	CurrentProfile string             `json:"current_profile,omitempty"`
	Profiles       map[string]Profile `json:"profiles,omitempty"`
}

Config is the on-disk LangSmith CLI config.

func Load

func Load() (*Config, error)

Load reads the default config path. Missing files return an empty config.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads a config file. Missing files return an empty config.

func (*Config) ResolveProfile

func (c *Config) ResolveProfile(flagProfile, envProfile string) (string, Profile, bool)

ResolveProfile returns the active profile by precedence.

func (*Config) ResolveProfileName

func (c *Config) ResolveProfileName(flagProfile, envProfile string) string

ResolveProfileName returns the active profile name by precedence.

func (*Config) Save

func (c *Config) Save() error

Save writes the config to the default config path with owner-only permissions.

func (*Config) SaveTo

func (c *Config) SaveTo(path string) error

SaveTo writes the config to path with owner-only permissions.

type OAuth

type OAuth struct {
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	ExpiresAt    string `json:"expires_at,omitempty"`
	Issuer       string `json:"issuer,omitempty"`
}

OAuth stores OAuth tokens written by `langsmith auth login`.

type Profile

type Profile struct {
	APIKey      string `json:"api_key,omitempty"`
	APIKeyEnv   string `json:"api_key_env,omitempty"`
	APIKeyCmd   string `json:"api_key_cmd,omitempty"`
	APIURL      string `json:"api_url,omitempty"`
	WorkspaceID string `json:"workspace_id,omitempty"`
	OAuth       OAuth  `json:"oauth,omitempty"`
}

Profile represents one named LangSmith CLI profile.

Instead of storing the API key, a profile can name where it lives: APIKeyEnv is an environment variable and APIKeyCmd a shell command that prints the key. APIKey wins over APIKeyEnv, which wins over APIKeyCmd.

func (Profile) APIKeySource added in v0.3.9

func (p Profile) APIKeySource() string

APIKeySource describes where the profile's API key comes from, for display: "config", "$NAME" for an environment variable, or "$(command)".

func (Profile) AccessToken

func (p Profile) AccessToken() string

AccessToken returns the OAuth access token to use for bearer auth.

func (Profile) HasAPIKey added in v0.3.9

func (p Profile) HasAPIKey() bool

HasAPIKey reports whether the profile stores an API key or names where one lives.

func (Profile) ResolveAPIKey added in v0.3.9

func (p Profile) ResolveAPIKey() (string, error)

ResolveAPIKey returns the profile's API key, reading api_key_env or running api_key_cmd when the key is not stored in the config.

func (Profile) TokenExpiresAtTime

func (p Profile) TokenExpiresAtTime() (time.Time, bool)

TokenExpiresAtTime parses oauth.expires_at.

Jump to

Keyboard shortcuts

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