agcodex_core/
codex_conversation.rs

1use crate::codex::Codex;
2use crate::error::Result as CodexResult;
3use crate::protocol::Event;
4use crate::protocol::Op;
5use crate::protocol::Submission;
6
7pub struct CodexConversation {
8    codex: Codex,
9}
10
11/// Conduit for the bidirectional stream of messages that compose a conversation
12/// in Codex.
13impl CodexConversation {
14    pub(crate) const fn new(codex: Codex) -> Self {
15        Self { codex }
16    }
17
18    pub async fn submit(&self, op: Op) -> CodexResult<String> {
19        self.codex.submit(op).await
20    }
21
22    /// Use sparingly: this is intended to be removed soon.
23    pub async fn submit_with_id(&self, sub: Submission) -> CodexResult<()> {
24        self.codex.submit_with_id(sub).await
25    }
26
27    pub async fn next_event(&self) -> CodexResult<Event> {
28        self.codex.next_event().await
29    }
30}