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.

§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_resume
Stream JSONL events from codex exec resume, invoking handler for each parsed JsonLineEvent.