pub struct CodexExecutor { /* private fields */ }Implementations§
Source§impl CodexExecutor
impl CodexExecutor
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Production transports: uTLS Chrome for chatgpt.com, Go’s standard transport elsewhere, both per effective proxy (crate::proxy). Token refreshes use the standard transport for the credential’s effective proxy.
Sourcepub fn with_client(client: Client, oauth: CodexOAuth) -> Self
pub fn with_client(client: Client, oauth: CodexOAuth) -> Self
Caller-built transports. Tests pass a plain client and an OAuth service pointed at
a local mock so nothing reaches OpenAI. Unproxied non-chatgpt.com requests use
client.
Sourcepub fn with_alpha_base_url(self, base: impl Into<String>) -> Self
pub fn with_alpha_base_url(self, base: impl Into<String>) -> Self
Test hook: where OAuth Alpha Search requests go.
Sourcepub fn quota(&self) -> &QuotaSignals
pub fn quota(&self) -> &QuotaSignals
Passive quota snapshots per credential (M4-0016), for the management API.
Sourcepub async fn execute_in_session(
&self,
credential: &Credential,
req: ExecRequest,
cfg: &Config,
session: &ExecSession,
) -> Result<ExecResponse, ExecError>
pub async fn execute_in_session( &self, credential: &Credential, req: ExecRequest, cfg: &Config, session: &ExecSession, ) -> Result<ExecResponse, ExecError>
One turn of a downstream Responses WebSocket session (CodexAutoExecutor):
credentials with websockets enabled keep a pooled upstream socket; others run
the HTTP stream with the session as prompt-cache identity and cannot continue
upstream state.
Sourcepub fn upstream_websocket(credential: &Credential) -> bool
pub fn upstream_websocket(credential: &Credential) -> bool
Whether credential keeps upstream state on a WebSocket (Go:
websocketUpstreamSupportsIncrementalInput).
Sourcepub fn response_steering_configured(cfg: &Config) -> bool
pub fn response_steering_configured(cfg: &Config) -> bool
upstream.codex.response-steering as the Responses WebSocket handler reads it
(Go SDKConfig.CodexResponseSteering), shared by every credential kind.
Sourcepub fn attach_steering(&self, session: &str, input: SteeringInput)
pub fn attach_steering(&self, session: &str, input: SteeringInput)
Binds a downstream connection’s later client frames to its session (Go
WithWebsocketInput and WithWebsocketAuthCheck). A steering turn on that session
reads them after its first response.created; Self::close_session releases them.
Sourcepub async fn interrupt_session(
&self,
session: &str,
payload: &[u8],
enabled: impl FnOnce(&str) -> bool,
) -> Result<(), InterruptError>
pub async fn interrupt_session( &self, session: &str, payload: &[u8], enabled: impl FnOnce(&str) -> bool, ) -> Result<(), InterruptError>
Go InterruptExecutionSession: forwards a client’s response.interrupt to the
session’s upstream socket while a turn reads on it (see codex_ws::Pool::interrupt).
Sourcepub fn session_loss(&self, id: &str) -> Option<ExecError>
pub fn session_loss(&self, id: &str) -> Option<ExecError>
The error that lost the session’s upstream socket, once it is lost (what Go’s disconnect notifier hands the downstream handler).
Sourcepub fn session_closed(
&self,
id: &str,
) -> impl Future<Output = ExecError> + Send + 'static
pub fn session_closed( &self, id: &str, ) -> impl Future<Output = ExecError> + Send + 'static
Resolves when the session’s upstream socket is lost.
Sourcepub fn close_session(&self, id: &str)
pub fn close_session(&self, id: &str)
Releases the session’s upstream socket (downstream connection ended).
Sourcepub fn needs_prepare(&self, credential: &Credential, cfg: &Config) -> bool
pub fn needs_prepare(&self, credential: &Credential, cfg: &Config) -> bool
Refresh due: the outer tokens under Go’s 96h Codex lead, or the Sign in with
ChatGPT partition under its 5-minute lead (Go shouldRefresh). Cheap and side-effect free.
pub fn needs_prepare_at( &self, credential: &Credential, _cfg: &Config, now: DateTime<Utc>, ) -> bool
Sourcepub fn refresher(&self, credential: &Credential, cfg: &Config) -> Refresher
pub fn refresher(&self, credential: &Credential, cfg: &Config) -> Refresher
The refresh grants for credential, on the client its proxy selects
(NewCodexAuthWithProxyURL(cfg, auth.ProxyURL): the credential’s proxy, then the
global one, on Go’s standard transport).
Sourcepub async fn prepare(
&self,
credential: &Credential,
cfg: &Config,
) -> Result<MetadataPatch, ExecError>
pub async fn prepare( &self, credential: &Credential, cfg: &Config, ) -> Result<MetadataPatch, ExecError>
Sourcepub async fn refresh_now(
&self,
credential: &Credential,
cfg: &Config,
) -> Result<MetadataPatch, ExecError>
pub async fn refresh_now( &self, credential: &Credential, cfg: &Config, ) -> Result<MetadataPatch, ExecError>
Sourcepub async fn refresh_all(
&self,
credential: &Credential,
cfg: &Config,
) -> Result<MetadataPatch, ExecError>
pub async fn refresh_all( &self, credential: &Credential, cfg: &Config, ) -> Result<MetadataPatch, ExecError>
pub async fn execute( &self, credential: &Credential, req: ExecRequest, cfg: &Config, ) -> Result<ExecResponse, ExecError>
Sourcepub fn alpha_search_url(
&self,
credential: &Credential,
cfg: &Config,
) -> Option<String>
pub fn alpha_search_url( &self, credential: &Credential, cfg: &Config, ) -> Option<String>
The URL an Alpha Search on credential posts to; None for an API key without
a base URL.
Sourcepub async fn alpha_search(
&self,
credential: &Credential,
body: &[u8],
client: &HeaderMap,
upstream_model: &str,
cfg: &Config,
capture: &CaptureSink,
) -> Result<ExecResponse, ExecError>
pub async fn alpha_search( &self, credential: &Credential, body: &[u8], client: &HeaderMap, upstream_model: &str, cfg: &Config, capture: &CaptureSink, ) -> Result<ExecResponse, ExecError>
The standalone Codex Alpha Search call (Server.codexAlphaSearch minus selection):
already in Codex search format, never translated. The upstream status and body are
returned as is, with only its Content-Type.
upstream_model is the credential-resolved model; it replaces model for API keys.
capture records the attempt as Go’s route does (server_routes.go).
Source§impl CodexExecutor
impl CodexExecutor
Sourcepub async fn images(
&self,
credential: &Credential,
req: ExecRequest,
request_path: &str,
cfg: &Config,
) -> Result<ExecResponse, ExecError>
pub async fn images( &self, credential: &Credential, req: ExecRequest, request_path: &str, cfg: &Config, ) -> Result<ExecResponse, ExecError>
The Images API on a Codex credential (executeOpenAIImage,
executeOpenAIImageStream). request_path is the inbound route; req.stream
asks for SSE.
Source§impl CodexExecutor
impl CodexExecutor
Sourcepub fn with_live_endpoints(
self,
call_url: impl Into<String>,
api_base: impl Into<String>,
) -> Self
pub fn with_live_endpoints( self, call_url: impl Into<String>, api_base: impl Into<String>, ) -> Self
Test hook: where live calls, sidebands and hangups go.
pub fn live_endpoints(&self) -> &Endpoints
Sourcepub async fn live_post(
&self,
target: &LiveTarget<'_>,
url: &str,
headers: Vec<(String, String)>,
body: Bytes,
) -> Result<Upstream, ExecError>
pub async fn live_post( &self, target: &LiveTarget<'_>, url: &str, headers: Vec<(String, String)>, body: Bytes, ) -> Result<Upstream, ExecError>
One live HTTP request (authManager.HttpRequest with the Codex executor): Go’s
client for the URL (Chrome TLS for chatgpt.com) through the credential’s proxy,
redirects followed like http.Client.Do.
Sourcepub async fn live_websocket(
&self,
target: &LiveTarget<'_>,
url: &str,
headers: Vec<(String, String)>,
protocols: Vec<String>,
) -> Result<LiveSocket, DialError>
pub async fn live_websocket( &self, target: &LiveTarget<'_>, url: &str, headers: Vec<(String, String)>, protocols: Vec<String>, ) -> Result<LiveSocket, DialError>
Dials a live WebSocket with Go’s standard dialer rules (credential or global proxy, else the environment’s) and the client’s subprotocols.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CodexExecutor
impl !RefUnwindSafe for CodexExecutor
impl !UnwindSafe for CodexExecutor
impl Forget for CodexExecutor
impl Move for CodexExecutor
impl Send for CodexExecutor
impl Sync for CodexExecutor
impl Unpin for CodexExecutor
impl UnsafeUnpin for CodexExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more