providerauth

package
v0.30.29 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// GithubCopilotClientID is GitHub Copilot's official OAuth App client ID.
	GithubCopilotClientID = "Iv1.b507a08c87ecfe98"
)

GitHub device flow constants.

View Source
const (
	OpenAIChatGPTClientID = "app_EMoamEEZ73f0CkXaXp7hrann"
)

Variables

This section is empty.

Functions

func CLIHealthCheckArgs added in v0.30.28

func CLIHealthCheckArgs(providerType string) []string

CLIHealthCheckArgs returns the non-interactive health-check arguments for a CLI-backed provider.

func DefaultCodexAuthPath added in v0.30.12

func DefaultCodexAuthPath() string

func DeviceFlow

func DeviceFlow(ctx context.Context) (string, error)

DeviceFlow implements GitHub's device flow for Copilot auth.

func LoadCodexAuth added in v0.30.12

func LoadCodexAuth(path string) (string, error)

LoadCodexAuth imports a Codex CLI auth.json file and returns a compact token bundle JSON string for ratchet secret storage.

func LocalOAuthServerPort

func LocalOAuthServerPort() int

LocalOAuthServerPort returns the port of the most recently started local OAuth callback server. Returns 0 if no OAuth flow has been started.

func OpenBrowserURL

func OpenBrowserURL(rawURL string) error

OpenBrowserURL opens a URL in the default browser.

func PollGitHubDeviceFlow

func PollGitHubDeviceFlow(ctx context.Context, clientID, deviceCode string, interval int) <-chan OAuthResult

PollGitHubDeviceFlow polls for the device flow token until authorized or timeout.

func PollOpenAIChatGPTDeviceFlow added in v0.30.12

func PollOpenAIChatGPTDeviceFlow(ctx context.Context, deviceAuthID, userCode string, interval int) <-chan OAuthResult

PollOpenAIChatGPTDeviceFlow polls until the device code is approved and returns a JSON token bundle suitable for the workflow-plugin-agent openai_chatgpt provider.

func PromptAPIKey

func PromptAPIKey(providerType string) (string, error)

PromptAPIKey prompts the user for an API key (hidden input).

func PromptBaseURL

func PromptBaseURL(defaultURL string) (string, error)

PromptBaseURL prompts for a base URL with a default value.

func PromptSecret added in v0.30.17

func PromptSecret(label string) (string, error)

PromptSecret prompts the user for a secret value (hidden input).

func StartAnthropicMaxOAuth

func StartAnthropicMaxOAuth(ctx context.Context) <-chan OAuthResult

StartAnthropicMaxOAuth runs the Max/Pro subscription OAuth PKCE flow. Uses claude.ai as the authorize endpoint; the resulting token is used directly as a Bearer token (no API key creation step). Experimental: may have restrictions.

func StartAnthropicOAuth

func StartAnthropicOAuth(ctx context.Context) <-chan OAuthResult

StartAnthropicOAuth runs the Console OAuth PKCE flow for Anthropic. It uses redirect_uri=https://console.anthropic.com/oauth/code/callback (Anthropic's own callback page) with scopes org:create_api_key user:profile user:inference. Since Anthropic redirects to their own page (not localhost), the CLI opens a local server to accept a manually-pasted code — we keep a localhost callback for a seamless paste-free experience on platforms where it works.

Flow:

  1. Open browser to authorize URL
  2. User authorizes; Anthropic redirects to their callback page showing the code
  3. Our local server also accepts the redirect if the browser follows localhost
  4. On success, exchange code for access token then create a permanent API key

func ValidateCatalog added in v0.30.28

func ValidateCatalog(runtimeTypes []string) error

ValidateCatalog checks catalog structure and coverage of runtime types.

Types

type AuthStrategy added in v0.30.28

type AuthStrategy string

AuthStrategy identifies the credential flow used during setup.

const (
	AuthAPIKey        AuthStrategy = "api_key"
	AuthAnthropic     AuthStrategy = "anthropic"
	AuthGitHubDevice  AuthStrategy = "github_device"
	AuthOpenAIChatGPT AuthStrategy = "openai_chatgpt"
	AuthNone          AuthStrategy = "none"
	AuthCLINative     AuthStrategy = "cli_native"
)

type Category added in v0.30.28

type Category string

Category groups provider setup entries for presentation.

const (
	CategoryAPI          Category = "api"
	CategoryCompatible   Category = "compatible"
	CategorySubscription Category = "subscription"
	CategoryCloud        Category = "cloud"
	CategoryLocal        Category = "local"
	CategoryCLI          Category = "cli"
)

type DeviceCodeResult

type DeviceCodeResult struct {
	DeviceCode      string
	UserCode        string
	VerificationURI string
	ExpiresIn       int
	Interval        int
}

DeviceCodeResult holds the response from a device code request.

func StartGitHubDeviceFlow

func StartGitHubDeviceFlow(ctx context.Context, clientID string) (*DeviceCodeResult, error)

StartGitHubDeviceFlow initiates the GitHub device code flow. Returns the device code result so the TUI can display the user code, then call PollGitHubDeviceFlow to wait for authorization.

func StartOpenAIChatGPTDeviceFlow added in v0.30.12

func StartOpenAIChatGPTDeviceFlow(ctx context.Context) (*DeviceCodeResult, error)

StartOpenAIChatGPTDeviceFlow starts the official Codex ChatGPT device-code flow.

type ModelInfo

type ModelInfo = wfprovider.ModelInfo

ModelInfo describes an available model from a provider.

func ListModels

func ListModels(ctx context.Context, providerType, apiKey, baseURL string) ([]ModelInfo, error)

ListModels fetches available models from the provider implementation package.

func ListModelsWithSettings added in v0.30.17

func ListModelsWithSettings(ctx context.Context, providerType, apiKey, baseURL string, settings map[string]string) ([]ModelInfo, error)

ListModelsWithSettings fetches available models with provider-specific discovery settings.

type ModelStrategy added in v0.30.28

type ModelStrategy string

ModelStrategy identifies how setup obtains a model.

const (
	ModelDynamic  ModelStrategy = "dynamic"
	ModelManual   ModelStrategy = "manual"
	ModelOllama   ModelStrategy = "ollama"
	ModelExternal ModelStrategy = "external"
)

type OAuthResult

type OAuthResult struct {
	Token string
	Err   error
}

OAuthResult is returned when a browser-based auth flow completes.

type OpenAIChatGPTTokenBundle added in v0.30.12

type OpenAIChatGPTTokenBundle struct {
	IDToken                 string `json:"id_token,omitempty"`
	AccessToken             string `json:"access_token"`
	RefreshToken            string `json:"refresh_token"`
	AccountID               string `json:"account_id,omitempty"`
	ChatGPTAccountID        string `json:"chatgpt_account_id,omitempty"`
	ChatGPTAccountIsFedRAMP bool   `json:"chatgpt_account_is_fedramp,omitempty"`
	ChatGPTUserID           string `json:"chatgpt_user_id,omitempty"`
	PlanType                string `json:"chatgpt_plan_type,omitempty"`
}

type SettingField added in v0.30.28

type SettingField struct {
	Key         string
	Label       string
	Placeholder string
	Default     string
	Required    bool
	Choices     []string
}

SettingField describes a non-secret provider setting.

type SetupEntry added in v0.30.28

type SetupEntry struct {
	Type               string
	DisplayName        string
	Description        string
	Aliases            []string
	Category           Category
	Auth               AuthStrategy
	Setup              SetupStrategy
	Model              ModelStrategy
	APIKeyEnv          string
	CredentialLabel    string
	CredentialRequired bool
	PromptBaseURL      bool
	DefaultBaseURL     string
	BaseURLRequired    bool
	Settings           []SettingField
	AllowManualModel   bool
	SetupAlias         string
	SetupCommand       string
	DefaultAlias       string
	CLICommand         string
	InstallHint        string
	AuthHint           string
	ModelBehavior      string
	CredentialBoundary string
}

SetupEntry describes one user-visible provider setup path.

func Catalog added in v0.30.28

func Catalog() []SetupEntry

Catalog returns a defensive copy of all user-visible setup entries.

func LookupSetup added in v0.30.28

func LookupSetup(name string) (SetupEntry, bool)

LookupSetup resolves a canonical provider type or accepted setup alias.

type SetupStrategy added in v0.30.28

type SetupStrategy string

SetupStrategy identifies provider-specific setup behavior.

const (
	SetupInteractive SetupStrategy = "interactive"
	SetupOllama      SetupStrategy = "ollama"
	SetupCLINative   SetupStrategy = "cli_native"
)

Jump to

Keyboard shortcuts

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