A real world agent
See how it works in real
The Problem
The Solution
import { model, systemPrompt, Agent, tool } from "@axarai/axar";
import { JiraClient } from "./tools/jira";
import { BitbucketClient } from "./tools/bitbucket";
/**
* An AI agent that generates daily team updates by collecting and summarizing
* activities from JIRA and Bitbucket. The agent follows a structured approach
* to gather information about team members and their activities.
*
* @model openai:gpt-4o-mini - Uses GPT-4 for natural language processing
* @systemPrompt - Main system prompt for the agent
*/
@model("openai:gpt-4o-mini")
@systemPrompt(`
# Objective
Your task is to create a daily team update summarizing the activities of each team member.
# Steps
## 1. Retrieve Team Members
- Use the appropriate tools to fetch the list of team members.
## 2. Collect Activities
- Use the tools to gather each member's **JIRA activities** for the day.
- Use the tools to gather each member's **Bitbucket activities** for the day.
## 3. Summarize Activities
- Create a **short, readable summary** of the activities for each team member in a **TL;DR format**.
- If a team member has **no activities**, include the message: "No activities for the day."
# Output Format
- Organize the output into **separate sections** for each team member.
- Present the information in **Markdown format**.
`)
export class DailyUpdateAgent extends Agent<string, string> {
/**
* Creates a new instance of DailyUpdateAgent
* @param jiraClient - Client for interacting with JIRA API
* @param bitbucketClient - Client for interacting with Bitbucket API
*/
constructor(
private jiraClient: JiraClient,
private bitbucketClient: BitbucketClient
) {
super();
}
/**
* Fetches all active members from the JIRA workspace
* @returns Markdown formatted string containing workspace member details
*/
@tool("Fetch all active members from the JIRA workspace")
async getWorkspaceMembers(): Promise<string> {
return this.jiraClient.fetchWorkspaceMembers();
}
/**
* Retrieves JIRA activities (issues, updates) from the last 24 hours
* @returns Markdown formatted string containing recent JIRA activities
*/
@tool("Retrieve recent JIRA activities (issues, updates)")
async getRecentJiraActivities(): Promise<string> {
return this.jiraClient.fetchRecentActivities();
}
/**
* Retrieves Bitbucket activities (commits) from the last 24 hours
* @returns Markdown formatted string containing recent Bitbucket activities
*/
@tool("Retrieve recent Bitbucket activities")
async getRecentBitbucketActivities(): Promise<string> {
return this.bitbucketClient.fetchRecentActivities();
}
}
/**
* Main function to run the daily update agent
* Initializes JIRA and Bitbucket clients with authentication details
* and executes the agent to generate the daily update
*/
async function main() {
// Initialize JIRA client with authentication details
const jiraClient = new JiraClient({
baseUrl: "https://timetackle-team.atlassian.net",
email: "your@email.com",
apiToken: "YOUR-API-KEY",
projectKey: "YOUR-PROJECT-KEY",
});
// Initialize Bitbucket client with authentication details
const bitbucketClient = new BitbucketClient({
auth: {
username: "YOUR-USER-NAME",
password: "YOUR-APP-PASSWORD",
},
workspace: "YOUR-WORKSPACE-ID",
});
// Create and run the agent
const agent = new DailyUpdateAgent(jiraClient, bitbucketClient);
const response = await agent.run("Give me the daily update for the team");
console.log(response);
}
// Execute the main function and handle any errors
main().catch(console.error);
💡 What just happened?
1
2
3
4
5
Conclusion
Last updated