systemprompt_agent/repository/task/
task_messages.rs1use super::TaskRepository;
2use crate::models::a2a::{Message, Part};
3use crate::repository::context::message::{
4 PersistMessageWithTxParams, get_message_parts, get_messages_by_context, get_messages_by_task,
5 get_next_sequence_number, get_next_sequence_number_in_tx, message_exists,
6 persist_message_with_tx,
7};
8use systemprompt_traits::RepositoryError;
9
10impl TaskRepository {
11 pub async fn message_exists(
12 &self,
13 message_id: &systemprompt_identifiers::MessageId,
14 ) -> Result<bool, RepositoryError> {
15 message_exists(&self.pool, message_id).await
16 }
17
18 pub async fn get_next_sequence_number(
19 &self,
20 task_id: &systemprompt_identifiers::TaskId,
21 ) -> Result<i32, RepositoryError> {
22 get_next_sequence_number(&self.pool, task_id).await
23 }
24
25 pub async fn get_messages_by_task(
26 &self,
27 task_id: &systemprompt_identifiers::TaskId,
28 ) -> Result<Vec<Message>, RepositoryError> {
29 get_messages_by_task(&self.pool, task_id).await
30 }
31
32 pub async fn get_message_parts(
33 &self,
34 message_id: &systemprompt_identifiers::MessageId,
35 ) -> Result<Vec<Part>, RepositoryError> {
36 get_message_parts(&self.pool, message_id).await
37 }
38
39 pub async fn get_messages_by_context(
40 &self,
41 context_id: &systemprompt_identifiers::ContextId,
42 ) -> Result<Vec<Message>, RepositoryError> {
43 get_messages_by_context(&self.pool, context_id).await
44 }
45
46 pub async fn get_next_sequence_number_in_tx(
47 &self,
48 tx: &mut dyn systemprompt_database::DatabaseTransaction,
49 task_id: &systemprompt_identifiers::TaskId,
50 ) -> Result<i32, RepositoryError> {
51 get_next_sequence_number_in_tx(tx, task_id).await
52 }
53
54 pub async fn persist_message_with_tx(
55 &self,
56 params: PersistMessageWithTxParams<'_>,
57 ) -> Result<(), RepositoryError> {
58 persist_message_with_tx(params).await
59 }
60}