Skip to main content

CodexExecutor

Struct CodexExecutor 

Source
pub struct CodexExecutor { /* private fields */ }

Implementations§

Source§

impl CodexExecutor

Source

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.

Source

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.

Source

pub fn with_alpha_base_url(self, base: impl Into<String>) -> Self

Test hook: where OAuth Alpha Search requests go.

Source

pub fn quota(&self) -> &QuotaSignals

Passive quota snapshots per credential (M4-0016), for the management API.

Source

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.

Source

pub fn upstream_websocket(credential: &Credential) -> bool

Whether credential keeps upstream state on a WebSocket (Go: websocketUpstreamSupportsIncrementalInput).

Source

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.

Source

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.

Source

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).

Source

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).

Source

pub fn session_closed( &self, id: &str, ) -> impl Future<Output = ExecError> + Send + 'static

Resolves when the session’s upstream socket is lost.

Source

pub fn close_session(&self, id: &str)

Releases the session’s upstream socket (downstream connection ended).

Source

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.

Source

pub fn needs_prepare_at( &self, credential: &Credential, _cfg: &Config, now: DateTime<Utc>, ) -> bool

Source

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).

Source

pub async fn prepare( &self, credential: &Credential, cfg: &Config, ) -> Result<MetadataPatch, ExecError>

Source

pub async fn refresh_now( &self, credential: &Credential, cfg: &Config, ) -> Result<MetadataPatch, ExecError>

Source

pub async fn refresh_all( &self, credential: &Credential, cfg: &Config, ) -> Result<MetadataPatch, ExecError>

Source

pub async fn execute( &self, credential: &Credential, req: ExecRequest, cfg: &Config, ) -> Result<ExecResponse, ExecError>

Source

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.

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

Source

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

Source

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.

Source

pub fn live_endpoints(&self) -> &Endpoints

Source

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.

Source

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§

Source§

impl Default for CodexExecutor

The production executor. Construction only fails if the TLS backend cannot initialise.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more