Documentation
¶
Index ¶
- func EnvVarForProvider(provider string) string
- func IsSupportedProvider(provider string) bool
- func PatchCodexAuthKey(data []byte, apiKey string) ([]byte, bool)
- func PatchOpenCodeAuth(data []byte, providers []string) ([]byte, bool)
- func ReadCodexAuthFile() ([]byte, string)
- func ReadOpenCodeAuthFile() ([]byte, string)
- func SupportedProviders() []string
- type Credentials
- type Manager
- func (m *Manager) GetKey(provider string) (string, error)
- func (m *Manager) GetTarget() string
- func (m *Manager) ListProviders() ([]string, error)
- func (m *Manager) Load() (*Credentials, error)
- func (m *Manager) RemoveKey(provider string) error
- func (m *Manager) Save(creds *Credentials) error
- func (m *Manager) SetKey(provider, key string) error
- type ProviderCredential
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnvVarForProvider ¶
EnvVarForProvider returns the environment variable name for a given provider. Returns an empty string for unknown providers.
func IsSupportedProvider ¶
IsSupportedProvider returns true if the given provider is supported.
func PatchCodexAuthKey ¶
PatchCodexAuthKey sets OPENAI_API_KEY in the codex auth JSON and returns the updated bytes. It also removes OAuth "tokens" so codex falls back to the API key instead of using OAuth tokens that may lack required scopes. Returns nil, false if the JSON cannot be processed.
func PatchOpenCodeAuth ¶
PatchOpenCodeAuth removes OAuth entries for the given providers from the opencode auth JSON, forcing opencode to fall back to API keys from its config or environment. Returns the updated bytes and true on success. Returns nil, false if the JSON cannot be processed.
func ReadCodexAuthFile ¶
ReadCodexAuthFile reads ~/.codex/auth.json and returns its contents and path. Returns nil, "" if the file cannot be read.
func ReadOpenCodeAuthFile ¶
ReadOpenCodeAuthFile reads ~/.local/share/opencode/auth.json and returns its contents and path. Returns nil, "" if the file cannot be read.
func SupportedProviders ¶
func SupportedProviders() []string
SupportedProviders returns a copy of the supported provider list.
Types ¶
type Credentials ¶
type Credentials struct {
Version int `toml:"version"`
Providers map[string]ProviderCredential `toml:"providers"`
}
Credentials represents the stored API credentials in credentials.toml.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages reading and writing credentials.toml in the .tapes/ directory.
func NewManager ¶
NewManager creates a new credentials Manager. If override is non-empty it is used as the .tapes/ directory; otherwise the standard dotdir resolution applies. When no .tapes/ directory is found, one is created at ~/.tapes/.
func (*Manager) GetKey ¶
GetKey returns the stored API key for the given provider. Returns an empty string if no key is stored.
func (*Manager) ListProviders ¶
ListProviders returns the names of providers that have stored credentials.
func (*Manager) Load ¶
func (m *Manager) Load() (*Credentials, error)
Load reads credentials.toml from the target directory. Returns an empty Credentials if the file does not exist.
func (*Manager) Save ¶
func (m *Manager) Save(creds *Credentials) error
Save writes credentials to credentials.toml with 0600 permissions.
type ProviderCredential ¶
type ProviderCredential struct {
APIKey string `toml:"api_key"`
}
ProviderCredential holds the API key for a single provider.