diff --git a/proto/agynio/api/chat/v1/chat.proto b/proto/agynio/api/chat/v1/chat.proto index 39918b6..88f5c64 100644 --- a/proto/agynio/api/chat/v1/chat.proto +++ b/proto/agynio/api/chat/v1/chat.proto @@ -28,7 +28,7 @@ service ChatService { rpc UpdateChat(UpdateChatRequest) returns (UpdateChatResponse); // List messages in a chat with pagination. - // Returns an unread_count derived from Threads.GetUnackedMessages. + // Returns an unread_count derived from Threads.GetUnackedMessageCounts. // Read-only — does not change acknowledgment state. rpc GetMessages(GetMessagesRequest) returns (GetMessagesResponse); @@ -52,6 +52,19 @@ enum ChatStatus { CHAT_STATUS_CLOSED = 2; } +enum ChatActivityStatus { + // No workload activity data available (no non-passive agent participants + // or the thread is degraded). + CHAT_ACTIVITY_STATUS_UNSPECIFIED = 0; + // At least one most recent workload is running. + CHAT_ACTIVITY_STATUS_RUNNING = 1; + // At least one most recent workload is starting, stopping, or failed + // (non-degraded), and none are running. + CHAT_ACTIVITY_STATUS_PENDING = 2; + // All most recent workloads are stopped or absent. + CHAT_ACTIVITY_STATUS_FINISHED = 3; +} + // A chat thread between participants. message Chat { string id = 1; // UUID — maps to Threads thread_id @@ -61,6 +74,18 @@ message Chat { string organization_id = 5; // UUID — owning organization ChatStatus status = 6; optional string summary = 7; + // Workload activity summary for the chat. Derived from the most recent + // workload per (thread, agent) with aggregation RUNNING > PENDING > FINISHED. + // PENDING includes starting, stopping, and (non-degraded) failed workloads, + // so it may be set even when active_workload_ids is empty. UNSPECIFIED when + // workload activity is not tracked for this chat. + ChatActivityStatus activity_status = 8; + // Unacknowledged message count for the authenticated user in this chat. + // Derived from Threads.GetUnackedMessageCounts (missing entry => 0). + int32 unread_count = 9; + // Workload IDs in starting, running, or stopping state for this chat. + // Failed and stopped workloads are excluded. + repeated string active_workload_ids = 10; } // A participant in a chat. @@ -138,7 +163,7 @@ message GetMessagesResponse { repeated ChatMessage messages = 1; string next_page_token = 2; // Number of unacknowledged messages for the authenticated user in this - // chat. Derived from Threads.GetUnackedMessages. + // chat. Derived from Threads.GetUnackedMessageCounts (missing entry => 0). int32 unread_count = 3; } diff --git a/proto/agynio/api/gateway/v1/threads.proto b/proto/agynio/api/gateway/v1/threads.proto index e9c6558..d1f15ff 100644 --- a/proto/agynio/api/gateway/v1/threads.proto +++ b/proto/agynio/api/gateway/v1/threads.proto @@ -17,5 +17,6 @@ service ThreadsGateway { rpc GetThread(agynio.api.threads.v1.GetThreadRequest) returns (agynio.api.threads.v1.GetThreadResponse); rpc GetMessages(agynio.api.threads.v1.GetMessagesRequest) returns (agynio.api.threads.v1.GetMessagesResponse); rpc GetUnackedMessages(agynio.api.threads.v1.GetUnackedMessagesRequest) returns (agynio.api.threads.v1.GetUnackedMessagesResponse); + rpc GetUnackedMessageCounts(agynio.api.threads.v1.GetUnackedMessageCountsRequest) returns (agynio.api.threads.v1.GetUnackedMessageCountsResponse); rpc AckMessages(agynio.api.threads.v1.AckMessagesRequest) returns (agynio.api.threads.v1.AckMessagesResponse); } diff --git a/proto/agynio/api/threads/v1/threads.proto b/proto/agynio/api/threads/v1/threads.proto index c209140..18a7bd0 100644 --- a/proto/agynio/api/threads/v1/threads.proto +++ b/proto/agynio/api/threads/v1/threads.proto @@ -47,6 +47,9 @@ service ThreadsService { // List unacknowledged messages for a participant across all threads. rpc GetUnackedMessages(GetUnackedMessagesRequest) returns (GetUnackedMessagesResponse); + // Get unacknowledged message counts per thread for a participant. + rpc GetUnackedMessageCounts(GetUnackedMessageCountsRequest) returns (GetUnackedMessageCountsResponse); + // Acknowledge messages as processed by a participant. rpc AckMessages(AckMessagesRequest) returns (AckMessagesResponse); } @@ -337,6 +340,20 @@ message GetUnackedMessagesResponse { string next_page_token = 2; } +// =========================================================================== +// GetUnackedMessageCounts +// =========================================================================== + +message GetUnackedMessageCountsRequest { + string participant_id = 1; // UUID +} + +message GetUnackedMessageCountsResponse { + // key = thread_id, value = unacknowledged message count. + // Only threads with unacknowledged messages are included (missing key => 0). + map counts_by_thread_id = 1; +} + // =========================================================================== // AckMessages // ===========================================================================