diff --git a/cli/src/bridge/v2/faults.rs b/cli/src/bridge/v2/faults.rs
index 3e9f9ce8f..a75eb435d 100644
--- a/cli/src/bridge/v2/faults.rs
+++ b/cli/src/bridge/v2/faults.rs
@@ -3146,3 +3146,356 @@ async fn stop_ends_background_work_left_running_after_its_turn() {
Some("Nothing is running.")
);
}
+
+/// A voice message from the owner in the DM. `transcript` is the text the
+/// server edits in; the audio URL is never fetched (not HTTPS).
+fn voice_message(message_id: i64, duration_ms: u64, transcript: Option<&str>) -> MessageRecord {
+ MessageRecord {
+ chat_id: InlineId::new(9),
+ message_id: InlineId::new(message_id),
+ sender_id: InlineId::new(1),
+ timestamp: 1,
+ is_outgoing: false,
+ reply_to_message_id: None,
+ transaction: None,
+ content: inline_client::MessageContent::Media {
+ kind: inline_client::MediaKind::Voice,
+ file_id: format!("voice-{message_id}"),
+ url: Some(format!("http://127.0.0.1:9/voice-{message_id}.m4a")),
+ mime_type: Some("audio/mp4".into()),
+ file_name: Some("voice.m4a".into()),
+ caption: transcript.map(str::to_owned),
+ size_bytes: Some(2048),
+ width: None,
+ height: None,
+ duration_ms: Some(duration_ms),
+ },
+ metadata: inline_client::MessageMetadata {
+ sender_is_bot: Some(false),
+ edit_timestamp: transcript.map(|_| 2),
+ ..Default::default()
+ },
+ }
+}
+
+fn received(harness: &FakeHarness) -> Vec {
+ harness.session.received.lock().unwrap().clone()
+}
+
+fn sends(harness: &FakeHarness) -> usize {
+ harness.session.sends.load(Ordering::SeqCst)
+}
+
+fn voice_holds(runtime: &Runtime) -> usize {
+ runtime.agent.ledger.voice_holds().unwrap().len()
+}
+
+/// Past every voice deadline.
+fn after_deadlines() -> i64 {
+ super::voice::now_ms() + 100_000
+}
+
+#[tokio::test]
+async fn a_voice_message_waits_for_its_transcript_and_goes_out_without_its_audio() {
+ let (mut runtime, harness, mut cleanup) = fixture(false);
+ runtime.agent.names.remember(1, "Owner".into()).await;
+ let id = input_id(2, 9, 300, "direct");
+ runtime
+ .on_message(&voice_message(300, 4_000, None))
+ .await
+ .unwrap();
+ assert_eq!(state(&runtime, &id), Some(InputState::Pending));
+ assert_eq!(voice_holds(&runtime), 1);
+ // The sender sees the agent working while it waits, repeated until the
+ // transcript comes.
+ assert_eq!(runtime.voice_working_sent, [(9, true)]);
+ runtime.voice_tick(super::voice::now_ms()).await;
+ assert_eq!(runtime.voice_working_sent.len(), 1, "not yet due again");
+ runtime.voice_working_due = Some(tokio::time::Instant::now());
+ runtime.voice_tick(super::voice::now_ms()).await;
+ assert_eq!(runtime.voice_working_sent, [(9, true), (9, true)]);
+ tokio::time::sleep(Duration::from_millis(50)).await;
+ assert_eq!(sends(&harness), 0, "held for the transcript");
+ runtime
+ .on_message(&voice_message(300, 4_000, Some("Ship the fix today.")))
+ .await
+ .unwrap();
+ until(|| sends(&harness) == 1).await;
+ let input = &received(&harness)[0];
+ assert_eq!(input.id.as_str(), id);
+ assert_eq!(
+ input.content.text,
+ "Voice message (0:04), transcribed by Inline:\n\nShip the fix today."
+ );
+ assert!(input.content.attachments.is_empty(), "no audio download");
+ assert_eq!(voice_holds(&runtime), 0);
+ // A replayed edit is the same message.
+ runtime
+ .on_message(&voice_message(300, 4_000, Some("Ship the fix today.")))
+ .await
+ .unwrap();
+ tokio::time::sleep(Duration::from_millis(50)).await;
+ assert_eq!(sends(&harness), 1);
+ cleanup.tasks.push(runtime.works.remove(&9).unwrap().task);
+}
+
+#[tokio::test]
+async fn past_its_deadline_a_voice_message_goes_out_with_its_audio_and_a_late_transcript_follows() {
+ let (mut runtime, harness, mut cleanup) = fixture(false);
+ runtime.agent.names.remember(1, "Owner".into()).await;
+ let id = input_id(2, 9, 301, "direct");
+ runtime
+ .on_message(&voice_message(301, 42_000, None))
+ .await
+ .unwrap();
+ // Not yet due: nothing goes out.
+ runtime.voice_tick(super::voice::now_ms()).await;
+ tokio::time::sleep(Duration::from_millis(50)).await;
+ assert_eq!(sends(&harness), 0);
+ runtime.voice_tick(after_deadlines()).await;
+ until(|| sends(&harness) == 1).await;
+ let input = &received(&harness)[0];
+ assert_eq!(input.id.as_str(), id);
+ assert!(
+ input.content.text.starts_with(
+ "Review the attached voice message (0:42). Inline hasn't transcribed it yet"
+ ),
+ "{}",
+ input.content.text
+ );
+ assert_eq!(input.content.attachments.len(), 1);
+ assert_eq!(
+ input.content.attachments[0].kind,
+ inline_agent_bridge::InputAttachmentKind::Audio
+ );
+ // The hold stays for a late transcript.
+ assert!(runtime.agent.ledger.voice_holds().unwrap()[0].delivered_audio);
+ runtime
+ .on_message(&voice_message(301, 42_000, Some("Late words.")))
+ .await
+ .unwrap();
+ until(|| sends(&harness) == 2).await;
+ let follow_up = &received(&harness)[1];
+ assert_eq!(
+ follow_up.id.as_str(),
+ input_id(2, 9, 301, "voice-transcript")
+ );
+ assert_eq!(
+ follow_up.content.text,
+ "Transcript of the voice message you received earlier (message 301), transcribed by Inline:\n\nLate words."
+ );
+ assert!(follow_up.content.attachments.is_empty());
+ assert_eq!(voice_holds(&runtime), 0);
+ runtime
+ .on_message(&voice_message(301, 42_000, Some("Late words.")))
+ .await
+ .unwrap();
+ tokio::time::sleep(Duration::from_millis(50)).await;
+ assert_eq!(sends(&harness), 2, "the follow-up goes out once");
+ cleanup.tasks.push(runtime.works.remove(&9).unwrap().task);
+}
+
+#[tokio::test]
+async fn a_held_voice_message_survives_a_restart_and_is_never_reported_lost() {
+ let (mut runtime, harness, mut cleanup) = fixture(false);
+ runtime.agent.names.remember(1, "Owner".into()).await;
+ let found = input_id(2, 9, 302, "direct");
+ let waiting = input_id(2, 9, 303, "direct");
+ for message_id in [302, 303] {
+ runtime
+ .on_message(&voice_message(message_id, 8_000, None))
+ .await
+ .unwrap();
+ }
+ cleanup.tasks.push(runtime.works.remove(&9).unwrap().task);
+ drop(runtime);
+ let mut restarted = super::faults::runtime(&mut cleanup, harness.clone());
+ // Inline has the first transcript by now, not the second.
+ restarted.voice_lookups.insert(
+ (9, 302),
+ proto::Message {
+ id: 302,
+ message: Some("Written while you were away.".into()),
+ edit_date: Some(2),
+ ..Default::default()
+ },
+ );
+ restarted.voice_lookups.insert(
+ (9, 303),
+ proto::Message {
+ id: 303,
+ ..Default::default()
+ },
+ );
+ restarted.recover().await;
+ until(|| sends(&harness) == 1).await;
+ let input = &received(&harness)[0];
+ assert_eq!(input.id.as_str(), found);
+ assert_eq!(
+ input.content.text,
+ "Voice message (0:08), transcribed by Inline:\n\nWritten while you were away."
+ );
+ // The other keeps waiting for its original deadline: not "restarted
+ // before this ran".
+ assert_eq!(state(&restarted, &waiting), Some(InputState::Pending));
+ assert_eq!(voice_holds(&restarted), 1);
+ restarted.voice_tick(after_deadlines()).await;
+ until(|| sends(&harness) == 2).await;
+ assert_eq!(received(&harness)[1].id.as_str(), waiting);
+ assert_eq!(received(&harness)[1].content.attachments.len(), 1);
+ cleanup.tasks.push(restarted.works.remove(&9).unwrap().task);
+}
+
+#[tokio::test]
+async fn a_restart_past_the_deadline_sends_the_audio_without_asking_again() {
+ let (mut runtime, harness, mut cleanup) = fixture(false);
+ runtime.agent.names.remember(1, "Owner".into()).await;
+ runtime
+ .on_message(&voice_message(304, 8_000, None))
+ .await
+ .unwrap();
+ // The deadline passed while the bridge was down.
+ {
+ let mut hold = runtime.agent.ledger.voice_holds().unwrap().remove(0);
+ runtime
+ .agent
+ .ledger
+ .remove_voice_hold(&hold.input_id)
+ .unwrap();
+ hold.deadline_at_ms = 1;
+ runtime.agent.ledger.hold_voice(&hold).unwrap();
+ }
+ cleanup.tasks.push(runtime.works.remove(&9).unwrap().task);
+ drop(runtime);
+ let mut restarted = super::faults::runtime(&mut cleanup, harness.clone());
+ restarted.recover().await;
+ until(|| sends(&harness) == 1).await;
+ let input = &received(&harness)[0];
+ assert_eq!(input.id.as_str(), input_id(2, 9, 304, "direct"));
+ assert_eq!(input.content.attachments.len(), 1);
+ assert!(
+ restarted.agent.ledger.voice_holds().unwrap()[0].delivered_audio,
+ "a late transcript still follows"
+ );
+ cleanup.tasks.push(restarted.works.remove(&9).unwrap().task);
+}
+
+#[tokio::test]
+async fn voice_too_long_to_transcribe_goes_out_with_its_audio_at_once() {
+ let (mut runtime, harness, mut cleanup) = fixture(false);
+ runtime.agent.names.remember(1, "Owner".into()).await;
+ runtime
+ .on_message(&voice_message(305, 601_000, None))
+ .await
+ .unwrap();
+ until(|| sends(&harness) == 1).await;
+ let input = &received(&harness)[0];
+ assert_eq!(input.content.text, "Review the attached voice message.");
+ assert_eq!(input.content.attachments.len(), 1);
+ assert_eq!(voice_holds(&runtime), 0);
+ cleanup.tasks.push(runtime.works.remove(&9).unwrap().task);
+}
+
+#[tokio::test]
+async fn voice_with_its_transcript_goes_out_at_once_without_its_audio() {
+ let (mut runtime, harness, mut cleanup) = fixture(false);
+ runtime.agent.names.remember(1, "Owner".into()).await;
+ runtime
+ .on_message(&voice_message(306, 12_000, Some("Already transcribed.")))
+ .await
+ .unwrap();
+ until(|| sends(&harness) == 1).await;
+ let input = &received(&harness)[0];
+ assert_eq!(
+ input.content.text,
+ "Voice message (0:12), transcribed by Inline:\n\nAlready transcribed."
+ );
+ assert!(input.content.attachments.is_empty());
+ assert_eq!(voice_holds(&runtime), 0);
+ cleanup.tasks.push(runtime.works.remove(&9).unwrap().task);
+}
+
+#[tokio::test]
+async fn stop_drops_a_held_voice_message() {
+ let (mut runtime, harness, mut cleanup) = fixture(false);
+ runtime.agent.names.remember(1, "Owner".into()).await;
+ let id = input_id(2, 9, 307, "direct");
+ runtime
+ .on_message(&voice_message(307, 4_000, None))
+ .await
+ .unwrap();
+ assert_eq!(voice_holds(&runtime), 1);
+ let stop = MessageRecord {
+ chat_id: InlineId::new(9),
+ message_id: InlineId::new(308),
+ sender_id: InlineId::new(1),
+ timestamp: 1,
+ is_outgoing: false,
+ reply_to_message_id: None,
+ transaction: None,
+ content: inline_client::MessageContent::Text {
+ text: "/stop".into(),
+ },
+ metadata: inline_client::MessageMetadata {
+ sender_is_bot: Some(false),
+ entities: vec![inline_client::MessageEntityRecord {
+ kind: "TYPE_BOT_COMMAND".into(),
+ offset: 0,
+ length: 5,
+ user_id: None,
+ agent_id: None,
+ group_id: None,
+ chat_id: None,
+ value: None,
+ }],
+ ..Default::default()
+ },
+ };
+ runtime.on_message(&stop).await.unwrap();
+ assert_eq!(state(&runtime, &id), Some(InputState::Discarded));
+ assert_eq!(voice_holds(&runtime), 0);
+ assert_eq!(runtime.voice_working_sent.last(), Some(&(9, false)));
+ // Neither the transcript nor the deadline brings it back.
+ runtime
+ .on_message(&voice_message(307, 4_000, Some("Never mind.")))
+ .await
+ .unwrap();
+ runtime.voice_tick(after_deadlines()).await;
+ tokio::time::sleep(Duration::from_millis(50)).await;
+ assert_eq!(sends(&harness), 0);
+ cleanup.tasks.push(runtime.works.remove(&9).unwrap().task);
+}
+
+#[tokio::test]
+async fn the_apps_stop_drops_held_voice_only_for_someone_who_may_stop() {
+ let (mut runtime, _harness, mut cleanup) = fixture(false);
+ runtime.agent.names.remember(1, "Owner".into()).await;
+ runtime
+ .on_message(&voice_message(309, 4_000, None))
+ .await
+ .unwrap();
+ until(|| runtime.works[&9].agent_session_id() == Some(1)).await;
+ let stop = |actor: i64| ClientEvent::AgentSessionControlRequested {
+ interaction_id: InlineId::new(1),
+ chat_id: InlineId::new(9),
+ agent_session_id: InlineId::new(1),
+ actor_user_id: InlineId::new(actor),
+ op: proto::AgentSessionControl::Stop as i32,
+ };
+ // Someone without access to this agent.
+ tokio::time::timeout(Duration::from_secs(5), runtime.handle(&stop(5)))
+ .await
+ .expect("handled")
+ .unwrap();
+ assert_eq!(voice_holds(&runtime), 1);
+ tokio::time::timeout(Duration::from_secs(5), runtime.handle(&stop(1)))
+ .await
+ .expect("handled")
+ .unwrap();
+ assert_eq!(voice_holds(&runtime), 0);
+ assert_eq!(
+ state(&runtime, &input_id(2, 9, 309, "direct")),
+ Some(InputState::Discarded)
+ );
+ cleanup.tasks.push(runtime.works.remove(&9).unwrap().task);
+}
diff --git a/cli/src/bridge/v2/ledger.rs b/cli/src/bridge/v2/ledger.rs
index ef77e20b4..11de13558 100644
--- a/cli/src/bridge/v2/ledger.rs
+++ b/cli/src/bridge/v2/ledger.rs
@@ -183,6 +183,16 @@ impl Ledger {
key TEXT PRIMARY KEY,
value TEXT NOT NULL,
updated_at INTEGER NOT NULL
+ );
+ CREATE TABLE IF NOT EXISTS v2_voice_holds (
+ input_id TEXT PRIMARY KEY,
+ chat_id INTEGER NOT NULL,
+ message_id INTEGER NOT NULL,
+ duration_ms INTEGER,
+ deadline_at INTEGER NOT NULL,
+ delivered_audio INTEGER NOT NULL DEFAULT 0,
+ held TEXT NOT NULL,
+ created_at INTEGER NOT NULL
);",
)?;
Ok(Self {
@@ -586,6 +596,71 @@ impl Ledger {
Ok(())
}
+ /// Holds a recorded voice message until its transcript arrives: the
+ /// input becomes `pending` and its hold is saved, in one transaction.
+ pub(crate) fn hold_voice(&self, hold: &VoiceHoldRecord) -> rusqlite::Result<()> {
+ let mut connection = self.connection.lock().expect("ledger poisoned");
+ let tx = connection.transaction()?;
+ tx.execute(
+ "UPDATE v2_inputs SET state = ?2, updated_at = ?3 WHERE input_id = ?1",
+ params![hold.input_id, InputState::Pending.as_str(), now_seconds()],
+ )?;
+ tx.execute(
+ "INSERT INTO v2_voice_holds (input_id, chat_id, message_id, duration_ms, deadline_at, delivered_audio, held, created_at)
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8) ON CONFLICT (input_id) DO NOTHING",
+ params![
+ hold.input_id,
+ hold.chat_id,
+ hold.message_id,
+ hold.duration_ms,
+ hold.deadline_at_ms,
+ hold.delivered_audio,
+ hold.held,
+ now_seconds()
+ ],
+ )?;
+ tx.commit()
+ }
+
+ /// Every saved voice hold, oldest first.
+ pub(crate) fn voice_holds(&self) -> rusqlite::Result> {
+ let connection = self.connection.lock().expect("ledger poisoned");
+ let mut statement = connection.prepare(
+ "SELECT input_id, chat_id, message_id, duration_ms, deadline_at, delivered_audio, held
+ FROM v2_voice_holds ORDER BY created_at, rowid",
+ )?;
+ statement
+ .query_map([], |row| {
+ Ok(VoiceHoldRecord {
+ input_id: row.get(0)?,
+ chat_id: row.get(1)?,
+ message_id: row.get(2)?,
+ duration_ms: row.get(3)?,
+ deadline_at_ms: row.get(4)?,
+ delivered_audio: row.get(5)?,
+ held: row.get(6)?,
+ })
+ })?
+ .collect()
+ }
+
+ /// The voice message went out with its audio; a late transcript still
+ /// follows it.
+ pub(crate) fn voice_audio_delivered(&self, input_id: &str) -> rusqlite::Result<()> {
+ let connection = self.connection.lock().expect("ledger poisoned");
+ connection.execute(
+ "UPDATE v2_voice_holds SET delivered_audio = 1 WHERE input_id = ?1",
+ [input_id],
+ )?;
+ Ok(())
+ }
+
+ pub(crate) fn remove_voice_hold(&self, input_id: &str) -> rusqlite::Result<()> {
+ let connection = self.connection.lock().expect("ledger poisoned");
+ connection.execute("DELETE FROM v2_voice_holds WHERE input_id = ?1", [input_id])?;
+ Ok(())
+ }
+
/// Drops settled records older than `max_age_secs`.
pub(crate) fn prune(&self, max_age_secs: i64) -> rusqlite::Result {
let connection = self.connection.lock().expect("ledger poisoned");
@@ -620,6 +695,22 @@ fn row_child(row: &rusqlite::Row<'_>) -> rusqlite::Result {
})
}
+/// A voice message waiting for Inline's transcript (`runtime/voice.rs`).
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub(crate) struct VoiceHoldRecord {
+ pub input_id: String,
+ pub chat_id: i64,
+ pub message_id: i64,
+ pub duration_ms: Option,
+ /// Unix milliseconds: past it, the audio goes out without a transcript.
+ pub deadline_at_ms: i64,
+ /// The audio went out at the deadline; the hold stays for a late
+ /// transcript.
+ pub delivered_audio: bool,
+ /// The held input and its routing, as JSON.
+ pub held: String,
+}
+
/// A task's report waiting for its lead.
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct LeadEventRecord {
@@ -813,6 +904,43 @@ mod tests {
);
}
+ #[test]
+ fn a_voice_hold_survives_reopening_and_keeps_its_input_pending() {
+ let dir = tempfile::tempdir().unwrap();
+ let path = dir.path().join("ledger.sqlite");
+ let hold = VoiceHoldRecord {
+ input_id: "voice".to_owned(),
+ chat_id: 5,
+ message_id: 10,
+ duration_ms: Some(42_000),
+ deadline_at_ms: 1_700_000_036_000,
+ delivered_audio: false,
+ held: r#"{"input":{}}"#.to_owned(),
+ };
+ {
+ let ledger = Ledger::open(&path).unwrap();
+ ledger.begin("voice", 5, 10, 7).unwrap();
+ ledger.hold_voice(&hold).unwrap();
+ // A replayed hold keeps the first one.
+ ledger
+ .hold_voice(&VoiceHoldRecord {
+ deadline_at_ms: 1,
+ ..hold.clone()
+ })
+ .unwrap();
+ }
+ let ledger = Ledger::open(&path).unwrap();
+ assert_eq!(ledger.voice_holds().unwrap(), vec![hold.clone()]);
+ assert_eq!(
+ ledger.get("voice").unwrap().unwrap().state,
+ InputState::Pending
+ );
+ ledger.voice_audio_delivered("voice").unwrap();
+ assert!(ledger.voice_holds().unwrap()[0].delivered_audio);
+ ledger.remove_voice_hold("voice").unwrap();
+ assert!(ledger.voice_holds().unwrap().is_empty());
+ }
+
#[test]
fn task_links_and_lead_reports_survive_reopening() {
let dir = tempfile::tempdir().unwrap();
diff --git a/cli/src/bridge/v2/runtime.rs b/cli/src/bridge/v2/runtime.rs
index b101e0b45..d9db2e158 100644
--- a/cli/src/bridge/v2/runtime.rs
+++ b/cli/src/bridge/v2/runtime.rs
@@ -486,9 +486,20 @@ pub(crate) struct Runtime {
/// Agent messages addressed to this agent that took a loop hop, acted on or
/// not: a refused mention streamed in many edits takes one.
counted_agent_messages: RecentMessages,
+ /// Input ID → a voice message waiting for its transcript, as saved in
+ /// the ledger (`voice.rs`).
+ voice_holds: HashMap,
+ /// When "working" is next repeated for held voice messages.
+ voice_working_due: Option,
/// Tests: sent messages as Inline holds them, read instead of asking.
#[cfg(test)]
cards: HashMap<(i64, i64), super::doc::Doc>,
+ /// Tests: messages as Inline holds them, read instead of asking.
+ #[cfg(test)]
+ voice_lookups: HashMap<(i64, i64), proto::Message>,
+ /// Tests: the "working" states sent for held voice messages.
+ #[cfg(test)]
+ voice_working_sent: Vec<(i64, bool)>,
}
/// Recent (chat, message) IDs, bounded so a long-lived bridge doesn't grow.
@@ -634,8 +645,14 @@ impl Runtime {
agent_profiles: None,
acted_agent_messages: RecentMessages::default(),
counted_agent_messages: RecentMessages::default(),
+ voice_holds: HashMap::new(),
+ voice_working_due: None,
#[cfg(test)]
cards: HashMap::new(),
+ #[cfg(test)]
+ voice_lookups: HashMap::new(),
+ #[cfg(test)]
+ voice_working_sent: Vec::new(),
})
}
@@ -734,6 +751,7 @@ impl Runtime {
self.publish_pending = false;
self.beat(false);
}
+ let voice_wake = self.voice_wake();
tokio::select! {
biased;
_ = &mut shutdown => break Ok(()),
@@ -753,6 +771,16 @@ impl Runtime {
self.lead_request(request).await;
note_slow("lead", started);
}
+ () = async {
+ match voice_wake {
+ Some(at) => tokio::time::sleep_until(at).await,
+ None => std::future::pending().await,
+ }
+ } => {
+ let started = Instant::now();
+ self.voice_tick(voice::now_ms()).await;
+ note_slow("voice", started);
+ }
_ = connection.tick() => {
let started = Instant::now();
self.keep_connected().await;
@@ -853,10 +881,16 @@ impl Runtime {
return;
}
};
+ // Voice messages waiting for their transcript were never lost: they
+ // resume below.
+ let held = self.saved_voice_holds();
// Written but unconfirmed: the thread's session settles them when it
// opens, by what it shows it already consumed.
let mut uncertain: HashMap> = HashMap::new();
for record in unresolved {
+ if held.contains(&record.input_id) {
+ continue;
+ }
if matches!(record.state, InputState::Unknown | InputState::Sent)
&& let Ok(input) = InputId::new(record.input_id.clone())
{
@@ -942,6 +976,7 @@ impl Runtime {
for lead in leads {
self.deliver_lead_events(lead).await;
}
+ self.resume_voice_holds().await;
let _ = self.agent.ledger.prune(LEDGER_RETENTION_SECS);
}
@@ -1230,6 +1265,17 @@ impl Runtime {
Ok(proto::AgentSessionControl::Resume) => Some(Control::Resume),
_ => None,
};
+ // Only someone who may stop the work stops its voice holds;
+ // the work checks its own controls.
+ if let (Some(chat), Some(Control::Stop)) = (chat, control)
+ && self
+ .access
+ .grants(actor_user_id.get())
+ .await
+ .permits(Operation::Stop)
+ {
+ self.cancel_voice_holds(chat);
+ }
let toast = match (chat, control) {
(Some(chat), Some(control)) => {
self.ask(chat, |reply| Command::Control {
@@ -2023,16 +2069,16 @@ impl Runtime {
skills.into_iter().find(|skill| skill.answers_to(name))
}
- /// Applies the thread's or mentioned Skilled Agent to a message. False
- /// when the message must not run.
- async fn apply_agent_profile(
+ /// The thread's or mentioned Skilled Agent this message runs as (`Ok(None)`: this bot's
+ /// default), applied with [`Self::as_skilled_agent`]. `Err` when it
+ /// cannot run; the sender was told.
+ async fn agent_profile(
&self,
message: &MessageRecord,
chat_id: i64,
- input: &mut Input,
- ) -> bool {
+ ) -> Result