pub struct Shim<C: BoxCodec> { /* private fields */ }Expand description
A single-owner, per-conversation bridge between K1 boxes and Codex turns.
Shim deliberately contains no locking. A caller creates one shim for one
conversation and invokes it sequentially. Different shims may share clones
of the same Adapter, whose actor owns transport concurrency.
Implementations§
Source§impl<C: BoxCodec> Shim<C>
impl<C: BoxCodec> Shim<C>
Sourcepub fn new(
adapter: Adapter,
conversation_key: impl Into<String>,
codec: C,
launcher: Box<dyn ToolCallLauncher<C::Box>>,
) -> Self
pub fn new( adapter: Adapter, conversation_key: impl Into<String>, codec: C, launcher: Box<dyn ToolCallLauncher<C::Box>>, ) -> Self
Creates a ready shim for one conversation.
Sourcepub fn record_box(&mut self, box_: C::Box)
pub fn record_box(&mut self, box_: C::Box)
Appends one externally produced box in canonical chat-engine order.
Call boxes returned by Shim::infer are output only and are not added
to this pending queue automatically.
Sourcepub fn record_boxes(&mut self, boxes: impl IntoIterator<Item = C::Box>)
pub fn record_boxes(&mut self, boxes: impl IntoIterator<Item = C::Box>)
Appends externally produced boxes without changing their order.
Sourcepub fn pending_box_count(&self) -> usize
pub fn pending_box_count(&self) -> usize
Number of boxes waiting to be submitted to a fresh Codex turn.
Sourcepub async fn infer(
&mut self,
input: impl Into<String>,
) -> Result<ShimOutput<C::Box>, Error>
pub async fn infer( &mut self, input: impl Into<String>, ) -> Result<ShimOutput<C::Box>, Error>
Runs exactly one fresh native Codex turn through terminal completion.
Pending K1 boxes prefix ordinary input and are removed only after the
adapter accepts the turn. Every dynamic call is converted once, launched,
acknowledged with ASYNC_TOOL_ACKNOWLEDGEMENT, and retained as an
ordered output box. No partial output is returned if the active turn
fails.