bxctl: chat --speaker NAME, the speaker on every turn of the chat

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-09-28 10:57:11 -07:00
co-authored by ornith-1.5-35b-a3b
parent fae12c3fe2
commit 5199bd7149
8 changed files with 435 additions and 10 deletions
+6 -4
View File
@@ -73,12 +73,14 @@ pub fn new_session_id() -> SessionId {
SessionId::new(&candidate).unwrap_or_else(|_| SessionId::new("chat-0-0").unwrap_or_default())
}
/// Sends one turn and reads the reply. `on_event` sees every event frame as it arrives.
/// Sends one turn and reads the reply. `on_event` sees every event frame as it arrives. `speaker`
/// is `--speaker`'s value, sent as it is; `None` sends none.
pub fn run_turn(
socket: &Path,
session: &SessionId,
content: &str,
resume: bool,
speaker: Option<&str>,
on_event: &mut dyn FnMut(&TurnEvent),
) -> Result<TurnDone, ChatError> {
let mut stream = UnixStream::connect(socket).map_err(ChatError::Connect)?;
@@ -87,8 +89,7 @@ pub fn run_turn(
session: session.clone(),
content: content.to_string(),
resume,
// Set in M5c-1 task 04, from `--speaker`. Until then no turn has a speaker.
speaker: None,
speaker: speaker.map(str::to_string),
};
write_frame(
&mut stream,
@@ -324,11 +325,12 @@ pub fn stream_turn(
session: &SessionId,
text: &str,
resume: bool,
speaker: Option<&str>,
approvals: &Approvals<'_>,
io: &mut TurnIo<'_>,
) -> std::io::Result<Result<TurnDone, ChatError>> {
let mut err = None;
let outcome = run_turn(socket, session, text, resume, &mut |event| {
let outcome = run_turn(socket, session, text, resume, speaker, &mut |event| {
if err.is_some() {
return;
}