Documentation
¶
Overview ¶
Package openaicodex supplies the credential and HTTP request policy for the experimental ChatGPT Codex backend. It deliberately does not implement an LLM provider: successful Responses encoding and streaming translation remain in provider/openai.
Index ¶
Constants ¶
const ( // BaseURL is the one endpoint permitted by the manual-token provider. BaseURL = "https://chatgpt.com/backend-api/codex" // UserAgent identifies mecatl honestly; it deliberately does not imitate the // Codex CLI. UserAgent = "mecatl" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credential ¶
type Credential struct {
// contains filtered or unexported fields
}
Credential is an immutable snapshot of a manually supplied ChatGPT access token and its unverified routing metadata. JWT payload decoding here is not signature verification; the backend remains the authority when the token is used.
func NewCredential ¶
func NewCredential(accessToken, accountID, expiresAt string, now time.Time) (Credential, error)
NewCredential builds and validates a credential snapshot. accountID and expiresAt are optional explicit auth.yaml fields. When both JWT and explicit expiry exist, the earlier expiry wins. now is the startup validation time.
func (Credential) Configured ¶
func (c Credential) Configured() bool
Configured reports whether this value is a populated credential snapshot. It does not replace Validate: callers must still check expiry at use time.
func (Credential) Format ¶
func (c Credential) Format(state fmt.State, _ rune)
Format makes every fmt rendering secret-safe, including when Credential is nested inside another formatted struct. Account IDs are routing metadata but still identity-shaped, so the representation intentionally exposes neither them nor the bearer token.
func (Credential) LogValue ¶
func (c Credential) LogValue() slog.Value
LogValue gives structured slog handlers the same redacted representation as fmt. It returns only non-secret presence metadata; expiry, account ID, and token never cross the logging boundary.
type Lister ¶
type Lister struct {
// contains filtered or unexported fields
}
Lister enumerates only the models granted to the current ChatGPT account.
func NewLister ¶
func NewLister(policy RequestPolicy) *Lister
NewLister derives its HTTP path from the same immutable RequestPolicy used by inference. A separate client supplies the bounded listing timeout over the exact same final transport; inference itself has no blanket timeout.
type Model ¶
type Model struct {
ID string
DisplayName string
ContextLimit int
InputModalities []string
InputModalitiesKnown bool
Reasoning bool
ReasoningKnown bool
ToolCall bool
}
Model is the package-owned projection of one picker-visible Codex entitlement. It carries no credential or endpoint data.
type RequestPolicy ¶
type RequestPolicy struct {
// contains filtered or unexported fields
}
RequestPolicy is the final HTTP transport shared by inference and model listing. It owns the exact endpoint, headers, request-time expiry check, redirect refusal, and bounded authentication errors. SDK retry configuration remains at the provider construction boundary because a transport cannot disable an SDK retry loop.
func NewRequestPolicy ¶
func NewRequestPolicy(credential Credential, now func() time.Time, transport http.RoundTripper) (RequestPolicy, error)
NewRequestPolicy creates an immutable policy. transport is an offline-test seam; nil uses http.DefaultTransport. The returned client never follows a redirect and deliberately has no blanket timeout because inference streams.
func (RequestPolicy) HTTPClient ¶
func (p RequestPolicy) HTTPClient() *http.Client
HTTPClient returns an inference-safe client over this policy. It deliberately has no blanket timeout because a streaming response may run for minutes. The lister builds its own bounded client over the same immutable transport.
type StatusError ¶
type StatusError struct {
// contains filtered or unexported fields
}
StatusError is the bounded manual-token authentication error. Its status is retained for the shared resilience classifier while provider body content, request metadata, and credential values are intentionally omitted.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
func (*StatusError) StatusCode ¶
func (e *StatusError) StatusCode() int
StatusCode preserves the generic classifier seam used by llmresilience.