app

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountManager

func AccountManager(id provider.ID, client httputil.Doer) provider.AccountManager

AccountManager returns the AccountManager for a provider, or nil if unsupported. The client is used for providers that refresh metadata on switch (e.g. Claude).

func GetActiveCredentials

func GetActiveCredentials() (token, email string)

GetActiveCredentials reads the active Claude access token and email from the credentials file. Returns empty strings on any error.

func PrintAccounts

func PrintAccounts(id provider.ID, accounts []provider.Account, activeToken, activeEmail string)

PrintAccounts renders a list of accounts with active-account highlighting.

func PrintClaudeAccounts

func PrintClaudeAccounts(accounts []provider.Account, activeEmail string)

PrintClaudeAccounts renders Claude accounts with plan, multiplier, and active status.

func PrintCodexAccounts

func PrintCodexAccounts(accounts []provider.Account)

PrintCodexAccounts renders Codex accounts with plan and active status.

func RunAccounts

func RunAccounts(id provider.ID) error

RunAccounts lists discovered accounts for the given provider.

func RunCodexLogin

func RunCodexLogin(ctx context.Context, client httputil.Doer, activate bool) error

RunCodexLogin performs the Codex OAuth PKCE login flow via Auth0. After login, it stores the account to ~/.codex/accounts/ for codex-auth interop.

func RunLogin

func RunLogin(ctx context.Context, client httputil.Doer, activate bool) error

RunLogin performs the Claude OAuth PKCE login flow. The caller is responsible for creating and passing the HTTP client.

func RunSwitch

func RunSwitch(id provider.ID, email string, client httputil.Doer) error

RunSwitch switches the active account for the given provider.

Types

type AggregateReport

type AggregateReport struct {
	ProviderID provider.ID                                `json:"provider_id"`
	Kind       string                                     `json:"kind"`
	Summary    aggregate.AccountSummary                   `json:"summary"`
	Windows    map[quota.WindowName]quota.AggregateResult `json:"windows"`
}

type Cache

type Cache interface {
	Get(ctx context.Context, id string) ([]quota.Result, bool, error)
	Put(ctx context.Context, id string, results []quota.Result) error
	Age(ctx context.Context, id string) (time.Duration, bool)
}

type Clock

type Clock interface {
	Now() time.Time
}

type ProviderReport

type ProviderReport struct {
	ID        provider.ID      `json:"id"`
	Name      string           `json:"name"`
	Results   []quota.Result   `json:"results"`
	Aggregate *AggregateReport `json:"aggregate,omitempty"`
}

type Renderer

type Renderer interface {
	Render(ctx context.Context, report Report) error
}

type Report

type Report struct {
	GeneratedAt time.Time        `json:"generated_at"`
	Providers   []ProviderReport `json:"providers"`
}

type RunRequest

type RunRequest struct {
	Providers []provider.ID
	Refresh   bool
}

type Runner

type Runner struct {
	Clock    Clock
	Cache    Cache // nil = no caching
	Services map[provider.ID]provider.Services
	Renderer Renderer
}

func (*Runner) BuildReport

func (r *Runner) BuildReport(ctx context.Context, req RunRequest) (Report, error)

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, req RunRequest) error

Jump to

Keyboard shortcuts

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