1+ package io .sentrius .agent .analysis .agents .verbs ;
2+
3+ import io .sentrius .agent .analysis .agents .integration .AIAgentJiraIntegrationService ;
4+ import io .sentrius .sso .core .dto .TicketDTO ;
5+ import io .sentrius .sso .core .dto .ztat .AgentExecution ;
6+ import io .sentrius .sso .core .model .users .User ;
7+ import io .sentrius .sso .core .model .verbs .Verb ;
8+ import lombok .RequiredArgsConstructor ;
9+ import lombok .extern .slf4j .Slf4j ;
10+ import org .springframework .boot .autoconfigure .condition .ConditionalOnBean ;
11+ import org .springframework .stereotype .Service ;
12+
13+ import java .util .List ;
14+ import java .util .Map ;
15+
16+ /**
17+ * Service that provides AI agent verbs for JIRA integration.
18+ * These verbs can be discovered and called by the AI agent system.
19+ */
20+ @ Slf4j
21+ @ Service
22+ @ ConditionalOnBean (AIAgentJiraIntegrationService .class )
23+ @ RequiredArgsConstructor
24+ public class AIAgentJiraVerbService {
25+
26+ private final AIAgentJiraIntegrationService jiraIntegrationService ;
27+
28+ /**
29+ * Searches for JIRA tickets based on a query string.
30+ * This verb allows AI agents to search for tickets using JQL or simple text.
31+ *
32+ * @param execution The agent execution context
33+ * @param args Map containing the search query
34+ * @return List of tickets matching the query
35+ */
36+ @ Verb (
37+ name = "searchJiraTickets" ,
38+ description = "Search for JIRA tickets using a query string. Can use JQL or simple text search." ,
39+ returnType = List .class ,
40+ isAiCallable = true ,
41+ paramDescriptions = {"Search query string (JQL or simple text)" }
42+ )
43+ public List <TicketDTO > searchJiraTickets (AgentExecution execution , Map <String , Object > args ) {
44+ log .info ("AI Agent verb: searchJiraTickets called with args: {}" , args );
45+
46+ String query = (String ) args .get ("query" );
47+ if (query == null || query .trim ().isEmpty ()) {
48+ log .warn ("No query provided for JIRA ticket search" );
49+ return List .of ();
50+ }
51+
52+ return jiraIntegrationService .searchForTickets (query );
53+ }
54+
55+ /**
56+ * Assigns a JIRA ticket to a user.
57+ * This verb allows AI agents to assign tickets to users.
58+ *
59+ * @param execution The agent execution context
60+ * @param args Map containing the ticket key and user
61+ * @return true if assignment was successful, false otherwise
62+ */
63+ @ Verb (
64+ name = "assignJiraTicket" ,
65+ description = "Assign a JIRA ticket to a user" ,
66+ returnType = Boolean .class ,
67+ isAiCallable = true ,
68+ paramDescriptions = {"JIRA ticket key (e.g., PROJ-123)" , "User to assign the ticket to" }
69+ )
70+ public Boolean assignJiraTicket (AgentExecution execution , Map <String , Object > args ) {
71+ log .info ("AI Agent verb: assignJiraTicket called with args: {}" , args );
72+
73+ String ticketKey = (String ) args .get ("ticketKey" );
74+ User user = (User ) args .get ("user" );
75+
76+ if (ticketKey == null || ticketKey .trim ().isEmpty ()) {
77+ log .warn ("No ticket key provided for JIRA ticket assignment" );
78+ return false ;
79+ }
80+
81+ if (user == null ) {
82+ log .warn ("No user provided for JIRA ticket assignment" );
83+ return false ;
84+ }
85+
86+ return jiraIntegrationService .assignTicket (ticketKey , user );
87+ }
88+
89+ /**
90+ * Updates a JIRA ticket with a comment.
91+ * This verb allows AI agents to add comments to tickets.
92+ *
93+ * @param execution The agent execution context
94+ * @param args Map containing the ticket key, user, and message
95+ * @return true if update was successful, false otherwise
96+ */
97+ @ Verb (
98+ name = "updateJiraTicket" ,
99+ description = "Add a comment to a JIRA ticket" ,
100+ returnType = Boolean .class ,
101+ isAiCallable = true ,
102+ paramDescriptions = {"JIRA ticket key (e.g., PROJ-123)" , "User adding the comment" , "Comment message" }
103+ )
104+ public Boolean updateJiraTicket (AgentExecution execution , Map <String , Object > args ) {
105+ log .info ("AI Agent verb: updateJiraTicket called with args: {}" , args );
106+
107+ String ticketKey = (String ) args .get ("ticketKey" );
108+ User user = (User ) args .get ("user" );
109+ String message = (String ) args .get ("message" );
110+
111+ if (ticketKey == null || ticketKey .trim ().isEmpty ()) {
112+ log .warn ("No ticket key provided for JIRA ticket update" );
113+ return false ;
114+ }
115+
116+ if (user == null ) {
117+ log .warn ("No user provided for JIRA ticket update" );
118+ return false ;
119+ }
120+
121+ if (message == null || message .trim ().isEmpty ()) {
122+ log .warn ("No message provided for JIRA ticket update" );
123+ return false ;
124+ }
125+
126+ return jiraIntegrationService .updateTicket (ticketKey , user , message );
127+ }
128+
129+ /**
130+ * Checks if JIRA integration is configured and available.
131+ * This verb allows AI agents to check JIRA availability before attempting operations.
132+ *
133+ * @param execution The agent execution context
134+ * @param args Map (can be empty)
135+ * @return true if JIRA integration is available, false otherwise
136+ */
137+ @ Verb (
138+ name = "checkJiraAvailability" ,
139+ description = "Check if JIRA integration is configured and available" ,
140+ returnType = Boolean .class ,
141+ isAiCallable = true ,
142+ paramDescriptions = {}
143+ )
144+ public Boolean checkJiraAvailability (AgentExecution execution , Map <String , Object > args ) {
145+ log .info ("AI Agent verb: checkJiraAvailability called" );
146+ return jiraIntegrationService .isJiraAvailable ();
147+ }
148+ }
0 commit comments