CodexEx.AppServer.ClientManager (codex_ex v0.1.0)

Copy Markdown View Source

Shares long-lived Codex app-server clients across callers with the same launcher config.

The stdio transport spawns an OS codex app-server process, so reusing clients by launcher config prevents one subprocess per session page or sync call.

Summary

Functions

Returns a specification to start this module under a supervisor.

Publishes already-active threads through the shared local observer.

Types

client_key()

@type client_key() ::
  {:client, transport :: term(), runner_id :: term(), url :: term(),
   executable :: term(), args :: term(), workspace_id :: term(),
   workspace_root :: term(), initialize_params :: term(),
   strict_protocol :: boolean(), proxy_only :: boolean(),
   broadcasts_thread_activity :: boolean()}

get_client_result()

@type get_client_result() :: {:ok, CodexEx.AppServer.Client.t()} | {:error, term()}

state()

@type state() :: %{
  clients: %{required(client_key()) => pid()},
  refs: %{required(reference()) => client_key()},
  thread_activity_observer_key: client_key() | nil,
  thread_activity_retry_ref: reference() | nil
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_client(opts)

@spec get_client(keyword()) :: get_client_result()

reconcile_thread_activity()

@spec reconcile_thread_activity() :: :ok

Publishes already-active threads through the shared local observer.

remote_thread_activity_client?(client, runner_id, workspace_id)

@spec remote_thread_activity_client?(pid(), binary(), binary()) :: boolean()

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()