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