codex

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package codex turns a ChatGPT (Codex) subscription into a memcode backend by reusing the login the Codex CLI already stored. It reads ~/.codex/auth.json (or $CODEX_HOME), refreshes the access token when it's expiring, pulls the account id out of the access-token JWT, and returns the ChatGPT/Codex endpoint plus the identity headers Cloudflare and the backend require. No vendor SDK — file read + OAuth refresh + JWT decode — so it returns a plain Backend the provider package adapts to an endpoint.

Consent-gated upstream: it activates only when the user explicitly selects the codex source. It reuses the Codex CLI's file and, on a refresh, writes the rotated tokens back there so both tools stay in sync on the single-use refresh token.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

Available reports whether a Codex CLI login file is present, for the wizard's menu (no parse, no network).

Types

type Backend

type Backend struct {
	BaseURL string
	Token   string
	Headers map[string]string
}

Backend is the resolved Codex endpoint: the ChatGPT backend base, the access token (Bearer), and the identity headers every turn must carry.

func Resolve

func Resolve() (Backend, error)

Resolve reads the Codex CLI login, refreshes it if the access token is expiring, and shapes it into a backend. An error explains the fix (install/sign in with the Codex CLI).

Jump to

Keyboard shortcuts

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