Documentation
¶
Overview ¶
Offline OpenAI auth-status report backing `codemeld auth status`: classifies the OpenAI Platform (API-key) and OpenAI ChatGPT (subscription) providers from OPENAI_API_KEY and the global settings file only, without printing secrets, composing project-local settings, constructing a provider client, or making any network call.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render writes the report to w as JSON when asJSON is true, otherwise as the human-readable form.
func RenderHuman ¶
RenderHuman writes one line per provider, reporting each independently with no cross-provider precedence.
Types ¶
type Kind ¶
type Kind string
Kind is the JSON `kind` enum: how a provider authenticates. It is distinct from the provider package's internal AuthKind vocabulary.
type ProviderStatus ¶
type ProviderStatus struct {
ID string `json:"id"`
Kind Kind `json:"kind"`
Authenticated bool `json:"authenticated"`
Source Source `json:"source"`
State State `json:"state"`
}
ProviderStatus is one provider's offline auth state. authenticated is true only when the provider has a usable local credential: a Platform key, or a present (not expired/invalid) ChatGPT session. It never asserts upstream entitlement. No field carries a key, token, or account identifier.
type Report ¶
type Report struct {
Providers []ProviderStatus `json:"providers"`
}
Report is the full offline status. Providers is always ordered Platform first, then ChatGPT, so JSON and scripts do not depend on map iteration.
func Collect ¶
Collect builds the offline auth-status Report from the global settings file at settingsPath and the process environment, classifying the ChatGPT session via the session classifier relative to now. It reads only OPENAI_API_KEY and the global settings file; it never composes project-local settings, constructs a provider client, or performs any network call. It returns an error when the global settings file exists but cannot be read, parsed, or schema-validated — the one exception being a malformed auth.openai-chatgpt session shape, which is masked out of validation and classified by the session classifier as local_session_invalid instead of failing the command. A missing file is reported as unauthenticated, not an error. The error names only the path, never credential content.
type Source ¶
type Source string
Source is the JSON `source` enum: where the credential the status reflects was found. none means no usable credential was located.
const ( // SourceEnv means the OpenAI Platform key came from OPENAI_API_KEY. SourceEnv Source = "env" // SourceGlobalSettings means the credential came from the global settings file: // provider.openai.api_key for Platform, or auth.openai-chatgpt for ChatGPT. SourceGlobalSettings Source = "global_settings" // SourceNone means no credential was found for the provider. SourceNone Source = "none" )
type State ¶
type State string
State is the JSON `state` enum reported per provider. The four ChatGPT values mirror the session classifier's authstate.Status string values exactly.
const ( // StateUsingAPIKey: an OpenAI Platform key is present (env or global settings). StateUsingAPIKey State = "using_api_key" // StateNoAPIKey: no OpenAI Platform key is configured anywhere status reads. StateNoAPIKey State = "no_api_key" // StateLocalSessionPresent: a complete, non-expired ChatGPT session is stored. StateLocalSessionPresent State = "local_session_present" // StateLocalSessionExpired: a ChatGPT session is stored but its expiry has passed. StateLocalSessionExpired State = "local_session_expired" // StateLocalSessionInvalid: stored ChatGPT session state is corrupted or malformed. StateLocalSessionInvalid State = "local_session_invalid" // StateNoLocalSession: no ChatGPT session is stored. StateNoLocalSession State = "no_local_session" )