Codex.Transport behaviour (Codex SDK v0.7.2)

Copy Markdown View Source

Behaviour for Codex transport implementations.

Transports handle the communication protocol between the SDK and the Codex runtime.

Summary

Callbacks

Interrupts a running turn.

Executes a single turn and returns the accumulated result.

Executes a turn and returns a stream of events.

Types

event_stream()

@type event_stream() :: Enumerable.t()

input()

@type input() :: String.t()

thread()

@type thread() :: Codex.Thread.t()

turn_opts()

@type turn_opts() :: map() | keyword()

turn_result()

@type turn_result() :: Codex.Turn.Result.t()

Callbacks

interrupt(thread, turn_id)

(optional)
@callback interrupt(thread(), turn_id :: String.t()) :: :ok | {:error, term()}

Interrupts a running turn.

Optional for transports that don't support it.

run_turn(thread, input, turn_opts)

@callback run_turn(thread(), input(), turn_opts()) ::
  {:ok, turn_result()} | {:error, term()}

Executes a single turn and returns the accumulated result.

run_turn_streamed(thread, input, turn_opts)

@callback run_turn_streamed(thread(), input(), turn_opts()) ::
  {:ok, event_stream()} | {:error, term()}

Executes a turn and returns a stream of events.