{"modulePath":"github.com/Agent-Field/codeaf","version":"v0.8.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package codexauth\n\nPackage codexauth signs a codeaf profile in to a ChatGPT plan in the same way the Codex CLI does, and adapts that plan's Responses API for codeaf's provider client. OpenAI's terms for a ChatGPT plan apply to work run on it.\n\n## Constants\n\n```go\nconst (\n\tDefaultIssuer  = \"https://auth.openai.com\"\n\tDefaultBackend = \"https://chatgpt.com/backend-api/codex\"\n\tClientID       = \"app_EMoamEEZ73f0CkXaXp7hrann\"\n\tSentinel       = \"chatgpt\"\n\tOriginator     = \"codex_cli_rs\"\n)\n```\n\n```go\nconst FallbackContextWindow = 272000\n```\nFallbackContextWindow is the window the account's own model list gave every visible model when it was last observed (2026-09-21, a Pro account: \\`\"context\\_window\": 272000\\` on each row). It is ONE figure because the fallback rows below are one observation, and a row that carried no window would leave a conversation that moved onto it compacting at its previous model's figure.\n\n```go\nconst QuotaWords = \"codex reached your chatgpt plan's usage limit · it resets on its own\"\n```\nQuotaWords is the person-facing outcome for a ChatGPT plan window that has been spent. The plan owns its reset, so there is no billing action to offer.\n\n## Variables\n\n```go\nvar ErrSignInExpired error = \u0026signInExpiredError{}\n```\nErrSignInExpired is the one actionable sentence returned when the issuer no longer accepts a profile's rotating refresh token.\n\n```go\nvar FallbackModels = []Model{\n\t{ID: \"gpt-5.5\", ContextLength: FallbackContextWindow},\n\t{ID: \"gpt-5.6-sol\", ContextLength: FallbackContextWindow},\n\t{ID: \"gpt-5.6-terra\", ContextLength: FallbackContextWindow},\n\t{ID: \"gpt-5.6-luna\", ContextLength: FallbackContextWindow},\n}\n```\nFallbackModels is the last observed public list used when a fresh account listing cannot be reached during connection.\n\n## Functions\n\n```go\nfunc Backend() string\n```\nBackend returns the configured ChatGPT backend used by both listing and turns.\n\n```go\nfunc Client(profileDir string) *http.Client\n```\nClient returns the refreshing and translating client for one profile.\n\n```go\nfunc ClientWithOptions(profileDir string, options Options) *http.Client\n```\nClientWithOptions returns the same client with deterministic test edges.\n\n```go\nfunc Connected(profileDir string) bool\n```\nConnected reports whether a usable sign-in currently exists.\n\n```go\nfunc Issuer() string\n```\nIssuer returns the configured issuer without changing the fixed callback.\n\n```go\nfunc ModelsPath(profileDir string) string\n```\nModelsPath names the non-secret listing cached beside the tokens.\n\n```go\nfunc Path(profileDir string) string\n```\nPath names the owner-readable token file in a profile.\n\n```go\nfunc Remove(profileDir string) error\n```\nRemove forgets the browser sign-in and its model listing.\n\n```go\nfunc Save(profileDir string, tokens Tokens) error\n```\nSave replaces the token file with an owner-only file.\n\n```go\nfunc Translate(profileDir string, options Options) http.RoundTripper\n```\nTranslate authenticates every backend request and translates the provider client's chat-completions path into the ChatGPT Responses API.\n\n## Types\n\n```go\ntype Flow struct {\n\t// contains filtered or unexported fields\n}\n```\nFlow is one browser connection whose fixed loopback listener is already standing when Begin returns.\n\n```go\nfunc Begin(ctx context.Context, options Options) (*Flow, error)\n```\nBegin starts the exact S256 loopback flow registered for the Codex CLI, trying its primary port and then its one fallback.\n\n```go\nfunc (f *Flow) Cancel()\n```\nCancel releases the fixed loopback listener. It is safe after Wait.\n\n```go\nfunc (f *Flow) URL() string\n```\nURL is the one sign-in address the person opens.\n\n```go\nfunc (f *Flow) Wait(ctx context.Context) (Tokens, error)\n```\nWait returns the token set after the browser has returned once.\n\n```go\ntype Model struct {\n\tID string `json:\"id\"`\n\t// ContextLength is the listing's own `context_window`, zero when the row\n\t// carried none. It is what the session compacts against and what the status\n\t// line's meter is a share of, so a Codex model that dropped it kept whatever\n\t// window the conversation's previous model had (#1383).\n\tContextLength   int      `json:\"context_length,omitempty\"`\n\tReasoningLevels []string `json:\"reasoning_levels,omitempty\"`\n}\n```\nModel is one model the signed-in account may choose, with how many tokens it accepts and the reasoning levels the request translator is allowed to send for it.\n\n```go\nfunc List(ctx context.Context, profileDir string, options Options) ([]Model, error)\n```\nList asks the account's own backend which models are visible and remembers the reasoning levels needed by later turns.\n\n```go\ntype Options struct {\n\tIssuer     string\n\tBackend    string\n\tHTTPClient *http.Client\n\tRandom     io.Reader\n\tListen     func(network, address string) (net.Listener, error)\n\tNow        func() time.Time\n\tSessionID  string\n}\n```\nOptions holds every replaceable edge of a Codex browser sign-in and its later backend calls. The zero value is the shipped service.\n\n```go\ntype Tokens struct {\n\tAccessToken  string    `json:\"access_token\"`\n\tRefreshToken string    `json:\"refresh_token\"`\n\tIDToken      string    `json:\"id_token\"`\n\tAccountID    string    `json:\"account_id\"`\n\tEmail        string    `json:\"email\"`\n\tPlan         string    `json:\"plan\"`\n\tExpiresAt    time.Time `json:\"expires_at\"`\n\tLastRefresh  time.Time `json:\"last_refresh\"`\n}\n```\nTokens is the complete durable answer from one browser sign-in.\n\n```go\nfunc Load(profileDir string) (Tokens, error)\n```\nLoad reads the current token set and immediately registers every credential with the record scrubber.\n\n","path":"github.com/Agent-Field/codeaf/internal/codexauth","name":"codexauth","synopsis":"Package codexauth signs a codeaf profile in to a ChatGPT plan in the same way the Codex CLI does, and adapts that plan's Responses API for codeaf's provider client.","isRedistributable":true}
