Skip to main content

Shim

Struct Shim 

Source
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>

Source

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.

Source

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.

Source

pub fn record_boxes(&mut self, boxes: impl IntoIterator<Item = C::Box>)

Appends externally produced boxes without changing their order.

Source

pub fn pending_box_count(&self) -> usize

Number of boxes waiting to be submitted to a fresh Codex turn.

Source

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.

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for Shim<C>

§

impl<C> !Sync for Shim<C>

§

impl<C> !UnwindSafe for Shim<C>

§

impl<C> Freeze for Shim<C>
where C: Freeze, Box<dyn ToolCallLauncher<<C as BoxCodec>::Box>>: Freeze, VecDeque<<C as BoxCodec>::Box>: Freeze,

§

impl<C> Send for Shim<C>
where C: Send, Box<dyn ToolCallLauncher<<C as BoxCodec>::Box>>: Send, VecDeque<<C as BoxCodec>::Box>: Send,

§

impl<C> Unpin for Shim<C>
where C: Unpin, Box<dyn ToolCallLauncher<<C as BoxCodec>::Box>>: Unpin, VecDeque<<C as BoxCodec>::Box>: Unpin,

§

impl<C> UnsafeUnpin for Shim<C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.