Documentation
¶
Index ¶
- Constants
- Variables
- func AntigravityDefaultCallbackURI() string
- func AntigravityRequestUserAgent(userAgent string) string
- func AntigravityUserAgent() string
- func BuildAntigravityAuth(tokenResp *AntigravityTokenResponse, email, projectID string) *coreauth.Auth
- func BuildAntigravityAuthURL(state, redirectURI string) string
- func CompleteAntigravityOAuth(ctx context.Context, code, redirectURI string, httpClient *http.Client) (*coreauth.Auth, error)
- func FetchAntigravityProjectID(ctx context.Context, accessToken string, httpClient *http.Client) (string, error)
- func FetchAntigravityUserInfo(ctx context.Context, accessToken string, httpClient *http.Client) (string, error)
- func GetTokenStore() coreauth.Store
- func RegisterPluginAuthParser(parser PluginAuthParser)
- func RegisterTokenStore(store coreauth.Store)
- func StartAntigravityVersionUpdater(ctx context.Context)
- type AntigravityAuthenticator
- type AntigravityTokenResponse
- type Authenticator
- type ClaudeAuthenticator
- type CodexAuthenticator
- type DevinAuthenticator
- type EmailRequiredError
- type FileTokenStore
- type KimiAuthenticator
- type LoginOptions
- type Manager
- type MetaAuthenticator
- type PluginAuthParser
- type PluginMultiAuthParser
- type XAIAuthenticator
Constants ¶
const AntigravityDefaultCallbackPort = antigravity.CallbackPort
AntigravityDefaultCallbackPort is the default local port used for Antigravity OAuth loopback callbacks.
Variables ¶
var ErrRefreshNotSupported = errors.New("cliproxy auth: refresh not supported")
Functions ¶
func AntigravityDefaultCallbackURI ¶
func AntigravityDefaultCallbackURI() string
AntigravityDefaultCallbackURI returns the default loopback redirect URI for Antigravity OAuth.
func AntigravityRequestUserAgent ¶ added in v8.0.33
AntigravityRequestUserAgent returns the User-Agent for Antigravity runtime requests, falling back to AntigravityUserAgent when userAgent is empty.
func AntigravityUserAgent ¶
func AntigravityUserAgent() string
AntigravityUserAgent returns the canonical User-Agent string used by the Antigravity Hub family.
func BuildAntigravityAuth ¶
func BuildAntigravityAuth(tokenResp *AntigravityTokenResponse, email, projectID string) *coreauth.Auth
BuildAntigravityAuth constructs an in-memory *coreauth.Auth object from token credentials and metadata.
func BuildAntigravityAuthURL ¶
BuildAntigravityAuthURL generates the OAuth authorization URL for Antigravity. If redirectURI is empty, the default loopback callback URI is used.
func CompleteAntigravityOAuth ¶
func CompleteAntigravityOAuth(ctx context.Context, code, redirectURI string, httpClient *http.Client) (*coreauth.Auth, error)
CompleteAntigravityOAuth performs code exchange, user identity retrieval, and GCP project discovery using an injected HTTP client, returning an assembled *coreauth.Auth without touching the filesystem.
func FetchAntigravityProjectID ¶
func FetchAntigravityProjectID(ctx context.Context, accessToken string, httpClient *http.Client) (string, error)
FetchAntigravityProjectID exposes project discovery for external callers.
func FetchAntigravityUserInfo ¶
func FetchAntigravityUserInfo(ctx context.Context, accessToken string, httpClient *http.Client) (string, error)
FetchAntigravityUserInfo retrieves the user email address using the given access token.
func GetTokenStore ¶
GetTokenStore returns the globally registered token store.
func RegisterPluginAuthParser ¶
func RegisterPluginAuthParser(parser PluginAuthParser)
RegisterPluginAuthParser registers the current plugin auth parser.
func RegisterTokenStore ¶
RegisterTokenStore sets the global token store used by the authentication helpers.
func StartAntigravityVersionUpdater ¶ added in v8.0.33
StartAntigravityVersionUpdater starts background refresh for the Antigravity Hub version. Pass a process-lifetime ctx; it runs only once and is not auto-started by SDK packages.
Types ¶
type AntigravityAuthenticator ¶
type AntigravityAuthenticator struct{}
AntigravityAuthenticator implements OAuth login for the antigravity provider.
func (AntigravityAuthenticator) Login ¶
func (AntigravityAuthenticator) Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
Login launches a local OAuth flow to obtain antigravity tokens and persists them.
func (AntigravityAuthenticator) Provider ¶
func (AntigravityAuthenticator) Provider() string
Provider returns the provider key for antigravity.
func (AntigravityAuthenticator) RefreshLead ¶
func (AntigravityAuthenticator) RefreshLead() *time.Duration
RefreshLead instructs the manager to refresh 30 minutes before expiry.
type AntigravityTokenResponse ¶
type AntigravityTokenResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int64 `json:"expires_in"`
TokenType string `json:"token_type"`
}
AntigravityTokenResponse captures the tokens returned by Antigravity OAuth exchange.
func ExchangeAntigravityCode ¶
func ExchangeAntigravityCode(ctx context.Context, code, redirectURI string, httpClient *http.Client) (*AntigravityTokenResponse, error)
ExchangeAntigravityCode exchanges an authorization code for access and refresh tokens.
type Authenticator ¶
type Authenticator interface {
Provider() string
Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
RefreshLead() *time.Duration
}
Authenticator manages login and optional refresh flows for a provider.
func NewAntigravityAuthenticator ¶
func NewAntigravityAuthenticator() Authenticator
NewAntigravityAuthenticator constructs a new authenticator instance.
func NewKimiAIAuthenticator ¶
func NewKimiAIAuthenticator() Authenticator
NewKimiAIAuthenticator constructs a new Kimi authenticator for kimi.ai with provider "kimi-ai".
func NewKimiAIDotAuthenticator ¶
func NewKimiAIDotAuthenticator() Authenticator
NewKimiAIDotAuthenticator constructs a new Kimi authenticator for kimi.ai with provider "kimi.ai".
func NewKimiAuthenticator ¶
func NewKimiAuthenticator() Authenticator
NewKimiAuthenticator constructs a new Kimi authenticator for kimi.com.
func NewMetaAuthenticator ¶
func NewMetaAuthenticator() Authenticator
NewMetaAuthenticator constructs a new Meta authenticator.
func NewXAIAuthenticator ¶
func NewXAIAuthenticator() Authenticator
NewXAIAuthenticator constructs a new xAI authenticator.
type ClaudeAuthenticator ¶
type ClaudeAuthenticator struct {
CallbackPort int
}
ClaudeAuthenticator implements the OAuth login flow for Anthropic Claude accounts.
func NewClaudeAuthenticator ¶
func NewClaudeAuthenticator() *ClaudeAuthenticator
NewClaudeAuthenticator constructs a Claude authenticator with default settings.
func (*ClaudeAuthenticator) Login ¶
func (a *ClaudeAuthenticator) Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
func (*ClaudeAuthenticator) Provider ¶
func (a *ClaudeAuthenticator) Provider() string
func (*ClaudeAuthenticator) RefreshLead ¶
func (a *ClaudeAuthenticator) RefreshLead() *time.Duration
type CodexAuthenticator ¶
type CodexAuthenticator struct {
CallbackPort int
}
CodexAuthenticator implements the OAuth login flow for Codex accounts.
func NewCodexAuthenticator ¶
func NewCodexAuthenticator() *CodexAuthenticator
NewCodexAuthenticator constructs a Codex authenticator with default settings.
func (*CodexAuthenticator) Login ¶
func (a *CodexAuthenticator) Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
func (*CodexAuthenticator) Provider ¶
func (a *CodexAuthenticator) Provider() string
func (*CodexAuthenticator) RefreshLead ¶
func (a *CodexAuthenticator) RefreshLead() *time.Duration
type DevinAuthenticator ¶
type DevinAuthenticator struct {
CallbackPort int
AuthService *devinauth.DevinAuthService
}
DevinAuthenticator implements OAuth and headless authentication for Devin / Cognition.
func NewDevinAuthenticator ¶
func NewDevinAuthenticator() *DevinAuthenticator
NewDevinAuthenticator constructs a new Devin authenticator instance.
func (*DevinAuthenticator) Login ¶
func (a *DevinAuthenticator) Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
Login executes the interactive browser-based or headless manual authentication flow for Devin.
func (*DevinAuthenticator) Provider ¶
func (a *DevinAuthenticator) Provider() string
Provider returns the unique provider identifier for Devin.
func (*DevinAuthenticator) RefreshLead ¶
func (a *DevinAuthenticator) RefreshLead() *time.Duration
RefreshLead returns nil since Devin OAuth tokens are permanent session tokens.
type EmailRequiredError ¶
type EmailRequiredError struct {
Prompt string
}
EmailRequiredError indicates that the calling context must provide an email or alias.
func (*EmailRequiredError) Error ¶
func (e *EmailRequiredError) Error() string
type FileTokenStore ¶
type FileTokenStore struct {
// contains filtered or unexported fields
}
FileTokenStore persists token records and auth metadata using the filesystem as backing storage.
func NewFileTokenStore ¶
func NewFileTokenStore() *FileTokenStore
NewFileTokenStore creates a token store that saves credentials to disk through the TokenStorage implementation embedded in the token record.
func (*FileTokenStore) Delete ¶
func (s *FileTokenStore) Delete(ctx context.Context, id string) error
Delete removes the auth file.
func (*FileTokenStore) List ¶
func (s *FileTokenStore) List(ctx context.Context) ([]*cliproxyauth.Auth, error)
List enumerates all auth JSON files under the configured directory.
func (*FileTokenStore) Save ¶
func (s *FileTokenStore) Save(ctx context.Context, auth *cliproxyauth.Auth) (string, error)
Save persists token storage and metadata to the resolved auth file path.
func (*FileTokenStore) SetBaseDir ¶
func (s *FileTokenStore) SetBaseDir(dir string)
SetBaseDir updates the default directory used for auth JSON persistence when no explicit path is provided.
type KimiAuthenticator ¶
type KimiAuthenticator struct {
// contains filtered or unexported fields
}
KimiAuthenticator implements the OAuth device flow login for Kimi (Moonshot AI).
func (KimiAuthenticator) Login ¶
func (a KimiAuthenticator) Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
Login initiates the Kimi device flow authentication.
func (KimiAuthenticator) Provider ¶
func (a KimiAuthenticator) Provider() string
Provider returns the provider key for kimi.
func (KimiAuthenticator) RefreshLead ¶
func (KimiAuthenticator) RefreshLead() *time.Duration
RefreshLead returns the duration before token expiry when refresh should occur. Kimi tokens expire and need to be refreshed before expiry.
type LoginOptions ¶
type LoginOptions struct {
NoBrowser bool
ProjectID string
CallbackPort int
Metadata map[string]string
Prompt func(prompt string) (string, error)
}
LoginOptions captures generic knobs shared across authenticators. Provider-specific logic can inspect Metadata for extra parameters.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager aggregates authenticators and coordinates persistence via a token store.
func NewManager ¶
func NewManager(store coreauth.Store, authenticators ...Authenticator) *Manager
NewManager constructs a manager with the provided token store and authenticators. If store is nil, the caller must set it later using SetStore.
func (*Manager) Login ¶
func (m *Manager) Login(ctx context.Context, provider string, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, string, error)
Login executes the provider login flow and persists the resulting auth record.
func (*Manager) Register ¶
func (m *Manager) Register(a Authenticator)
Register adds or replaces an authenticator keyed by its provider identifier.
type MetaAuthenticator ¶
type MetaAuthenticator struct{}
MetaAuthenticator implements the Meta Muse OAuth device-code flow.
func (MetaAuthenticator) Login ¶
func (a MetaAuthenticator) Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
Login launches the OAuth device-code flow to obtain Meta tokens and persists them.
func (MetaAuthenticator) Provider ¶
func (MetaAuthenticator) Provider() string
Provider returns the provider key for Meta.
func (MetaAuthenticator) RefreshLead ¶
func (MetaAuthenticator) RefreshLead() *time.Duration
RefreshLead instructs the manager on token refresh lead time. Meta credentials do not advertise an API key expiration, so scheduled refresh is disabled and recovery is triggered on demand (e.g. on 401 or request preparation).
type PluginAuthParser ¶
type PluginAuthParser interface {
ParseAuth(context.Context, pluginapi.AuthParseRequest) (*cliproxyauth.Auth, bool, error)
}
PluginAuthParser parses auth JSON owned by plugin providers.
type PluginMultiAuthParser ¶
type PluginMultiAuthParser interface {
ParseAuths(context.Context, pluginapi.AuthParseRequest) ([]*cliproxyauth.Auth, bool, error)
}
PluginMultiAuthParser expands one auth JSON payload into multiple plugin auth records. Returning handled=true with an empty slice means the plugin intentionally suppresses built-in parsing.
type XAIAuthenticator ¶
type XAIAuthenticator struct{}
XAIAuthenticator implements the xAI Grok OAuth device-code flow.
func (XAIAuthenticator) Login ¶
func (a XAIAuthenticator) Login(ctx context.Context, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, error)
Login launches the OAuth device-code flow to obtain xAI tokens and persists them.
func (XAIAuthenticator) Provider ¶
func (XAIAuthenticator) Provider() string
Provider returns the provider key for xAI.
func (XAIAuthenticator) RefreshLead ¶
func (XAIAuthenticator) RefreshLead() *time.Duration
RefreshLead instructs the manager to refresh before token expiry.