codex

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accounts

type Accounts struct {
	FS fsutil.FileSystem
}

Accounts implements provider.AccountManager for Codex.

func (*Accounts) Discover

func (a *Accounts) Discover(_ context.Context) ([]provider.Account, error)

Discover returns all known Codex accounts.

func (*Accounts) ProviderID

func (a *Accounts) ProviderID() provider.ID

func (*Accounts) Switch

func (a *Accounts) Switch(_ context.Context, identifier string) (provider.Account, error)

Switch sets the active Codex account by copying the matching account's auth file to ~/.codex/auth.json and updating codex-auth's registry. Before overwriting, it adopts the current auth.json into ~/.codex/accounts/ if it's not already stored there (preserves accounts created by codex login).

type CodexAccount

type CodexAccount struct {
	AccessToken string
	IDToken     string
	AccountID   string // from tokens.account_id
	UserID      string // from JWT chatgpt_user_id
	Email       string // from JWT id_token
	PlanType    string // from JWT id_token
	RecordKey   string // "{user_id}::{account_id}" — codex-auth compat
	FilePath    string // source file path
	IsActive    bool   // true if from ~/.codex/auth.json
}

CodexAccount holds parsed credentials from a Codex auth.json file.

func DiscoverAccounts

func DiscoverAccounts(fs fsutil.FileSystem) []CodexAccount

DiscoverAccounts finds all Codex accounts from: 1. ~/.codex/auth.json (active account) 2. ~/.codex/accounts/*.auth.json (additional accounts, codex-auth interop)

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements provider.Provider for Codex (OpenAI).

func New

func New(client httputil.Doer) *Provider

New creates a Provider that uses the given HTTP client for API calls.

func (*Provider) Fetch

func (p *Provider) Fetch(ctx context.Context, _ time.Time) ([]quota.Result, error)

Fetch discovers all Codex accounts and fetches quota for each in parallel.

Jump to

Keyboard shortcuts

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