pub struct AppServerBuilder<'a> { /* private fields */ }Expand description
Builds and starts an AppServer.
Created by AppServer::builder.
Implementations§
Source§impl<'a> AppServerBuilder<'a>
impl<'a> AppServerBuilder<'a>
Sourcepub fn client_info(
self,
name: impl Into<String>,
version: impl Into<String>,
) -> Self
pub fn client_info( self, name: impl Into<String>, version: impl Into<String>, ) -> Self
Name and version reported to the server in initialize. The server
includes them in its user agent. Defaults to codex-wrapper and this
crate’s version.
Sourcepub fn opt_out_notification(self, method: impl Into<String>) -> Self
pub fn opt_out_notification(self, method: impl Into<String>) -> Self
Ask the server not to send a notification method on this connection,
by exact name. Streaming deltas (item/agentMessage/delta) are the
usual candidate for a caller that only needs completed items.
Sourcepub fn capability(self, name: impl Into<String>, value: Value) -> Self
pub fn capability(self, name: impl Into<String>, value: Value) -> Self
Set a field of the initialize request’s capabilities by its
protocol name, replacing an earlier value for the same name. Sent as
given and not checked, except optOutNotificationMethods, which is
combined with opt_out_notification as
the module documentation describes.
Sourcepub fn experimental_api(self, enabled: bool) -> Self
pub fn experimental_api(self, enabled: bool) -> Self
Set the experimentalApi capability, which asks the server to allow
methods and fields it marks experimental. Shorthand for
capability("experimentalApi", Value::Bool(enabled)).
Sourcepub fn max_frame_bytes(self, bytes: usize) -> Self
pub fn max_frame_bytes(self, bytes: usize) -> Self
The most bytes one line from the server may hold, newline included. A
longer line ends the session with Error::AppServerLimitExceeded
once the limit is reached, without buffering the rest. Unlimited by
default. Attached WebSocket mode counts JSON payload bytes instead.
Sourcepub fn max_queued_messages(self, messages: usize) -> Self
pub fn max_queued_messages(self, messages: usize) -> Self
The most notifications and server requests that may wait for
AppServer::next_message. One more ends the session. Unlimited by
default.
Sourcepub fn max_queued_bytes(self, bytes: usize) -> Self
pub fn max_queued_bytes(self, bytes: usize) -> Self
The most bytes, counted as each message’s line plus its newline, that
may wait for AppServer::next_message. Attached mode counts JSON
payload bytes without WebSocket framing. Unlimited by default.
Sourcepub fn max_writer_queue_messages(self, messages: usize) -> Self
pub fn max_writer_queue_messages(self, messages: usize) -> Self
The most lines that may wait to be written to the server, the one being written included. Unlimited by default.
Sourcepub fn max_writer_queue_bytes(self, bytes: usize) -> Self
pub fn max_writer_queue_bytes(self, bytes: usize) -> Self
The most bytes, newlines included, that may wait to be written to the server, the line being written included. Attached mode counts JSON payload bytes without WebSocket framing. Unlimited by default.
Sourcepub fn connect_unix(self, socket: impl Into<PathBuf>) -> Self
pub fn connect_unix(self, socket: impl Into<PathBuf>) -> Self
Attach to an existing server over a Unix WebSocket connection.
Spawns no process and never signals the shared server. The endpoint must be selected explicitly. Verified with CLI 0.163.0; this provider transport is experimental. Reconnect by creating a fresh connection and explicitly reconciling threads and approvals; requests are not replayed.
Sourcepub fn initialize_params(&self) -> Result<Value>
pub fn initialize_params(&self) -> Result<Value>
The params of the initialize request start sends.
§Errors
Error::AppServerConfig if optOutNotificationMethods was set
through capability to something other than an
array of strings or null.
Sourcepub fn args(&self) -> Vec<String>
pub fn args(&self) -> Vec<String>
The owned-server arguments: app-server --listen stdio://. Empty for
an attached connection, which spawns no command.
--listen stdio:// is the default transport. It is passed anyway so a
change of default cannot move this client onto a socket.
Sourcepub fn to_command_string(&self) -> String
pub fn to_command_string(&self) -> String
The command start will run, as a copy-pasteable shell
string, including the client’s global args. Empty for an attached connection.
Sourcepub async fn start(self) -> Result<AppServer>
pub async fn start(self) -> Result<AppServer>
Spawn codex app-server and complete the handshake.
Owned mode runs codex [global args] app-server --listen stdio://. The
client’s binary, environment, working directory, process-group policy,
die_with_parent, and on_spawn observer apply to that process. The
handshake is bounded by the client’s timeout, when set.
§Errors
Error::AppServerConfig for an invalid setting, before anything is
spawned. Error::Io if the process cannot be spawned. If the process
exits before the handshake finishes, the failure is classified from its
stderr as any failed command is, so a rejected -c key is
Error::Config. Otherwise the handshake’s own error.