Skip to main content

Crate cpa_exec

Crate cpa_exec 

Source
Expand description

Upstream executors. One module per provider; each owns its wire format, auth headers and HTTP client profile. Executors dispatches on Credential::provider.

Each call gets the config snapshot current when the request started, so a hot reload never changes behaviour halfway through one execution.

Credential preparation (token refresh, device identity creation) is a two-step contract so the runtime can single-flight it: Executors::readiness is a cheap check, and Executors::prepare does the work and returns a MetadataPatch that the runtime commits. Executors never write credential files themselves.

Readiness separates the two reasons Go prepares a credential. Requests block only on Readiness::PrepareNow (Go RequestAuthPreparer: Claude identity, Meta API-key mint, Antigravity project ID; also an Antigravity token inside five minutes of expiry, which Go’s executor refreshes inline). Token refresh is Readiness::RefreshSoon: the background loop refreshes inside the provider’s refresh lead while requests keep using the current token, and an upstream 401 triggers one refresh-and-retry (Go tryRefreshAfterUnauthorized). An already expired token is still RefreshSoon: Go sends it and recovers on 401.

Modules§

aistudio
AI Studio over the /v1/ws relay (internal/runtime/executor/aistudio_executor.go).
antigravity
The Antigravity executor (internal/runtime/executor/antigravity_executor*.go).
antigravity_auth
Antigravity OAuth (internal/auth/antigravity, sdk/auth/antigravity.go) and the executor’s credential preparation (antigravity_executor_auth.go).
antigravity_credits
Antigravity AI credits (antigravity_executor_credits.go and sdk/cliproxy/auth/antigravity_credits.go).
antigravity_version
The Antigravity client version and user agents (internal/misc/antigravity_version.go).
claude
Claude executor: Anthropic Messages and count_tokens with OAuth tokens or API keys.
claude_login
--claude-login: Go’s browser OAuth flow (sdk/auth/claude.go, sdk/auth/manager.go, internal/auth/claude/{oauth_server,html_templates,filename}.go).
codex
Codex executor: OpenAI Responses on the ChatGPT Codex backend, with an OAuth token (bearer + Chatgpt-Account-Id) or a configured API key (codex-api-key).
codex_live
Codex live calls (internal/client/codex/live): the WebRTC SDP bootstrap request to the ChatGPT realtime calls endpoint, its sideband and standard Realtime WebSockets, and hangup.
codex_oauth
Codex (ChatGPT) OAuth: browser PKCE and device login, token refresh, and the auth file Go writes (internal/auth/codex, sdk/auth/codex.go, sdk/auth/codex_device.go, internal/runtime/executor/codex_executor_auth.go).
codex_quota
Codex passive quota observation: codex.rate_limits WebSocket events and error-frame headers normalised into X-Codex-* headers (helps/codex_quota.go), and the provider-scoped signal snapshot Go keeps per credential (sdk/cliproxy/auth/quota_signals.go).
codex_refresh
Codex token refresh: which token partitions refresh (Go codex_executor_auth.go Refresh / refreshLocked), and the partition-scoped result that lands on the credential file as read under its lock (internal/auth/codex/refresh_patch.go).
codex_siwc
Codex Sign in with ChatGPT (SIWC): the authorization URL, the code exchange and the bound credential file (Go internal/auth/codex/siwc_auth.go, openai.go CodexSIWCTokenData and sdk/cliproxy/auth/codex_siwc_bind.go). SIWC is a second token partition (siwc) of an existing Codex OAuth credential. Refresh and request use (use_siwc) belong to the Codex executor.
codex_siwc_bind
-siwc-bind (Go internal/cmd/siwc_bind.go, 7b0319fb): runs the Sign in with ChatGPT browser flow from the command line and writes the siwc token partition and use_siwc into an existing Codex OAuth credential file in auth-dir, under Go’s credential lock file (internal/auth/codex/token.go WithFileLock).
devin
Devin executor (internal/runtime/executor/devin_executor.go).
devin_auth
Devin login and account status (internal/auth/devin, sdk/auth/devin.go, internal/cmd/devin_login.go).
devin_models
Devin model resolution (helps/devin_models.go). The catalog updater lives in cpa_server::model_updater.
gemini
Gemini API keys and native Interactions keys (internal/runtime/executor/gemini_executor.go).
kimi
Kimi executor (internal/runtime/executor/kimi_executor.go).
kimi_auth
Kimi (.com and .ai) RFC 8628 device login, token refresh and credential files (internal/auth/kimi, sdk/auth/kimi.go).
meta
Meta Muse executor (internal/runtime/executor/meta_executor*.go).
meta_auth
Meta Muse RFC 8628 device login, API-key minting and credential files (internal/auth/meta/meta.go, sdk/auth/meta.go, internal/cmd/meta_login.go).
oauth
Claude OAuth acquisition and metadata preparation. Runtime owns patch publication.
openai_compat
OpenAI-compatible upstreams (internal/runtime/executor/openai_compat_executor.go): configured providers reached with a bearer API key at base_url, speaking Chat Completions, Responses compact and the Images API.
openai_compat_multipart
Go mime/multipart and mime.ParseMediaType, as the images paths use them (Reader.ReadForm, then Writer.WriteField / CreatePart). Ported from Go 1.26 mime/multipart/multipart.go, formdata.go and mime/mediatype.go.
proxy
Proxy-aware HTTP clients with Go net/http semantics, shared by every executor (helps/proxy_helpers.go, sdk/proxyutil, net/http client behaviour; M4-0029).
vertex
Vertex AI (internal/runtime/executor/gemini_vertex_executor.go).
vertex_auth
Vertex service-account credentials (internal/auth/vertex, internal/cmd/vertex_import.go) and the Google JWT token source the Vertex executor uses (golang.org/x/oauth2/google CredentialsFromJSON with the cloud-platform scope, v0.30.0).
wsrelay
The /v1/ws relay (internal/wsrelay): an AI Studio browser bridge connects over a websocket and performs HTTP requests on the proxy’s behalf. Each connection is a session named aistudio-<16 random characters>; requests and their responses are JSON messages correlated by ID.
xai
xAI Grok (internal/runtime/executor/xai_executor*.go): the Responses API reached with an API key at api.x.ai or with a Grok OAuth token at the Grok CLI chat proxy, plus Responses compact, token counting and the image and video APIs.
xai_auth
xAI RFC 8628 device login with OIDC discovery, token refresh and credential files (internal/auth/xai, sdk/auth/xai.go, internal/runtime/executor/xai_executor_auth.go).
xai_url
The part of Go’s net/url.Parse that xAI endpoint validation depends on: the same accept/reject decisions, the same Hostname() and the same error text. Rust’s url crate follows WHATWG and disagrees with Go on inputs such as https://%61uth.x.ai, https://auth.x.ai\@evil.com, embedded tabs, https:auth.x.ai and port 99999.

Structs§

DeviceExecutors
Executors for the device-login providers, grouped so adding one does not touch every Executors construction site.
Executors
GoogleExecutors
Google-family executors, grouped like DeviceExecutors.
OpenAIExecutors
OpenAI-wire executors, grouped like DeviceExecutors.

Enums§

Readiness
What a credential needs before or around use. See the module docs.

Functions§

ensure_responses_usage_details
Go helps.EnsureResponsesUsageDetails, for paths outside the executors (plugin executors’ Responses payloads and stream chunks). EnsureResponsesUsageDetails.
expiration
Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead). Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead). Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead). Go Auth.ExpirationTime: access-token JWT exp, then metadata expiry fields.
last_refresh
Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead). Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead). Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead).
preferred_interval
Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead). Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead). Go Auth.ExpirationTime, authLastRefreshTimestamp and authPreferredInterval, for the server’s plugin refresh schedule (Go shouldRefresh for providers without a lead).
websockets_enabled
xaiWebsocketsEnabled (and Go’s identical authWebsocketsEnabled): the websockets attribute when it parses, else the metadata value (a bool, or a string that parses).