Skip to main content

Module streaming

Module streaming 

Source
Expand description

Streaming execution for codex exec commands.

Instead of buffering all JSONL output and returning it at once, the streaming API pipes stdout from the child process and delivers each JsonLineEvent to a caller-supplied callback as soon as it arrives. Malformed UTF-8 in exec stdout and stderr is decoded with replacement characters, matching buffered exec.

§Example

use codex_wrapper::{Codex, ExecCommand, JsonLineEvent};

let codex = Codex::builder().build()?;
let cmd = ExecCommand::new("what is 2+2?").ephemeral();

cmd.stream(&codex, |event: JsonLineEvent| {
    println!("{}: {:?}", event.event_type, event.extra);
})
.await?;

Functions§

stream_exec
Stream JSONL events from codex exec <prompt>, invoking handler for each parsed JsonLineEvent.
stream_exec_cancellable
Stream JSONL events until the command completes or cancel resolves.
stream_exec_resume
Stream JSONL events from codex exec resume, invoking handler for each parsed JsonLineEvent.
stream_exec_resume_cancellable
Stream resumed-turn JSONL events until completion or cancellation.