pub struct Thread { /* private fields */ }Expand description
A conversation thread with the Codex agent.
Each call to run() or run_streamed() spawns a codex exec subprocess.
Implementations§
Source§impl Thread
impl Thread
Sourcepub fn with_approval_callback(self, callback: ApprovalCallback) -> Self
pub fn with_approval_callback(self, callback: ApprovalCallback) -> Self
Set an approval callback for handling permission requests.
Sourcepub fn with_patch_approval_callback(
self,
callback: PatchApprovalCallback,
) -> Self
pub fn with_patch_approval_callback( self, callback: PatchApprovalCallback, ) -> Self
Set a patch approval callback for handling file-patch approval requests.
Sourcepub fn with_event_callback(self, callback: EventCallback) -> Self
pub fn with_event_callback(self, callback: EventCallback) -> Self
Set an event callback for observing, transforming, or filtering events.
Sourcepub fn with_hooks(self, hooks: Vec<HookMatcher>) -> Self
pub fn with_hooks(self, hooks: Vec<HookMatcher>) -> Self
Add hooks to this thread.
Sourcepub fn with_transport(self, transport: Arc<dyn Transport>) -> Self
pub fn with_transport(self, transport: Arc<dyn Transport>) -> Self
Override the transport used for this thread (useful for testing).
When set, the provided transport is used instead of spawning a real
codex subprocess. The same connect / write / end_input / read_messages / close call sequence is used regardless.
Sourcepub async fn interrupt(&self) -> Result<()>
pub async fn interrupt(&self) -> Result<()>
Interrupt the currently running turn by sending SIGINT to the CLI subprocess.
Equivalent to pressing Ctrl-C. The CLI has close_timeout seconds to clean
up before being force-killed. Returns Ok(()) if no turn is in progress.
Sourcepub async fn run(
&mut self,
input: impl Into<Input>,
turn_options: TurnOptions,
) -> Result<Turn>
pub async fn run( &mut self, input: impl Into<Input>, turn_options: TurnOptions, ) -> Result<Turn>
Run a prompt and collect all events into a Turn.
Sourcepub async fn run_streamed(
&mut self,
input: impl Into<Input>,
turn_options: TurnOptions,
) -> Result<StreamedTurn>
pub async fn run_streamed( &mut self, input: impl Into<Input>, turn_options: TurnOptions, ) -> Result<StreamedTurn>
Run a prompt and return a streaming StreamedTurn.
Auto Trait Implementations§
impl Freeze for Thread
impl !RefUnwindSafe for Thread
impl Send for Thread
impl Sync for Thread
impl Unpin for Thread
impl UnsafeUnpin for Thread
impl !UnwindSafe for Thread
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more